QGIS API Documentation
3.20.0-Odense (decaadbb31)
|
Handles the management of QgsLocatorFilter objects and async collection of search results from them. More...
#include <qgslocator.h>
Signals | |
void | finished () |
Emitted when locator has finished a query, either as a result of successful completion or early cancellation. More... | |
void | foundResult (const QgsLocatorResult &result) |
Emitted whenever a filter encounters a matching result after the fetchResults() method is called. More... | |
void | searchPrepared () |
Emitted when locator has prepared the search (. More... | |
Public Member Functions | |
QgsLocator (QObject *parent=nullptr) | |
Constructor for QgsLocator. More... | |
~QgsLocator () override | |
Destructor for QgsLocator. More... | |
void | cancel () |
Cancels any current running query, and blocks until query is completely canceled by all filters. More... | |
void | cancelWithoutBlocking () |
Triggers cancellation of any current running query without blocking. More... | |
void | clearPreviousResults () |
Will call clearPreviousResults on all filters. More... | |
QStringList | completionList () const |
Returns the list for auto completion This list is updated when preparing the search. More... | |
void | deregisterFilter (QgsLocatorFilter *filter) |
Deregisters a filter from the locator and deletes it. More... | |
void | fetchResults (const QString &string, const QgsLocatorContext &context, QgsFeedback *feedback=nullptr) |
Triggers the background fetching of filter results for a specified search string. More... | |
QList< QgsLocatorFilter * > | filters (const QString &prefix=QString()) |
Returns the list of filters registered in the locator. More... | |
bool | isRunning () const |
Returns true if a query is currently being executed by the locator. More... | |
Q_DECL_DEPRECATED QMap< QString, QgsLocatorFilter * > | prefixedFilters () const |
Returns a map of prefix to filter, for all registered filters with valid prefixes. More... | |
void | registerFilter (QgsLocatorFilter *filter) |
Registers a filter within the locator. More... | |
Static Public Attributes | |
static const QList< QString > | CORE_FILTERS |
List of core filters (i.e. not plugin filters) More... | |
static const QgsSettingsEntryBool | settingsLocatorFilterDefault = QgsSettingsEntryBool( QStringLiteral( "locator_filters/default_%1" ), QgsSettings::Gui, false, "Locator filter default value" ) |
Settings entry locator filter default value. More... | |
static const QgsSettingsEntryBool | settingsLocatorFilterEnabled = QgsSettingsEntryBool( QStringLiteral( "locator_filters/enabled_%1" ), QgsSettings::Gui, true, "Locator filter enabled" ) |
Settings entry locator filter enabled. More... | |
static const QgsSettingsEntryString | settingsLocatorFilterPrefix = QgsSettingsEntryString( QStringLiteral( "locator_filters/prefix_%1" ), QgsSettings::Gui, QString(), "Locator filter prefix" ) |
Settings entry locator filter prefix. More... | |
Handles the management of QgsLocatorFilter objects and async collection of search results from them.
QgsLocator acts as both a registry for QgsLocatorFilter objects and a means of firing up asynchronous queries against these filter objects.
Filters are first registered to the locator by calling registerFilter(). Registering filters transfers their ownership to the locator object. Plugins which register filters to the locator must take care to correctly call deregisterFilter() and deregister their filter upon plugin unload to avoid crashes.
In order to trigger a search across registered filters, the fetchResults() method is called. This triggers threaded calls to QgsLocatorFilter::fetchResults() for all registered filters. As individual filters find matching results, the foundResult() signal will be triggered for each result. Callers should connect this signal to an appropriate slot designed to collect and handle these results. Since foundResult() is triggered whenever a filter encounters an individual result, it will usually be triggered many times for a single call to fetchResults().
Definition at line 58 of file qgslocator.h.
QgsLocator::QgsLocator | ( | QObject * | parent = nullptr | ) |
Constructor for QgsLocator.
Definition at line 36 of file qgslocator.cpp.
|
override |
Destructor for QgsLocator.
Destruction will block while any currently running query is terminated.
Definition at line 42 of file qgslocator.cpp.
void QgsLocator::cancel | ( | ) |
Cancels any current running query, and blocks until query is completely canceled by all filters.
Definition at line 250 of file qgslocator.cpp.
void QgsLocator::cancelWithoutBlocking | ( | ) |
Triggers cancellation of any current running query without blocking.
The query may take some time to cancel after calling this.
Definition at line 255 of file qgslocator.cpp.
void QgsLocator::clearPreviousResults | ( | ) |
Will call clearPreviousResults on all filters.
Definition at line 266 of file qgslocator.cpp.
|
inline |
Returns the list for auto completion This list is updated when preparing the search.
Definition at line 154 of file qgslocator.h.
void QgsLocator::deregisterFilter | ( | QgsLocatorFilter * | filter | ) |
Deregisters a filter from the locator and deletes it.
Calling this will block whilst any currently running query is terminated.
Plugins which register filters to the locator must take care to correctly call deregisterFilter() to deregister their filters upon plugin unload to avoid crashes.
Definition at line 48 of file qgslocator.cpp.
void QgsLocator::fetchResults | ( | const QString & | string, |
const QgsLocatorContext & | context, | ||
QgsFeedback * | feedback = nullptr |
||
) |
Triggers the background fetching of filter results for a specified search string.
The context argument encapsulates the context relating to the search (such as a map extent to prioritize).
If specified, the feedback object must exist for the lifetime of this query.
The foundResult() signal will be emitted for each individual result encountered by the registered filters.
Definition at line 129 of file qgslocator.cpp.
QList< QgsLocatorFilter * > QgsLocator::filters | ( | const QString & | prefix = QString() | ) |
Returns the list of filters registered in the locator.
prefix | If prefix is not empty, the list returned corresponds to the filter with the given active prefix |
Definition at line 55 of file qgslocator.cpp.
|
signal |
Emitted when locator has finished a query, either as a result of successful completion or early cancellation.
|
signal |
Emitted whenever a filter encounters a matching result after the fetchResults() method is called.
bool QgsLocator::isRunning | ( | ) | const |
Returns true
if a query is currently being executed by the locator.
Definition at line 261 of file qgslocator.cpp.
QMap< QString, QgsLocatorFilter * > QgsLocator::prefixedFilters | ( | ) | const |
Returns a map of prefix to filter, for all registered filters with valid prefixes.
Definition at line 75 of file qgslocator.cpp.
void QgsLocator::registerFilter | ( | QgsLocatorFilter * | filter | ) |
Registers a filter within the locator.
Ownership of the filter is transferred to the locator.
Definition at line 92 of file qgslocator.cpp.
|
signal |
Emitted when locator has prepared the search (.
|
static |
List of core filters (i.e. not plugin filters)
Definition at line 65 of file qgslocator.h.
|
inlinestatic |
Settings entry locator filter default value.
Definition at line 160 of file qgslocator.h.
|
inlinestatic |
Settings entry locator filter enabled.
Definition at line 158 of file qgslocator.h.
|
inlinestatic |
Settings entry locator filter prefix.
Definition at line 162 of file qgslocator.h.