QGIS API Documentation 3.39.0-Master (3aed037ce22)
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"
23#include <QMap>
24#include <QDomElement>
25#include <QDomDocument>
26
27#include "qgsreadwritecontext.h"
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
212 bool reuseLastValue( int index ) const;
213
221 void setReuseLastValue( int index, bool reuse );
222
223 // Python form init function stuff
224
231 QString initFunction() const;
232
239 void setInitFunction( const QString &function );
240
244 QString initCode() const;
245
251 void setInitCode( const QString &code );
252
256 QString initFilePath() const;
257
263 void setInitFilePath( const QString &filePath );
264
270 Qgis::AttributeFormPythonInitCodeSource initCodeSource() const;
271
273 void setInitCodeSource( Qgis::AttributeFormPythonInitCodeSource initCodeSource );
274
276 Qgis::AttributeFormSuppression suppress() const;
278 void setSuppress( Qgis::AttributeFormSuppression s );
279
280 // Serialization
281
286 void readXml( const QDomNode &node, QgsReadWriteContext &context );
287
292 void writeXml( QDomNode &node, const QgsReadWriteContext &context ) const;
293
298 Q_DECL_DEPRECATED QgsAttributeEditorElement *attributeEditorElementFromDomElement( QDomElement &elem, QgsAttributeEditorElement *parent, const QString &layerId = QString(), const QgsReadWriteContext &context = QgsReadWriteContext() ) SIP_DEPRECATED;
299
303 explicit QgsEditFormConfig();
304
309 void setDataDefinedFieldProperties( const QString &fieldName, const QgsPropertyCollection &properties );
310
315 QgsPropertyCollection dataDefinedFieldProperties( const QString &fieldName ) const;
316
321 static const QgsPropertiesDefinition &propertyDefinitions();
322
323 private:
324
329 void setFields( const QgsFields &fields );
330
334 void onRelationsLoaded();
335
340 bool legacyUpdateRelationWidgetInTabs( QgsAttributeEditorContainer *container, const QString &widgetName, const QVariantMap &config );
341
342 private:
343 void fixLegacyConfig( QDomElement &el );
344
345 QExplicitlySharedDataPointer<QgsEditFormConfigPrivate> d;
346
347 friend class QgsVectorLayer;
348};
349
350#endif // QGSEDITFORMCONFIG_H
AttributeFormSuppression
Available form types for layout of the attribute form editor.
Definition qgis.h:4844
AttributeFormPythonInitCodeSource
The Python init code source for attribute forms.
Definition qgis.h:4859
AttributeFormLayout
Available form types for layout of the attribute form editor.
Definition qgis.h:4829
This is a container for attribute editors, used to group them visually in the attribute form if it is...
This is an abstract base class for any elements of a drag and drop form.
Contains configuration settings for an editor form.
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 a integer key value.
The class is used as a container of context for various read/write operations on other objects.
This class manages a set of relations between layers.
Represents a vector layer which manages a vector based data sets.
#define SIP_DEPRECATED
Definition qgis_sip.h:106
#define SIP_MONKEYPATCH_SCOPEENUM_UNNEST(OUTSIDE_CLASS, FORMERNAME)
Definition qgis_sip.h:271
#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