Skip to content

Commit

Permalink
code layout
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed Apr 30, 2020
1 parent b97543d commit 9488f06
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 4 deletions.
3 changes: 3 additions & 0 deletions python/core/auto_generated/qgsfeaturepickermodel.sip.in
Expand Up @@ -48,6 +48,9 @@ Returns the current feature

signals:
void featureChanged( const QgsFeature &feature );
%Docstring
Emitted when the current feature changes
%End


};
Expand Down
3 changes: 3 additions & 0 deletions python/core/auto_generated/qgsfeaturepickermodelbase.sip.in
Expand Up @@ -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



Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsfeaturefiltermodel.cpp
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsfeaturepickermodel.cpp
Expand Up @@ -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() );} );
}
Expand Down
1 change: 1 addition & 0 deletions src/core/qgsfeaturepickermodel.h
Expand Up @@ -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 );


Expand Down
4 changes: 3 additions & 1 deletion src/core/qgsfeaturepickermodelbase.h
Expand Up @@ -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
Expand All @@ -284,10 +285,11 @@ class CORE_EXPORT QgsFeaturePickerModelBase : public QAbstractItemModel SIP_ABST
*/
virtual QSet<QString> 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;
Expand Down
2 changes: 1 addition & 1 deletion tests/src/python/test_qgsfeaturepicker.py
Expand Up @@ -102,7 +102,7 @@ def testLineEdit(self):
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)

Expand Down

0 comments on commit 9488f06

Please sign in to comment.