QGIS API Documentation  3.14.0-Pi (9f7028fd23)
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
crs
const QgsCoordinateReferenceSystem & crs
Definition: qgswfsgetfeature.cpp:105
QgsProjectionSelectionDialog
Definition: qgsprojectionselectiondialog.h:51
QgsProjectionSelectionWidget
A widget for selecting a projection.
Definition: qgsprojectionselectionwidget.h:38
SIP_SKIP
#define SIP_SKIP
Definition: qgis_sip.h:126
QgsProjectionSelectionWidget::ProjectCrs
@ ProjectCrs
Current project CRS (if OTF reprojection enabled)
Definition: qgsprojectionselectionwidget.h:49
QgsHighlightableComboBox
Definition: qgshighlightablecombobox.h:34
qgis_sip.h
QgsProjectionSelectionWidget::RecentCrs
@ RecentCrs
Recently used CRS.
Definition: qgsprojectionselectionwidget.h:52
QgsProjectionSelectionWidget::CrsNotSet
@ CrsNotSet
Not set (hidden by default)
Definition: qgsprojectionselectionwidget.h:53
QgsCoordinateReferenceSystem
Definition: qgscoordinatereferencesystem.h:206
QgsProjectionSelectionWidget::LayerCrs
@ LayerCrs
Optional layer CRS.
Definition: qgsprojectionselectionwidget.h:48
QgsProjectionSelectionWidget::DefaultCrs
@ DefaultCrs
Global default QGIS CRS.
Definition: qgsprojectionselectionwidget.h:51
QgsMapLayer
Definition: qgsmaplayer.h:81
QgsProjectionSelectionWidget::CrsOption
CrsOption
Predefined CRS options shown in widget.
Definition: qgsprojectionselectionwidget.h:46
SIP_TRANSFERTHIS
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
qgscoordinatereferencesystem.h
QgsProjectionSelectionWidget::CurrentCrs
@ CurrentCrs
Current user selected CRS.
Definition: qgsprojectionselectionwidget.h:50