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() )
108 mWidget->
setRelation( relation,
config( QStringLiteral(
"AllowNULL" ) ).toBool() );
116 return QVariant(
field().type() );
120 if ( fkeys.isEmpty() )
122 return QVariant(
field().type() );
127 Q_ASSERT( fieldPairs.count() == fkeys.count() );
128 for (
int i = 0; i < fieldPairs.count(); i++ )
130 if ( fieldPairs.at( i ).referencingField() ==
field().name() )
131 return fkeys.at( i );
133 return QVariant(
field().type() );
148 mIndeterminateState =
true;
159 for (
int i = 0; i < mWidget->
relation().fieldPairs().count(); i++ )
161 values << QVariant();
169 const int fieldCount = std::min( fieldPairs.count(), values.count() );
170 for (
int i = 0; i < fieldCount; i++ )
172 if ( fieldPairs.at( i ).referencingField() ==
field().name() )
174 values.removeAt( i );
185 return QStringList();
189 for (
int i = 0; i < fieldPairs.count(); i++ )
191 if ( fieldPairs.at( i ).referencingField() ==
field().name() )
194 fields << fieldPairs.at( i ).referencingField();
199void QgsRelationReferenceWidgetWrapper::updateValues(
const QVariant &val,
const QVariantList &additionalValues )
204 mIndeterminateState =
false;
206 QVariantList values = additionalValues;
208 for (
int i = 0; i < fieldPairs.count(); i++ )
210 if ( fieldPairs.at( i ).referencingField() ==
field().name() )
212 values.insert( i, val );
216 Q_ASSERT( values.count() == fieldPairs.count() );
232void QgsRelationReferenceWidgetWrapper::foreignKeysChanged(
const QVariantList &values )
234 if ( mBlockChanges != 0 )
237 QVariant mainValue = QVariant(
field().type() );
248 QVariantList additionalValues = values;
250 for (
int i = 0; i < fieldPairs.count(); i++ )
252 if ( fieldPairs.at( i ).referencingField() ==
field().name() )
253 mainValue = additionalValues.takeAt( i );
255 Q_ASSERT( additionalValues.count() == values.count() - 1 );
269 widget()->setStyleSheet( QString() );
276 mWidget->setStyleSheet( QString() );
280 mWidget->setStyleSheet( QStringLiteral(
".QComboBox { background-color: #dd7777; }" ) );
284 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.
QList< QgsRelation::FieldPair > fieldPairs() const
Returns the field pairs which form this relation The first element of each pair are the field names o...
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.
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