QGIS API Documentation 3.29.0-Master (53715c36dc)
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
28#include "qgsreadwritecontext.h"
29
31class QgsEditFormConfigPrivate;
33
39class CORE_EXPORT QgsEditFormConfig
40{
41
42 Q_GADGET
43
44 public:
45
48 {
49 GeneratedLayout = 0,
50 TabLayout = 1,
51 UiFileLayout = 2
52 };
53 Q_ENUM( EditorLayout )
54
55 struct GroupData
56 {
58 GroupData() = default;
59 GroupData( const QString &name, const QList<QString> &fields )
60 : mName( name )
61 , mFields( fields )
62 {}
63 QString mName;
64 QList<QString> mFields;
65 };
66
67 struct TabData
68 {
70 TabData() = default;
71 TabData( const QString &name, const QList<QString> &fields, const QList<QgsEditFormConfig::GroupData> &groups )
72 : mName( name )
73 , mFields( fields )
74 , mGroups( groups )
75 {}
76 QString mName;
77 QList<QString> mFields;
78 QList<QgsEditFormConfig::GroupData> mGroups;
79 };
80
85 {
86 SuppressDefault = 0,
87 SuppressOn = 1,
88 SuppressOff = 2
89 };
90 Q_ENUM( FeatureFormSuppress )
91
92
96 {
97 CodeSourceNone = 0,
98 CodeSourceFile = 1,
99 CodeSourceDialog = 2,
100 CodeSourceEnvironment = 3
101 };
102 Q_ENUM( PythonInitCodeSource )
103
104
112 {
113 NoProperty = 0,
114 AllProperties = 1,
115 Alias = 2,
116 };
117
125
126 QgsEditFormConfig &operator=( const QgsEditFormConfig &o );
127 // TODO c++20 - replace with = default
128 bool operator==( const QgsEditFormConfig &o ) const;
129
135 void addTab( QgsAttributeEditorElement *data SIP_TRANSFER );
136
140 QList< QgsAttributeEditorElement * > tabs() const;
141
145 void clearTabs();
146
152 QgsAttributeEditorContainer *invisibleRootContainer();
153
155 EditorLayout layout() const;
156
158 void setLayout( EditorLayout editorLayout );
159
163 QString uiForm() const;
164
173 void setUiForm( const QString &ui );
174
193 bool setWidgetConfig( const QString &widgetName, const QVariantMap &config );
194
202 QVariantMap widgetConfig( const QString &widgetName ) const;
203
211 bool removeWidgetConfig( const QString &widgetName );
212
217 bool readOnly( int idx ) const;
218
222 void setReadOnly( int idx, bool readOnly = true );
223
229 bool labelOnTop( int idx ) const;
230
237 void setLabelOnTop( int idx, bool onTop );
238
246 bool reuseLastValue( int index ) const;
247
255 void setReuseLastValue( int index, bool reuse );
256
257 // Python form init function stuff
258
265 QString initFunction() const;
266
273 void setInitFunction( const QString &function );
274
278 QString initCode() const;
279
285 void setInitCode( const QString &code );
286
290 QString initFilePath() const;
291
297 void setInitFilePath( const QString &filePath );
298
304 PythonInitCodeSource initCodeSource() const;
305
307 void setInitCodeSource( PythonInitCodeSource initCodeSource );
308
310 FeatureFormSuppress suppress() const;
312 void setSuppress( FeatureFormSuppress s );
313
314 // Serialization
315
320 void readXml( const QDomNode &node, QgsReadWriteContext &context );
321
326 void writeXml( QDomNode &node, const QgsReadWriteContext &context ) const;
327
332 Q_DECL_DEPRECATED QgsAttributeEditorElement *attributeEditorElementFromDomElement( QDomElement &elem, QgsAttributeEditorElement *parent, const QString &layerId = QString(), const QgsReadWriteContext &context = QgsReadWriteContext() ) SIP_DEPRECATED;
333
337 explicit QgsEditFormConfig();
338
343 void setDataDefinedFieldProperties( const QString &fieldName, const QgsPropertyCollection &properties );
344
349 QgsPropertyCollection dataDefinedFieldProperties( const QString &fieldName ) const;
350
351
356 static const QgsPropertiesDefinition &propertyDefinitions();
357
358 private:
359
364 void setFields( const QgsFields &fields );
365
369 void onRelationsLoaded();
370
375 bool legacyUpdateRelationWidgetInTabs( QgsAttributeEditorContainer *container, const QString &widgetName, const QVariantMap &config );
376
377 private:
378 void fixLegacyConfig( QDomElement &el );
379
380 QExplicitlySharedDataPointer<QgsEditFormConfigPrivate> d;
381
382 friend class QgsVectorLayer;
383};
384
385#endif // QGSEDITFORMCONFIG_H
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.
EditorLayout
The different types to layout the attribute editor.
FeatureFormSuppress
Types of feature form suppression after feature creation.
DataDefinedProperty
Data defined properties.
PythonInitCodeSource
The Python init code source options.
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