QGIS API Documentation 4.0.0-Norrköping (1ddcee3d0e4)
Loading...
Searching...
No Matches
qgslocator.h
Go to the documentation of this file.
1/***************************************************************************
2 qgslocator.h
3 ------------
4 begin : May 2017
5 copyright : (C) 2017 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef QGSLOCATOR_H
19#define QGSLOCATOR_H
20
21#include <memory>
22
23#include "qgis_core.h"
24#include "qgis_sip.h"
25#include "qgsfeedback.h"
26#include "qgslocatorcontext.h"
27#include "qgslocatorfilter.h"
28#include "qgssettingstree.h"
29
30#include <QFuture>
31#include <QFutureWatcher>
32#include <QMap>
33#include <QObject>
34#include <QString>
35
36using namespace Qt::StringLiterals;
37
40
41
64class CORE_EXPORT QgsLocator : public QObject
65{
66 Q_OBJECT
67
68 public:
70 static const QList<QString> CORE_FILTERS;
71
75 QgsLocator( QObject *parent SIP_TRANSFERTHIS = nullptr );
76
80 ~QgsLocator() override;
81
90
100 void deregisterFilter( QgsLocatorFilter *filter );
101
107 QList< QgsLocatorFilter *> filters( const QString &prefix = QString() );
108
115 Q_DECL_DEPRECATED QMap<QString, QgsLocatorFilter *> prefixedFilters() const;
116
127 void fetchResults( const QString &string, const QgsLocatorContext &context, QgsFeedback *feedback = nullptr );
128
134 void cancel();
135
142
146 bool isRunning() const;
147
153
159 QStringList completionList() const { return mAutocompletionList; }
160
161#ifndef SIP_RUN
163
170#endif
171
172 signals:
173
178 void foundResult( const QgsLocatorResult &result );
179
186
191 void finished();
192
193 private slots:
194
195 void filterSentResult( QgsLocatorResult result );
196
197 private:
198 QgsFeedback *mFeedback = nullptr;
199 std::unique_ptr< QgsFeedback > mOwnedFeedback;
200
201 QList< QgsLocatorFilter * > mFilters;
202 QList< QThread * > mActiveThreads;
203
204 QStringList mAutocompletionList;
205
206 void cancelRunningQuery();
207};
208
209#endif // QGSLOCATOR_H
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition qgsfeedback.h:44
Encapsulates the properties relating to the context of a locator search.
Abstract base class for filters which collect locator results.
Encapsulates properties of an individual matching result found by a QgsLocatorFilter.
static QgsSettingsTreeNamedListNode * sTreeLocatorFilters
Definition qgslocator.h:162
static const QList< QString > CORE_FILTERS
List of core filters (i.e. not plugin filters).
Definition qgslocator.h:70
void searchPrepared()
Emitted when locator has prepared the search (.
void cancel()
Cancels any current running query, and blocks until query is completely canceled by all filters.
QgsLocator(QObject *parent=nullptr)
Constructor for QgsLocator.
static const QgsSettingsEntryBool * settingsLocatorFilterDefault
Settings entry locator filter default value.
Definition qgslocator.h:167
void registerFilter(QgsLocatorFilter *filter)
Registers a filter within the locator.
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.
void fetchResults(const QString &string, const QgsLocatorContext &context, QgsFeedback *feedback=nullptr)
Triggers the background fetching of filter results for a specified search string.
void clearPreviousResults()
Will call clearPreviousResults on all filters.
static const QgsSettingsEntryBool * settingsLocatorFilterEnabled
Settings entry locator filter enabled.
Definition qgslocator.h:165
Q_DECL_DEPRECATED QMap< QString, QgsLocatorFilter * > prefixedFilters() const
Returns a map of prefix to filter, for all registered filters with valid prefixes.
bool isRunning() const
Returns true if a query is currently being executed by the locator.
static const QgsSettingsEntryString * settingsLocatorFilterPrefix
Settings entry locator filter prefix.
Definition qgslocator.h:169
void cancelWithoutBlocking()
Triggers cancellation of any current running query without blocking.
QList< QgsLocatorFilter * > filters(const QString &prefix=QString())
Returns the list of filters registered in the locator.
void deregisterFilter(QgsLocatorFilter *filter)
Deregisters a filter from the locator and deletes it.
QStringList completionList() const
Returns the list for auto completion This list is updated when preparing the search.
Definition qgslocator.h:159
A boolean settings entry.
A string settings entry.
A named list tree node for the settings tree to help organizing and introspecting the tree.
QgsSettingsTreeNamedListNode * createNamedListNode(const QString &key, const Qgis::SettingsTreeNodeOptions &options=Qgis::SettingsTreeNodeOptions())
Creates a named list tree node.
static QgsSettingsTreeNode * treeRoot()
Returns the tree root node for the settings tree.
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:52
#define SIP_TRANSFER
Definition qgis_sip.h:35