QGIS API Documentation  3.2.0-Bonn (bc43194)
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.h"
20 #include "qgis_gui.h"
22 
23 
24 class QgsVertexMarker;
25 class QResizeEvent;
26 
41 class GUI_EXPORT QgsProjectionSelectionTreeWidget : public QWidget, private Ui::QgsProjectionSelectorBase
42 {
43  Q_OBJECT
44 
45  public:
46 
50  QgsProjectionSelectionTreeWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr );
51 
53 
59  QgsCoordinateReferenceSystem crs() const;
60 
67  void setShowNoProjection( bool show );
68 
74  void setShowBoundsMap( bool show );
75 
82  bool showNoProjection() const;
83 
89  bool showBoundsMap() const;
90 
97  bool hasValidSelection() const;
98 
99  public slots:
100 
106  void setCrs( const QgsCoordinateReferenceSystem &crs );
107 
113  void setPreviewRect( const QgsRectangle &rect );
114 
120  QgsRectangle previewRect() const;
121 
134  void setOgcWmsCrsFilter( const QSet<QString> &crsFilter );
135 
139  void pushProjectionToFront();
140 
141  signals:
142 
146  void crsSelected();
147 
152  void initialized();
153 
158  void projectionDoubleClicked();
159 
160  protected:
161  // Used to ensure the projection list view is actually populated
162  void showEvent( QShowEvent *event ) override;
163 
164  // Used to manage column sizes
165  void resizeEvent( QResizeEvent *event ) override;
166 
167  private:
168 
176  void loadUserCrsList( QSet<QString> *crsFilter = nullptr );
177 
185  void loadCrsList( QSet<QString> *crsFilter = nullptr );
186 
195  QString sqlSafeString( const QString &string ) const;
196 
208  QString ogcWmsCrsFilterAsSqlExpression( QSet<QString> *crsFilter );
209 
220  void applySelection( int column = QgsProjectionSelectionTreeWidget::None, QString value = QString() );
221 
227  QString getSelectedExpression( const QString &e ) const;
228 
229  QString selectedName();
230 
231  QString selectedProj4String();
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  QgsRubberBand *mPreviewBand;
291  QgsRubberBand *mPreviewBand2;
292  QgsVertexMarker *mVertexMarker;
293 
294  bool mShowMap = true;
295 
296  QList<QgsMapLayer *> mLayers;
297 
298  QgsRectangle mPreviewRect;
299 
300 
301  private slots:
303  void updateBoundsPreview();
304  QStringList authorities();
305 
307  void lstCoordinateSystems_itemDoubleClicked( QTreeWidgetItem *current, int column );
308  void lstRecent_itemDoubleClicked( QTreeWidgetItem *current, int column );
309  void lstCoordinateSystems_currentItemChanged( QTreeWidgetItem *current, QTreeWidgetItem *prev );
310  void lstRecent_currentItemChanged( QTreeWidgetItem *current, QTreeWidgetItem *prev );
311  void updateFilter();
312 };
313 
314 #endif
A rectangle specified with double values.
Definition: qgsrectangle.h:40
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:46
A widget for selecting a coordinate reference system from a tree.
A class for drawing transient features (e.g.
Definition: qgsrubberband.h:37
A class for marking vertices of features using e.g.
This class represents a coordinate reference system (CRS).