QGIS API Documentation  3.10.0-A Coruña (6c816b4204)
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  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 
141  QString uiForm() const;
142 
151  void setUiForm( const QString &ui );
152 
170  bool setWidgetConfig( const QString &widgetName, const QVariantMap &config );
171 
179  QVariantMap widgetConfig( const QString &widgetName ) const;
180 
188  bool removeWidgetConfig( const QString &widgetName );
189 
194  bool readOnly( int idx ) const;
195 
199  void setReadOnly( int idx, bool readOnly = true );
200 
206  bool labelOnTop( int idx ) const;
207 
214  void setLabelOnTop( int idx, bool onTop );
215 
216 
217  // Python form init function stuff
218 
225  QString initFunction() const;
226 
233  void setInitFunction( const QString &function );
234 
238  QString initCode() const;
239 
245  void setInitCode( const QString &code );
246 
250  QString initFilePath() const;
251 
257  void setInitFilePath( const QString &filePath );
258 
264  PythonInitCodeSource initCodeSource() const;
265 
267  void setInitCodeSource( PythonInitCodeSource initCodeSource );
268 
270  FeatureFormSuppress suppress() const;
272  void setSuppress( FeatureFormSuppress s );
273 
274  // Serialization
275 
280  void readXml( const QDomNode &node, QgsReadWriteContext &context );
281 
286  void writeXml( QDomNode &node, const QgsReadWriteContext &context ) const;
287 
291  QgsAttributeEditorElement *attributeEditorElementFromDomElement( QDomElement &elem, QgsAttributeEditorElement *parent, const QString &layerId = QString(), const QgsReadWriteContext &context = QgsReadWriteContext() );
292 
296  explicit QgsEditFormConfig();
297 
298  private:
299 
304  void setFields( const QgsFields &fields );
305 
309  void onRelationsLoaded();
310 
311  private:
312  QExplicitlySharedDataPointer<QgsEditFormConfigPrivate> d;
313 
314  friend class QgsVectorLayer;
315 };
316 
317 #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.