Skip to content

Commit 7933847

Browse files
committed
Small fixes to QgsProjectionSelectionWidget
Add API docs, const correctness, method for getting CRS, tab order fixes.
1 parent 077eb6c commit 7933847

File tree

4 files changed

+183
-372
lines changed

4 files changed

+183
-372
lines changed
Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,38 @@
1-
1+
/**
2+
* \class QgsProjectionSelectionWidget
3+
* \ingroup gui
4+
* \brief A widget for selecting a projection.
5+
* \note added in QGIS 2.7
6+
*/
27
class QgsProjectionSelectionWidget : QWidget
38
{
49
%TypeHeaderCode
510
#include <qgsprojectionselectionwidget.h>
611
%End
712

813
public:
14+
915
explicit QgsProjectionSelectionWidget( QWidget *parent /TransferThis/ = 0 );
1016

17+
/* Returns the currently selected CRS for the widget
18+
* @returns current CRS
19+
*/
20+
QgsCoordinateReferenceSystem crs() const;
21+
1122
signals:
23+
24+
/* Emitted when the selected CRS is changed
25+
*/
1226
void crsChanged( QgsCoordinateReferenceSystem );
1327

1428
public slots:
29+
30+
/* Sets the current CRS for the widget
31+
* @param crs new CRS
32+
*/
1533
void setCrs( QgsCoordinateReferenceSystem crs );
34+
35+
/* Opens the dialog for selecting a new CRS
36+
*/
1637
void selectCrs();
1738
};

src/gui/qgsprojectionselectionwidget.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,22 @@
2323
QgsProjectionSelectionWidget::QgsProjectionSelectionWidget( QWidget *parent ) :
2424
QWidget( parent )
2525
{
26-
2726
QHBoxLayout* layout = new QHBoxLayout();
2827
layout->setContentsMargins( 0, 0, 0, 0 );
2928
layout->setSpacing( 0 );
3029
setLayout( layout );
3130

3231
mCrsLineEdit = new QLineEdit( tr( "invalid projection" ), this );
33-
mCrsLineEdit->setReadOnly(true);
32+
mCrsLineEdit->setReadOnly( true );
3433
layout->addWidget( mCrsLineEdit );
3534

3635
mButton = new QToolButton( this );
3736
mButton->setIcon( QgsApplication::getThemeIcon( "mActionSetProjection.svg" ) );
3837
layout->addWidget( mButton );
3938

39+
setFocusPolicy( Qt::StrongFocus );
40+
setFocusProxy( mButton );
41+
4042
connect( mButton, SIGNAL( clicked() ), this, SLOT( selectCrs() ) );
4143
}
4244

@@ -64,7 +66,7 @@ void QgsProjectionSelectionWidget::selectCrs()
6466
}
6567

6668

67-
void QgsProjectionSelectionWidget::setCrs( QgsCoordinateReferenceSystem crs )
69+
void QgsProjectionSelectionWidget::setCrs( const QgsCoordinateReferenceSystem& crs )
6870
{
6971
if ( crs.isValid() )
7072
{

src/gui/qgsprojectionselectionwidget.h

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,38 @@
2323

2424
#include "qgscoordinatereferencesystem.h"
2525

26+
/**
27+
* \class QgsProjectionSelectionWidget
28+
* \ingroup gui
29+
* \brief A widget for selecting a projection.
30+
* \note added in QGIS 2.7
31+
*/
2632
class GUI_EXPORT QgsProjectionSelectionWidget : public QWidget
2733
{
2834
Q_OBJECT
2935
public:
3036
explicit QgsProjectionSelectionWidget( QWidget *parent = 0 );
3137

38+
/* Returns the currently selected CRS for the widget
39+
* @returns current CRS
40+
*/
41+
QgsCoordinateReferenceSystem crs() const { return mCrs; }
42+
3243
signals:
44+
45+
/* Emitted when the selected CRS is changed
46+
*/
3347
void crsChanged( QgsCoordinateReferenceSystem );
3448

3549
public slots:
36-
void setCrs( QgsCoordinateReferenceSystem crs );
50+
51+
/* Sets the current CRS for the widget
52+
* @param crs new CRS
53+
*/
54+
void setCrs( const QgsCoordinateReferenceSystem& crs );
55+
56+
/* Opens the dialog for selecting a new CRS
57+
*/
3758
void selectCrs();
3859

3960
private:

0 commit comments

Comments
 (0)