QGIS API Documentation 4.1.0-Master (376402f9aeb)
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"
24#include "qgsreadwritecontext.h"
25
26#include <QDomDocument>
27#include <QDomElement>
28#include <QMap>
29
31class QgsEditFormConfigPrivate;
34
40class CORE_EXPORT QgsEditFormConfig
41{
42 Q_GADGET
43
44 public:
45 struct GroupData
46 {
47 GroupData() = default;
48 GroupData( const QString &name, const QList<QString> &fields )
49 : mName( name )
50 , mFields( fields )
51 {}
52 QString mName;
53 QList<QString> mFields;
54 };
55
56 struct TabData
57 {
58 TabData() = default;
59 TabData( const QString &name, const QList<QString> &fields, const QList<QgsEditFormConfig::GroupData> &groups )
60 : mName( name )
61 , mFields( fields )
62 , mGroups( groups )
63 {}
64 QString mName;
65 QList<QString> mFields;
66 QList<QgsEditFormConfig::GroupData> mGroups;
67 };
68
69 // *INDENT-OFF*
70
79 {
80 NoProperty = 0,
81 AllProperties = 1,
82 Alias = 2,
83 Editable = 3,
84 CustomComment = 4,
85 };
86 // *INDENT-ON*
87
90
91 QgsEditFormConfig &operator=( const QgsEditFormConfig &o );
92 // TODO c++20 - replace with = default
93 bool operator==( const QgsEditFormConfig &o ) const;
94
100 void addTab( QgsAttributeEditorElement *data SIP_TRANSFER );
101
105 QList< QgsAttributeEditorElement * > tabs() const;
106
110 void clearTabs();
111
117 QgsAttributeEditorContainer *invisibleRootContainer();
118
120 Qgis::AttributeFormLayout layout() const;
121
123 void setLayout( Qgis::AttributeFormLayout editorLayout );
124
128 QString uiForm() const;
129
138 void setUiForm( const QString &ui );
139
158 bool setWidgetConfig( const QString &widgetName, const QVariantMap &config );
159
167 QVariantMap widgetConfig( const QString &widgetName ) const;
168
176 bool removeWidgetConfig( const QString &widgetName );
177
182 bool readOnly( int idx ) const;
183
187 void setReadOnly( int idx, bool readOnly = true );
188
194 bool labelOnTop( int idx ) const;
195
202 void setLabelOnTop( int idx, bool onTop );
203
212 Q_DECL_DEPRECATED bool reuseLastValue( int index ) const;
213
222 Q_DECL_DEPRECATED void setReuseLastValue( int index, bool reuse );
223
230 Qgis::AttributeFormReuseLastValuePolicy reuseLastValuePolicy( int index ) const;
231
238 void setReuseLastValuePolicy( int index, Qgis::AttributeFormReuseLastValuePolicy policy );
239
240 // Python form init function stuff
241
248 QString initFunction() const;
249
256 void setInitFunction( const QString &function );
257
261 QString initCode() const;
262
268 void setInitCode( const QString &code );
269
273 QString initFilePath() const;
274
280 void setInitFilePath( const QString &filePath );
281
287 Qgis::AttributeFormPythonInitCodeSource initCodeSource() const;
288
290 void setInitCodeSource( Qgis::AttributeFormPythonInitCodeSource initCodeSource );
291
293 Qgis::AttributeFormSuppression suppress() const;
295 void setSuppress( Qgis::AttributeFormSuppression s );
296
297 // Serialization
298
303 void readXml( const QDomNode &node, QgsReadWriteContext &context );
304
309 void writeXml( QDomNode &node, const QgsReadWriteContext &context ) const;
310
315 Q_DECL_DEPRECATED QgsAttributeEditorElement *attributeEditorElementFromDomElement(
316 QDomElement &elem, QgsAttributeEditorElement *parent, const QString &layerId = QString(), const QgsReadWriteContext &context = QgsReadWriteContext()
318
322 explicit QgsEditFormConfig();
323
328 void setDataDefinedFieldProperties( const QString &fieldName, const QgsPropertyCollection &properties );
329
334 QgsPropertyCollection dataDefinedFieldProperties( const QString &fieldName ) const;
335
340 static const QgsPropertiesDefinition &propertyDefinitions();
341
342 private:
347 void setFields( const QgsFields &fields );
348
352 void onRelationsLoaded(); // cppcheck-suppress functionConst
353
358 bool legacyUpdateRelationWidgetInTabs( QgsAttributeEditorContainer *container, const QString &widgetName, const QVariantMap &config );
359
360 private:
361 void fixLegacyConfig( QDomElement &el ) const;
362
363 QExplicitlySharedDataPointer<QgsEditFormConfigPrivate> d;
364
365 friend class QgsVectorLayer;
366};
367
368#endif // QGSEDITFORMCONFIG_H
AttributeFormReuseLastValuePolicy
Attribute form policy for reusing last entered values.
Definition qgis.h:6041
AttributeFormSuppression
Available form types for layout of the attribute form editor.
Definition qgis.h:6012
AttributeFormPythonInitCodeSource
The Python init code source for attribute forms.
Definition qgis.h:6027
AttributeFormLayout
Available form types for layout of the attribute form editor.
Definition qgis.h:5997
A container for attribute editors, used to group them visually in the attribute form if it is set to ...
An abstract base class for any elements of a drag and drop form.
Contains configuration settings for an editor form.
friend class QgsVectorLayer
QgsEditFormConfig(const QgsEditFormConfig &o)
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 an integer key value.
A container for the context for various read/write operations on objects.
Manages a set of relations between layers.
#define SIP_DEPRECATED
Definition qgis_sip.h:113
#define SIP_MONKEYPATCH_SCOPEENUM_UNNEST(OUTSIDE_CLASS, FORMERNAME)
Definition qgis_sip.h:267
#define SIP_TRANSFER
Definition qgis_sip.h:35
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