QGIS API Documentation  2.99.0-Master (0a63d1f)
qgsprojectionselector.h
Go to the documentation of this file.
1 /***************************************************************************
2  * qgsprojectionselector.h *
3  * Copyright (C) 2005 by Tim Sutton *
4  * [email protected] *
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"
21 
22 class QResizeEvent;
23 
29 class GUI_EXPORT QgsProjectionSelector : public QWidget, private Ui::QgsProjectionSelectorBase
30 {
31  Q_OBJECT
32  public:
33  QgsProjectionSelector( QWidget* parent, const char *name = "", Qt::WindowFlags fl = 0 );
34 
36 
46  void loadUserCrsList( QSet<QString> *crsFilter = nullptr );
47 
57  void loadCrsList( QSet<QString> *crsFilter = nullptr );
58 
68  const QString sqlSafeString( const QString& theSQL );
69 
71  QString selectedAuthId();
72 
73  public slots:
74  void setSelectedCrsName( const QString& theCRSName );
75 
76  QString selectedName();
77 
78  void setSelectedCrsId( long theCRSID );
79 
80  void setSelectedAuthId( const QString& authId );
81 
82  QString selectedProj4String();
83 
85  long selectedPostgresSrId();
86 
88  long selectedCrsId();
89 
102  void setOgcWmsCrsFilter( const QSet<QString>& crsFilter );
103  void on_lstCoordinateSystems_currentItemChanged( QTreeWidgetItem *current, QTreeWidgetItem *prev );
104  void on_lstRecent_currentItemChanged( QTreeWidgetItem *current, QTreeWidgetItem *prev );
105  void on_cbxHideDeprecated_stateChanged();
106  void on_leSearch_textChanged( const QString & );
107 
109  void pushProjectionToFront();
110 
111  protected:
112  // Used to ensure the projection list view is actually populated
113  void showEvent( QShowEvent * theEvent ) override;
114 
115  // Used to manage column sizes
116  void resizeEvent( QResizeEvent * theEvent ) override;
117 
118  private:
119 
131  QString ogcWmsCrsFilterAsSqlExpression( QSet<QString> * crsFilter );
132 
143  void applySelection( int column = QgsProjectionSelector::None, QString value = QString::null );
144 
150  QString getSelectedExpression( const QString& e );
151 
153  void showDBMissingWarning( const QString& theFileName );
154  // List view nodes for the tree view of projections
156  QTreeWidgetItem *mUserProjList;
158  QTreeWidgetItem *mGeoList;
160  QTreeWidgetItem *mProjList;
161 
163  QString mCustomCsFile;
165  QString mSrsDatabaseFileName;
166 
170  long getLargestCrsIdMatch( const QString& theSql );
171 
173  void insertRecent( long theCrsId );
174 
176  bool mProjListDone;
177 
179  bool mUserProjListDone;
180 
181 
183  bool mRecentProjListDone;
184 
185  enum Columns { NameColumn, AuthidColumn, QgisCrsIdColumn, None };
186  int mSearchColumn;
187  QString mSearchValue;
188 
189  bool mPushProjectionToFront;
190 
192  QSet<QString> mCrsFilter;
193 
195  QStringList mRecentProjections;
196 
198  void hideDeprecated( QTreeWidgetItem *item );
199 
200  private slots:
202  QStringList authorities();
203 
205  void on_lstCoordinateSystems_itemDoubleClicked( QTreeWidgetItem *current, int column );
206  void on_lstRecent_itemDoubleClicked( QTreeWidgetItem *current, int column );
207 
208  signals:
209  void sridSelected( const QString& theSRID );
211  void refresh();
213  void searchBoxHasFocus( bool );
216  void initialized();
219  void projectionDoubleClicked();
220 };
221 
222 #endif
A widget for selecting a Coordinate reference system from a tree.