diff --git a/app/attributes/attributecontroller.cpp b/app/attributes/attributecontroller.cpp index 7415f731b..fec3e1cd9 100644 --- a/app/attributes/attributecontroller.cpp +++ b/app/attributes/attributecontroller.cpp @@ -127,17 +127,16 @@ void AttributeController::prefillRelationReferenceField() const QList fieldPairs = mLinkedRelation.fieldPairs(); for ( const QgsRelation::FieldPair &fieldPair : fieldPairs ) { - QMap>::iterator formItemsIterator = mFormItems.begin(); - while ( formItemsIterator != mFormItems.end() ) + QVariant foreignKey = mParentController->featureLayerPair().feature().attribute( fieldPair.referencedField() ); + QString referencingField = fieldPair.referencingField(); + QgsVectorLayer *childLayer = mLinkedRelation.referencingLayer(); + if ( childLayer ) { - std::shared_ptr itemData = formItemsIterator.value(); - if ( itemData->field().name() == fieldPair.referencingField() ) + int fieldIndex = childLayer->fields().lookupField( referencingField ); + if ( fieldIndex != -1 ) { - QVariant fk = mParentController->featureLayerPair().feature().attribute( fieldPair.referencedField() ); - setFormValue( itemData->id(), fk ); - break; + mFeatureLayerPair.featureRef().setAttribute( fieldIndex, foreignKey ); } - ++formItemsIterator; } } } diff --git a/app/attributes/rememberattributescontroller.cpp b/app/attributes/rememberattributescontroller.cpp index 7d73a217f..37700fedf 100644 --- a/app/attributes/rememberattributescontroller.cpp +++ b/app/attributes/rememberattributescontroller.cpp @@ -79,7 +79,7 @@ bool RememberAttributesController::shouldRememberValue( const QgsVectorLayer *la return from.attributeFilter.at( fieldIndex ); } -bool RememberAttributesController::setShouldRememberValue( const QgsVectorLayer *layer, int fieldIndex, bool shouldRemember ) +bool RememberAttributesController::setShouldRememberValue( const QgsVectorLayer *layer, int fieldIndex, bool shouldRemember ) const { // global switch off of the functionality if ( !mRememberValuesAllowed ) diff --git a/app/attributes/rememberattributescontroller.h b/app/attributes/rememberattributescontroller.h index 1c8970412..20810fe9c 100644 --- a/app/attributes/rememberattributescontroller.h +++ b/app/attributes/rememberattributescontroller.h @@ -56,7 +56,7 @@ class RememberAttributesController : public QObject bool shouldRememberValue( const QgsVectorLayer *layer, int fieldIndex ) const; // Returns whether value was changed - bool setShouldRememberValue( const QgsVectorLayer *layer, int fieldIndex, bool shouldRemember ); + bool setShouldRememberValue( const QgsVectorLayer *layer, int fieldIndex, bool shouldRemember ) const; signals: void rememberValuesAllowedChanged(); diff --git a/app/fieldsmodel.cpp b/app/fieldsmodel.cpp index 49c78965e..5da8c7633 100644 --- a/app/fieldsmodel.cpp +++ b/app/fieldsmodel.cpp @@ -122,7 +122,7 @@ bool FieldsModel::setData( const QModelIndex &index, const QVariant &value, int return false; } -bool FieldsModel::contains( const QString &name ) +bool FieldsModel::contains( const QString &name ) const { for ( int i = 0; i < mFields.count(); ++i ) { diff --git a/app/fieldsmodel.h b/app/fieldsmodel.h index f33ee6135..3efd89277 100644 --- a/app/fieldsmodel.h +++ b/app/fieldsmodel.h @@ -62,7 +62,7 @@ class FieldsModel: public QAbstractListModel QList mFields; - bool contains( const QString &name ); + bool contains( const QString &name ) const; }; #endif // FIELDSMODEL_H diff --git a/core/credentialstore.h b/core/credentialstore.h index 50d7443fc..276f666b2 100644 --- a/core/credentialstore.h +++ b/core/credentialstore.h @@ -45,7 +45,7 @@ class CredentialStore : public QObject const QString &password, const QString &token, const QDateTime &tokenExpiration, - int method = 0 ); + int method = 0 ) const; //! Reads authentication data from keychain and emits a signal with all auth values void readAuthData(); diff --git a/core/credentialstoreplaintext.cpp b/core/credentialstoreplaintext.cpp index 7d8297f72..751a5d062 100644 --- a/core/credentialstoreplaintext.cpp +++ b/core/credentialstoreplaintext.cpp @@ -37,7 +37,7 @@ void CredentialStore::writeAuthData const QString &password, const QString &token, const QDateTime &tokenExpiration, - int method ) + int method ) const { QSettings settings; settings.beginGroup( KEYCHAIN_GROUP );