QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
qgseditformconfig.h
Go to the documentation of this file.
1/***************************************************************************
2 qgseditformconfig.h
3 -------------------
4 begin : Nov 18, 2015
5 copyright : (C) 2015 by Matthias Kuhn
6 email : matthias at opengis dot ch
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef QGSEDITFORMCONFIG_H
19#define QGSEDITFORMCONFIG_H
20
21#include "qgis_core.h"
22#include "qgis_sip.h"
24#include "qgsreadwritecontext.h"
25
26#include <QDomDocument>
27#include <QDomElement>
28#include <QMap>
29
31class QgsEditFormConfigPrivate;
34
40class CORE_EXPORT QgsEditFormConfig
41{
42
43 Q_GADGET
44
45 public:
46
47 struct GroupData
48 {
49 GroupData() = default;
50 GroupData( const QString &name, const QList<QString> &fields )
51 : mName( name )
52 , mFields( fields )
53 {}
54 QString mName;
55 QList<QString> mFields;
56 };
57
58 struct TabData
59 {
60 TabData() = default;
61 TabData( const QString &name, const QList<QString> &fields, const QList<QgsEditFormConfig::GroupData> &groups )
62 : mName( name )
63 , mFields( fields )
64 , mGroups( groups )
65 {}
66 QString mName;
67 QList<QString> mFields;
68 QList<QgsEditFormConfig::GroupData> mGroups;
69 };
70
71 // *INDENT-OFF*
72
81 {
82 NoProperty = 0,
83 AllProperties = 1,
84 Alias = 2,
85 Editable = 3,
86 };
87 // *INDENT-ON*
88
91
92 QgsEditFormConfig &operator=( const QgsEditFormConfig &o );
93 // TODO c++20 - replace with = default
94 bool operator==( const QgsEditFormConfig &o ) const;
95
101 void addTab( QgsAttributeEditorElement *data SIP_TRANSFER );
102
106 QList< QgsAttributeEditorElement * > tabs() const;
107
111 void clearTabs();
112
118 QgsAttributeEditorContainer *invisibleRootContainer();
119
121 Qgis::AttributeFormLayout layout() const;
122
124 void setLayout( Qgis::AttributeFormLayout editorLayout );
125
129 QString uiForm() const;
130
139 void setUiForm( const QString &ui );
140
159 bool setWidgetConfig( const QString &widgetName, const QVariantMap &config );
160
168 QVariantMap widgetConfig( const QString &widgetName ) const;
169
177 bool removeWidgetConfig( const QString &widgetName );
178
183 bool readOnly( int idx ) const;
184
188 void setReadOnly( int idx, bool readOnly = true );
189
195 bool labelOnTop( int idx ) const;
196
203 void setLabelOnTop( int idx, bool onTop );
204
213 Q_DECL_DEPRECATED bool reuseLastValue( int index ) const;
214
223 Q_DECL_DEPRECATED void setReuseLastValue( int index, bool reuse );
224
231 Qgis::AttributeFormReuseLastValuePolicy reuseLastValuePolicy( int index ) const;
232
239 void setReuseLastValuePolicy( int index, Qgis::AttributeFormReuseLastValuePolicy policy );
240
241 // Python form init function stuff
242
249 QString initFunction() const;
250
257 void setInitFunction( const QString &function );
258
262 QString initCode() const;
263
269 void setInitCode( const QString &code );
270
274 QString initFilePath() const;
275
281 void setInitFilePath( const QString &filePath );
282
288 Qgis::AttributeFormPythonInitCodeSource initCodeSource() const;
289
291 void setInitCodeSource( Qgis::AttributeFormPythonInitCodeSource initCodeSource );
292
294 Qgis::AttributeFormSuppression suppress() const;
296 void setSuppress( Qgis::AttributeFormSuppression s );
297
298 // Serialization
299
304 void readXml( const QDomNode &node, QgsReadWriteContext &context );
305
310 void writeXml( QDomNode &node, const QgsReadWriteContext &context ) const;
311
316 Q_DECL_DEPRECATED QgsAttributeEditorElement *attributeEditorElementFromDomElement( QDomElement &elem, QgsAttributeEditorElement *parent, const QString &layerId = QString(), const QgsReadWriteContext &context = QgsReadWriteContext() ) SIP_DEPRECATED;
317
321 explicit QgsEditFormConfig();
322
327 void setDataDefinedFieldProperties( const QString &fieldName, const QgsPropertyCollection &properties );
328
333 QgsPropertyCollection dataDefinedFieldProperties( const QString &fieldName ) const;
334
339 static const QgsPropertiesDefinition &propertyDefinitions();
340
341 private:
342
347 void setFields( const QgsFields &fields );
348
352 void onRelationsLoaded(); // cppcheck-suppress functionConst
353
358 bool legacyUpdateRelationWidgetInTabs( QgsAttributeEditorContainer *container, const QString &widgetName, const QVariantMap &config );
359
360 private:
361 void fixLegacyConfig( QDomElement &el ) const;
362
363 QExplicitlySharedDataPointer<QgsEditFormConfigPrivate> d;
364
365 friend class QgsVectorLayer;
366};
367
368#endif // QGSEDITFORMCONFIG_H
AttributeFormReuseLastValuePolicy
Attribute form policy for reusing last entered values.
Definition qgis.h:5529
AttributeFormSuppression
Available form types for layout of the attribute form editor.
Definition qgis.h:5500
AttributeFormPythonInitCodeSource
The Python init code source for attribute forms.
Definition qgis.h:5515
AttributeFormLayout
Available form types for layout of the attribute form editor.
Definition qgis.h:5485
A container for attribute editors, used to group them visually in the attribute form if it is set to ...
An abstract base class for any elements of a drag and drop form.
Contains configuration settings for an editor form.
friend class QgsVectorLayer
QgsEditFormConfig(const QgsEditFormConfig &o)
DataDefinedProperty
Data defined properties.
Container of fields for a vector layer.
Definition qgsfields.h:46
A grouped map of multiple QgsProperty objects, each referenced by an integer key value.
A container for the context for various read/write operations on objects.
Manages a set of relations between layers.
#define SIP_DEPRECATED
Definition qgis_sip.h:114
#define SIP_MONKEYPATCH_SCOPEENUM_UNNEST(OUTSIDE_CLASS, FORMERNAME)
Definition qgis_sip.h:268
#define SIP_TRANSFER
Definition qgis_sip.h:36
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
QMap< int, QgsPropertyDefinition > QgsPropertiesDefinition
Definition of available properties.
GroupData(const QString &name, const QList< QString > &fields)
TabData(const QString &name, const QList< QString > &fields, const QList< QgsEditFormConfig::GroupData > &groups)
QList< QgsEditFormConfig::GroupData > mGroups