QGIS API Documentation 3.32.0-Lima (311a8cb8a6)
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 {
50 GroupData() = default;
51 GroupData( const QString &name, const QList<QString> &fields )
52 : mName( name )
53 , mFields( fields )
54 {}
55 QString mName;
56 QList<QString> mFields;
57 };
58
59 struct TabData
60 {
62 TabData() = default;
63 TabData( const QString &name, const QList<QString> &fields, const QList<QgsEditFormConfig::GroupData> &groups )
64 : mName( name )
65 , mFields( fields )
66 , mGroups( groups )
67 {}
68 QString mName;
69 QList<QString> mFields;
70 QList<QgsEditFormConfig::GroupData> mGroups;
71 };
72
81 {
82 NoProperty = 0,
83 AllProperties = 1,
84 Alias = 2,
85 Editable = 3,
86 };
87
95
96 QgsEditFormConfig &operator=( const QgsEditFormConfig &o );
97 // TODO c++20 - replace with = default
98 bool operator==( const QgsEditFormConfig &o ) const;
99
105 void addTab( QgsAttributeEditorElement *data SIP_TRANSFER );
106
110 QList< QgsAttributeEditorElement * > tabs() const;
111
115 void clearTabs();
116
122 QgsAttributeEditorContainer *invisibleRootContainer();
123
125 Qgis::AttributeFormLayout layout() const;
126
128 void setLayout( Qgis::AttributeFormLayout editorLayout );
129
133 QString uiForm() const;
134
143 void setUiForm( const QString &ui );
144
163 bool setWidgetConfig( const QString &widgetName, const QVariantMap &config );
164
172 QVariantMap widgetConfig( const QString &widgetName ) const;
173
181 bool removeWidgetConfig( const QString &widgetName );
182
187 bool readOnly( int idx ) const;
188
192 void setReadOnly( int idx, bool readOnly = true );
193
199 bool labelOnTop( int idx ) const;
200
207 void setLabelOnTop( int idx, bool onTop );
208
216 bool reuseLastValue( int index ) const;
217
225 void setReuseLastValue( int index, bool reuse );
226
227 // Python form init function stuff
228
235 QString initFunction() const;
236
243 void setInitFunction( const QString &function );
244
248 QString initCode() const;
249
255 void setInitCode( const QString &code );
256
260 QString initFilePath() const;
261
267 void setInitFilePath( const QString &filePath );
268
274 Qgis::AttributeFormPythonInitCodeSource initCodeSource() const;
275
277 void setInitCodeSource( Qgis::AttributeFormPythonInitCodeSource initCodeSource );
278
280 Qgis::AttributeFormSuppression suppress() const;
282 void setSuppress( Qgis::AttributeFormSuppression s );
283
284 // Serialization
285
290 void readXml( const QDomNode &node, QgsReadWriteContext &context );
291
296 void writeXml( QDomNode &node, const QgsReadWriteContext &context ) const;
297
302 Q_DECL_DEPRECATED QgsAttributeEditorElement *attributeEditorElementFromDomElement( QDomElement &elem, QgsAttributeEditorElement *parent, const QString &layerId = QString(), const QgsReadWriteContext &context = QgsReadWriteContext() ) SIP_DEPRECATED;
303
307 explicit QgsEditFormConfig();
308
313 void setDataDefinedFieldProperties( const QString &fieldName, const QgsPropertyCollection &properties );
314
319 QgsPropertyCollection dataDefinedFieldProperties( const QString &fieldName ) const;
320
325 static const QgsPropertiesDefinition &propertyDefinitions();
326
327 private:
328
333 void setFields( const QgsFields &fields );
334
338 void onRelationsLoaded();
339
344 bool legacyUpdateRelationWidgetInTabs( QgsAttributeEditorContainer *container, const QString &widgetName, const QVariantMap &config );
345
346 private:
347 void fixLegacyConfig( QDomElement &el );
348
349 QExplicitlySharedDataPointer<QgsEditFormConfigPrivate> d;
350
351 friend class QgsVectorLayer;
352};
353
354#endif // QGSEDITFORMCONFIG_H
AttributeFormSuppression
Available form types for layout of the attribute form editor.
Definition: qgis.h:3592
AttributeFormPythonInitCodeSource
The Python init code source for attribute forms.
Definition: qgis.h:3607
AttributeFormLayout
Available form types for layout of the attribute form editor.
Definition: qgis.h:3577
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:45
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_TRANSFER
Definition: qgis_sip.h:36
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
QMap< int, QgsPropertyDefinition > QgsPropertiesDefinition
Definition of available properties.
GroupData()=default
Constructor for GroupData.
GroupData(const QString &name, const QList< QString > &fields)
TabData()=default
Constructor for TabData.
TabData(const QString &name, const QList< QString > &fields, const QList< QgsEditFormConfig::GroupData > &groups)
QList< QgsEditFormConfig::GroupData > mGroups