QGIS API Documentation 3.99.0-Master (26c88405ac0)
Loading...
Searching...
No Matches
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.h"
20#include "qgis_core.h"
21#include "qgis_sip.h"
22
23#include <QColor>
24#include <QFont>
25
26class QDomNode;
27class QDomElement;
28class QDomDocument;
29class QgsFields;
31
42
44{
45
46#ifdef SIP_RUN
48 switch ( sipCpp->type() )
49 {
51 sipType = sipType_QgsAttributeEditorContainer;
52 break;
54 sipType = sipType_QgsAttributeEditorField;
55 break;
57 sipType = sipType_QgsAttributeEditorRelation;
58 break;
60 sipType = sipType_QgsAttributeEditorAction;
61 break;
62 default:
63 sipType = nullptr;
64 break;
65 }
67#endif
68 public:
69
74 struct CORE_EXPORT LabelStyle
75 {
76
78 QColor color;
79
81 QFont font;
82
84 bool overrideColor = false;
85
87 bool overrideFont = false;
88
93 void readXml( const QDomNode &node ) SIP_SKIP;
94
99 QDomElement writeXml( QDomDocument &document ) const SIP_SKIP;
100
105 bool operator==( LabelStyle const &other ) const SIP_SKIP;
106 };
107
120
121 virtual ~QgsAttributeEditorElement() = default;
122
128 static QgsAttributeEditorElement *create( const QDomElement &element, const QString &layerId, const QgsFields &fields, const QgsReadWriteContext &context, QgsAttributeEditorElement *parent = nullptr ) SIP_FACTORY;
129
135 QString name() const { return mName; }
136
143
149
157 QDomElement toDomElement( QDomDocument &doc ) const;
158
164
169 bool showLabel() const;
170
174 void setShowLabel( bool showLabel );
175
184 int horizontalStretch() const { return mHorizontalStretch; }
185
194 void setHorizontalStretch( int stretch ) { mHorizontalStretch = stretch; }
195
204 int verticalStretch() const { return mVerticalStretch; }
205
214 void setVerticalStretch( int stretch ) { mVerticalStretch = stretch; }
215
221 LabelStyle labelStyle() const;
222
228 void setLabelStyle( const LabelStyle &labelStyle );
229
230
231 protected:
232#ifndef SIP_RUN
234 QString mName;
236 bool mShowLabel = true;
240#endif
241
242 private:
243
248 virtual void saveConfiguration( QDomElement &elem, QDomDocument &doc ) const = 0;
249
254 virtual void loadConfiguration( const QDomElement &element, const QString &layerId, const QgsReadWriteContext &context, const QgsFields &fields ) = 0;
255
261 virtual QString typeIdentifier() const = 0;
262
263};
264
265#endif // QGSATTRIBUTEEDITORELEMENT_H
AttributeEditorType
Attribute editor types.
Definition qgis.h:5451
@ Action
A layer action element.
Definition qgis.h:5457
@ Container
A container.
Definition qgis.h:5452
@ Relation
A relation.
Definition qgis.h:5454
void setHorizontalStretch(int stretch)
Sets the horizontal stretch factor for the element.
QgsAttributeEditorElement * parent() const
Gets the parent of this element.
QgsAttributeEditorElement(Qgis::AttributeEditorType type, const QString &name, QgsAttributeEditorElement *parent=nullptr)
Constructor.
QgsAttributeEditorElement * mParent
Qgis::AttributeEditorType type() const
The type of this element.
int verticalStretch() const
Returns the vertical stretch factor for the element.
Qgis::AttributeEditorType mType
bool showLabel() const
Controls if this element should be labeled with a title (field, relation or groupname).
QString name() const
Returns the name of this element.
static QgsAttributeEditorElement * create(const QDomElement &element, const QString &layerId, const QgsFields &fields, const QgsReadWriteContext &context, QgsAttributeEditorElement *parent=nullptr)
Constructs the editor element from the given element.
void setVerticalStretch(int stretch)
Sets the vertical stretch factor for the element.
void setShowLabel(bool showLabel)
Controls if this element should be labeled with a title (field, relation or groupname).
virtual ~QgsAttributeEditorElement()=default
int horizontalStretch() const
Returns the horizontal stretch factor for the element.
virtual QgsAttributeEditorElement * clone(QgsAttributeEditorElement *parent) const =0
Returns a clone of this element.
Container of fields for a vector layer.
Definition qgsfields.h:46
A container for the context for various read/write operations on objects.
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition qgis_sip.h:199
#define SIP_SKIP
Definition qgis_sip.h:134
#define SIP_ABSTRACT
Definition qgis_sip.h:221
#define SIP_FACTORY
Definition qgis_sip.h:84
#define SIP_END
Definition qgis_sip.h:216
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
The TabStyle struct defines color and font overrides for form fields, tabs and groups labels.
void readXml(const QDomNode &node)
Reads configuration from node.
QDomElement writeXml(QDomDocument &document) const
Creates the XML configuration from document.