QGIS API Documentation  3.18.1-Zürich (202f1bf7e5)
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 
23 class QResizeEvent;
24 
39 class 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 
144  void pushProjectionToFront();
145 
146  signals:
147 
151  void crsSelected();
152 
157  void initialized();
158 
164 
170  void hasValidSelectionChanged( bool isValid );
171 
172  protected:
173  // Used to ensure the projection list view is actually populated
174  void showEvent( QShowEvent *event ) override;
175 
176  // Used to manage column sizes
177  void resizeEvent( QResizeEvent *event ) override;
178 
179  private:
180 
188  void loadUserCrsList( QSet<QString> *crsFilter = nullptr );
189 
197  void loadCrsList( QSet<QString> *crsFilter = nullptr );
198 
199 
200  void loadUnknownCrs( const QgsCoordinateReferenceSystem &crs );
201 
210  QString sqlSafeString( const QString &string ) const;
211 
223  QString ogcWmsCrsFilterAsSqlExpression( QSet<QString> *crsFilter );
224 
235  void applySelection( int column = QgsProjectionSelectionTreeWidget::None, QString value = QString() );
236 
242  QString getSelectedExpression( const QString &e ) const;
243 
244  QString selectedName();
245 
247  long selectedCrsId();
248 
250  void showDBMissingWarning( const QString &fileName );
251 
252  enum Roles
253  {
254  RoleDeprecated = Qt::UserRole,
255  RoleWkt,
256  RoleProj
257  };
258 
259  // List view nodes for the tree view of projections
261  QTreeWidgetItem *mUserProjList = nullptr;
263  QTreeWidgetItem *mGeoList = nullptr;
265  QTreeWidgetItem *mProjList = nullptr;
266 
267  QTreeWidgetItem *mUnknownList = nullptr;
268 
270  QString mCustomCsFile;
272  QString mSrsDatabaseFileName;
273 
277  long getLargestCrsIdMatch( const QString &sql );
278 
280  void insertRecent( const QgsCoordinateReferenceSystem &crs );
281 
283  bool mProjListDone = false;
284 
286  bool mUserProjListDone = false;
287 
289  bool mRecentProjListDone = false;
290 
291  enum Columns { NameColumn, AuthidColumn, QgisCrsIdColumn, None };
292  int mSearchColumn = QgsProjectionSelectionTreeWidget::None;
293  QString mSearchValue;
294 
295  bool mPushProjectionToFront = false;
296 
298  QSet<QString> mCrsFilter;
299 
301  QList< QgsCoordinateReferenceSystem > mRecentProjections;
302 
304  void hideDeprecated( QTreeWidgetItem *item );
305 
306  bool mShowMap = true;
307 
308  bool mInitialized = false;
309  QgsCoordinateReferenceSystem mDeferredLoadCrs;
310  bool mBlockSignals = false;
311 
312  private slots:
314  void updateBoundsPreview();
315  QStringList authorities();
316 
318  void lstCoordinateSystems_itemDoubleClicked( QTreeWidgetItem *current, int column );
319  void lstRecent_itemDoubleClicked( QTreeWidgetItem *current, int column );
320  void lstCoordinateSystems_currentItemChanged( QTreeWidgetItem *current, QTreeWidgetItem *prev );
321  void lstRecent_currentItemChanged( QTreeWidgetItem *current, QTreeWidgetItem *prev );
322  void updateFilter();
323 };
324 
325 #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_TRANSFERTHIS
Definition: qgis_sip.h:53
const QgsCoordinateReferenceSystem & crs