QGIS API Documentation  3.24.2-Tisler (13c1a02865)
qgsprojectionselectionwidget.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsprojectionselectionwidget.h
3  --------------------------------------
4  Date : 05.01.2015
5  Copyright : (C) 2015 Denis Rouzaud
6  Email : [email protected]
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 
17 #ifndef QGSPROJECTIONSELECTIONWIDGET_H
18 #define QGSPROJECTIONSELECTIONWIDGET_H
19 
20 #include <QWidget>
21 #include "qgis_sip.h"
22 #include <QLineEdit>
23 #include <QToolButton>
24 #include <QComboBox>
25 #include <QPointer>
26 
28 #include "qgis_gui.h"
29 
32 class QLabel;
33 
40 class GUI_EXPORT QgsProjectionSelectionWidget : public QWidget
41 {
42  Q_OBJECT
43  public:
44 
48  enum CrsOption
49  {
56  };
57 
59  explicit QgsProjectionSelectionWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr );
60 
66 
73  void setOptionVisible( CrsOption option, bool visible );
74 
80  bool optionVisible( CrsOption option ) const;
81 
87  void setNotSetText( const QString &text );
88 
95  void setMessage( const QString &text );
96 
103  static QString crsOptionText( const QgsCoordinateReferenceSystem &crs ) SIP_SKIP;
104 
112  bool showAccuracyWarnings() const;
113 
121  void setShowAccuracyWarnings( bool show );
122 
132  void setSourceEnsemble( const QString &ensemble );
133 
143  QString sourceEnsemble() const;
144 
150  void setDialogTitle( const QString &title );
151 
157  QString dialogTitle() const;
158 
159  signals:
160 
165 
170  void cleared();
171 
172  public slots:
173 
178  void setCrs( const QgsCoordinateReferenceSystem &crs );
179 
185  void setLayerCrs( const QgsCoordinateReferenceSystem &crs );
186 
190  void selectCrs();
191 
192  protected:
193 
194  void dragEnterEvent( QDragEnterEvent *event ) override;
195  void dragLeaveEvent( QDragLeaveEvent *event ) override;
196  void dropEvent( QDropEvent *event ) override;
197 
198  private:
199 
202  QgsCoordinateReferenceSystem mProjectCrs;
203  QgsCoordinateReferenceSystem mDefaultCrs;
204  QgsHighlightableComboBox *mCrsComboBox = nullptr;
205  QToolButton *mButton = nullptr;
206  QString mNotSetText;
207  QString mMessage;
208 
209  bool mShowAccuracyWarnings = false;
210  QString mSourceEnsemble;
211 
212  QWidget *mWarningLabelContainer = nullptr;
213  QLabel *mWarningLabel = nullptr;
214 
215  QPointer< QgsCrsSelectionWidget > mActivePanel;
216  int mIgnorePanelSignals = 0;
217 
218  QString mDialogTitle;
219 
220  void addNotSetOption();
221  void addProjectCrsOption();
222  void addDefaultCrsOption();
223  void addCurrentCrsOption();
224 
225  void addRecentCrs();
226  bool crsIsShown( long srsid ) const;
227 
228  int firstRecentCrsIndex() const;
229  void updateTooltip();
230 
231  QgsMapLayer *mapLayerFromMimeData( const QMimeData *data ) const;
232 
233  private slots:
234 
235  void comboIndexChanged( int idx );
236  void updateWarning();
237 
238 };
239 
240 #endif // QGSPROJECTIONSELECTIONWIDGET_H
This class represents a coordinate reference system (CRS).
A generic widget allowing users to pick a Coordinate Reference System (or define their own).
A QComboBox subclass with the ability to "highlight" the edges of the widget.
Base class for all map layer types.
Definition: qgsmaplayer.h:73
A widget for selecting a projection.
void cleared()
Emitted when the not set option is selected.
void crsChanged(const QgsCoordinateReferenceSystem &)
Emitted when the selected CRS is changed.
CrsOption
Predefined CRS options shown in widget.
@ CrsNotSet
Not set (hidden by default)
@ ProjectCrs
Current project CRS (if OTF reprojection enabled)
@ CurrentCrs
Current user selected CRS.
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
#define SIP_SKIP
Definition: qgis_sip.h:126
const QgsCoordinateReferenceSystem & crs