QGIS API Documentation 4.3.0-Master (0cfde48c85b)
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
7 email : matthias@opengis.ch
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#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
68 public:
73 struct CORE_EXPORT LabelStyle
74 {
76 QColor color;
77
79 QFont font;
80
82 bool overrideColor = false;
83
85 bool overrideFont = false;
86
91 void readXml( const QDomNode &node ) SIP_SKIP;
92
97 QDomElement writeXml( QDomDocument &document ) const SIP_SKIP;
98
103 bool operator==( LabelStyle const &other ) const SIP_SKIP;
104 };
105
118
119 virtual ~QgsAttributeEditorElement() = default;
120
121 // clang-format off
127 static std::unique_ptr<QgsAttributeEditorElement> create( const QDomElement &element, const QString &layerId, const QgsFields &fields, const QgsReadWriteContext &context, QgsAttributeEditorElement *parent = nullptr );
128 // clang-format on
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:
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#endif // QGSATTRIBUTEEDITORELEMENT_H
AttributeEditorType
Attribute editor types.
Definition qgis.h:6271
@ Action
A layer action element.
Definition qgis.h:6277
@ Container
A container.
Definition qgis.h:6272
@ Relation
A relation.
Definition qgis.h:6274
void setHorizontalStretch(int stretch)
Sets the horizontal stretch factor for the element.
static std::unique_ptr< 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.
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.
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:45
A container for the context for various read/write operations on objects.
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition qgis_sip.h:203
#define SIP_SKIP
Definition qgis_sip.h:138
#define SIP_ABSTRACT
Definition qgis_sip.h:225
#define SIP_FACTORY
Definition qgis_sip.h:83
#define SIP_END
Definition qgis_sip.h:220
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.