Skip to content

Commit

Permalink
Invalidate current locator results when locator options are changed
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed May 17, 2017
1 parent 7635b44 commit df9d9f6
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 4 deletions.
6 changes: 6 additions & 0 deletions python/gui/locator/qgslocatorwidget.sip
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ class QgsLocatorWidget : QWidget
Triggers the locator widget to focus, open and start searching for a specified ``string``.
%End

void invalidateResults();
%Docstring
Invalidates the current search results, e.g. as a result of changes to the locator
filter settings.
%End

signals:

void configTriggered();
Expand Down
7 changes: 5 additions & 2 deletions src/app/locator/qgslocatoroptionswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@
***************************************************************************/

#include "qgslocatoroptionswidget.h"
#include "qgslocatorwidget.h"
#include "qgssettings.h"

QgsLocatorOptionsWidget::QgsLocatorOptionsWidget( QgsLocator *locator, QWidget *parent )
QgsLocatorOptionsWidget::QgsLocatorOptionsWidget( QgsLocatorWidget *locator, QWidget *parent )
: QWidget( parent )
, mLocator( locator )
, mLocatorWidget( locator )
, mLocator( locator->locator() )
{
setupUi( this );

Expand All @@ -34,6 +36,7 @@ QgsLocatorOptionsWidget::QgsLocatorOptionsWidget( QgsLocator *locator, QWidget *
void QgsLocatorOptionsWidget::commitChanges()
{
mModel->commitChanges();
mLocatorWidget->invalidateResults();
}


Expand Down
4 changes: 3 additions & 1 deletion src/app/locator/qgslocatoroptionswidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,23 @@
#include "ui_qgslocatoroptionswidgetbase.h"

class QgsLocatorFiltersModel;
class QgsLocatorWidget;

class QgsLocatorOptionsWidget : public QWidget, private Ui::QgsLocatorOptionsWidgetBase
{
Q_OBJECT

public:

QgsLocatorOptionsWidget( QgsLocator *locator, QWidget *parent = nullptr );
QgsLocatorOptionsWidget( QgsLocatorWidget *locator, QWidget *parent = nullptr );

public slots:

void commitChanges();

private:

QgsLocatorWidget *mLocatorWidget = nullptr;
QgsLocator *mLocator = nullptr;
QgsLocatorFiltersModel *mModel = nullptr;
};
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsoptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QList<QgsOpti
mVariableEditor->setEditableScopeIndex( 0 );

// locator
mLocatorOptionsWidget = new QgsLocatorOptionsWidget( QgisApp::instance()->locatorWidget()->locator(), this );
mLocatorOptionsWidget = new QgsLocatorOptionsWidget( QgisApp::instance()->locatorWidget(), this );
QVBoxLayout *locatorLayout = new QVBoxLayout();
locatorLayout->addWidget( mLocatorOptionsWidget );
mOptionsLocatorGroupBox->setLayout( locatorLayout );
Expand Down
7 changes: 7 additions & 0 deletions src/gui/locator/qgslocatorwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,13 @@ void QgsLocatorWidget::search( const QString &string )
performSearch();
}

void QgsLocatorWidget::invalidateResults()
{
mLocator->cancelWithoutBlocking();
mLocatorModel->clear();
mResultsContainer->hide();
}

void QgsLocatorWidget::scheduleDelayedPopup()
{
mPopupTimer.start();
Expand Down
6 changes: 6 additions & 0 deletions src/gui/locator/qgslocatorwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ class GUI_EXPORT QgsLocatorWidget : public QWidget
*/
void search( const QString &string );

/**
* Invalidates the current search results, e.g. as a result of changes to the locator
* filter settings.
*/
void invalidateResults();

signals:

/**
Expand Down

0 comments on commit df9d9f6

Please sign in to comment.