QGIS API Documentation 3.30.0-'s-Hertogenbosch (f186b8efe0)
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 {
114 };
115
123 QgsAttributeEditorElement( AttributeEditorType type, const QString &name, QgsAttributeEditorElement *parent = nullptr )
124 : mType( type )
125 , mName( name )
126 , mParent( parent )
127 , mShowLabel( true )
128 {}
129
130 virtual ~QgsAttributeEditorElement() = default;
131
137 static QgsAttributeEditorElement *create( const QDomElement &element, const QString &layerId, const QgsFields &fields, const QgsReadWriteContext &context, QgsAttributeEditorElement *parent = nullptr ) SIP_FACTORY;
138
144 QString name() const { return mName; }
145
151 AttributeEditorType type() const { return mType; }
152
158 QgsAttributeEditorElement *parent() const { return mParent; }
159
167 QDomElement toDomElement( QDomDocument &doc ) const;
168
175
181 bool showLabel() const;
182
187 void setShowLabel( bool showLabel );
188
194 LabelStyle labelStyle() const;
195
201 void setLabelStyle( const LabelStyle &labelStyle );
202
203
204 protected:
205#ifndef SIP_RUN
207 QString mName;
208 QgsAttributeEditorElement *mParent = nullptr;
211#endif
212
213 private:
214
220 virtual void saveConfiguration( QDomElement &elem, QDomDocument &doc ) const = 0;
221
226 virtual void loadConfiguration( const QDomElement &element, const QString &layerId, const QgsReadWriteContext &context, const QgsFields &fields ) = 0;
227
234 virtual QString typeIdentifier() const = 0;
235
236};
237
238#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.
@ AeTypeTextElement
A text element (since QGIS 3.30)
@ AeTypeSpacerElement
A spacer element (since QGIS 3.30)
@ 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.