QGIS API Documentation  3.0.2-Girona (307d082)
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 "qgis_core.h"
22 #include "qgis_sip.h"
23 #include "qgslocatorfilter.h"
24 #include "qgsfeedback.h"
25 #include "qgslocatorcontext.h"
26 #include <QObject>
27 #include <QFuture>
28 #include <QFutureWatcher>
29 #include <memory>
30 
54 class CORE_EXPORT QgsLocator : public QObject
55 {
56  Q_OBJECT
57 
58  public:
59 
63  QgsLocator( QObject *parent SIP_TRANSFERTHIS = nullptr );
64 
68  ~QgsLocator() override;
69 
77  void registerFilter( QgsLocatorFilter *filter SIP_TRANSFER );
78 
88  void deregisterFilter( QgsLocatorFilter *filter );
89 
94  QList< QgsLocatorFilter *> filters();
95 
101  QMap< QString, QgsLocatorFilter *> prefixedFilters() const;
102 
113  void fetchResults( const QString &string, const QgsLocatorContext &context, QgsFeedback *feedback = nullptr );
114 
120  void cancel();
121 
127  void cancelWithoutBlocking();
128 
132  bool isRunning() const;
133 
134  signals:
135 
140  void foundResult( const QgsLocatorResult &result );
141 
146  void finished();
147 
148  private slots:
149 
150  void filterSentResult( QgsLocatorResult result );
151 
152  private:
153 
154  QgsFeedback *mFeedback = nullptr;
155  std::unique_ptr< QgsFeedback > mOwnedFeedback;
156 
157  QList< QgsLocatorFilter * > mFilters;
158  QMap< QString, QgsLocatorFilter *> mPrefixedFilters;
159  QList< QThread * > mActiveThreads;
160 
161  void cancelRunningQuery();
162 
163 };
164 
165 #endif // QGSLOCATOR_H
166 
167 
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:46
Base class for feedback objects to be used for cancelation of something running in a worker thread...
Definition: qgsfeedback.h:44
#define SIP_TRANSFER
Definition: qgis_sip.h:36
Encapsulates the properties relating to the context of a locator search.
Encapsulates properties of an individual matching result found by a QgsLocatorFilter.
Abstract base class for filters which collect locator results.
Handles the management of QgsLocatorFilter objects and async collection of search results from them...
Definition: qgslocator.h:54