QGIS API Documentation 3.32.0-Lima (311a8cb8a6)
qgsprojectionselectiontreewidget.h
Go to the documentation of this file.
1/***************************************************************************
2 * qgsprojectionselector.h *
3 * Copyright (C) 2005 by Tim Sutton *
5 * *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
10 ***************************************************************************/
11#ifndef QGSCRSSELECTOR_H
12#define QGSCRSSELECTOR_H
13
14#include "ui_qgsprojectionselectorbase.h"
15
16#include <QSet>
17#include <QStringList>
18
19#include "qgis_sip.h"
20#include "qgis_gui.h"
22
23class QResizeEvent;
24
39class GUI_EXPORT QgsProjectionSelectionTreeWidget : public QWidget, private Ui::QgsProjectionSelectorBase
40{
41 Q_OBJECT
42
43 public:
44
48 QgsProjectionSelectionTreeWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr );
49
51
58
65 void setShowNoProjection( bool show );
66
72 void setShowBoundsMap( bool show );
73
80 bool showNoProjection() const;
81
87 void setNotSetText( const QString &text );
88
94 bool showBoundsMap() const;
95
102 bool hasValidSelection() const;
103
104 public slots:
105
111 void setCrs( const QgsCoordinateReferenceSystem &crs );
112
118 void setPreviewRect( const QgsRectangle &rect );
119
125 QgsRectangle previewRect() const;
126
139 void setOgcWmsCrsFilter( const QSet<QString> &crsFilter );
140
146 Q_DECL_DEPRECATED void pushProjectionToFront() SIP_DEPRECATED;
147
148
154 void clearRecentCrs();
155
156 signals:
157
162
168
174
180 void hasValidSelectionChanged( bool isValid );
181
182 protected:
183 // Used to ensure the projection list view is actually populated
184 void showEvent( QShowEvent *event ) override;
185
186 // Used to manage column sizes
187 void resizeEvent( QResizeEvent *event ) override;
188
189 // Used to catch key presses on the recent projections list
190 bool eventFilter( QObject *obj, QEvent *ev ) override;
191
192 private:
193
201 void loadUserCrsList( QSet<QString> *crsFilter = nullptr );
202
210 void loadCrsList( QSet<QString> *crsFilter = nullptr );
211
212
213 void loadUnknownCrs( const QgsCoordinateReferenceSystem &crs );
214
223 QString sqlSafeString( const QString &string ) const;
224
236 QString ogcWmsCrsFilterAsSqlExpression( QSet<QString> *crsFilter );
237
248 void applySelection( int column = QgsProjectionSelectionTreeWidget::None, QString value = QString() );
249
251 QString expressionForItem( QTreeWidgetItem *item, const QString &expression ) const;
252
254 QgsCoordinateReferenceSystem crsForItem( QTreeWidgetItem *item ) const;
255
256 QString selectedName();
257
259 long selectedCrsId();
260
262 void showDBMissingWarning( const QString &fileName );
263
264 enum Roles
265 {
266 RoleDeprecated = Qt::UserRole,
267 RoleWkt,
268 RoleProj
269 };
270
271 // List view nodes for the tree view of projections
273 QTreeWidgetItem *mUserProjList = nullptr;
275 QTreeWidgetItem *mGeoList = nullptr;
277 QTreeWidgetItem *mProjList = nullptr;
278
279 QTreeWidgetItem *mUnknownList = nullptr;
280
282 QString mCustomCsFile;
284 QString mSrsDatabaseFileName;
285
289 long getLargestCrsIdMatch( const QString &sql );
290
292 void insertRecent( const QgsCoordinateReferenceSystem &crs );
293
295 bool mProjListDone = false;
296
298 bool mUserProjListDone = false;
299
301 bool mRecentProjListDone = false;
302
303 enum Columns { NameColumn, AuthidColumn, QgisCrsIdColumn, ClearColumn, None };
304 int mSearchColumn = QgsProjectionSelectionTreeWidget::None;
305 QString mSearchValue;
306
308 QSet<QString> mCrsFilter;
309
311 QList< QgsCoordinateReferenceSystem > mRecentProjections;
312
314 void hideDeprecated( QTreeWidgetItem *item );
315
316 bool mShowMap = true;
317
318 bool mInitialized = false;
319 QgsCoordinateReferenceSystem mDeferredLoadCrs;
320 bool mBlockSignals = false;
321
322 private slots:
324 void updateBoundsPreview();
325 QStringList authorities();
326
328 void lstCoordinateSystems_itemDoubleClicked( QTreeWidgetItem *current, int column );
329 void lstRecent_itemDoubleClicked( QTreeWidgetItem *current, int column );
330 void lstCoordinateSystems_currentItemChanged( QTreeWidgetItem *current, QTreeWidgetItem *prev );
331 void lstRecent_currentItemChanged( QTreeWidgetItem *current, QTreeWidgetItem *prev );
332 void updateFilter();
333
334 void removeRecentCrsItem( QTreeWidgetItem *item );
335};
336
337#endif
This class represents a coordinate reference system (CRS).
A widget for selecting a coordinate reference system from a tree.
void crsSelected()
Emitted when a projection is selected in the widget.
void projectionDoubleClicked()
Emitted when a projection is double clicked in the list.
void initialized()
Notifies others that the widget is now fully initialized, including deferred selection of projection.
void hasValidSelectionChanged(bool isValid)
Emitted when the selection in the tree is changed from a valid selection to an invalid selection,...
A rectangle specified with double values.
Definition: qgsrectangle.h:42
#define SIP_DEPRECATED
Definition: qgis_sip.h:106
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
const QgsCoordinateReferenceSystem & crs