QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
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
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"
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 }
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 {
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
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
205 QString mName;
206 QgsAttributeEditorElement *mParent = nullptr;
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
This is an abstract base class for any elements of a drag and drop form.
QgsAttributeEditorElement * parent() const
Gets the parent 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
virtual QgsAttributeEditorElement * clone(QgsAttributeEditorElement *parent) const =0
Returns a clone 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:186
#define SIP_SKIP
Definition: qgis_sip.h:126
#define SIP_ABSTRACT
Definition: qgis_sip.h:208
#define SIP_FACTORY
Definition: qgis_sip.h:76
#define SIP_END
Definition: qgis_sip.h:203
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
The TabStyle struct defines color and font overrides for form fields, tabs and groups labels.