QGIS API Documentation  3.24.2-Tisler (13c1a02865)
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 
146  Q_DECL_DEPRECATED void pushProjectionToFront() SIP_DEPRECATED;
147 
148  signals:
149 
153  void crsSelected();
154 
159  void initialized();
160 
166 
172  void hasValidSelectionChanged( bool isValid );
173 
174  protected:
175  // Used to ensure the projection list view is actually populated
176  void showEvent( QShowEvent *event ) override;
177 
178  // Used to manage column sizes
179  void resizeEvent( QResizeEvent *event ) override;
180 
181  private:
182 
190  void loadUserCrsList( QSet<QString> *crsFilter = nullptr );
191 
199  void loadCrsList( QSet<QString> *crsFilter = nullptr );
200 
201 
202  void loadUnknownCrs( const QgsCoordinateReferenceSystem &crs );
203 
212  QString sqlSafeString( const QString &string ) const;
213 
225  QString ogcWmsCrsFilterAsSqlExpression( QSet<QString> *crsFilter );
226 
237  void applySelection( int column = QgsProjectionSelectionTreeWidget::None, QString value = QString() );
238 
244  QString getSelectedExpression( const QString &e ) const;
245 
246  QString selectedName();
247 
249  long selectedCrsId();
250 
252  void showDBMissingWarning( const QString &fileName );
253 
254  enum Roles
255  {
256  RoleDeprecated = Qt::UserRole,
257  RoleWkt,
258  RoleProj
259  };
260 
261  // List view nodes for the tree view of projections
263  QTreeWidgetItem *mUserProjList = nullptr;
265  QTreeWidgetItem *mGeoList = nullptr;
267  QTreeWidgetItem *mProjList = nullptr;
268 
269  QTreeWidgetItem *mUnknownList = nullptr;
270 
272  QString mCustomCsFile;
274  QString mSrsDatabaseFileName;
275 
279  long getLargestCrsIdMatch( const QString &sql );
280 
282  void insertRecent( const QgsCoordinateReferenceSystem &crs );
283 
285  bool mProjListDone = false;
286 
288  bool mUserProjListDone = false;
289 
291  bool mRecentProjListDone = false;
292 
293  enum Columns { NameColumn, AuthidColumn, QgisCrsIdColumn, None };
294  int mSearchColumn = QgsProjectionSelectionTreeWidget::None;
295  QString mSearchValue;
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_DEPRECATED
Definition: qgis_sip.h:106
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
const QgsCoordinateReferenceSystem & crs