QGIS API Documentation 3.34.0-Prizren (ffbdd678812)
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
61class CORE_EXPORT QgsLocator : public QObject
62{
63 Q_OBJECT
64
65 public:
66
68 static const QList<QString> CORE_FILTERS;
69
73 QgsLocator( QObject *parent SIP_TRANSFERTHIS = nullptr );
74
78 ~QgsLocator() override;
79
87 void registerFilter( QgsLocatorFilter *filter SIP_TRANSFER );
88
98 void deregisterFilter( QgsLocatorFilter *filter );
99
105 QList< QgsLocatorFilter *> filters( const QString &prefix = QString() );
106
113 Q_DECL_DEPRECATED QMap<QString, QgsLocatorFilter *> prefixedFilters() const;
114
125 void fetchResults( const QString &string, const QgsLocatorContext &context, QgsFeedback *feedback = nullptr );
126
132 void cancel();
133
139 void cancelWithoutBlocking();
140
144 bool isRunning() const;
145
150 void clearPreviousResults();
151
157 QStringList completionList() const {return mAutocompletionList;}
158
159#ifndef SIP_RUN
160 static inline QgsSettingsTreeNamedListNode *sTreeLocatorFilters = QgsSettingsTree::treeRoot()->createNamedListNode( QStringLiteral( "locator-filters" ) );
161
168#endif
169
170 signals:
171
176 void foundResult( const QgsLocatorResult &result );
177
184
189 void finished();
190
191 private slots:
192
193 void filterSentResult( QgsLocatorResult result );
194
195 private:
196
197 QgsFeedback *mFeedback = nullptr;
198 std::unique_ptr< QgsFeedback > mOwnedFeedback;
199
200 QList< QgsLocatorFilter * > mFilters;
201 QList< QThread * > mActiveThreads;
202
203 QStringList mAutocompletionList;
204
205 void cancelRunningQuery();
206
207};
208
209#endif // QGSLOCATOR_H
210
211
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition qgsfeedback.h:45
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:62
static const QList< QString > CORE_FILTERS
List of core filters (i.e. not plugin filters)
Definition qgslocator.h:68
void searchPrepared()
Emitted when locator has prepared the search (.
static const QgsSettingsEntryBool * settingsLocatorFilterDefault
Settings entry locator filter default value.
Definition qgslocator.h:165
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:163
static const QgsSettingsEntryString * settingsLocatorFilterPrefix
Settings entry locator filter prefix.
Definition qgslocator.h:167
QStringList completionList() const
Returns the list for auto completion This list is updated when preparing the search.
Definition qgslocator.h:157
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