QGIS API Documentation 3.41.0-Master (45a0abf3bec)
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 <QObject>
22#include <QFuture>
23#include <QFutureWatcher>
24#include <QMap>
25#include <memory>
26
27#include "qgis_core.h"
28#include "qgis_sip.h"
29#include "qgslocatorfilter.h"
30#include "qgsfeedback.h"
31#include "qgslocatorcontext.h"
32#include "qgssettingstree.h"
33
36
37
60class CORE_EXPORT QgsLocator : public QObject
61{
62 Q_OBJECT
63
64 public:
65
67 static const QList<QString> CORE_FILTERS;
68
72 QgsLocator( QObject *parent SIP_TRANSFERTHIS = nullptr );
73
77 ~QgsLocator() override;
78
86 void registerFilter( QgsLocatorFilter *filter SIP_TRANSFER );
87
97 void deregisterFilter( QgsLocatorFilter *filter );
98
104 QList< QgsLocatorFilter *> filters( const QString &prefix = QString() );
105
112 Q_DECL_DEPRECATED QMap<QString, QgsLocatorFilter *> prefixedFilters() const;
113
124 void fetchResults( const QString &string, const QgsLocatorContext &context, QgsFeedback *feedback = nullptr );
125
131 void cancel();
132
138 void cancelWithoutBlocking();
139
143 bool isRunning() const;
144
149 void clearPreviousResults();
150
156 QStringList completionList() const {return mAutocompletionList;}
157
158#ifndef SIP_RUN
159 static inline QgsSettingsTreeNamedListNode *sTreeLocatorFilters = QgsSettingsTree::treeRoot()->createNamedListNode( QStringLiteral( "locator-filters" ) );
160
167#endif
168
169 signals:
170
175 void foundResult( const QgsLocatorResult &result );
176
183
188 void finished();
189
190 private slots:
191
192 void filterSentResult( QgsLocatorResult result );
193
194 private:
195
196 QgsFeedback *mFeedback = nullptr;
197 std::unique_ptr< QgsFeedback > mOwnedFeedback;
198
199 QList< QgsLocatorFilter * > mFilters;
200 QList< QThread * > mActiveThreads;
201
202 QStringList mAutocompletionList;
203
204 void cancelRunningQuery();
205
206};
207
208#endif // QGSLOCATOR_H
209
210
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.
Handles the management of QgsLocatorFilter objects and async collection of search results from them.
Definition qgslocator.h:61
static const QList< QString > CORE_FILTERS
List of core filters (i.e. not plugin filters)
Definition qgslocator.h:67
void searchPrepared()
Emitted when locator has prepared the search (.
static const QgsSettingsEntryBool * settingsLocatorFilterDefault
Settings entry locator filter default value.
Definition qgslocator.h:164
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.
static const QgsSettingsEntryBool * settingsLocatorFilterEnabled
Settings entry locator filter enabled.
Definition qgslocator.h:162
static const QgsSettingsEntryString * settingsLocatorFilterPrefix
Settings entry locator filter prefix.
Definition qgslocator.h:166
QStringList completionList() const
Returns the list for auto completion This list is updated when preparing the search.
Definition qgslocator.h:156
A boolean settings entry.
A string settings entry.
QgsSettingsTreeNamedListNode is a named list tree node for the settings tree to help organizing and i...
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:53
#define SIP_TRANSFER
Definition qgis_sip.h:36