Skip to content

Commit

Permalink
Small fixes to QgsProjectionSelectionWidget
Browse files Browse the repository at this point in the history
Add API docs, const correctness, method for getting CRS, tab order
fixes.
  • Loading branch information
nyalldawson committed Jan 5, 2015
1 parent 077eb6c commit 7933847
Show file tree
Hide file tree
Showing 4 changed files with 183 additions and 372 deletions.
23 changes: 22 additions & 1 deletion python/gui/qgsprojectionselectionwidget.sip
@@ -1,17 +1,38 @@

/**
* \class QgsProjectionSelectionWidget
* \ingroup gui
* \brief A widget for selecting a projection.
* \note added in QGIS 2.7
*/
class QgsProjectionSelectionWidget : QWidget
{
%TypeHeaderCode
#include <qgsprojectionselectionwidget.h>
%End

public:

explicit QgsProjectionSelectionWidget( QWidget *parent /TransferThis/ = 0 );

/* Returns the currently selected CRS for the widget
* @returns current CRS
*/
QgsCoordinateReferenceSystem crs() const;

signals:

/* Emitted when the selected CRS is changed
*/
void crsChanged( QgsCoordinateReferenceSystem );

public slots:

/* Sets the current CRS for the widget
* @param crs new CRS
*/
void setCrs( QgsCoordinateReferenceSystem crs );

/* Opens the dialog for selecting a new CRS
*/
void selectCrs();
};
8 changes: 5 additions & 3 deletions src/gui/qgsprojectionselectionwidget.cpp
Expand Up @@ -23,20 +23,22 @@
QgsProjectionSelectionWidget::QgsProjectionSelectionWidget( QWidget *parent ) :
QWidget( parent )
{

QHBoxLayout* layout = new QHBoxLayout();
layout->setContentsMargins( 0, 0, 0, 0 );
layout->setSpacing( 0 );
setLayout( layout );

mCrsLineEdit = new QLineEdit( tr( "invalid projection" ), this );
mCrsLineEdit->setReadOnly(true);
mCrsLineEdit->setReadOnly( true );
layout->addWidget( mCrsLineEdit );

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

setFocusPolicy( Qt::StrongFocus );
setFocusProxy( mButton );

connect( mButton, SIGNAL( clicked() ), this, SLOT( selectCrs() ) );
}

Expand Down Expand Up @@ -64,7 +66,7 @@ void QgsProjectionSelectionWidget::selectCrs()
}


void QgsProjectionSelectionWidget::setCrs( QgsCoordinateReferenceSystem crs )
void QgsProjectionSelectionWidget::setCrs( const QgsCoordinateReferenceSystem& crs )
{
if ( crs.isValid() )
{
Expand Down
23 changes: 22 additions & 1 deletion src/gui/qgsprojectionselectionwidget.h
Expand Up @@ -23,17 +23,38 @@

#include "qgscoordinatereferencesystem.h"

/**
* \class QgsProjectionSelectionWidget
* \ingroup gui
* \brief A widget for selecting a projection.
* \note added in QGIS 2.7
*/
class GUI_EXPORT QgsProjectionSelectionWidget : public QWidget
{
Q_OBJECT
public:
explicit QgsProjectionSelectionWidget( QWidget *parent = 0 );

/* Returns the currently selected CRS for the widget
* @returns current CRS
*/
QgsCoordinateReferenceSystem crs() const { return mCrs; }

signals:

/* Emitted when the selected CRS is changed
*/
void crsChanged( QgsCoordinateReferenceSystem );

public slots:
void setCrs( QgsCoordinateReferenceSystem crs );

/* Sets the current CRS for the widget
* @param crs new CRS
*/
void setCrs( const QgsCoordinateReferenceSystem& crs );

/* Opens the dialog for selecting a new CRS
*/
void selectCrs();

private:
Expand Down

0 comments on commit 7933847

Please sign in to comment.