QGIS API Documentation 3.43.0-Master (32433f7016e)
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 : denis@opengis.ch
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
42class 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
76 QgsCoordinateTransformContext transformContext() const { return mTransformContext; }
77
85 void setTransformContext( const QgsCoordinateTransformContext &context ) { mTransformContext = context; }
86
87 signals:
90
93
96
97 public slots:
99 void invalidateResults();
100
102 void updateCanvasExtent( const QgsRectangle &extent );
103
105 void updateCanvasCrs( const QgsCoordinateReferenceSystem &crs );
106
111 void selectionChanged( const QItemSelection &selected, const QItemSelection &deselected );
112
113 private slots:
114 void searchFinished();
115 void addResult( const QgsLocatorResult &result );
116
117 private:
118 QgsLocatorContext createContext();
119 void setIsRunning( bool isRunning );
120
121 QgsLocator *mLocator = nullptr;
122 QgsLocatorModel *mLocatorModel = nullptr;
123 QgsLocatorProxyModel *mProxyModel = nullptr;
124
125 QString mNextRequestedString;
126 bool mHasQueuedRequest = false;
127 bool mIsRunning = false;
128
129 // keep track of map canvas extent and CRS
130 // if much if needed, it would be possible to add
131 // a QgsMapCanvasController in core to achieve this
132 // see discussion in https://github.com/qgis/QGIS/pull/8404
133 QgsRectangle mCanvasExtent;
135 QgsCoordinateTransformContext mTransformContext;
136};
137
138#endif // QGSLOCATORMODELBRIDGE_H
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.
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