QGIS API Documentation  3.22.4-Białowieża (ce8e65e95e)
qgsattributeeditorelement.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsattributeeditorelement.h - QgsAttributeEditorElement
3 
4  ---------------------
5  begin : 18.8.2016
6  copyright : (C) 2016 by Matthias Kuhn
7  email : [email protected]
8  ***************************************************************************
9  * *
10  * This program is free software; you can redistribute it and/or modify *
11  * it under the terms of the GNU General Public License as published by *
12  * the Free Software Foundation; either version 2 of the License, or *
13  * (at your option) any later version. *
14  * *
15  ***************************************************************************/
16 #ifndef QGSATTRIBUTEEDITORELEMENT_H
17 #define QGSATTRIBUTEEDITORELEMENT_H
18 
19 #include "qgis_core.h"
20 #include "qgsrelation.h"
21 #include "qgsoptionalexpression.h"
22 #include "qgspropertycollection.h"
23 #include <QColor>
24 
37 {
38 
39 #ifdef SIP_RUN
41  switch ( sipCpp->type() )
42  {
44  sipType = sipType_QgsAttributeEditorContainer;
45  break;
47  sipType = sipType_QgsAttributeEditorField;
48  break;
50  sipType = sipType_QgsAttributeEditorRelation;
51  break;
53  sipType = sipType_QgsAttributeEditorAction;
54  break;
55  default:
56  sipType = nullptr;
57  break;
58  }
59  SIP_END
60 #endif
61  public:
63  {
70  AeTypeAction
71  };
72 
80  QgsAttributeEditorElement( AttributeEditorType type, const QString &name, QgsAttributeEditorElement *parent = nullptr )
81  : mType( type )
82  , mName( name )
83  , mParent( parent )
84  , mShowLabel( true )
85  {}
86 
87  virtual ~QgsAttributeEditorElement() = default;
88 
94  static QgsAttributeEditorElement *create( const QDomElement &element, const QString &layerId, const QgsFields &fields, const QgsReadWriteContext &context, QgsAttributeEditorElement *parent = nullptr ) SIP_FACTORY;
95 
101  QString name() const { return mName; }
102 
108  AttributeEditorType type() const { return mType; }
109 
115  QgsAttributeEditorElement *parent() const { return mParent; }
116 
124  QDomElement toDomElement( QDomDocument &doc ) const;
125 
132 
138  bool showLabel() const;
139 
144  void setShowLabel( bool showLabel );
145 
146  protected:
147 #ifndef SIP_RUN
149  QString mName;
150  QgsAttributeEditorElement *mParent = nullptr;
152 #endif
153 
154  private:
155 
161  virtual void saveConfiguration( QDomElement &elem, QDomDocument &doc ) const = 0;
162 
167  virtual void loadConfiguration( const QDomElement &element, const QString &layerId, const QgsReadWriteContext &context, const QgsFields &fields ) = 0;
168 
175  virtual QString typeIdentifier() const = 0;
176 
177 };
178 
179 #endif // QGSATTRIBUTEEDITORELEMENT_H
This is an abstract base class for any elements of a drag and drop form.
virtual QgsAttributeEditorElement * clone(QgsAttributeEditorElement *parent) const =0
Returns a clone of this element.
AttributeEditorType type() const
The type of this element.
QgsAttributeEditorElement(AttributeEditorType type, const QString &name, QgsAttributeEditorElement *parent=nullptr)
Constructor.
@ AeTypeAction
A layer action element (since QGIS 3.22)
virtual ~QgsAttributeEditorElement()=default
QgsAttributeEditorElement * parent() const
Gets the parent of this element.
Container of fields for a vector layer.
Definition: qgsfields.h:45
The class is used as a container of context for various read/write operations on other objects.
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition: qgis_sip.h:177
#define SIP_ABSTRACT
Definition: qgis_sip.h:199
#define SIP_FACTORY
Definition: qgis_sip.h:76
#define SIP_END
Definition: qgis_sip.h:194