-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dedicated class for projection selection widget
- Loading branch information
Showing
3 changed files
with
126 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/*************************************************************************** | ||
qgsprojectionselectionwidget.cpp | ||
-------------------------------------- | ||
Date : 05.01.2015 | ||
Copyright : (C) 2015 Denis Rouzaud | ||
Email : denis.rouzaud@gmail.com | ||
*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#include <QHBoxLayout> | ||
|
||
|
||
#include "qgsprojectionselectionwidget.h" | ||
#include "qgsapplication.h" | ||
#include "qgsgenericprojectionselector.h" | ||
|
||
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); | ||
layout->addWidget( mCrsLineEdit ); | ||
|
||
mButton = new QToolButton( this ); | ||
mButton->setIcon( QgsApplication::getThemeIcon( "mActionSetProjection.svg" ) ); | ||
layout->addWidget( mButton ); | ||
|
||
connect( mButton, SIGNAL( clicked() ), this, SLOT( selectCrs() ) ); | ||
} | ||
|
||
void QgsProjectionSelectionWidget::selectCrs() | ||
{ | ||
QgsGenericProjectionSelector* mySelector = new QgsGenericProjectionSelector( this ); | ||
|
||
//find out crs id of current proj4 string | ||
if ( mCrs.isValid() ) | ||
{ | ||
mySelector->setSelectedCrsId( mCrs.srsid() ); | ||
} | ||
|
||
if ( mySelector->exec() ) | ||
{ | ||
QgsCoordinateReferenceSystem crs; | ||
crs.createFromOgcWmsCrs( mySelector->selectedAuthId() ); | ||
setCrs( crs ); | ||
emit crsChanged( crs ); | ||
} | ||
else | ||
{ | ||
QApplication::restoreOverrideCursor(); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
} | ||
} | ||
|
||
|
||
void QgsProjectionSelectionWidget::setCrs( QgsCoordinateReferenceSystem crs ) | ||
{ | ||
if ( crs.isValid() ) | ||
{ | ||
mCrsLineEdit->setText( crs.authid() + " - " + crs.description() ); | ||
} | ||
else | ||
{ | ||
mCrsLineEdit->setText( tr( "invalid projection" ) ); | ||
} | ||
mCrs = crs; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/*************************************************************************** | ||
qgsprojectionselectionwidget.h | ||
-------------------------------------- | ||
Date : 05.01.2015 | ||
Copyright : (C) 2015 Denis Rouzaud | ||
Email : denis.rouzaud@gmail.com | ||
*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
|
||
#ifndef QGSPROJECTIONSELECTIONWIDGET_H | ||
#define QGSPROJECTIONSELECTIONWIDGET_H | ||
|
||
#include <QWidget> | ||
#include <QLineEdit> | ||
#include <QToolButton> | ||
|
||
#include "qgscoordinatereferencesystem.h" | ||
|
||
class GUI_EXPORT QgsProjectionSelectionWidget : public QWidget | ||
{ | ||
Q_OBJECT | ||
public: | ||
explicit QgsProjectionSelectionWidget( QWidget *parent = 0 ); | ||
|
||
signals: | ||
void crsChanged( QgsCoordinateReferenceSystem ); | ||
|
||
public slots: | ||
void setCrs( QgsCoordinateReferenceSystem crs ); | ||
void selectCrs(); | ||
|
||
private: | ||
QgsCoordinateReferenceSystem mCrs; | ||
QLineEdit* mCrsLineEdit; | ||
QToolButton* mButton; | ||
}; | ||
|
||
#endif // QGSPROJECTIONSELECTIONWIDGET_H |
@3nids this seems a little out of place - is it working around an oddity in QgsGenericProjectionSelector?