QGIS API Documentation  3.13.0-Master (740be229cb)
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 
38 class GUI_EXPORT QgsProjectionSelectionWidget : public QWidget
39 {
40  Q_OBJECT
41  public:
42 
46  enum CrsOption
47  {
54  };
55 
57  explicit QgsProjectionSelectionWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr );
58 
64 
71  void setOptionVisible( CrsOption option, bool visible );
72 
78  bool optionVisible( CrsOption option ) const;
79 
85  void setNotSetText( const QString &text );
86 
93  void setMessage( const QString &text );
94 
101  static QString crsOptionText( const QgsCoordinateReferenceSystem &crs ) SIP_SKIP;
102 
103  signals:
104 
108  void crsChanged( const QgsCoordinateReferenceSystem & );
109 
114  void cleared();
115 
116  public slots:
117 
122  void setCrs( const QgsCoordinateReferenceSystem &crs );
123 
129  void setLayerCrs( const QgsCoordinateReferenceSystem &crs );
130 
134  void selectCrs();
135 
136  protected:
137 
138  void dragEnterEvent( QDragEnterEvent *event ) override;
139  void dragLeaveEvent( QDragLeaveEvent *event ) override;
140  void dropEvent( QDropEvent *event ) override;
141 
142  private:
143 
146  QgsCoordinateReferenceSystem mProjectCrs;
147  QgsCoordinateReferenceSystem mDefaultCrs;
148  QgsHighlightableComboBox *mCrsComboBox = nullptr;
149  QToolButton *mButton = nullptr;
150  QgsProjectionSelectionDialog *mDialog = nullptr;
151  QString mNotSetText;
152  QString mMessage;
153 
154  void addNotSetOption();
155  void addProjectCrsOption();
156  void addDefaultCrsOption();
157  void addCurrentCrsOption();
158 
159  void addRecentCrs();
160  bool crsIsShown( long srsid ) const;
161 
162  int firstRecentCrsIndex() const;
163  void updateTooltip();
164 
165  QgsMapLayer *mapLayerFromMimeData( const QMimeData *data ) const;
166 
167  private slots:
168 
169  void comboIndexChanged( int idx );
170 
171 };
172 
173 #endif // QGSPROJECTIONSELECTIONWIDGET_H
Base class for all map layer types.
Definition: qgsmaplayer.h:80
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
Current project CRS (if OTF reprojection enabled)
const QgsCoordinateReferenceSystem & crs
A generic dialog to prompt the user for a Coordinate Reference System.
CrsOption
Predefined CRS options shown in widget.
#define SIP_SKIP
Definition: qgis_sip.h:126
A widget for selecting a projection.
This class represents a coordinate reference system (CRS).
A QComboBox subclass with the ability to "highlight" the edges of the widget.