QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
qgsattributeeditorrelation.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsattributeeditorrelation.h - QgsAttributeEditorElement
3
4 ---------------------
5 begin : 12.01.2021
6 copyright : (C) 2021 by Denis Rouzaud
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 QGSATTRIBUTEEDITORRELATION_H
17#define QGSATTRIBUTEEDITORRELATION_H
18
19#include "qgis_core.h"
21#include "qgsrelation.h"
24#include <QColor>
25
27
33{
34 Q_GADGET
35 public:
36
42 enum Button
43 {
44 Link = 1 << 1,
45 Unlink = 1 << 2,
46 SaveChildEdits = 1 << 3,
47 AddChildFeature = 1 << 4,
48 DuplicateChildFeature = 1 << 5,
49 DeleteChildFeature = 1 << 6,
50 ZoomToChildFeature = 1 << 7,
51 AllButtons = Link | Unlink | SaveChildEdits | AddChildFeature | DuplicateChildFeature | DeleteChildFeature | ZoomToChildFeature
52 };
53 // TODO QGIS 4: remove
54 // this could not be tagged with Q_DECL_DEPRECATED due to Doxygen warning
55
56 Q_ENUM( Button )
57 Q_DECLARE_FLAGS( Buttons, Button )
58 Q_FLAG( Buttons )
59
60
63 Q_DECL_DEPRECATED QgsAttributeEditorRelation( const QString &name, const QString &relationId, QgsAttributeEditorElement *parent )
64 : QgsAttributeEditorElement( AeTypeRelation, name, parent )
65 , mRelationId( relationId )
66 {}
67
71 Q_DECL_DEPRECATED QgsAttributeEditorRelation( const QString &name, const QgsRelation &relation, QgsAttributeEditorElement *parent )
72 : QgsAttributeEditorElement( AeTypeRelation, name, parent )
73 , mRelationId( relation.id() )
74 , mRelation( relation )
75 {}
76
83 QgsAttributeEditorRelation( const QString &relationId, QgsAttributeEditorElement *parent )
84 : QgsAttributeEditorElement( AeTypeRelation, relationId, parent )
85 , mRelationId( relationId )
86 {}
87
95 : QgsAttributeEditorElement( AeTypeRelation, relation.id(), parent )
96 , mRelationId( relation.id() )
97 , mRelation( relation )
98 {}
99
100
106 const QgsRelation &relation() const { return mRelation; }
107
114 bool init( QgsRelationManager *relManager );
115
117
122 bool forceSuppressFormPopup() const;
123
130 void setForceSuppressFormPopup( bool forceSuppressFormPopup );
131
136 QVariant nmRelationId() const;
137
143 void setNmRelationId( const QVariant &nmRelationId = QVariant() );
144
149 QString label() const;
150
156 void setLabel( const QString &label = QString() );
157
162 QString relationWidgetTypeId() const;
163
168 void setRelationWidgetTypeId( const QString &relationWidgetTypeId );
169
175 QVariantMap relationEditorConfiguration() const;
176
182 void setRelationEditorConfiguration( const QVariantMap &config );
183
184 private:
185 void saveConfiguration( QDomElement &elem, QDomDocument &doc ) const override;
186 void loadConfiguration( const QDomElement &element, const QString &layerId, const QgsReadWriteContext &context, const QgsFields &fields ) override;
187 QString typeIdentifier() const override;
188 QString mRelationId;
189 QgsRelation mRelation;
191 Buttons mButtons = Buttons( Button::AllButtons );
193 bool mForceSuppressFormPopup = false;
194 QVariant mNmRelationId;
195 QString mLabel;
196 QString mRelationWidgetTypeId;
197 QVariantMap mRelationEditorConfig;
198};
199
201Q_DECLARE_OPERATORS_FOR_FLAGS( QgsAttributeEditorRelation::Buttons )
203
204#endif // QGSATTRIBUTEEDITORRELATION_H
This is an abstract base class for any elements of a drag and drop form.
virtual QgsAttributeEditorElement * clone(QgsAttributeEditorElement *parent) const =0
Returns a clone of this element.
This element will load a relation editor onto the form.
const QgsRelation & relation() const
Gets the id of the relation which shall be embedded.
Q_DECL_DEPRECATED QgsAttributeEditorRelation(const QString &name, const QgsRelation &relation, QgsAttributeEditorElement *parent)
Button
Possible buttons shown in the relation editor.
QgsAttributeEditorRelation(const QString &relationId, QgsAttributeEditorElement *parent)
Creates a new element which embeds a relation.
QgsAttributeEditorRelation(const QgsRelation &relation, QgsAttributeEditorElement *parent)
Creates a new element which embeds a relation.
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.
This class manages a set of relations between layers.
#define Q_NOWARN_DEPRECATED_POP
Definition: qgis.h:3061
#define Q_NOWARN_DEPRECATED_PUSH
Definition: qgis.h:3060
#define SIP_FACTORY
Definition: qgis_sip.h:76
Q_DECLARE_OPERATORS_FOR_FLAGS(QgsField::ConfigurationFlags) CORE_EXPORT QDataStream &operator<<(QDataStream &out
Writes the field to stream out. QGIS version compatibility is not guaranteed.