QGIS API Documentation  3.12.1-BucureČ™ti (121cc00ff0)
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 
109 
110  QgsEditFormConfig &operator=( const QgsEditFormConfig &o );
111 
112  bool operator==( const QgsEditFormConfig &o );
113 
119  void addTab( QgsAttributeEditorElement *data SIP_TRANSFER );
120 
124  QList< QgsAttributeEditorElement * > tabs() const;
125 
129  void clearTabs();
130 
136  QgsAttributeEditorContainer *invisibleRootContainer();
137 
139  EditorLayout layout() const;
140 
142  void setLayout( EditorLayout editorLayout );
143 
147  QString uiForm() const;
148 
157  void setUiForm( const QString &ui );
158 
176  bool setWidgetConfig( const QString &widgetName, const QVariantMap &config );
177 
185  QVariantMap widgetConfig( const QString &widgetName ) const;
186 
194  bool removeWidgetConfig( const QString &widgetName );
195 
200  bool readOnly( int idx ) const;
201 
205  void setReadOnly( int idx, bool readOnly = true );
206 
212  bool labelOnTop( int idx ) const;
213 
220  void setLabelOnTop( int idx, bool onTop );
221 
222 
223  // Python form init function stuff
224 
231  QString initFunction() const;
232 
239  void setInitFunction( const QString &function );
240 
244  QString initCode() const;
245 
251  void setInitCode( const QString &code );
252 
256  QString initFilePath() const;
257 
263  void setInitFilePath( const QString &filePath );
264 
270  PythonInitCodeSource initCodeSource() const;
271 
273  void setInitCodeSource( PythonInitCodeSource initCodeSource );
274 
276  FeatureFormSuppress suppress() const;
278  void setSuppress( FeatureFormSuppress s );
279 
280  // Serialization
281 
286  void readXml( const QDomNode &node, QgsReadWriteContext &context );
287 
292  void writeXml( QDomNode &node, const QgsReadWriteContext &context ) const;
293 
297  QgsAttributeEditorElement *attributeEditorElementFromDomElement( QDomElement &elem, QgsAttributeEditorElement *parent, const QString &layerId = QString(), const QgsReadWriteContext &context = QgsReadWriteContext() );
298 
302  explicit QgsEditFormConfig();
303 
304  private:
305 
310  void setFields( const QgsFields &fields );
311 
315  void onRelationsLoaded();
316 
317  private:
318  QExplicitlySharedDataPointer<QgsEditFormConfigPrivate> d;
319 
320  friend class QgsVectorLayer;
321 };
322 
323 #endif // QGSEDITFORMCONFIG_H
The class is used as a container of context for various read/write operations on other objects...
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:42
QList< QgsEditFormConfig::GroupData > mGroups
FeatureFormSuppress
Types of feature form suppression after feature creation.
#define SIP_TRANSFER
Definition: qgis_sip.h:36
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...
Represents a vector layer which manages a vector based data sets.
PythonInitCodeSource
The Python init code source options.