26 , mMessageBar( messageBar )
27 , mIndeterminateState( false )
51 const bool showForm =
config( QStringLiteral(
"ShowForm" ),
false ).toBool();
52 const bool mapIdent =
config( QStringLiteral(
"MapIdentification" ),
false ).toBool();
53 const bool readOnlyWidget =
config( QStringLiteral(
"ReadOnly" ),
false ).toBool();
54 const bool showOpenFormButton =
config( QStringLiteral(
"ShowOpenFormButton" ),
true ).toBool();
61 const bool fetchLimitActive =
config( QStringLiteral(
"FetchLimitActive" ),
QgsSettings().
value( QStringLiteral(
"maxEntriesRelationWidget" ), 100,
QgsSettings::Gui ).toInt() > 0 ).toBool();
62 if ( fetchLimitActive )
67 if (
config( QStringLiteral(
"FilterFields" ), QVariant() ).isValid() )
72 if ( !
config( QStringLiteral(
"FilterExpression" ) ).toString().isEmpty() )
78 const QVariant relationName =
config( QStringLiteral(
"Relation" ) );
87 if ( relationName.isValid() )
110 if ( !
config( QStringLiteral(
"AllowNULL" ) ).isValid() )
116 mWidget->
setRelation( relation,
config( QStringLiteral(
"AllowNULL" ) ).toBool() );
129 if ( fkeys.isEmpty() )
136 Q_ASSERT( fieldPairs.count() == fkeys.count() );
137 for (
int i = 0; i < fieldPairs.count(); i++ )
139 if ( fieldPairs.at( i ).referencingField() ==
field().name() )
140 return fkeys.at( i );
157 mIndeterminateState =
true;
168 for (
int i = 0; i < mWidget->
relation().fieldPairs().count(); i++ )
170 values << QVariant();
178 const int fieldCount = std::min( fieldPairs.count(), values.count() );
179 for (
int i = 0; i < fieldCount; i++ )
181 if ( fieldPairs.at( i ).referencingField() ==
field().name() )
183 values.removeAt( i );
194 return QStringList();
198 for (
int i = 0; i < fieldPairs.count(); i++ )
200 if ( fieldPairs.at( i ).referencingField() ==
field().name() )
203 fields << fieldPairs.at( i ).referencingField();
208void QgsRelationReferenceWidgetWrapper::updateValues(
const QVariant &val,
const QVariantList &additionalValues )
213 mIndeterminateState =
false;
215 QVariantList values = additionalValues;
217 for (
int i = 0; i < fieldPairs.count(); i++ )
219 if ( fieldPairs.at( i ).referencingField() ==
field().name() )
221 values.insert( i, val );
225 Q_ASSERT( values.count() == fieldPairs.count() );
241void QgsRelationReferenceWidgetWrapper::foreignKeysChanged(
const QVariantList &values )
243 if ( mBlockChanges != 0 )
257 QVariantList additionalValues = values;
259 for (
int i = 0; i < fieldPairs.count(); i++ )
261 if ( fieldPairs.at( i ).referencingField() ==
field().name() )
262 mainValue = additionalValues.takeAt( i );
264 Q_ASSERT( additionalValues.count() == values.count() - 1 );
278 widget()->setStyleSheet( QString() );
285 mWidget->setStyleSheet( QString() );
289 mWidget->setStyleSheet( QStringLiteral(
".QComboBox { background-color: #dd7777; }" ) );
293 mWidget->setStyleSheet( QStringLiteral(
".QComboBox { background-color: #ffd85d; }" ) );
This class contains context information for attribute editor widgets.
const QgsAttributeEditorContext * parentContext() const
const QgsRelation & relation() const
Returns the attribute relation.
Map canvas is a class for displaying all GIS data types on a canvas.
A bar for displaying non-blocking messages to the user.
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.
QList< QgsRelation::FieldPair > fieldPairs() const
Returns the field pairs which form this relation The first element of each pair are the field names o...
bool referencingFieldsAllowNull() const
Returns true if none of the referencing fields has a NOT NULL constraint.
This class is a composition of two QSettings instances:
static bool isNull(const QVariant &variant, bool silenceNullWarnings=false)
Returns true if the specified variant should be considered a NULL value.
static QVariant createNullVariant(QMetaType::Type metaType)
Helper method to properly create a null QVariant from a metaType Returns the created QVariant.
Represents a vector layer which manages a vector based data sets.
QList< QgsRelation > referencingRelations(int idx) const
Returns the layer's relations, where the foreign key is on this layer.
#define Q_NOWARN_DEPRECATED_POP
#define Q_NOWARN_DEPRECATED_PUSH