QGIS API Documentation  3.10.0-A Coruña (6c816b4204)
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  bool showBoundsMap() const;
88 
95  bool hasValidSelection() const;
96 
97  public slots:
98 
104  void setCrs( const QgsCoordinateReferenceSystem &crs );
105 
111  void setPreviewRect( const QgsRectangle &rect );
112 
118  QgsRectangle previewRect() const;
119 
132  void setOgcWmsCrsFilter( const QSet<QString> &crsFilter );
133 
137  void pushProjectionToFront();
138 
139  signals:
140 
144  void crsSelected();
145 
150  void initialized();
151 
156  void projectionDoubleClicked();
157 
158  protected:
159  // Used to ensure the projection list view is actually populated
160  void showEvent( QShowEvent *event ) override;
161 
162  // Used to manage column sizes
163  void resizeEvent( QResizeEvent *event ) override;
164 
165  private:
166 
174  void loadUserCrsList( QSet<QString> *crsFilter = nullptr );
175 
183  void loadCrsList( QSet<QString> *crsFilter = nullptr );
184 
193  QString sqlSafeString( const QString &string ) const;
194 
206  QString ogcWmsCrsFilterAsSqlExpression( QSet<QString> *crsFilter );
207 
218  void applySelection( int column = QgsProjectionSelectionTreeWidget::None, QString value = QString() );
219 
225  QString getSelectedExpression( const QString &e ) const;
226 
227  QString selectedName();
228 
229  QString selectedProj4String();
230 
231  QString selectedWktString();
232 
234  long selectedCrsId();
235 
237  void showDBMissingWarning( const QString &fileName );
238 
239  enum Roles
240  {
241  RoleDeprecated = Qt::UserRole,
242  };
243 
244  // List view nodes for the tree view of projections
246  QTreeWidgetItem *mUserProjList = nullptr;
248  QTreeWidgetItem *mGeoList = nullptr;
250  QTreeWidgetItem *mProjList = nullptr;
251 
253  QString mCustomCsFile;
255  QString mSrsDatabaseFileName;
256 
260  long getLargestCrsIdMatch( const QString &sql );
261 
263  void insertRecent( long crsId );
264 
266  bool mProjListDone = false;
267 
269  bool mUserProjListDone = false;
270 
271 
273  bool mRecentProjListDone = false;
274 
275  enum Columns { NameColumn, AuthidColumn, QgisCrsIdColumn, None };
276  int mSearchColumn = QgsProjectionSelectionTreeWidget::None;
277  QString mSearchValue;
278 
279  bool mPushProjectionToFront = false;
280 
282  QSet<QString> mCrsFilter;
283 
285  QStringList mRecentProjections;
286 
288  void hideDeprecated( QTreeWidgetItem *item );
289 
290  bool mShowMap = true;
291 
292  bool mInitialized = false;
293 
294  private slots:
296  void updateBoundsPreview();
297  QStringList authorities();
298 
300  void lstCoordinateSystems_itemDoubleClicked( QTreeWidgetItem *current, int column );
301  void lstRecent_itemDoubleClicked( QTreeWidgetItem *current, int column );
302  void lstCoordinateSystems_currentItemChanged( QTreeWidgetItem *current, QTreeWidgetItem *prev );
303  void lstRecent_currentItemChanged( QTreeWidgetItem *current, QTreeWidgetItem *prev );
304  void updateFilter();
305 };
306 
307 #endif
A rectangle specified with double values.
Definition: qgsrectangle.h:41
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
A widget for selecting a coordinate reference system from a tree.
const QgsCoordinateReferenceSystem & crs
This class represents a coordinate reference system (CRS).