QGIS API Documentation 3.34.0-Prizren (ffbdd678812)
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
148 QgsAttributeEditorElement *parent() const { return mParent; }
149
157 QDomElement toDomElement( QDomDocument &doc ) const;
158
165
171 bool showLabel() const;
172
177 void setShowLabel( bool showLabel );
178
187 int horizontalStretch() const { return mHorizontalStretch; }
188
197 void setHorizontalStretch( int stretch ) { mHorizontalStretch = stretch; }
198
207 int verticalStretch() const { return mVerticalStretch; }
208
217 void setVerticalStretch( int stretch ) { mVerticalStretch = stretch; }
218
224 LabelStyle labelStyle() const;
225
231 void setLabelStyle( const LabelStyle &labelStyle );
232
233
234 protected:
235#ifndef SIP_RUN
237 QString mName;
238 QgsAttributeEditorElement *mParent = nullptr;
239 bool mShowLabel = true;
240 int mHorizontalStretch = 0;
241 int mVerticalStretch = 0;
243#endif
244
245 private:
246
252 virtual void saveConfiguration( QDomElement &elem, QDomDocument &doc ) const = 0;
253
258 virtual void loadConfiguration( const QDomElement &element, const QString &layerId, const QgsReadWriteContext &context, const QgsFields &fields ) = 0;
259
266 virtual QString typeIdentifier() const = 0;
267
268};
269
270#endif // QGSATTRIBUTEEDITORELEMENT_H
AttributeEditorType
Attribute editor types.
Definition qgis.h:3756
@ Action
A layer action element (since QGIS 3.22)
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: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.