QGIS API Documentation 3.41.0-Master (3440c17df1d)
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_core.h"
20#include "qgis_sip.h"
21#include "qgis.h"
22#include <QColor>
23#include <QFont>
24
25class QDomNode;
26class QDomElement;
27class QDomDocument;
28class QgsFields;
30
43{
44
45#ifdef SIP_RUN
47 switch ( sipCpp->type() )
48 {
50 sipType = sipType_QgsAttributeEditorContainer;
51 break;
53 sipType = sipType_QgsAttributeEditorField;
54 break;
56 sipType = sipType_QgsAttributeEditorRelation;
57 break;
59 sipType = sipType_QgsAttributeEditorAction;
60 break;
61 default:
62 sipType = nullptr;
63 break;
64 }
66#endif
67 public:
68
73 struct CORE_EXPORT LabelStyle
74 {
75
77 QColor color;
78
80 QFont font;
81
83 bool overrideColor = false;
84
86 bool overrideFont = false;
87
92 void readXml( const QDomNode &node ) SIP_SKIP;
93
98 QDomElement writeXml( QDomDocument &document ) const SIP_SKIP;
99
104 bool operator==( LabelStyle const &other ) const SIP_SKIP;
105 };
106
115 : mType( type )
116 , mName( name )
117 , mParent( parent )
118 {}
119
120 virtual ~QgsAttributeEditorElement() = default;
121
127 static QgsAttributeEditorElement *create( const QDomElement &element, const QString &layerId, const QgsFields &fields, const QgsReadWriteContext &context, QgsAttributeEditorElement *parent = nullptr ) SIP_FACTORY;
128
134 QString name() const { return mName; }
135
141 Qgis::AttributeEditorType type() const { return mType; }
142
147 QgsAttributeEditorElement *parent() const { return mParent; }
148
156 QDomElement toDomElement( QDomDocument &doc ) const;
157
163
168 bool showLabel() const;
169
173 void setShowLabel( bool showLabel );
174
183 int horizontalStretch() const { return mHorizontalStretch; }
184
193 void setHorizontalStretch( int stretch ) { mHorizontalStretch = stretch; }
194
203 int verticalStretch() const { return mVerticalStretch; }
204
213 void setVerticalStretch( int stretch ) { mVerticalStretch = stretch; }
214
220 LabelStyle labelStyle() const;
221
227 void setLabelStyle( const LabelStyle &labelStyle );
228
229
230 protected:
231#ifndef SIP_RUN
233 QString mName;
234 QgsAttributeEditorElement *mParent = nullptr;
235 bool mShowLabel = true;
236 int mHorizontalStretch = 0;
237 int mVerticalStretch = 0;
239#endif
240
241 private:
242
247 virtual void saveConfiguration( QDomElement &elem, QDomDocument &doc ) const = 0;
248
253 virtual void loadConfiguration( const QDomElement &element, const QString &layerId, const QgsReadWriteContext &context, const QgsFields &fields ) = 0;
254
260 virtual QString typeIdentifier() const = 0;
261
262};
263
264#endif // QGSATTRIBUTEEDITORELEMENT_H
AttributeEditorType
Attribute editor types.
Definition qgis.h:5062
@ Action
A layer action element.
This is an abstract base class for any elements of a drag and drop form.
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.
Qgis::AttributeEditorType type() const
The type of this element.
int verticalStretch() const
Returns the vertical stretch factor for the element.
void setVerticalStretch(int stretch)
Sets the vertical stretch factor for the element.
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
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:191
#define SIP_SKIP
Definition qgis_sip.h:126
#define SIP_ABSTRACT
Definition qgis_sip.h:213
#define SIP_FACTORY
Definition qgis_sip.h:76
#define SIP_END
Definition qgis_sip.h:208
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
The TabStyle struct defines color and font overrides for form fields, tabs and groups labels.