From 9488f06025a69c05865f231685d1656253e576bd Mon Sep 17 00:00:00 2001 From: Denis Rouzaud Date: Thu, 30 Apr 2020 06:52:22 +0200 Subject: [PATCH] code layout --- python/core/auto_generated/qgsfeaturepickermodel.sip.in | 3 +++ python/core/auto_generated/qgsfeaturepickermodelbase.sip.in | 3 +++ src/core/qgsfeaturefiltermodel.cpp | 2 +- src/core/qgsfeaturepickermodel.cpp | 2 +- src/core/qgsfeaturepickermodel.h | 1 + src/core/qgsfeaturepickermodelbase.h | 4 +++- tests/src/python/test_qgsfeaturepicker.py | 2 +- 7 files changed, 13 insertions(+), 4 deletions(-) diff --git a/python/core/auto_generated/qgsfeaturepickermodel.sip.in b/python/core/auto_generated/qgsfeaturepickermodel.sip.in index 176acbc6364..27628e58f01 100644 --- a/python/core/auto_generated/qgsfeaturepickermodel.sip.in +++ b/python/core/auto_generated/qgsfeaturepickermodel.sip.in @@ -48,6 +48,9 @@ Returns the current feature signals: void featureChanged( const QgsFeature &feature ); +%Docstring +Emitted when the current feature changes +%End }; diff --git a/python/core/auto_generated/qgsfeaturepickermodelbase.sip.in b/python/core/auto_generated/qgsfeaturepickermodelbase.sip.in index dbd48cb2a3b..61e14698c93 100644 --- a/python/core/auto_generated/qgsfeaturepickermodelbase.sip.in +++ b/python/core/auto_generated/qgsfeaturepickermodelbase.sip.in @@ -250,6 +250,9 @@ Update the request to match the current feature to be reloaded %End void setExtraIdentifierValueUnguarded( const QVariant &identifierValue ); +%Docstring +This will set the identifier value to be set in the model even if it doesn't exist currently in the data +%End diff --git a/src/core/qgsfeaturefiltermodel.cpp b/src/core/qgsfeaturefiltermodel.cpp index fc95b66ff64..55a0b250672 100644 --- a/src/core/qgsfeaturefiltermodel.cpp +++ b/src/core/qgsfeaturefiltermodel.cpp @@ -40,7 +40,7 @@ QgsFeatureFilterModel::QgsFeatureFilterModel( QObject *parent ) { setFetchGeometry( false ); setFetchLimit( QgsSettings().value( QStringLiteral( "maxEntriesRelationWidget" ), 100, QgsSettings::Gui ).toInt() ); - setExtraIdentifierValueUnguarded( QVariantList() ); + setExtraIdentifierValueUnguarded( nullIentifier() ); } QString QgsFeatureFilterModel::identifierField() const diff --git a/src/core/qgsfeaturepickermodel.cpp b/src/core/qgsfeaturepickermodel.cpp index 8ec4e3edbd6..536374e02d4 100644 --- a/src/core/qgsfeaturepickermodel.cpp +++ b/src/core/qgsfeaturepickermodel.cpp @@ -25,7 +25,7 @@ QgsFeaturePickerModel::QgsFeaturePickerModel( QObject *parent ) : QgsFeaturePickerModelBase( parent ) { setFetchGeometry( true ); - setExtraIdentifierValueUnguarded( FID_NULL ); + setExtraIdentifierValueUnguarded( nullIentifier() ); connect( this, &QgsFeaturePickerModelBase::extraIdentifierValueIndexChanged, this, [ = ]() {emit featureChanged( feature() );} ); } diff --git a/src/core/qgsfeaturepickermodel.h b/src/core/qgsfeaturepickermodel.h index 2cb035a7f69..8dba890f419 100644 --- a/src/core/qgsfeaturepickermodel.h +++ b/src/core/qgsfeaturepickermodel.h @@ -55,6 +55,7 @@ class CORE_EXPORT QgsFeaturePickerModel : public QgsFeaturePickerModelBase QgsFeature feature() const; signals: + //! Emitted when the current feature changes void featureChanged( const QgsFeature &feature ); diff --git a/src/core/qgsfeaturepickermodelbase.h b/src/core/qgsfeaturepickermodelbase.h index 6643b20f836..bfce7ceba1a 100644 --- a/src/core/qgsfeaturepickermodelbase.h +++ b/src/core/qgsfeaturepickermodelbase.h @@ -274,6 +274,7 @@ class CORE_EXPORT QgsFeaturePickerModelBase : public QAbstractItemModel SIP_ABST //! Update the request to match the current feature to be reloaded virtual void requestToReloadCurrentFeature( QgsFeatureRequest &request ) = 0; + //! This will set the identifier value to be set in the model even if it doesn't exist currently in the data void setExtraIdentifierValueUnguarded( const QVariant &identifierValue ); #ifndef SIP_RUN @@ -284,10 +285,11 @@ class CORE_EXPORT QgsFeaturePickerModelBase : public QAbstractItemModel SIP_ABST */ virtual QSet requestedAttributes() const {return {};} + //! Creates the value gatherer virtual QgsFeatureExpressionValuesGatherer *createValuesGatherer( const QgsFeatureRequest &request ) const = 0; //! Creates an entry with just the identifier so the feature can be retrieved in a next iteration - virtual QgsFeatureExpressionValuesGatherer::Entry createEntry( const QVariant &identifer ) const = 0; + virtual QgsFeatureExpressionValuesGatherer::Entry createEntry( const QVariant &identifier ) const = 0; //! Returns the identifier of the given entry virtual QVariant entryIdentifier( const QgsFeatureExpressionValuesGatherer::Entry &entry ) const = 0; diff --git a/tests/src/python/test_qgsfeaturepicker.py b/tests/src/python/test_qgsfeaturepicker.py index 32cf48a1806..66792a2893c 100644 --- a/tests/src/python/test_qgsfeaturepicker.py +++ b/tests/src/python/test_qgsfeaturepicker.py @@ -102,7 +102,7 @@ class TestQgsRelationEditWidget(unittest.TestCase): spy = QSignalSpy(w.featureChanged) spy.wait() w.findChild(QComboBox).lineEdit().clear() - QTest.keyClicks(w.findChild(QComboBox).lineEdit(), "test99"); + QTest.keyClicks(w.findChild(QComboBox).lineEdit(), "test99") spy.wait() self.assertEqual(w.feature().id(), 99)