QGIS API Documentation  3.17.0-Master (3b262f2a79)
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 
30 class QgsRelationManager;
31 class QgsEditFormConfigPrivate;
32 
37 class CORE_EXPORT QgsEditFormConfig
38 {
39 
40  Q_GADGET
41 
42  public:
43 
46  {
47  GeneratedLayout = 0,
48  TabLayout = 1,
49  UiFileLayout = 2
50  };
51  Q_ENUM( EditorLayout )
52 
53  struct GroupData
54  {
56  GroupData() = default;
57  GroupData( const QString &name, const QList<QString> &fields )
58  : mName( name )
59  , mFields( fields )
60  {}
61  QString mName;
62  QList<QString> mFields;
63  };
64 
65  struct TabData
66  {
68  TabData() = default;
69  TabData( const QString &name, const QList<QString> &fields, const QList<QgsEditFormConfig::GroupData> &groups )
70  : mName( name )
71  , mFields( fields )
72  , mGroups( groups )
73  {}
74  QString mName;
75  QList<QString> mFields;
76  QList<QgsEditFormConfig::GroupData> mGroups;
77  };
78 
83  {
84  SuppressDefault = 0,
85  SuppressOn = 1,
86  SuppressOff = 2
87  };
88  Q_ENUM( FeatureFormSuppress )
89 
90 
94  {
95  CodeSourceNone = 0,
96  CodeSourceFile = 1,
97  CodeSourceDialog = 2,
98  CodeSourceEnvironment = 3
99  };
100  Q_ENUM( PythonInitCodeSource )
101 
102 
110  {
111  NoProperty = 0,
112  AllProperties = 1,
113  Alias = 2,
114  };
115 
123 
124  QgsEditFormConfig &operator=( const QgsEditFormConfig &o );
125 
126  bool operator==( const QgsEditFormConfig &o );
127 
133  void addTab( QgsAttributeEditorElement *data SIP_TRANSFER );
134 
138  QList< QgsAttributeEditorElement * > tabs() const;
139 
143  void clearTabs();
144 
150  QgsAttributeEditorContainer *invisibleRootContainer();
151 
153  EditorLayout layout() const;
154 
156  void setLayout( EditorLayout editorLayout );
157 
161  QString uiForm() const;
162 
171  void setUiForm( const QString &ui );
172 
191  bool setWidgetConfig( const QString &widgetName, const QVariantMap &config );
192 
200  QVariantMap widgetConfig( const QString &widgetName ) const;
201 
209  bool removeWidgetConfig( const QString &widgetName );
210 
215  bool readOnly( int idx ) const;
216 
220  void setReadOnly( int idx, bool readOnly = true );
221 
227  bool labelOnTop( int idx ) const;
228 
235  void setLabelOnTop( int idx, bool onTop );
236 
237 
238  // Python form init function stuff
239 
246  QString initFunction() const;
247 
254  void setInitFunction( const QString &function );
255 
259  QString initCode() const;
260 
266  void setInitCode( const QString &code );
267 
271  QString initFilePath() const;
272 
278  void setInitFilePath( const QString &filePath );
279 
285  PythonInitCodeSource initCodeSource() const;
286 
288  void setInitCodeSource( PythonInitCodeSource initCodeSource );
289 
291  FeatureFormSuppress suppress() const;
293  void setSuppress( FeatureFormSuppress s );
294 
295  // Serialization
296 
301  void readXml( const QDomNode &node, QgsReadWriteContext &context );
302 
307  void writeXml( QDomNode &node, const QgsReadWriteContext &context ) const;
308 
312  QgsAttributeEditorElement *attributeEditorElementFromDomElement( QDomElement &elem, QgsAttributeEditorElement *parent, const QString &layerId = QString(), const QgsReadWriteContext &context = QgsReadWriteContext() );
313 
317  explicit QgsEditFormConfig();
318 
323  void setDataDefinedFieldProperties( const QString &fieldName, const QgsPropertyCollection &properties );
324 
329  QgsPropertyCollection dataDefinedFieldProperties( const QString &fieldName ) const;
330 
331 
336  static const QgsPropertiesDefinition &propertyDefinitions();
337 
338  private:
339 
344  void setFields( const QgsFields &fields );
345 
349  void onRelationsLoaded();
350 
355  bool legacyUpdateRelationWidgetInTabs( QgsAttributeEditorContainer *container, const QString &widgetName, const QVariantMap &config );
356 
357  private:
358  QExplicitlySharedDataPointer<QgsEditFormConfigPrivate> d;
359 
360  friend class QgsVectorLayer;
361 };
362 
363 #endif // QGSEDITFORMCONFIG_H
The class is used as a container of context for various read/write operations on other objects...
DataDefinedProperty
Data defined properties.
This is an abstract base class for any elements of a drag and drop form.
EditorLayout
The different types to layout the attribute editor.
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
Container of fields for a vector layer.
Definition: qgsfields.h:44
QList< QgsEditFormConfig::GroupData > mGroups
FeatureFormSuppress
Types of feature form suppression after feature creation.
#define SIP_TRANSFER
Definition: qgis_sip.h:36
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)
This class manages a set of relations between layers.
This is a container for attribute editors, used to group them visually in the attribute form if it is...
A grouped map of multiple QgsProperty objects, each referenced by a integer key value.
Represents a vector layer which manages a vector based data sets.
PythonInitCodeSource
The Python init code source options.