diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 6a6932338dc..1f0d941a139 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -118,6 +118,11 @@ qgsprojectionselector.h qgsrubberband.h qgsvertexmarker.h qgsmaptip.h + +${CMAKE_CURRENT_BINARY_DIR}/../ui/ui_qgsdetaileditemwidgetbase.h +${CMAKE_CURRENT_BINARY_DIR}/../ui/ui_qgsgenericprojectionselectorbase.h +${CMAKE_CURRENT_BINARY_DIR}/../ui/ui_qgsmessageviewer.h +${CMAKE_CURRENT_BINARY_DIR}/../ui/ui_qgsprojectionselectorbase.h ) diff --git a/src/gui/qgsgenericprojectionselector.cpp b/src/gui/qgsgenericprojectionselector.cpp index 3b3f614141e..da4f0e6da66 100644 --- a/src/gui/qgsgenericprojectionselector.cpp +++ b/src/gui/qgsgenericprojectionselector.cpp @@ -16,7 +16,7 @@ * * ***************************************************************************/ /* $Id$ */ -#include "qgsgenericprojectionselector.h" +#include #include /** diff --git a/src/gui/qgsgenericprojectionselector.h b/src/gui/qgsgenericprojectionselector.h index 9b5a6df1d50..304a207c758 100644 --- a/src/gui/qgsgenericprojectionselector.h +++ b/src/gui/qgsgenericprojectionselector.h @@ -18,8 +18,8 @@ /* $Id$ */ #ifndef QGSGENERICPROJECTIONSELECTOR_H #define QGSGENERICPROJECTIONSELECTOR_H -#include "ui_qgsgenericprojectionselectorbase.h" -#include "qgisgui.h" +#include +#include #include diff --git a/src/gui/qgsprojectionselector.cpp b/src/gui/qgsprojectionselector.cpp index 09a7826a81a..1fb089159a8 100644 --- a/src/gui/qgsprojectionselector.cpp +++ b/src/gui/qgsprojectionselector.cpp @@ -9,7 +9,7 @@ * (at your option) any later version. * ***************************************************************************/ /* $Id$ */ -#include "qgsprojectionselector.h" +#include //standard includes #include @@ -41,8 +41,8 @@ QgsProjectionSelector::QgsProjectionSelector( QWidget* parent, mProjListDone( FALSE ), mUserProjListDone( FALSE ), mCRSNameSelectionPending( FALSE ), - mCRSIDSelectionPending( FALSE ) - + mCRSIDSelectionPending( FALSE ), + mEPSGIDSelectionPending( FALSE ) { setupUi( this ); connect( lstCoordinateSystems, SIGNAL( currentItemChanged( QTreeWidgetItem*, QTreeWidgetItem* ) ), @@ -94,6 +94,10 @@ void QgsProjectionSelector::showEvent( QShowEvent * theEvent ) { applyCRSIDSelection(); } + if ( mEPSGIDSelectionPending ) + { + applyEPSGIDSelection(); + } // Pass up the inheritance heirarchy QWidget::showEvent( theEvent ); @@ -168,6 +172,7 @@ void QgsProjectionSelector::setSelectedCrsName( QString theCRSName ) mCRSNameSelection = theCRSName; mCRSNameSelectionPending = TRUE; mCRSIDSelectionPending = FALSE; // only one type can be pending at a time + mEPSGIDSelectionPending = TRUE; if ( isVisible() ) { @@ -184,6 +189,7 @@ void QgsProjectionSelector::setSelectedCrsId( long theCRSID ) mCRSIDSelection = theCRSID; mCRSIDSelectionPending = TRUE; mCRSNameSelectionPending = FALSE; // only one type can be pending at a time + mEPSGIDSelectionPending = FALSE; if ( isVisible() ) { @@ -196,7 +202,10 @@ void QgsProjectionSelector::setSelectedCrsId( long theCRSID ) void QgsProjectionSelector::setSelectedEpsg( long epsg ) { - //QgsSpatial + mEPSGIDSelection = epsg; + mCRSIDSelectionPending = FALSE; + mEPSGIDSelectionPending = TRUE; + mCRSNameSelectionPending = FALSE; // only one type can be pending at a time } void QgsProjectionSelector::applyCRSNameSelection() @@ -226,6 +235,33 @@ void QgsProjectionSelector::applyCRSNameSelection() } } +void QgsProjectionSelector::applyEPSGIDSelection() +{ + if ( + ( mEPSGIDSelectionPending ) && + ( mProjListDone ) && + ( mUserProjListDone ) + ) + { + //get the srid given the wkt so we can pick the correct list item + QgsDebugMsg( "called with " + QString::number( mEPSGIDSelection ) ); + QList nodes = lstCoordinateSystems->findItems( QString::number( mEPSGIDSelection ), Qt::MatchExactly | Qt::MatchRecursive, EPSG_COLUMN ); + + if ( nodes.count() > 0 ) + { + lstCoordinateSystems->setCurrentItem( nodes.first() ); + lstCoordinateSystems->scrollToItem( nodes.first() ); + } + else // unselect the selected item to avoid confusing the user + { + lstCoordinateSystems->clearSelection(); + teProjection->setText( "" ); + } + + mEPSGIDSelectionPending = FALSE; + } +} + void QgsProjectionSelector::applyCRSIDSelection() { if ( diff --git a/src/gui/qgsprojectionselector.h b/src/gui/qgsprojectionselector.h index b20a485a7c8..daa34f03153 100644 --- a/src/gui/qgsprojectionselector.h +++ b/src/gui/qgsprojectionselector.h @@ -11,7 +11,7 @@ #ifndef QGSCRSSELECTOR_H #define QGSCRSSELECTOR_H -#include "ui_qgsprojectionselectorbase.h" +#include #include @@ -151,10 +151,22 @@ class GUI_EXPORT QgsProjectionSelector: public QWidget, private Ui::QgsProjectio void applyCRSIDSelection(); /** - * \brief gets an arbitrary sqlite3 attribute of type "long" from the selection + * \brief does the legwork of applying the EPSG ID Selection * - * \param attributeName The sqlite3 column name, typically "srid" or "epsg" + * \warning This function does nothing unless getUserList() and getUserProjList() + * Have already been called + * + * \warning This function only expands the parents of the selection and + * does not scroll the list to the selection if the widget is not visible. + * Therefore you will typically want to use this in a showEvent(). */ + void applyEPSGIDSelection(); + + /** + * \brief gets an arbitrary sqlite3 attribute of type "long" from the selection + * + * \param attributeName The sqlite3 column name, typically "srid" or "epsg" + */ long getSelectedLongAttribute( QString attributeName ); /** Show the user a warning if the srs database could not be found */ @@ -189,12 +201,18 @@ class GUI_EXPORT QgsProjectionSelector: public QWidget, private Ui::QgsProjectio //! Is there a pending selection to be made by CRS ID? bool mCRSIDSelectionPending; + //! Is there a pending selection to be made by EPSG ID? + bool mEPSGIDSelectionPending; + //! The CRS Name that wants to be selected on this widget QString mCRSNameSelection; //! The CRS ID that wants to be selected on this widget long mCRSIDSelection; + //! The EPSG ID that wants to be selected on this widget + long mEPSGIDSelection; + //! The set of OGC WMS CRSs that want to be applied to this widget QSet mCrsFilter;