QGIS API Documentation 3.30.0-'s-Hertogenbosch (f186b8efe0)
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 Editable = 3,
117 };
118
126
127 QgsEditFormConfig &operator=( const QgsEditFormConfig &o );
128 // TODO c++20 - replace with = default
129 bool operator==( const QgsEditFormConfig &o ) const;
130
136 void addTab( QgsAttributeEditorElement *data SIP_TRANSFER );
137
141 QList< QgsAttributeEditorElement * > tabs() const;
142
146 void clearTabs();
147
153 QgsAttributeEditorContainer *invisibleRootContainer();
154
156 EditorLayout layout() const;
157
159 void setLayout( EditorLayout editorLayout );
160
164 QString uiForm() const;
165
174 void setUiForm( const QString &ui );
175
194 bool setWidgetConfig( const QString &widgetName, const QVariantMap &config );
195
203 QVariantMap widgetConfig( const QString &widgetName ) const;
204
212 bool removeWidgetConfig( const QString &widgetName );
213
218 bool readOnly( int idx ) const;
219
223 void setReadOnly( int idx, bool readOnly = true );
224
230 bool labelOnTop( int idx ) const;
231
238 void setLabelOnTop( int idx, bool onTop );
239
247 bool reuseLastValue( int index ) const;
248
256 void setReuseLastValue( int index, bool reuse );
257
258 // Python form init function stuff
259
266 QString initFunction() const;
267
274 void setInitFunction( const QString &function );
275
279 QString initCode() const;
280
286 void setInitCode( const QString &code );
287
291 QString initFilePath() const;
292
298 void setInitFilePath( const QString &filePath );
299
305 PythonInitCodeSource initCodeSource() const;
306
308 void setInitCodeSource( PythonInitCodeSource initCodeSource );
309
311 FeatureFormSuppress suppress() const;
313 void setSuppress( FeatureFormSuppress s );
314
315 // Serialization
316
321 void readXml( const QDomNode &node, QgsReadWriteContext &context );
322
327 void writeXml( QDomNode &node, const QgsReadWriteContext &context ) const;
328
333 Q_DECL_DEPRECATED QgsAttributeEditorElement *attributeEditorElementFromDomElement( QDomElement &elem, QgsAttributeEditorElement *parent, const QString &layerId = QString(), const QgsReadWriteContext &context = QgsReadWriteContext() ) SIP_DEPRECATED;
334
338 explicit QgsEditFormConfig();
339
344 void setDataDefinedFieldProperties( const QString &fieldName, const QgsPropertyCollection &properties );
345
350 QgsPropertyCollection dataDefinedFieldProperties( const QString &fieldName ) const;
351
352
357 static const QgsPropertiesDefinition &propertyDefinitions();
358
359 private:
360
365 void setFields( const QgsFields &fields );
366
370 void onRelationsLoaded();
371
376 bool legacyUpdateRelationWidgetInTabs( QgsAttributeEditorContainer *container, const QString &widgetName, const QVariantMap &config );
377
378 private:
379 void fixLegacyConfig( QDomElement &el );
380
381 QExplicitlySharedDataPointer<QgsEditFormConfigPrivate> d;
382
383 friend class QgsVectorLayer;
384};
385
386#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