QGIS API Documentation  3.14.0-Pi (9f7028fd23)
qgslocatormodelbridge.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgslocatormodelbridge.h
3  ------------------
4  begin : November 2018
5  copyright : (C) 2018 by Denis Rouzaud
6  email : [email protected]
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 QGSLOCATORMODELBRIDGE_H
19 #define QGSLOCATORMODELBRIDGE_H
20 
21 #include <QObject>
22 
23 #include "qgis_core.h"
25 #include "qgsrectangle.h"
26 
27 class QAction;
28 
29 class QgsLocatorResult;
30 class QgsLocator;
31 class QgsLocatorContext;
32 class QgsLocatorModel;
34 
35 
42 class CORE_EXPORT QgsLocatorModelBridge : public QObject
43 {
44  Q_OBJECT
45  Q_PROPERTY( bool isRunning READ isRunning NOTIFY isRunningChanged )
46  public:
48  explicit QgsLocatorModelBridge( QObject *parent = nullptr );
49  virtual ~QgsLocatorModelBridge() = default;
50 
52  Q_INVOKABLE void performSearch( const QString &text );
53 
55  QgsLocator *locator() const;
56 
58  Q_INVOKABLE QgsLocatorProxyModel *proxyModel() const;
59 
61  bool hasQueueRequested() const;
62 
64  bool isRunning() const;
65 
67  void triggerResult( const QModelIndex &index, const int actionId = -1 );
68 
69  signals:
71  void resultAdded();
72 
74  void isRunningChanged();
75 
77  void resultsCleared();
78 
79  public slots:
81  void invalidateResults();
82 
84  void updateCanvasExtent( const QgsRectangle &extent );
85 
87  void updateCanvasCrs( const QgsCoordinateReferenceSystem &crs );
88 
89  private slots:
90  void searchFinished();
91  void addResult( const QgsLocatorResult &result );
92 
93  private:
94  QgsLocatorContext createContext();
95  void setIsRunning( bool isRunning );
96 
97  QgsLocator *mLocator = nullptr;
98  QgsLocatorModel *mLocatorModel = nullptr;
99  QgsLocatorProxyModel *mProxyModel = nullptr;
100 
101  QString mNextRequestedString;
102  bool mHasQueuedRequest = false;
103  bool mIsRunning = false;
104 
105  // keep track of map canvas extent and CRS
106  // if much if needed, it would be possible to add
107  // a QgsMapCanvasController in core to achieve this
108  // see discussion in https://github.com/qgis/QGIS/pull/8404
109  QgsRectangle mCanvasExtent;
110  QgsCoordinateReferenceSystem mCanvasCrs;
111 };
112 
113 #endif // QGSLOCATORMODELBRIDGE_H
QgsLocator
Definition: qgslocator.h:57
qgsrectangle.h
crs
const QgsCoordinateReferenceSystem & crs
Definition: qgswfsgetfeature.cpp:105
QgsRectangle
Definition: qgsrectangle.h:41
QgsLocatorResult
Definition: qgslocatorfilter.h:39
QgsLocatorModel
Definition: qgslocatormodel.h:42
QgsLocatorContext
Definition: qgslocatorcontext.h:31
QgsLocatorModelBridge
Definition: qgslocatormodelbridge.h:42
QgsCoordinateReferenceSystem
Definition: qgscoordinatereferencesystem.h:206
QgsLocatorProxyModel
Definition: qgslocatormodel.h:191
qgscoordinatereferencesystem.h