QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
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 
165  protected:
166  // Used to ensure the projection list view is actually populated
167  void showEvent( QShowEvent *event ) override;
168 
169  // Used to manage column sizes
170  void resizeEvent( QResizeEvent *event ) override;
171 
172  private:
173 
181  void loadUserCrsList( QSet<QString> *crsFilter = nullptr );
182 
190  void loadCrsList( QSet<QString> *crsFilter = nullptr );
191 
192 
193  void loadUnknownCrs( const QgsCoordinateReferenceSystem &crs );
194 
203  QString sqlSafeString( const QString &string ) const;
204 
216  QString ogcWmsCrsFilterAsSqlExpression( QSet<QString> *crsFilter );
217 
228  void applySelection( int column = QgsProjectionSelectionTreeWidget::None, QString value = QString() );
229 
235  QString getSelectedExpression( const QString &e ) const;
236 
237  QString selectedName();
238 
240  long selectedCrsId();
241 
243  void showDBMissingWarning( const QString &fileName );
244 
245  enum Roles
246  {
247  RoleDeprecated = Qt::UserRole,
248  RoleWkt,
249  RoleProj
250  };
251 
252  // List view nodes for the tree view of projections
254  QTreeWidgetItem *mUserProjList = nullptr;
256  QTreeWidgetItem *mGeoList = nullptr;
258  QTreeWidgetItem *mProjList = nullptr;
259 
260  QTreeWidgetItem *mUnknownList = nullptr;
261 
263  QString mCustomCsFile;
265  QString mSrsDatabaseFileName;
266 
270  long getLargestCrsIdMatch( const QString &sql );
271 
273  void insertRecent( const QgsCoordinateReferenceSystem &crs );
274 
276  bool mProjListDone = false;
277 
279  bool mUserProjListDone = false;
280 
282  bool mRecentProjListDone = false;
283 
284  enum Columns { NameColumn, AuthidColumn, QgisCrsIdColumn, None };
285  int mSearchColumn = QgsProjectionSelectionTreeWidget::None;
286  QString mSearchValue;
287 
288  bool mPushProjectionToFront = false;
289 
291  QSet<QString> mCrsFilter;
292 
294  QList< QgsCoordinateReferenceSystem > mRecentProjections;
295 
297  void hideDeprecated( QTreeWidgetItem *item );
298 
299  bool mShowMap = true;
300 
301  bool mInitialized = false;
302  QgsCoordinateReferenceSystem mDeferredLoadCrs;
303  bool mBlockSignals = false;
304 
305  private slots:
307  void updateBoundsPreview();
308  QStringList authorities();
309 
311  void lstCoordinateSystems_itemDoubleClicked( QTreeWidgetItem *current, int column );
312  void lstRecent_itemDoubleClicked( QTreeWidgetItem *current, int column );
313  void lstCoordinateSystems_currentItemChanged( QTreeWidgetItem *current, QTreeWidgetItem *prev );
314  void lstRecent_currentItemChanged( QTreeWidgetItem *current, QTreeWidgetItem *prev );
315  void updateFilter();
316 };
317 
318 #endif
QgsProjectionSelectionTreeWidget::projectionDoubleClicked
void projectionDoubleClicked()
Emitted when a projection is double clicked in the list.
crs
const QgsCoordinateReferenceSystem & crs
Definition: qgswfsgetfeature.cpp:51
QgsRectangle
A rectangle specified with double values.
Definition: qgsrectangle.h:42
QgsProjectionSelectionTreeWidget::crsSelected
void crsSelected()
Emitted when a projection is selected in the widget.
qgis_sip.h
QgsCoordinateReferenceSystem
This class represents a coordinate reference system (CRS).
Definition: qgscoordinatereferencesystem.h:206
QgsProjectionSelectionTreeWidget
A widget for selecting a coordinate reference system from a tree.
Definition: qgsprojectionselectiontreewidget.h:40
QgsProjectionSelectionTreeWidget::initialized
void initialized()
Notifies others that the widget is now fully initialized, including deferred selection of projection.
SIP_TRANSFERTHIS
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
qgscoordinatereferencesystem.h