29#include "moc_qgsrelationwidgetwrapper.cpp"
31using namespace Qt::StringLiterals;
41 , mRelationEditorId( relationEditorName )
53 if ( !relationEditorWidget )
55 QgsLogger::warning( u
"Failed to create relation widget \"%1\", fallback to \"basic\" relation widget"_s.arg( mRelationEditorId ) );
61 return relationEditorWidget;
66 if ( mWidget && mRelation.isValid() )
72 if ( mWidget && mRelation.isValid() )
73 mWidget->setMultiEditFeatureIds( fids );
79 mWidget->setVisible( visible );
82void QgsRelationWidgetWrapper::aboutToSave()
101 ( void ) mRelation.referencingLayer()->isModified();
103 if ( mNmRelation.isValid() )
105 ( void ) mNmRelation.referencedLayer()->isModified();
116 if ( mWidget && attributeChanged )
119 if ( feature.
attribute( attribute ) != newValue )
124 mWidget->setEditorContext( newContext );
125 mWidget->setFeature( feature,
false );
126 mWidget->parentFormValueChanged( attribute, newValue );
170 if ( !editor->layout() )
172 editor->setLayout(
new QVBoxLayout( editor ) );
174 editor->layout()->addWidget( w );
181 if (
config( u
"force-suppress-popup"_s,
false ).toBool() )
202 || ( mNmRelation.isValid() && ctx->
relation().
id() == mNmRelation.id() ) )
204 w->setVisible(
false );
246 QVariantMap
config = mWidget->config();
249 mWidget->setConfig(
config );
270 return mWidget->forceSuppressFormPopup();
286 || ( mNmRelation.isValid() && ctx->
relation().
id() == mNmRelation.id() ) )
288 mWidget->setVisible(
false );
294 mWidget->setRelations( mRelation, mNmRelation );
301 return mWidget->nmRelationId();
319 mWidget->setConfig(
config );
324 return mWidget ? mWidget->config() : QVariantMap();
Contains context information for attribute editor widgets.
FormMode formMode() const
Returns the form mode.
@ Multiple
When showing a list of features (e.g. houses as an embedded form in a district form).
const QgsVectorLayerTools * vectorLayerTools() const
Returns the associated vector layer tools.
@ Embed
A form was embedded as a widget on another form.
void setParentFormFeature(const QgsFeature &feature)
Sets the feature of the currently edited parent form.
const QgsAttributeEditorContext * parentContext() const
const QgsRelation & relation() const
Returns the attribute relation.
@ SaveChildEdits
Save child edits button.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Q_INVOKABLE bool setAttribute(int field, const QVariant &attr)
Sets an attribute's value by field index.
Q_INVOKABLE QVariant attribute(const QString &name) const
Lookup attribute value by attribute name.
static QgsRelationWidgetRegistry * relationWidgetRegistry()
Returns the global relation widget registry, used for managing all known relation widget factories.
static void warning(const QString &msg)
Goes to qWarning.
QgsRelationManager * relationManager
static QgsProject * instance()
Returns the QgsProject singleton instance.
Q_INVOKABLE QgsRelation relation(const QString &id) const
Gets access to a relation by its id.
Represents a relationship between two vector layers.
QgsVectorLayer * referencedLayer
QgsVectorLayer * referencingLayer
Represents a vector layer which manages a vector based dataset.
#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
QSet< QgsFeatureId > QgsFeatureIds