QGIS API Documentation  3.22.4-Białowieża (ce8e65e95e)
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 
27 #include "qgis_gui.h"
28 
31 class QLabel;
32 
39 class GUI_EXPORT QgsProjectionSelectionWidget : public QWidget
40 {
41  Q_OBJECT
42  public:
43 
47  enum CrsOption
48  {
55  };
56 
58  explicit QgsProjectionSelectionWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr );
59 
65 
72  void setOptionVisible( CrsOption option, bool visible );
73 
79  bool optionVisible( CrsOption option ) const;
80 
86  void setNotSetText( const QString &text );
87 
94  void setMessage( const QString &text );
95 
102  static QString crsOptionText( const QgsCoordinateReferenceSystem &crs ) SIP_SKIP;
103 
111  bool showAccuracyWarnings() const;
112 
120  void setShowAccuracyWarnings( bool show );
121 
131  void setSourceEnsemble( const QString &ensemble );
132 
142  QString sourceEnsemble() const;
143 
144  signals:
145 
150 
155  void cleared();
156 
157  public slots:
158 
163  void setCrs( const QgsCoordinateReferenceSystem &crs );
164 
170  void setLayerCrs( const QgsCoordinateReferenceSystem &crs );
171 
175  void selectCrs();
176 
177  protected:
178 
179  void dragEnterEvent( QDragEnterEvent *event ) override;
180  void dragLeaveEvent( QDragLeaveEvent *event ) override;
181  void dropEvent( QDropEvent *event ) override;
182 
183  private:
184 
187  QgsCoordinateReferenceSystem mProjectCrs;
188  QgsCoordinateReferenceSystem mDefaultCrs;
189  QgsHighlightableComboBox *mCrsComboBox = nullptr;
190  QToolButton *mButton = nullptr;
191  QgsProjectionSelectionDialog *mDialog = nullptr;
192  QString mNotSetText;
193  QString mMessage;
194 
195  bool mShowAccuracyWarnings = false;
196  QString mSourceEnsemble;
197 
198  QWidget *mWarningLabelContainer = nullptr;
199  QLabel *mWarningLabel = nullptr;
200 
201  void addNotSetOption();
202  void addProjectCrsOption();
203  void addDefaultCrsOption();
204  void addCurrentCrsOption();
205 
206  void addRecentCrs();
207  bool crsIsShown( long srsid ) const;
208 
209  int firstRecentCrsIndex() const;
210  void updateTooltip();
211 
212  QgsMapLayer *mapLayerFromMimeData( const QMimeData *data ) const;
213 
214  private slots:
215 
216  void comboIndexChanged( int idx );
217  void updateWarning();
218 
219 };
220 
221 #endif // QGSPROJECTIONSELECTIONWIDGET_H
This class represents a coordinate reference system (CRS).
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 generic dialog to prompt the user for a Coordinate Reference System.
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