26 , mMessageBar( messageBar )
27 , mIndeterminateState( false )
51 bool showForm =
config( QStringLiteral(
"ShowForm" ),
false ).toBool();
52 bool mapIdent =
config( QStringLiteral(
"MapIdentification" ),
false ).toBool();
53 bool readOnlyWidget =
config( QStringLiteral(
"ReadOnly" ),
false ).toBool();
54 bool orderByValue =
config( QStringLiteral(
"OrderByValue" ),
false ).toBool();
55 bool showOpenFormButton =
config( QStringLiteral(
"ShowOpenFormButton" ),
true ).toBool();
62 if (
config( QStringLiteral(
"FilterFields" ), QVariant() ).isValid() )
67 if ( !
config( QStringLiteral(
"FilterExpression" ) ).toString().isEmpty() )
73 const QVariant relationName =
config( QStringLiteral(
"Relation" ) );
82 if ( relationName.isValid() )
103 mWidget->
setRelation( relation,
config( QStringLiteral(
"AllowNULL" ) ).toBool() );
111 return QVariant(
field().type() );
115 if ( fkeys.isEmpty() )
117 return QVariant(
field().type() );
122 Q_ASSERT( fieldPairs.count() == fkeys.count() );
123 for (
int i = 0; i < fieldPairs.count(); i++ )
125 if ( fieldPairs.at( i ).referencingField() ==
field().name() )
126 return fkeys.at( i );
128 return QVariant(
field().type() );
143 mIndeterminateState =
true;
151 for (
int i = 0; i < mWidget->
relation().fieldPairs().count(); i++ )
153 values << QVariant();
161 int fieldCount = std::min( fieldPairs.count(), values.count() );
162 for (
int i = 0; i < fieldCount; i++ )
164 if ( fieldPairs.at( i ).referencingField() ==
field().name() )
166 values.removeAt( i );
177 return QStringList();
181 for (
int i = 0; i < fieldPairs.count(); i++ )
183 if ( fieldPairs.at( i ).referencingField() ==
field().name() )
186 fields << fieldPairs.at( i ).referencingField();
191 void QgsRelationReferenceWidgetWrapper::updateValues(
const QVariant &val,
const QVariantList &additionalValues )
193 if ( !mWidget || ( !mIndeterminateState && val ==
value() && val.isNull() ==
value().isNull() ) )
196 mIndeterminateState =
false;
198 QVariantList values = additionalValues;
200 for (
int i = 0; i < fieldPairs.count(); i++ )
202 if ( fieldPairs.at( i ).referencingField() ==
field().name() )
204 values.insert( i, val );
208 Q_ASSERT( values.count() == fieldPairs.count() );
224 void QgsRelationReferenceWidgetWrapper::foreignKeysChanged(
const QVariantList &values )
226 if ( mBlockChanges != 0 )
229 QVariant mainValue = QVariant(
field().type() );
240 QVariantList additionalValues = values;
242 for (
int i = 0; i < fieldPairs.count(); i++ )
244 if ( fieldPairs.at( i ).referencingField() ==
field().name() )
245 mainValue = additionalValues.takeAt( i );
247 Q_ASSERT( additionalValues.count() == values.count() - 1 );
261 widget()->setStyleSheet( QString() );
268 mWidget->setStyleSheet( QString() );
272 mWidget->setStyleSheet( QStringLiteral(
".QComboBox { background-color: #dd7777; }" ) );
276 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...
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