QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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 #include <QFont>
25 
38 {
39 
40 #ifdef SIP_RUN
42  switch ( sipCpp->type() )
43  {
45  sipType = sipType_QgsAttributeEditorContainer;
46  break;
48  sipType = sipType_QgsAttributeEditorField;
49  break;
51  sipType = sipType_QgsAttributeEditorRelation;
52  break;
54  sipType = sipType_QgsAttributeEditorAction;
55  break;
56  default:
57  sipType = nullptr;
58  break;
59  }
60  SIP_END
61 #endif
62  public:
63 
68  struct CORE_EXPORT LabelStyle
69  {
70 
72  QColor color;
73 
75  QFont font;
76 
78  bool overrideColor = false;
79 
81  bool overrideFont = false;
82 
87  void readXml( const QDomNode &node ) SIP_SKIP;
88 
93  QDomElement writeXml( QDomDocument &document ) const SIP_SKIP;
94 
99  bool operator==( LabelStyle const &other ) const SIP_SKIP;
100  };
101 
102 
104  {
105  AeTypeContainer,
106  AeTypeField,
107  AeTypeRelation,
108  AeTypeInvalid,
109  AeTypeQmlElement,
110  AeTypeHtmlElement,
111  AeTypeAction
112  };
113 
121  QgsAttributeEditorElement( AttributeEditorType type, const QString &name, QgsAttributeEditorElement *parent = nullptr )
122  : mType( type )
123  , mName( name )
124  , mParent( parent )
125  , mShowLabel( true )
126  {}
127 
128  virtual ~QgsAttributeEditorElement() = default;
129 
135  static QgsAttributeEditorElement *create( const QDomElement &element, const QString &layerId, const QgsFields &fields, const QgsReadWriteContext &context, QgsAttributeEditorElement *parent = nullptr ) SIP_FACTORY;
136 
142  QString name() const { return mName; }
143 
149  AttributeEditorType type() const { return mType; }
150 
156  QgsAttributeEditorElement *parent() const { return mParent; }
157 
165  QDomElement toDomElement( QDomDocument &doc ) const;
166 
172  virtual QgsAttributeEditorElement *clone( QgsAttributeEditorElement *parent ) const = 0 SIP_FACTORY;
173 
179  bool showLabel() const;
180 
185  void setShowLabel( bool showLabel );
186 
192  LabelStyle labelStyle() const;
193 
199  void setLabelStyle( const LabelStyle &labelStyle );
200 
201 
202  protected:
203 #ifndef SIP_RUN
204  AttributeEditorType mType;
205  QString mName;
206  QgsAttributeEditorElement *mParent = nullptr;
207  bool mShowLabel;
208  LabelStyle mLabelStyle;
209 #endif
210 
211  private:
212 
218  virtual void saveConfiguration( QDomElement &elem, QDomDocument &doc ) const = 0;
219 
224  virtual void loadConfiguration( const QDomElement &element, const QString &layerId, const QgsReadWriteContext &context, const QgsFields &fields ) = 0;
225 
232  virtual QString typeIdentifier() const = 0;
233 
234 };
235 
236 #endif // QGSATTRIBUTEEDITORELEMENT_H
QgsAttributeEditorElement
This is an abstract base class for any elements of a drag and drop form.
Definition: qgsattributeeditorelement.h:37
qgsoptionalexpression.h
QgsReadWriteContext
The class is used as a container of context for various read/write operations on other objects.
Definition: qgsreadwritecontext.h:34
QgsAttributeEditorElement::AeTypeRelation
@ AeTypeRelation
A relation.
Definition: qgsattributeeditorelement.h:121
operator==
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
Definition: qgsfeatureiterator.h:425
QgsAttributeEditorElement::LabelStyle
The TabStyle struct defines color and font overrides for form fields, tabs and groups labels.
Definition: qgsattributeeditorelement.h:82
QgsFields
Container of fields for a vector layer.
Definition: qgsfields.h:44
QgsAttributeEditorElement::AeTypeAction
@ AeTypeAction
A layer action element (since QGIS 3.22)
Definition: qgsattributeeditorelement.h:125
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
SIP_CONVERT_TO_SUBCLASS_CODE
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition: qgis_sip.h:186
QgsAttributeEditorElement::AeTypeContainer
@ AeTypeContainer
A container.
Definition: qgsattributeeditorelement.h:119
SIP_SKIP
#define SIP_SKIP
Definition: qgis_sip.h:126
qgsrelation.h
qgspropertycollection.h
SIP_END
#define SIP_END
Definition: qgis_sip.h:203
QgsAttributeEditorElement::AttributeEditorType
AttributeEditorType
Definition: qgsattributeeditorelement.h:117
QgsAttributeEditorElement::AeTypeField
@ AeTypeField
A field.
Definition: qgsattributeeditorelement.h:120
SIP_ABSTRACT
#define SIP_ABSTRACT
Definition: qgis_sip.h:208