23#include "moc_qgsattributeeditorrelation.cpp"
25using namespace Qt::StringLiterals;
29 mRelation = relationManager->
relation( mRelationId );
36 element->mRelation = mRelation;
37 element->mButtons = mButtons;
38 element->mForceSuppressFormPopup = mForceSuppressFormPopup;
39 element->mNmRelationId = mNmRelationId;
40 element->mLabel = mLabel;
41 element->mRelationEditorConfig = mRelationEditorConfig;
42 element->mRelationWidgetTypeId = mRelationWidgetTypeId;
48void QgsAttributeEditorRelation::saveConfiguration( QDomElement &elem, QDomDocument &doc )
const
50 elem.setAttribute( u
"relation"_s, mRelationId );
51 elem.setAttribute( u
"forceSuppressFormPopup"_s, mForceSuppressFormPopup );
52 elem.setAttribute( u
"nmRelationId"_s, mNmRelationId.toString() );
53 elem.setAttribute( u
"label"_s, mLabel );
54 elem.setAttribute( u
"relationWidgetTypeId"_s, mRelationWidgetTypeId );
57 elemConfig.setTagName( u
"editor_configuration"_s );
58 elem.appendChild( elemConfig );
61void QgsAttributeEditorRelation::loadConfiguration(
const QDomElement &element,
const QString &layerId,
const QgsReadWriteContext &context,
const QgsFields &fields )
70 if ( config.isEmpty() )
74 if ( ! config.contains( u
"buttons"_s ) )
76 if ( element.hasAttribute(
"buttons" ) )
104 if ( element.hasAttribute( u
"nmRelationId"_s ) )
109 if ( element.hasAttribute(
"label" ) )
111 const QString
label = element.attribute( u
"label"_s );
114 if ( element.hasAttribute(
"relationWidgetTypeId" ) )
121QString QgsAttributeEditorRelation::typeIdentifier()
const
123 return u
"attributeEditorRelation"_s;
133 return mForceSuppressFormPopup;
143 return mNmRelationId;
158 return mRelationWidgetTypeId;
168 return mRelationEditorConfig;
173 mRelationEditorConfig = config;
QgsAttributeEditorElement * parent() const
Gets the parent of this element.
QgsAttributeEditorElement(Qgis::AttributeEditorType type, const QString &name, QgsAttributeEditorElement *parent=nullptr)
Constructor.
void setNmRelationId(const QVariant &nmRelationId=QVariant())
Sets nmRelationId for the relation id of the second relation involved in an N:M relation.
bool init(QgsRelationManager *relManager)
Initializes the relation from the id.
void setRelationWidgetTypeId(const QString &relationWidgetTypeId)
Sets the relation widget type.
QgsAttributeEditorElement * clone(QgsAttributeEditorElement *parent) const override
Returns a clone of this element.
QVariantMap relationEditorConfiguration() const
Returns the relation editor widget configuration.
void setForceSuppressFormPopup(bool forceSuppressFormPopup)
Sets force suppress form popup status to forceSuppressFormPopup.
@ SaveChildEdits
Save child edits button.
QVariant nmRelationId() const
Determines the relation id of the second relation involved in an N:M relation.
bool forceSuppressFormPopup() const
Determines the force suppress form popup status.
Q_DECL_DEPRECATED QgsAttributeEditorRelation(const QString &name, const QString &relationId, QgsAttributeEditorElement *parent)
QString relationWidgetTypeId() const
Returns the current relation widget type id.
void setRelationEditorConfiguration(const QVariantMap &config)
Sets the relation editor configuration.
void setLabel(const QString &label=QString())
Sets label for this element If it's empty it takes the relation id as label.
QString label() const
Determines the label of this element.
Container of fields for a vector layer.
A container for the context for various read/write operations on objects.
Manages a set of relations between layers.
Q_INVOKABLE QgsRelation relation(const QString &id) const
Gets access to a relation by its id.
static QDomElement writeVariant(const QVariant &value, QDomDocument &doc)
Write a QVariant to a QDomElement.
static QVariant readVariant(const QDomElement &element)
Read a QVariant from a QDomElement.
#define Q_NOWARN_DEPRECATED_POP
QString qgsFlagValueToKeys(const T &value, bool *returnOk=nullptr)
Returns the value for the given keys of a flag.
T qgsFlagKeysToValue(const QString &keys, const T &defaultValue, bool tryValueAsKey=true, bool *returnOk=nullptr)
Returns the value corresponding to the given keys of a flag.
#define Q_NOWARN_DEPRECATED_PUSH