22 mRelation = relationManager->
relation( mRelationId );
29 element->mRelation = mRelation;
30 element->mButtons = mButtons;
31 element->mForceSuppressFormPopup = mForceSuppressFormPopup;
32 element->mNmRelationId = mNmRelationId;
33 element->mLabel = mLabel;
34 element->mRelationEditorConfig = mRelationEditorConfig;
39 void QgsAttributeEditorRelation::saveConfiguration( QDomElement &elem, QDomDocument &doc )
const
41 elem.setAttribute( QStringLiteral(
"relation" ), mRelation.
id() );
42 elem.setAttribute( QStringLiteral(
"forceSuppressFormPopup" ), mForceSuppressFormPopup );
43 elem.setAttribute( QStringLiteral(
"nmRelationId" ), mNmRelationId.toString() );
44 elem.setAttribute( QStringLiteral(
"label" ), mLabel );
45 elem.setAttribute( QStringLiteral(
"relationWidgetTypeId" ), mRelationWidgetTypeId );
48 elemConfig.setTagName( QStringLiteral(
"editor_configuration" ) );
49 elem.appendChild( elemConfig );
52 void QgsAttributeEditorRelation::loadConfiguration(
const QDomElement &element,
const QString &layerId,
const QgsReadWriteContext &context,
const QgsFields &fields )
61 if ( config.isEmpty() )
65 if ( ! config.contains( QStringLiteral(
"buttons" ) ) )
67 if ( element.hasAttribute(
"buttons" ) )
74 const QString buttonString = element.attribute( QStringLiteral(
"buttons" ),
qgsFlagValueToKeys( QgsAttributeEditorRelation::Button::AllButtons ) );
82 QgsAttributeEditorRelation::Buttons buttons = QgsAttributeEditorRelation::Button::AllButtons;
83 buttons.setFlag( QgsAttributeEditorRelation::Button::Link, element.attribute( QStringLiteral(
"showLinkButton" ), QStringLiteral(
"1" ) ).toInt() );
84 buttons.setFlag( QgsAttributeEditorRelation::Button::Unlink, element.attribute( QStringLiteral(
"showUnlinkButton" ), QStringLiteral(
"1" ) ).toInt() );
85 buttons.setFlag( QgsAttributeEditorRelation::Button::SaveChildEdits, element.attribute( QStringLiteral(
"showSaveChildEditsButton" ), QStringLiteral(
"1" ) ).toInt() );
95 if ( element.hasAttribute( QStringLiteral(
"nmRelationId" ) ) )
97 setNmRelationId( element.attribute( QStringLiteral(
"nmRelationId" ) ) );
100 if ( element.hasAttribute(
"label" ) )
102 const QString
label = element.attribute( QStringLiteral(
"label" ) );
105 if ( element.hasAttribute(
"relationWidgetTypeId" ) )
107 const QString
relationWidgetTypeId = element.attribute( QStringLiteral(
"relationWidgetTypeId" ) );
112 QString QgsAttributeEditorRelation::typeIdentifier()
const
114 return QStringLiteral(
"attributeEditorRelation" );
124 return mForceSuppressFormPopup;
134 return mNmRelationId;
149 return mRelationWidgetTypeId;
159 return mRelationEditorConfig;
164 mRelationEditorConfig = config;
This is an abstract base class for any elements of a drag and drop form.
QgsAttributeEditorElement * parent() const
Gets the parent of this element.
This element will load a relation editor onto the form.
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.
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.
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.
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
#define Q_NOWARN_DEPRECATED_PUSH
T qgsFlagKeysToValue(const QString &keys, const T &defaultValue)
Returns the value corresponding to the given keys of a flag.
QString qgsFlagValueToKeys(const T &value)
Returns the value for the given keys of a flag.