QGIS API Documentation  3.14.0-Pi (9f7028fd23)
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 
185 
186  void loadUnknownCrs( const QgsCoordinateReferenceSystem &crs );
187 
196  QString sqlSafeString( const QString &string ) const;
197 
209  QString ogcWmsCrsFilterAsSqlExpression( QSet<QString> *crsFilter );
210 
221  void applySelection( int column = QgsProjectionSelectionTreeWidget::None, QString value = QString() );
222 
228  QString getSelectedExpression( const QString &e ) const;
229 
230  QString selectedName();
231 
233  long selectedCrsId();
234 
236  void showDBMissingWarning( const QString &fileName );
237 
238  enum Roles
239  {
240  RoleDeprecated = Qt::UserRole,
241  RoleWkt,
242  RoleProj
243  };
244 
245  // List view nodes for the tree view of projections
247  QTreeWidgetItem *mUserProjList = nullptr;
249  QTreeWidgetItem *mGeoList = nullptr;
251  QTreeWidgetItem *mProjList = nullptr;
252 
253  QTreeWidgetItem *mUnknownList = nullptr;
254 
256  QString mCustomCsFile;
258  QString mSrsDatabaseFileName;
259 
263  long getLargestCrsIdMatch( const QString &sql );
264 
266  void insertRecent( const QgsCoordinateReferenceSystem &crs );
267 
269  bool mProjListDone = false;
270 
272  bool mUserProjListDone = false;
273 
275  bool mRecentProjListDone = false;
276 
277  enum Columns { NameColumn, AuthidColumn, QgisCrsIdColumn, None };
278  int mSearchColumn = QgsProjectionSelectionTreeWidget::None;
279  QString mSearchValue;
280 
281  bool mPushProjectionToFront = false;
282 
284  QSet<QString> mCrsFilter;
285 
287  QList< QgsCoordinateReferenceSystem > mRecentProjections;
288 
290  void hideDeprecated( QTreeWidgetItem *item );
291 
292  bool mShowMap = true;
293 
294  bool mInitialized = false;
295  QgsCoordinateReferenceSystem mDeferredLoadCrs;
296  bool mBlockSignals = false;
297 
298  private slots:
300  void updateBoundsPreview();
301  QStringList authorities();
302 
304  void lstCoordinateSystems_itemDoubleClicked( QTreeWidgetItem *current, int column );
305  void lstRecent_itemDoubleClicked( QTreeWidgetItem *current, int column );
306  void lstCoordinateSystems_currentItemChanged( QTreeWidgetItem *current, QTreeWidgetItem *prev );
307  void lstRecent_currentItemChanged( QTreeWidgetItem *current, QTreeWidgetItem *prev );
308  void updateFilter();
309 };
310 
311 #endif
crs
const QgsCoordinateReferenceSystem & crs
Definition: qgswfsgetfeature.cpp:105
QgsRectangle
Definition: qgsrectangle.h:41
qgis_sip.h
QgsCoordinateReferenceSystem
Definition: qgscoordinatereferencesystem.h:206
QgsProjectionSelectionTreeWidget
Definition: qgsprojectionselectiontreewidget.h:39
SIP_TRANSFERTHIS
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
qgscoordinatereferencesystem.h