QGIS API Documentation  3.0.2-Girona (307d082)
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.h"
23 #include <QMap>
24 #include <QDomElement>
25 #include <QDomDocument>
26 
28 
30 class QgsRelationManager;
31 class QgsEditFormConfigPrivate;
32 
37 class CORE_EXPORT QgsEditFormConfig
38 {
39  public:
40 
43  {
44  GeneratedLayout = 0,
45  TabLayout = 1,
46  UiFileLayout = 2
47  };
48 
49  struct GroupData
50  {
52  GroupData() = default;
53  GroupData( const QString &name, const QList<QString> &fields )
54  : mName( name )
55  , mFields( fields )
56  {}
57  QString mName;
58  QList<QString> mFields;
59  };
60 
61  struct TabData
62  {
64  TabData() = default;
65  TabData( const QString &name, const QList<QString> &fields, const QList<QgsEditFormConfig::GroupData> &groups )
66  : mName( name )
67  , mFields( fields )
68  , mGroups( groups )
69  {}
70  QString mName;
71  QList<QString> mFields;
72  QList<QgsEditFormConfig::GroupData> mGroups;
73  };
74 
79  {
80  SuppressDefault = 0,
81  SuppressOn = 1,
82  SuppressOff = 2
83  };
84 
89  {
90  CodeSourceNone = 0,
91  CodeSourceFile = 1,
92  CodeSourceDialog = 2,
93  CodeSourceEnvironment = 3
94  };
95 
103 
104  QgsEditFormConfig &operator=( const QgsEditFormConfig &o );
105 
106  bool operator==( const QgsEditFormConfig &o );
107 
113  void addTab( QgsAttributeEditorElement *data SIP_TRANSFER );
114 
118  QList< QgsAttributeEditorElement * > tabs() const;
119 
123  void clearTabs();
124 
130  QgsAttributeEditorContainer *invisibleRootContainer();
131 
133  EditorLayout layout() const;
134 
136  void setLayout( EditorLayout editorLayout );
137 
139  QString uiForm() const;
140 
147  void setUiForm( const QString &ui );
148 
166  bool setWidgetConfig( const QString &widgetName, const QVariantMap &config );
167 
175  QVariantMap widgetConfig( const QString &widgetName ) const;
176 
184  bool removeWidgetConfig( const QString &widgetName );
185 
190  bool readOnly( int idx ) const;
191 
195  void setReadOnly( int idx, bool readOnly = true );
196 
202  bool labelOnTop( int idx ) const;
203 
210  void setLabelOnTop( int idx, bool onTop );
211 
212 
213  // Python form init function stuff
214 
221  QString initFunction() const;
222 
229  void setInitFunction( const QString &function );
230 
234  QString initCode() const;
235 
241  void setInitCode( const QString &code );
242 
246  QString initFilePath() const;
247 
253  void setInitFilePath( const QString &filePath );
254 
260  PythonInitCodeSource initCodeSource() const;
261 
263  void setInitCodeSource( PythonInitCodeSource initCodeSource );
264 
266  FeatureFormSuppress suppress() const;
268  void setSuppress( FeatureFormSuppress s );
269 
270  // Serialization
271 
276  void readXml( const QDomNode &node, const QgsReadWriteContext &context );
277 
282  void writeXml( QDomNode &node, const QgsReadWriteContext &context ) const;
283 
287  QgsAttributeEditorElement *attributeEditorElementFromDomElement( QDomElement &elem, QgsAttributeEditorElement *parent );
288 
292  explicit QgsEditFormConfig();
293 
294  private:
295 
300  void setFields( const QgsFields &fields );
301 
305  void onRelationsLoaded();
306 
307  private:
308  QExplicitlySharedDataPointer<QgsEditFormConfigPrivate> d;
309 
310  friend class QgsVectorLayer;
311 };
312 
313 #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.