QGIS API Documentation  3.0.2-Girona (307d082)
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  // List view nodes for the tree view of projections
240  QTreeWidgetItem *mUserProjList = nullptr;
242  QTreeWidgetItem *mGeoList = nullptr;
244  QTreeWidgetItem *mProjList = nullptr;
245 
247  QString mCustomCsFile;
249  QString mSrsDatabaseFileName;
250 
254  long getLargestCrsIdMatch( const QString &sql );
255 
257  void insertRecent( long crsId );
258 
260  bool mProjListDone = false;
261 
263  bool mUserProjListDone = false;
264 
265 
267  bool mRecentProjListDone = false;
268 
269  enum Columns { NameColumn, AuthidColumn, QgisCrsIdColumn, None };
270  int mSearchColumn = QgsProjectionSelectionTreeWidget::None;
271  QString mSearchValue;
272 
273  bool mPushProjectionToFront = false;
274 
276  QSet<QString> mCrsFilter;
277 
279  QStringList mRecentProjections;
280 
282  void hideDeprecated( QTreeWidgetItem *item );
283 
284  QgsRubberBand *mPreviewBand;
285  QgsRubberBand *mPreviewBand2;
286  QgsVertexMarker *mVertexMarker;
287 
288  bool mShowMap = true;
289 
290  QList<QgsMapLayer *> mLayers;
291 
292  QgsRectangle mPreviewRect;
293 
294 
295  private slots:
297  void updateBoundsPreview();
298  QStringList authorities();
299 
301  void lstCoordinateSystems_itemDoubleClicked( QTreeWidgetItem *current, int column );
302  void lstRecent_itemDoubleClicked( QTreeWidgetItem *current, int column );
303  void lstCoordinateSystems_currentItemChanged( QTreeWidgetItem *current, QTreeWidgetItem *prev );
304  void lstRecent_currentItemChanged( QTreeWidgetItem *current, QTreeWidgetItem *prev );
305  void cbxHideDeprecated_stateChanged();
306  void leSearch_textChanged( const QString & );
307 };
308 
309 #endif
A rectangle specified with double values.
Definition: qgsrectangle.h:39
#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).