QGIS API Documentation 3.29.0-Master (19d7edcfed)
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
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"
26#include "qgsrectangle.h"
27
29class QgsLocator;
31class QgsLocatorModel;
33
34
41class CORE_EXPORT QgsLocatorModelBridge : public QObject
42{
43 Q_OBJECT
44 Q_PROPERTY( bool isRunning READ isRunning NOTIFY isRunningChanged )
45 public:
47 explicit QgsLocatorModelBridge( QObject *parent = nullptr );
48 virtual ~QgsLocatorModelBridge() = default;
49
51 Q_INVOKABLE void performSearch( const QString &text );
52
54 QgsLocator *locator() const;
55
57 Q_INVOKABLE QgsLocatorProxyModel *proxyModel() const;
58
60 bool hasQueueRequested() const;
61
63 bool isRunning() const;
64
66 void triggerResult( const QModelIndex &index, const int actionId = -1 );
67
75 QgsCoordinateTransformContext transformContext() const { return mTransformContext; }
76
84 void setTransformContext( const QgsCoordinateTransformContext &context ) { mTransformContext = context; }
85
86 signals:
89
92
95
96 public slots:
98 void invalidateResults();
99
101 void updateCanvasExtent( const QgsRectangle &extent );
102
104 void updateCanvasCrs( const QgsCoordinateReferenceSystem &crs );
105
106 private slots:
107 void searchFinished();
108 void addResult( const QgsLocatorResult &result );
109
110 private:
111 QgsLocatorContext createContext();
112 void setIsRunning( bool isRunning );
113
114 QgsLocator *mLocator = nullptr;
115 QgsLocatorModel *mLocatorModel = nullptr;
116 QgsLocatorProxyModel *mProxyModel = nullptr;
117
118 QString mNextRequestedString;
119 bool mHasQueuedRequest = false;
120 bool mIsRunning = false;
121
122 // keep track of map canvas extent and CRS
123 // if much if needed, it would be possible to add
124 // a QgsMapCanvasController in core to achieve this
125 // see discussion in https://github.com/qgis/QGIS/pull/8404
126 QgsRectangle mCanvasExtent;
128 QgsCoordinateTransformContext mTransformContext;
129};
130
131#endif // QGSLOCATORMODELBRIDGE_H
This class represents a coordinate reference system (CRS).
Contains information about the context in which a coordinate transform is executed.
Encapsulates the properties relating to the context of a locator search.
The QgsLocatorModelBridge class provides the core functionality to be used in a locator widget.
void isRunningChanged()
Emitted when the running status changes.
void resultAdded()
Emitted when a result is added.
void setTransformContext(const QgsCoordinateTransformContext &context)
Sets the coordinate transform context, which should be used whenever the locator constructs a coordin...
QgsCoordinateTransformContext transformContext() const
Returns the coordinate transform context, which should be used whenever the locator constructs a coor...
void resultsCleared()
Emitted when the results are cleared.
virtual ~QgsLocatorModelBridge()=default
An abstract list model for displaying the results of locator searches.
A sort proxy model for QgsLocatorModel, which automatically sorts results by precedence.
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:59
A rectangle specified with double values.
Definition: qgsrectangle.h:42
const QgsCoordinateReferenceSystem & crs