QGIS API Documentation 3.40.0-Bratislava (b56115d8743)
Loading...
Searching...
No Matches
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
28class QItemSelection;
29
31class QgsLocator;
33class QgsLocatorModel;
35
36
43class CORE_EXPORT QgsLocatorModelBridge : public QObject
44{
45 Q_OBJECT
46 Q_PROPERTY( bool isRunning READ isRunning NOTIFY isRunningChanged )
47 public:
49 explicit QgsLocatorModelBridge( QObject *parent = nullptr );
50 virtual ~QgsLocatorModelBridge() = default;
51
53 Q_INVOKABLE void performSearch( const QString &text );
54
56 QgsLocator *locator() const;
57
59 Q_INVOKABLE QgsLocatorProxyModel *proxyModel() const;
60
62 bool hasQueueRequested() const;
63
65 bool isRunning() const;
66
68 void triggerResult( const QModelIndex &index, const int actionId = -1 );
69
77 QgsCoordinateTransformContext transformContext() const { return mTransformContext; }
78
86 void setTransformContext( const QgsCoordinateTransformContext &context ) { mTransformContext = context; }
87
88 signals:
91
94
97
98 public slots:
100 void invalidateResults();
101
103 void updateCanvasExtent( const QgsRectangle &extent );
104
106 void updateCanvasCrs( const QgsCoordinateReferenceSystem &crs );
107
112 void selectionChanged( const QItemSelection &selected, const QItemSelection &deselected );
113
114 private slots:
115 void searchFinished();
116 void addResult( const QgsLocatorResult &result );
117
118 private:
119 QgsLocatorContext createContext();
120 void setIsRunning( bool isRunning );
121
122 QgsLocator *mLocator = nullptr;
123 QgsLocatorModel *mLocatorModel = nullptr;
124 QgsLocatorProxyModel *mProxyModel = nullptr;
125
126 QString mNextRequestedString;
127 bool mHasQueuedRequest = false;
128 bool mIsRunning = false;
129
130 // keep track of map canvas extent and CRS
131 // if much if needed, it would be possible to add
132 // a QgsMapCanvasController in core to achieve this
133 // see discussion in https://github.com/qgis/QGIS/pull/8404
134 QgsRectangle mCanvasExtent;
136 QgsCoordinateTransformContext mTransformContext;
137};
138
139#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:61
A rectangle specified with double values.
const QgsCoordinateReferenceSystem & crs