QGIS API Documentation
3.16.0-Hannover (43b64b13f3)
|
Go to the documentation of this file.
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() );
219 void QgsRelationReferenceWidgetWrapper::foreignKeysChanged(
const QVariantList &values )
221 QVariant mainValue = QVariant(
field().type() );
232 QVariantList additionalValues = values;
234 for (
int i = 0; i < fieldPairs.count(); i++ )
236 if ( fieldPairs.at( i ).referencingField() ==
field().name() )
237 mainValue = additionalValues.takeAt( i );
239 Q_ASSERT( additionalValues.count() == values.count() - 1 );
253 widget()->setStyleSheet( QString() );
260 mWidget->setStyleSheet( QString() );
264 mWidget->setStyleSheet( QStringLiteral(
".QComboBox { background-color: #dd7777; }" ) );
268 mWidget->setStyleSheet( QStringLiteral(
".QComboBox { background-color: #ffd85d; }" ) );
QgsRelationManager * relationManager
Map canvas is a class for displaying all GIS data types on a canvas.
static QgsProject * instance()
Returns the QgsProject singleton instance.
Q_INVOKABLE QgsRelation relation(const QString &id) const
Gets access to a relation by its id.
const QgsRelation & relation() const
Returns the attribute relation.
#define Q_NOWARN_DEPRECATED_POP
A bar for displaying non-blocking messages to the user.
QList< QgsRelation > referencingRelations(int idx) const
Returns the layer's relations, where the foreign key is on this layer.
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.
const QgsAttributeEditorContext * parentContext() const
This class contains context information for attribute editor widgets.
#define Q_NOWARN_DEPRECATED_PUSH