24#include <QItemSelection>
26#include "moc_qgslocatormodelbridge.cpp"
34 mProxyModel->setSourceModel( mLocatorModel );
48 mLocator->clearPreviousResults();
60 if ( deselected.count() > 0 && deselected.indexes().at( 0 ).isValid() )
62 const QModelIndex deselectedIndex = deselected.indexes().at( 0 );
70 if ( selected.count() > 0 && selected.indexes().at( 0 ).isValid() )
72 const QModelIndex selectedIndex = selected.indexes().at( 0 );
81void QgsLocatorModelBridge::setIsRunning(
bool isRunning )
92 mLocator->cancelWithoutBlocking();
93 mLocatorModel->clear();
98 mCanvasExtent = extent;
113void QgsLocatorModelBridge::searchFinished()
115 if ( mHasQueuedRequest )
118 const QString nextSearch = mNextRequestedString;
119 mNextRequestedString.clear();
120 mHasQueuedRequest =
false;
125 if ( !mLocator->isRunning() )
126 setIsRunning(
false );
132 setIsRunning(
true );
134 if ( mLocator->isRunning() )
139 mLocator->cancelWithoutBlocking();
140 mNextRequestedString = text;
141 mHasQueuedRequest =
true;
147 mLocatorModel->deferredClear();
148 mLocator->fetchResults( text, createContext() );
164 return mHasQueuedRequest;
Represents a coordinate reference system (CRS).
Encapsulates the properties relating to the context of a locator search.
QgsCoordinateTransformContext transformContext
Coordinate transform context, to use whenever performing coordinate transformations inside a locator.
QgsCoordinateReferenceSystem targetExtentCrs
Coordinate reference system for the map extent variable.
QgsRectangle targetExtent
Map extent to target in results.
virtual void triggerResultFromAction(const QgsLocatorResult &result, const int actionId)
Triggers a filter result from this filter for an entry in the context menu.
virtual void triggerResult(const QgsLocatorResult &result)=0
Triggers a filter result from this filter.
virtual void resultDeselected(const QgsLocatorResult &result)
This is called when a result is deselected.
virtual void resultSelected(const QgsLocatorResult &result)
This is called when the result is selected by the user.
QgsLocatorModelBridge(QObject *parent=nullptr)
Constructor of QgsLocatorModelBridge.
Q_INVOKABLE QgsLocatorProxyModel * proxyModel() const
Returns the proxy model.
void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
This will call filters implementation of selection/deselection of results.
void isRunningChanged()
Emitted when the running status changes.
void resultAdded()
Emitted when a result is added.
void triggerResult(const QModelIndex &index, const int actionId=-1)
Triggers the result at given index and with optional actionId if an additional action was triggered.
QgsLocator * locator() const
Returns the locator.
bool hasQueueRequested() const
Returns true if some text to be search is pending in the queue.
Q_INVOKABLE void performSearch(const QString &text)
Perform a search.
void resultsCleared()
Emitted when the results are cleared.
void updateCanvasCrs(const QgsCoordinateReferenceSystem &crs)
Update the canvas CRS used to create search context.
void updateCanvasExtent(const QgsRectangle &extent)
Update the canvas extent used to create search context.
void invalidateResults()
This will invalidate current search results.
An abstract list model for displaying the results of locator searches.
@ ResultData
QgsLocatorResult data.
void addResult(const QgsLocatorResult &result)
Adds a new result to the model.
A sort proxy model for QgsLocatorModel, which automatically sorts results by precedence.
Encapsulates properties of an individual matching result found by a QgsLocatorFilter.
QgsLocatorFilter * filter
Filter from which the result was obtained.
Handles the management of QgsLocatorFilter objects and async collection of search results from them.
void finished()
Emitted when locator has finished a query, either as a result of successful completion or early cance...
void foundResult(const QgsLocatorResult &result)
Emitted whenever a filter encounters a matching result after the fetchResults() method is called.
A rectangle specified with double values.