Skip to content

Commit

Permalink
Be gentle, allow for delays!
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvn committed Nov 25, 2024
1 parent a81f884 commit 04cd153
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/core/locator/qfieldlocatorfilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ QFieldLocatorFilter::QFieldLocatorFilter( QObject *parent )
QFieldLocatorFilter *QFieldLocatorFilter::clone() const
{
QFieldLocatorFilter *filter = new QFieldLocatorFilter();
filter->setFetchResultsDelay( fetchResultsDelay() );
filter->setName( mName );
filter->setDisplayName( mDisplayName );
filter->setPrefix( mPrefix );
Expand Down Expand Up @@ -74,6 +75,15 @@ void QFieldLocatorFilter::setLocatorBridge( LocatorModelSuperBridge *locatorBrid
emit locatorBridgeChanged();
}

void QFieldLocatorFilter::setDelay( int delay )
{
if ( fetchResultsDelay() == delay )
return;

setFetchResultsDelay( delay );
emit delayChanged();
}

void QFieldLocatorFilter::setName( const QString &name )
{
if ( mName == name )
Expand Down
10 changes: 10 additions & 0 deletions src/core/locator/qfieldlocatorfilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class QFieldLocatorFilter : public QgsLocatorFilter
{
Q_OBJECT

Q_PROPERTY( int delay READ delay WRITE setDelay NOTIFY delayChanged )
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 )
Expand All @@ -50,6 +51,12 @@ class QFieldLocatorFilter : public QgsLocatorFilter
//! Clone the locator filter
QFieldLocatorFilter *clone() const override;

//! Returns the delay before which the fetching of results is triggered
int delay() const { return fetchResultsDelay(); }

//! Sets the delay before which the fetching of results is triggered
void setDelay( int delay );

//! \copydoc QgsLocatorFilter::name
QString name() const override { return mName; }

Expand Down Expand Up @@ -115,6 +122,9 @@ class QFieldLocatorFilter : public QgsLocatorFilter
void triggerResultFromAction( const QgsLocatorResult &result, const int actionId ) override;

signals:
//! Emitted when the fetch result delay has changed
void delayChanged();

//! Emitted when the name has changed
void nameChanged();

Expand Down

0 comments on commit 04cd153

Please sign in to comment.