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() )
70 const QVariant relationName =
config( QStringLiteral(
"Relation" ) );
79 if ( relationName.isValid() )
100 mWidget->
setRelation( relation,
config( QStringLiteral(
"AllowNULL" ) ).toBool() );
108 return QVariant(
field().type() );
112 if ( fkeys.isEmpty() )
114 return QVariant(
field().type() );
119 Q_ASSERT( fieldPairs.count() == fkeys.count() );
120 for (
int i = 0; i < fieldPairs.count(); i++ )
122 if ( fieldPairs.at( i ).referencingField() ==
field().name() )
123 return fkeys.at( i );
125 return QVariant(
field().type() );
140 mIndeterminateState =
true;
148 for (
int i = 0; i < mWidget->
relation().fieldPairs().count(); i++ )
150 values << QVariant();
158 int fieldCount = std::min( fieldPairs.count(), values.count() );
159 for (
int i = 0; i < fieldCount; i++ )
161 if ( fieldPairs.at( i ).referencingField() ==
field().name() )
163 values.removeAt( i );
174 return QStringList();
178 for (
int i = 0; i < fieldPairs.count(); i++ )
180 if ( fieldPairs.at( i ).referencingField() ==
field().name() )
183 fields << fieldPairs.at( i ).referencingField();
188 void QgsRelationReferenceWidgetWrapper::updateValues(
const QVariant &val,
const QVariantList &additionalValues )
190 if ( !mWidget || ( !mIndeterminateState && val ==
value() && val.isNull() ==
value().isNull() ) )
193 mIndeterminateState =
false;
195 QVariantList values = additionalValues;
197 for (
int i = 0; i < fieldPairs.count(); i++ )
199 if ( fieldPairs.at( i ).referencingField() ==
field().name() )
201 values.insert( i, val );
205 Q_ASSERT( values.count() == fieldPairs.count() );
221 void QgsRelationReferenceWidgetWrapper::foreignKeysChanged(
const QVariantList &values )
223 if ( mBlockChanges != 0 )
226 QVariant mainValue = QVariant(
field().type() );
237 QVariantList additionalValues = values;
239 for (
int i = 0; i < fieldPairs.count(); i++ )
241 if ( fieldPairs.at( i ).referencingField() ==
field().name() )
242 mainValue = additionalValues.takeAt( i );
244 Q_ASSERT( additionalValues.count() == values.count() - 1 );
258 widget()->setStyleSheet( QString() );
265 mWidget->setStyleSheet( QString() );
269 mWidget->setStyleSheet( QStringLiteral(
".QComboBox { background-color: #dd7777; }" ) );
273 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