1
+ /* **************************************************************************
2
+ qgsprojectionselectionwidget.cpp
3
+ --------------------------------------
4
+ Date : 05.01.2015
5
+ Copyright : (C) 2015 Denis Rouzaud
6
+ Email : denis.rouzaud@gmail.com
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
+ #include < QHBoxLayout>
17
+
18
+
19
+ #include " qgsprojectionselectionwidget.h"
20
+ #include " qgsapplication.h"
21
+ #include " qgsgenericprojectionselector.h"
22
+
23
+ QgsProjectionSelectionWidget::QgsProjectionSelectionWidget ( QWidget *parent ) :
24
+ QWidget( parent )
25
+ {
26
+
27
+ QHBoxLayout* layout = new QHBoxLayout ();
28
+ layout->setContentsMargins ( 0 , 0 , 0 , 0 );
29
+ layout->setSpacing ( 0 );
30
+ setLayout ( layout );
31
+
32
+ mCrsLineEdit = new QLineEdit ( tr ( " invalid projection" ), this );
33
+ mCrsLineEdit ->setReadOnly (true );
34
+ layout->addWidget ( mCrsLineEdit );
35
+
36
+ mButton = new QToolButton ( this );
37
+ mButton ->setIcon ( QgsApplication::getThemeIcon ( " mActionSetProjection.svg" ) );
38
+ layout->addWidget ( mButton );
39
+
40
+ connect ( mButton , SIGNAL ( clicked () ), this , SLOT ( selectCrs () ) );
41
+ }
42
+
43
+ void QgsProjectionSelectionWidget::selectCrs ()
44
+ {
45
+ QgsGenericProjectionSelector* mySelector = new QgsGenericProjectionSelector ( this );
46
+
47
+ // find out crs id of current proj4 string
48
+ if ( mCrs .isValid () )
49
+ {
50
+ mySelector->setSelectedCrsId ( mCrs .srsid () );
51
+ }
52
+
53
+ if ( mySelector->exec () )
54
+ {
55
+ QgsCoordinateReferenceSystem crs;
56
+ crs.createFromOgcWmsCrs ( mySelector->selectedAuthId () );
57
+ setCrs ( crs );
58
+ emit crsChanged ( crs );
59
+ }
60
+ else
61
+ {
62
+ QApplication::restoreOverrideCursor ();
Collapse comment Comment on line R62
@3nids this seems a little out of place - is it working around an oddity in QgsGenericProjectionSelector?
This used to be in the code in QgsOptions.
I can remove this.
Code has comments. Press enter to view.
63
+ }
64
+ }
65
+
66
+
67
+ void QgsProjectionSelectionWidget::setCrs ( QgsCoordinateReferenceSystem crs )
68
+ {
69
+ if ( crs.isValid () )
70
+ {
71
+ mCrsLineEdit ->setText ( crs.authid () + " - " + crs.description () );
72
+ }
73
+ else
74
+ {
75
+ mCrsLineEdit ->setText ( tr ( " invalid projection" ) );
76
+ }
77
+ mCrs = crs;
78
+ }
0 commit comments