Skip to content

Commit

Permalink
also move triggering of results to core
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed Nov 9, 2018
1 parent dd14e58 commit 31cd164
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
Expand Up @@ -53,6 +53,11 @@ Returns true if some text to be search is pending in the queue
bool isRunning() const;
%Docstring
Returns true if the a search is currently running
%End

void triggerResult( const QModelIndex &index );
%Docstring
Triggers the result at given index
%End

signals:
Expand Down
7 changes: 7 additions & 0 deletions src/core/locator/qgslocatormodelbridge.cpp
Expand Up @@ -37,6 +37,13 @@ bool QgsLocatorModelBridge::isRunning() const
return mIsRunning;
}

void QgsLocatorModelBridge::triggerResult( const QModelIndex &index )
{
mLocator->clearPreviousResults();
QgsLocatorResult result = mProxyModel->data( index, QgsLocatorModel::ResultDataRole ).value< QgsLocatorResult >();
result.filter->triggerResult( result );
}

void QgsLocatorModelBridge::setIsRunning( bool isRunning )
{
if ( mIsRunning == isRunning )
Expand Down
3 changes: 3 additions & 0 deletions src/core/locator/qgslocatormodelbridge.h
Expand Up @@ -60,6 +60,9 @@ class CORE_EXPORT QgsLocatorModelBridge : public QObject
//! Returns true if the a search is currently running
bool isRunning() const;

//! Triggers the result at given index
void triggerResult( const QModelIndex &index );

signals:
//! Emitted when a result is added
void resultAdded();
Expand Down
4 changes: 1 addition & 3 deletions src/gui/locator/qgslocatorwidget.cpp
Expand Up @@ -312,11 +312,9 @@ void QgsLocatorWidget::acceptCurrentEntry()
if ( !index.isValid() )
return;

QgsLocatorResult result = mModelBridge->proxyModel()->data( index, QgsLocatorModel::ResultDataRole ).value< QgsLocatorResult >();
mResultsContainer->hide();
mLineEdit->clearFocus();
mModelBridge->locator()->clearPreviousResults();
result.filter->triggerResult( result );
mModelBridge->triggerResult( index );
}
}

Expand Down

0 comments on commit 31cd164

Please sign in to comment.