QGIS API Documentation 4.1.0-Master (60fea48833c)
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 };
85 // *INDENT-ON*
86
89
90 QgsEditFormConfig &operator=( const QgsEditFormConfig &o );
91 // TODO c++20 - replace with = default
92 bool operator==( const QgsEditFormConfig &o ) const;
93
99 void addTab( QgsAttributeEditorElement *data SIP_TRANSFER );
100
104 QList< QgsAttributeEditorElement * > tabs() const;
105
109 void clearTabs();
110
116 QgsAttributeEditorContainer *invisibleRootContainer();
117
119 Qgis::AttributeFormLayout layout() const;
120
122 void setLayout( Qgis::AttributeFormLayout editorLayout );
123
127 QString uiForm() const;
128
137 void setUiForm( const QString &ui );
138
157 bool setWidgetConfig( const QString &widgetName, const QVariantMap &config );
158
166 QVariantMap widgetConfig( const QString &widgetName ) const;
167
175 bool removeWidgetConfig( const QString &widgetName );
176
181 bool readOnly( int idx ) const;
182
186 void setReadOnly( int idx, bool readOnly = true );
187
193 bool labelOnTop( int idx ) const;
194
201 void setLabelOnTop( int idx, bool onTop );
202
211 Q_DECL_DEPRECATED bool reuseLastValue( int index ) const;
212
221 Q_DECL_DEPRECATED void setReuseLastValue( int index, bool reuse );
222
229 Qgis::AttributeFormReuseLastValuePolicy reuseLastValuePolicy( int index ) const;
230
237 void setReuseLastValuePolicy( int index, Qgis::AttributeFormReuseLastValuePolicy policy );
238
239 // Python form init function stuff
240
247 QString initFunction() const;
248
255 void setInitFunction( const QString &function );
256
260 QString initCode() const;
261
267 void setInitCode( const QString &code );
268
272 QString initFilePath() const;
273
279 void setInitFilePath( const QString &filePath );
280
286 Qgis::AttributeFormPythonInitCodeSource initCodeSource() const;
287
289 void setInitCodeSource( Qgis::AttributeFormPythonInitCodeSource initCodeSource );
290
292 Qgis::AttributeFormSuppression suppress() const;
294 void setSuppress( Qgis::AttributeFormSuppression s );
295
296 // Serialization
297
302 void readXml( const QDomNode &node, QgsReadWriteContext &context );
303
308 void writeXml( QDomNode &node, const QgsReadWriteContext &context ) const;
309
314 Q_DECL_DEPRECATED QgsAttributeEditorElement *attributeEditorElementFromDomElement(
315 QDomElement &elem, QgsAttributeEditorElement *parent, const QString &layerId = QString(), const QgsReadWriteContext &context = QgsReadWriteContext()
317
321 explicit QgsEditFormConfig();
322
327 void setDataDefinedFieldProperties( const QString &fieldName, const QgsPropertyCollection &properties );
328
333 QgsPropertyCollection dataDefinedFieldProperties( const QString &fieldName ) const;
334
339 static const QgsPropertiesDefinition &propertyDefinitions();
340
341 private:
346 void setFields( const QgsFields &fields );
347
351 void onRelationsLoaded(); // cppcheck-suppress functionConst
352
357 bool legacyUpdateRelationWidgetInTabs( QgsAttributeEditorContainer *container, const QString &widgetName, const QVariantMap &config );
358
359 private:
360 void fixLegacyConfig( QDomElement &el ) const;
361
362 QExplicitlySharedDataPointer<QgsEditFormConfigPrivate> d;
363
364 friend class QgsVectorLayer;
365};
366
367#endif // QGSEDITFORMCONFIG_H
AttributeFormReuseLastValuePolicy
Attribute form policy for reusing last entered values.
Definition qgis.h:5885
AttributeFormSuppression
Available form types for layout of the attribute form editor.
Definition qgis.h:5856
AttributeFormPythonInitCodeSource
The Python init code source for attribute forms.
Definition qgis.h:5871
AttributeFormLayout
Available form types for layout of the attribute form editor.
Definition qgis.h:5841
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