QGIS API Documentation 3.36.0-Maidenhead (09951dc0acf)
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 {
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
73 // *INDENT-OFF*
74
83 {
84 NoProperty = 0,
85 AllProperties = 1,
86 Alias = 2,
87 Editable = 3,
88 };
89 // *INDENT-ON*
90
97
98 QgsEditFormConfig &operator=( const QgsEditFormConfig &o );
99 // TODO c++20 - replace with = default
100 bool operator==( const QgsEditFormConfig &o ) const;
101
107 void addTab( QgsAttributeEditorElement *data SIP_TRANSFER );
108
112 QList< QgsAttributeEditorElement * > tabs() const;
113
117 void clearTabs();
118
124 QgsAttributeEditorContainer *invisibleRootContainer();
125
127 Qgis::AttributeFormLayout layout() const;
128
130 void setLayout( Qgis::AttributeFormLayout editorLayout );
131
135 QString uiForm() const;
136
145 void setUiForm( const QString &ui );
146
165 bool setWidgetConfig( const QString &widgetName, const QVariantMap &config );
166
174 QVariantMap widgetConfig( const QString &widgetName ) const;
175
183 bool removeWidgetConfig( const QString &widgetName );
184
189 bool readOnly( int idx ) const;
190
194 void setReadOnly( int idx, bool readOnly = true );
195
201 bool labelOnTop( int idx ) const;
202
209 void setLabelOnTop( int idx, bool onTop );
210
218 bool reuseLastValue( int index ) const;
219
227 void setReuseLastValue( int index, bool reuse );
228
229 // Python form init function stuff
230
237 QString initFunction() const;
238
245 void setInitFunction( const QString &function );
246
250 QString initCode() const;
251
257 void setInitCode( const QString &code );
258
262 QString initFilePath() const;
263
269 void setInitFilePath( const QString &filePath );
270
276 Qgis::AttributeFormPythonInitCodeSource initCodeSource() const;
277
279 void setInitCodeSource( Qgis::AttributeFormPythonInitCodeSource initCodeSource );
280
282 Qgis::AttributeFormSuppression suppress() const;
284 void setSuppress( Qgis::AttributeFormSuppression s );
285
286 // Serialization
287
292 void readXml( const QDomNode &node, QgsReadWriteContext &context );
293
298 void writeXml( QDomNode &node, const QgsReadWriteContext &context ) const;
299
304 Q_DECL_DEPRECATED QgsAttributeEditorElement *attributeEditorElementFromDomElement( QDomElement &elem, QgsAttributeEditorElement *parent, const QString &layerId = QString(), const QgsReadWriteContext &context = QgsReadWriteContext() ) SIP_DEPRECATED;
305
309 explicit QgsEditFormConfig();
310
315 void setDataDefinedFieldProperties( const QString &fieldName, const QgsPropertyCollection &properties );
316
321 QgsPropertyCollection dataDefinedFieldProperties( const QString &fieldName ) const;
322
327 static const QgsPropertiesDefinition &propertyDefinitions();
328
329 private:
330
335 void setFields( const QgsFields &fields );
336
340 void onRelationsLoaded();
341
346 bool legacyUpdateRelationWidgetInTabs( QgsAttributeEditorContainer *container, const QString &widgetName, const QVariantMap &config );
347
348 private:
349 void fixLegacyConfig( QDomElement &el );
350
351 QExplicitlySharedDataPointer<QgsEditFormConfigPrivate> d;
352
353 friend class QgsVectorLayer;
354};
355
356#endif // QGSEDITFORMCONFIG_H
AttributeFormSuppression
Available form types for layout of the attribute form editor.
Definition qgis.h:4371
AttributeFormPythonInitCodeSource
The Python init code source for attribute forms.
Definition qgis.h:4386
AttributeFormLayout
Available form types for layout of the attribute form editor.
Definition qgis.h:4356
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_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()=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