Skip to content

Commit

Permalink
Allow for QML locator filters to pass on parameters to the locator pr…
Browse files Browse the repository at this point in the history
…ocessing source
  • Loading branch information
nirvn committed Nov 23, 2024
1 parent 892d1e1 commit 4701c89
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/core/locator/qfieldlocatorfilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,21 @@ QFieldLocatorFilter *QFieldLocatorFilter::clone() const
filter->setName( mName );
filter->setDisplayName( mDisplayName );
filter->setPrefix( mPrefix );
filter->setParameters( mParameters );
filter->setSource( mSource );
filter->setLocatorBridge( mLocatorBridge );
return filter;
}

void QFieldLocatorFilter::setParameters( const QVariantMap &parameters )
{
if ( mParameters == parameters )
return;

mParameters = parameters;
emit parametersChanged();
}

void QFieldLocatorFilter::setSource( const QUrl &source )
{
if ( mSource.path() == source.path() )
Expand Down Expand Up @@ -128,7 +138,7 @@ void QFieldLocatorFilter::fetchResults( const QString &string, const QgsLocatorC
connect( object, SIGNAL( fetchResultsEnded() ), &loop, SLOT( quit() ) );
connect( feedback, &QgsFeedback::canceled, &loop, &QEventLoop::quit );

QMetaObject::invokeMethod( object, QStringLiteral( "fetchResults" ).toStdString().c_str(), QVariant( string ), QVariant::fromValue<QgsLocatorContext>( context ) );
QMetaObject::invokeMethod( object, QStringLiteral( "fetchResults" ).toStdString().c_str(), QVariant( string ), QVariant::fromValue<QgsLocatorContext>( context ), QVariant::fromValue( mParameters ) );
if ( !mFetchResultsEnded )
{
loop.exec();
Expand Down
8 changes: 8 additions & 0 deletions src/core/locator/qfieldlocatorfilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ class QFieldLocatorFilter : public QgsLocatorFilter
Q_PROPERTY( QString name READ name WRITE setName NOTIFY nameChanged )
Q_PROPERTY( QString displayName READ displayName WRITE setDisplayName NOTIFY displayNameChanged )
Q_PROPERTY( QString prefix READ prefix WRITE setPrefix NOTIFY prefixChanged )

Q_PROPERTY( QVariantMap parameters READ parameters WRITE setParameters NOTIFY parametersChanged )
Q_PROPERTY( QUrl source READ source WRITE setSource NOTIFY sourceChanged )

Q_PROPERTY( LocatorModelSuperBridge *locatorBridge READ locatorBridge WRITE setLocatorBridge NOTIFY locatorBridgeChanged )

public:
Expand All @@ -57,6 +60,9 @@ class QFieldLocatorFilter : public QgsLocatorFilter
QUrl source() const { return mSource; }
void setSource( const QUrl &source );

QVariantMap parameters() const { return mParameters; }
void setParameters( const QVariantMap &parameters );

LocatorModelSuperBridge *locatorBridge() const { return mLocatorBridge; }
void setLocatorBridge( LocatorModelSuperBridge *locatorBridge );

Expand All @@ -70,6 +76,7 @@ class QFieldLocatorFilter : public QgsLocatorFilter
void nameChanged();
void displayNameChanged();
void prefixChanged();
void parametersChanged();
void sourceChanged();
void locatorBridgeChanged();

Expand All @@ -84,6 +91,7 @@ class QFieldLocatorFilter : public QgsLocatorFilter

bool mFetchResultsEnded = false;

QVariantMap mParameters;
QUrl mSource;

LocatorModelSuperBridge *mLocatorBridge = nullptr;
Expand Down

0 comments on commit 4701c89

Please sign in to comment.