Skip to content

Commit df9d9f6

Browse files
committedMay 17, 2017
Invalidate current locator results when locator options are changed
1 parent 7635b44 commit df9d9f6

File tree

6 files changed

+28
-4
lines changed

6 files changed

+28
-4
lines changed
 

‎python/gui/locator/qgslocatorwidget.sip

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ class QgsLocatorWidget : QWidget
4949
Triggers the locator widget to focus, open and start searching for a specified ``string``.
5050
%End
5151

52+
void invalidateResults();
53+
%Docstring
54+
Invalidates the current search results, e.g. as a result of changes to the locator
55+
filter settings.
56+
%End
57+
5258
signals:
5359

5460
void configTriggered();

‎src/app/locator/qgslocatoroptionswidget.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@
1616
***************************************************************************/
1717

1818
#include "qgslocatoroptionswidget.h"
19+
#include "qgslocatorwidget.h"
1920
#include "qgssettings.h"
2021

21-
QgsLocatorOptionsWidget::QgsLocatorOptionsWidget( QgsLocator *locator, QWidget *parent )
22+
QgsLocatorOptionsWidget::QgsLocatorOptionsWidget( QgsLocatorWidget *locator, QWidget *parent )
2223
: QWidget( parent )
23-
, mLocator( locator )
24+
, mLocatorWidget( locator )
25+
, mLocator( locator->locator() )
2426
{
2527
setupUi( this );
2628

@@ -34,6 +36,7 @@ QgsLocatorOptionsWidget::QgsLocatorOptionsWidget( QgsLocator *locator, QWidget *
3436
void QgsLocatorOptionsWidget::commitChanges()
3537
{
3638
mModel->commitChanges();
39+
mLocatorWidget->invalidateResults();
3740
}
3841

3942

‎src/app/locator/qgslocatoroptionswidget.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,23 @@
2323
#include "ui_qgslocatoroptionswidgetbase.h"
2424

2525
class QgsLocatorFiltersModel;
26+
class QgsLocatorWidget;
2627

2728
class QgsLocatorOptionsWidget : public QWidget, private Ui::QgsLocatorOptionsWidgetBase
2829
{
2930
Q_OBJECT
3031

3132
public:
3233

33-
QgsLocatorOptionsWidget( QgsLocator *locator, QWidget *parent = nullptr );
34+
QgsLocatorOptionsWidget( QgsLocatorWidget *locator, QWidget *parent = nullptr );
3435

3536
public slots:
3637

3738
void commitChanges();
3839

3940
private:
4041

42+
QgsLocatorWidget *mLocatorWidget = nullptr;
4143
QgsLocator *mLocator = nullptr;
4244
QgsLocatorFiltersModel *mModel = nullptr;
4345
};

‎src/app/qgsoptions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -943,7 +943,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QList<QgsOpti
943943
mVariableEditor->setEditableScopeIndex( 0 );
944944

945945
// locator
946-
mLocatorOptionsWidget = new QgsLocatorOptionsWidget( QgisApp::instance()->locatorWidget()->locator(), this );
946+
mLocatorOptionsWidget = new QgsLocatorOptionsWidget( QgisApp::instance()->locatorWidget(), this );
947947
QVBoxLayout *locatorLayout = new QVBoxLayout();
948948
locatorLayout->addWidget( mLocatorOptionsWidget );
949949
mOptionsLocatorGroupBox->setLayout( locatorLayout );

‎src/gui/locator/qgslocatorwidget.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,13 @@ void QgsLocatorWidget::search( const QString &string )
122122
performSearch();
123123
}
124124

125+
void QgsLocatorWidget::invalidateResults()
126+
{
127+
mLocator->cancelWithoutBlocking();
128+
mLocatorModel->clear();
129+
mResultsContainer->hide();
130+
}
131+
125132
void QgsLocatorWidget::scheduleDelayedPopup()
126133
{
127134
mPopupTimer.start();

‎src/gui/locator/qgslocatorwidget.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ class GUI_EXPORT QgsLocatorWidget : public QWidget
7474
*/
7575
void search( const QString &string );
7676

77+
/**
78+
* Invalidates the current search results, e.g. as a result of changes to the locator
79+
* filter settings.
80+
*/
81+
void invalidateResults();
82+
7783
signals:
7884

7985
/**

0 commit comments

Comments
 (0)