QGIS API Documentation
3.14.0-Pi (9f7028fd23)
|
Go to the documentation of this file.
25 , mMessageBar( messageBar )
26 , mIndeterminateState( false )
50 bool showForm =
config( QStringLiteral(
"ShowForm" ),
false ).toBool();
51 bool mapIdent =
config( QStringLiteral(
"MapIdentification" ),
false ).toBool();
52 bool readOnlyWidget =
config( QStringLiteral(
"ReadOnly" ),
false ).toBool();
53 bool orderByValue =
config( QStringLiteral(
"OrderByValue" ),
false ).toBool();
54 bool showOpenFormButton =
config( QStringLiteral(
"ShowOpenFormButton" ),
true ).toBool();
61 if (
config( QStringLiteral(
"FilterFields" ), QVariant() ).isValid() )
68 const QVariant relationName =
config( QStringLiteral(
"Relation" ) );
77 if ( relationName.isValid() )
98 mWidget->
setRelation( relation,
config( QStringLiteral(
"AllowNULL" ) ).toBool() );
106 return QVariant(
field().type() );
110 if ( fkeys.isEmpty() )
112 return QVariant(
field().type() );
117 Q_ASSERT( fieldPairs.count() == fkeys.count() );
118 for (
int i = 0; i < fieldPairs.count(); i++ )
120 if ( fieldPairs.at( i ).referencingField() ==
field().name() )
121 return fkeys.at( i );
123 return QVariant(
field().type() );
138 mIndeterminateState =
true;
146 for (
int i = 0; i < mWidget->
relation().fieldPairs().count(); i++ )
148 values << QVariant();
156 int fieldCount = std::min( fieldPairs.count(), values.count() );
157 for (
int i = 0; i < fieldCount; i++ )
159 if ( fieldPairs.at( i ).referencingField() ==
field().name() )
161 values.removeAt( i );
172 return QStringList();
176 for (
int i = 0; i < fieldPairs.count(); i++ )
178 if ( fieldPairs.at( i ).referencingField() ==
field().name() )
181 fields << fieldPairs.at( i ).referencingField();
186 void QgsRelationReferenceWidgetWrapper::updateValues(
const QVariant &val,
const QVariantList &additionalValues )
188 if ( !mWidget || ( !mIndeterminateState && val ==
value() && val.isNull() ==
value().isNull() ) )
191 mIndeterminateState =
false;
193 QVariantList values = additionalValues;
195 for (
int i = 0; i < fieldPairs.count(); i++ )
197 if ( fieldPairs.at( i ).referencingField() ==
field().name() )
199 values.insert( i, val );
203 Q_ASSERT( values.count() == fieldPairs.count() );
217 void QgsRelationReferenceWidgetWrapper::foreignKeysChanged(
const QVariantList &values )
219 QVariant mainValue = QVariant(
field().type() );
230 QVariantList additionalValues = values;
232 for (
int i = 0; i < fieldPairs.count(); i++ )
234 if ( fieldPairs.at( i ).referencingField() ==
field().name() )
235 mainValue = additionalValues.takeAt( i );
237 Q_ASSERT( additionalValues.count() == values.count() - 1 );
251 widget()->setStyleSheet( QString() );
258 mWidget->setStyleSheet( QString() );
262 mWidget->setStyleSheet( QStringLiteral(
".QComboBox { background-color: #dd7777; }" ) );
266 mWidget->setStyleSheet( QStringLiteral(
".QComboBox { background-color: #ffd85d; }" ) );
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.
const QgsRelation & relation() const
Returns the attribute relation.
#define Q_NOWARN_DEPRECATED_POP
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...
const QgsAttributeEditorContext * parentContext() const
#define Q_NOWARN_DEPRECATED_PUSH