diff --git a/python/gui/gui.sip b/python/gui/gui.sip index fac0dd745c8..18135978b1c 100644 --- a/python/gui/gui.sip +++ b/python/gui/gui.sip @@ -10,7 +10,7 @@ %Include qgisinterface.sip %Include qgsencodingfiledialog.sip -%Include qgslayerprojectionselector.sip +%Include qgsgenericprojectionselector.sip %Include qgsmapcanvas.sip %Include qgsmapcanvasitem.sip %Include qgsmapcanvasmap.sip diff --git a/python/gui/qgslayerprojectionselector.sip b/python/gui/qgsgenericprojectionselector.sip similarity index 60% rename from python/gui/qgslayerprojectionselector.sip rename to python/gui/qgsgenericprojectionselector.sip index 3d4ea01efe7..8d72e1a4caf 100644 --- a/python/gui/qgslayerprojectionselector.sip +++ b/python/gui/qgsgenericprojectionselector.sip @@ -1,32 +1,37 @@ /** - * \class QgsLayerProjectionSelector - * \brief Set Projection system for a layer + * \class QgsGenericProjectionSelector + * \brief A generic dialog to prompt the user for a Coordinate Reference System */ - -class QgsLayerProjectionSelector : QDialog //, private Ui::QgsLayerProjectionSelectorBase +class QgsGenericProjectionSelector : QDialog //, private Ui::QgsGenericProjectionSelectorBase { %TypeHeaderCode -#include +#include %End public: /** * Constructor */ - QgsLayerProjectionSelector(QWidget *parent = 0, + QgsGenericProjectionSelector(QWidget *parent = 0, Qt::WFlags fl = QgisGui::ModalDialogFlags); //! Destructor - ~QgsLayerProjectionSelector(); + ~QgsGenericProjectionSelector(); public slots: - QString getCurrentProj4String(); - long getCurrentSRSID(); - long getCurrentEpsg(); + /** If no paramter is passed, the message will be a generic + * 'define the CRS for this layer'. + */ + void setMessage(QString theMessage=""); + + QString getSelectedProj4String(); + long getSelectedSRSID(); + long getSelectedEpsg(); void setSelectedSRSName(QString theName); void setSelectedSRSID(long theID); + void setSelectedEpsg(long theID); /** * \brief filters this dialog by the given CRSs diff --git a/python/gui/qgsprojectionselector.sip b/python/gui/qgsprojectionselector.sip index dc2503d933a..ddc7305b4db 100644 --- a/python/gui/qgsprojectionselector.sip +++ b/python/gui/qgsprojectionselector.sip @@ -54,7 +54,7 @@ class QgsProjectionSelector: QWidget //, private Ui::QgsProjectionSelectorBase const QString stringSQLSafe(const QString theSQL); //! Gets the current EPSG-style projection identifier - long getCurrentEpsg(); + long getSelectedEpsg(); public slots: void setSelectedSRSName(QString theSRSName); @@ -62,14 +62,16 @@ class QgsProjectionSelector: QWidget //, private Ui::QgsProjectionSelectorBase QString getSelectedName(); void setSelectedSRSID(long theSRSID); + + void setSelectedEpsg(long epsg); - QString getCurrentProj4String(); + QString getSelectedProj4String(); //! Gets the current PostGIS-style projection identifier - long getCurrentSRID(); + long getSelectedSRID(); //! Gets the current QGIS projection identfier - long getCurrentSRSID(); + long getSelectedSRSID(); /** * \brief filters this widget by the given CRSs diff --git a/src/app/qgisapp.cpp b/src/app/qgisapp.cpp index 79876dc3108..ccda15d5be0 100644 --- a/src/app/qgisapp.cpp +++ b/src/app/qgisapp.cpp @@ -96,7 +96,7 @@ #include "qgsfeature.h" #include "qgsgeomtypedialog.h" #include "qgshelpviewer.h" -#include "qgslayerprojectionselector.h" +#include "qgsgenericprojectionselector.h" #include "qgslegend.h" #include "qgslegendlayerfile.h" #include "qgslegendlayer.h" @@ -264,7 +264,8 @@ static void customSrsValidation_(QgsSpatialRefSys* srs) //@note this class is not a descendent of QWidget so we cant pass //it in the ctor of the layer projection selector - QgsLayerProjectionSelector * mySelector = new QgsLayerProjectionSelector(); + QgsGenericProjectionSelector * mySelector = new QgsGenericProjectionSelector(); + mySelector->setMessage(); //shows a generic message proj4String = QgsProject::instance()->readEntry("SpatialRefSys","//ProjectSRSProj4String",GEOPROJ4); QgsSpatialRefSys defaultSRS; if(defaultSRS.createFromProj4(proj4String)) @@ -274,8 +275,8 @@ static void customSrsValidation_(QgsSpatialRefSys* srs) if(mySelector->exec()) { - QgsDebugMsg("Layer srs set from dialog: " + QString::number(mySelector->getCurrentSRSID())); - srs->createFromProj4(mySelector->getCurrentProj4String()); + QgsDebugMsg("Layer srs set from dialog: " + QString::number(mySelector->getSelectedSRSID())); + srs->createFromProj4(mySelector->getSelectedProj4String()); srs->debugPrint(); } else diff --git a/src/app/qgsoptions.cpp b/src/app/qgsoptions.cpp index a4ea3507820..a414eac1055 100644 --- a/src/app/qgsoptions.cpp +++ b/src/app/qgsoptions.cpp @@ -20,7 +20,7 @@ #include "qgsoptions.h" #include "qgis.h" #include "qgisapp.h" -#include "qgslayerprojectionselector.h" +#include "qgsgenericprojectionselector.h" #include "qgsspatialrefsys.h" #include @@ -365,7 +365,7 @@ void QgsOptions::saveOptions() void QgsOptions::on_pbnSelectProjection_clicked() { QSettings settings; - QgsLayerProjectionSelector * mySelector = new QgsLayerProjectionSelector(this); + QgsGenericProjectionSelector * mySelector = new QgsGenericProjectionSelector(this); //find out srs id of current proj4 string QgsSpatialRefSys refSys; @@ -380,7 +380,7 @@ void QgsOptions::on_pbnSelectProjection_clicked() std::cout << "------ Global Default Projection Selection Set ----------" << std::endl; #endif //! @todo changes this control name in gui to txtGlobalProjString - txtGlobalWKT->setText(mySelector->getCurrentProj4String()); + txtGlobalWKT->setText(mySelector->getSelectedProj4String()); #ifdef QGISDEBUG std::cout << "------ Global Default Projection now set to ----------\n" << mGlobalSRSID << std::endl; #endif diff --git a/src/app/qgsprojectproperties.cpp b/src/app/qgsprojectproperties.cpp index fc4c2280362..caf5d8a1501 100644 --- a/src/app/qgsprojectproperties.cpp +++ b/src/app/qgsprojectproperties.cpp @@ -245,15 +245,15 @@ void QgsProjectProperties::apply() // selected that has an srid. This prevents error if the user // selects a top-level node rather than an actual coordinate // system - long mySRSID = projectionSelector->getCurrentSRSID(); + long mySRSID = projectionSelector->getSelectedSRSID(); if (mySRSID) { QgsSpatialRefSys srs(mySRSID, QgsSpatialRefSys::QGIS_SRSID); myRender->setDestinationSrs(srs); // write the currently selected projections _proj string_ to project settings - std::cout << "SpatialRefSys/ProjectSRSProj4String: " << projectionSelector->getCurrentProj4String().toLocal8Bit().data() << std::endl; - QgsProject::instance()->writeEntry("SpatialRefSys","/ProjectSRSProj4String",projectionSelector->getCurrentProj4String()); + std::cout << "SpatialRefSys/ProjectSRSProj4String: " << projectionSelector->getSelectedProj4String().toLocal8Bit().data() << std::endl; + QgsProject::instance()->writeEntry("SpatialRefSys","/ProjectSRSProj4String",projectionSelector->getSelectedProj4String()); // Set the map units to the projected coordinates if we are projecting if (isProjected()) diff --git a/src/app/qgsrasterlayerproperties.cpp b/src/app/qgsrasterlayerproperties.cpp index 9b898fb7116..c9c0a04f50c 100644 --- a/src/app/qgsrasterlayerproperties.cpp +++ b/src/app/qgsrasterlayerproperties.cpp @@ -20,7 +20,7 @@ #include "qgisapp.h" #include "qgscoordinatetransform.h" #include "qgsrasterlayerproperties.h" -#include "qgslayerprojectionselector.h" +#include "qgsgenericprojectionselector.h" #include "qgsproject.h" #include "qgsrasterbandstats.h" #include "qgsrasterlayer.h" @@ -1704,11 +1704,11 @@ void QgsRasterLayerProperties::on_pbnAddValuesManually_clicked() void QgsRasterLayerProperties::on_pbnChangeSpatialRefSys_clicked() { - QgsLayerProjectionSelector * mySelector = new QgsLayerProjectionSelector(this); + QgsGenericProjectionSelector * mySelector = new QgsGenericProjectionSelector(this); mySelector->setSelectedSRSID(mRasterLayer->srs().srsid()); if(mySelector->exec()) { - QgsSpatialRefSys srs(mySelector->getCurrentSRSID(), QgsSpatialRefSys::QGIS_SRSID); + QgsSpatialRefSys srs(mySelector->getSelectedSRSID(), QgsSpatialRefSys::QGIS_SRSID); mRasterLayer->setSrs(srs); } else diff --git a/src/app/qgsserversourceselect.cpp b/src/app/qgsserversourceselect.cpp index 4ed8b4818bf..ba6a22cb691 100644 --- a/src/app/qgsserversourceselect.cpp +++ b/src/app/qgsserversourceselect.cpp @@ -18,7 +18,7 @@ #include "qgsserversourceselect.h" -#include "qgslayerprojectionselector.h" +#include "qgsgenericprojectionselector.h" #include "qgsnewhttpconnection.h" #include "qgsnumericsortlistviewitem.h" @@ -429,8 +429,9 @@ void QgsServerSourceSelect::on_btnChangeSpatialRefSys_clicked() QSet crsFilter = mWmsProvider->supportedCrsForLayers(m_selectedLayers); - QgsLayerProjectionSelector * mySelector = - new QgsLayerProjectionSelector(this); + QgsGenericProjectionSelector * mySelector = + new QgsGenericProjectionSelector(this); + mySelector->setMessage(); mySelector->setOgcWmsCrsFilter(crsFilter); @@ -443,7 +444,7 @@ void QgsServerSourceSelect::on_btnChangeSpatialRefSys_clicked() if (mySelector->exec()) { - m_Epsg = mySelector->getCurrentEpsg(); + m_Epsg = mySelector->getSelectedEpsg(); } else { @@ -451,7 +452,7 @@ void QgsServerSourceSelect::on_btnChangeSpatialRefSys_clicked() } labelCoordRefSys->setText( descriptionForEpsg(m_Epsg) ); -// labelCoordRefSys->setText( mySelector->getCurrentProj4String() ); +// labelCoordRefSys->setText( mySelector->getSelectedProj4String() ); delete mySelector; diff --git a/src/app/qgsvectorlayerproperties.cpp b/src/app/qgsvectorlayerproperties.cpp index 6b834aff995..60105ef2f53 100644 --- a/src/app/qgsvectorlayerproperties.cpp +++ b/src/app/qgsvectorlayerproperties.cpp @@ -27,7 +27,7 @@ #include "qgsgraduatedsymboldialog.h" #include "qgslabeldialog.h" #include "qgslabel.h" -#include "qgslayerprojectionselector.h" +#include "qgsgenericprojectionselector.h" #include "qgslogger.h" #include "qgsproject.h" #include "qgssinglesymboldialog.h" @@ -609,11 +609,12 @@ QString QgsVectorLayerProperties::getMetadata() void QgsVectorLayerProperties::on_pbnChangeSpatialRefSys_clicked() { - QgsLayerProjectionSelector * mySelector = new QgsLayerProjectionSelector(this); + QgsGenericProjectionSelector * mySelector = new QgsGenericProjectionSelector(this); + mySelector->setMessage(); mySelector->setSelectedSRSID(layer->srs().srsid()); if(mySelector->exec()) { - QgsSpatialRefSys srs(mySelector->getCurrentSRSID(), QgsSpatialRefSys::QGIS_SRSID); + QgsSpatialRefSys srs(mySelector->getSelectedSRSID(), QgsSpatialRefSys::QGIS_SRSID); layer->setSrs(srs); } else diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 4e4e872b5ca..d8bd0e0be59 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -9,7 +9,7 @@ qgsdetaileditemwidget.cpp qgsdetaileditemdata.cpp qgsencodingfiledialog.cpp qgsfiledropedit.cpp -qgslayerprojectionselector.cpp +qgsgenericprojectionselector.cpp qgsmapcanvas.cpp qgsmapcanvasitem.cpp qgsmapcanvasmap.cpp @@ -32,7 +32,7 @@ qgsdetaileditemdelegate.h qgsdetaileditemwidget.h qgisinterface.h qgsencodingfiledialog.h -qgslayerprojectionselector.h +qgsgenericprojectionselector.h qgsmapcanvas.h qgsmapoverviewcanvas.h qgsmaptoolemitpoint.h @@ -101,7 +101,7 @@ qgscolorbutton.h qgscursors.h qgsencodingfiledialog.h qgsfiledropedit.h -qgslayerprojectionselector.h +qgsgenericprojectionselector.h qgsmapcanvas.h qgsmapcanvasitem.h qgsmapcanvasmap.h diff --git a/src/gui/qgsgenericprojectionselector.cpp b/src/gui/qgsgenericprojectionselector.cpp new file mode 100644 index 00000000000..0fcec207ba8 --- /dev/null +++ b/src/gui/qgsgenericprojectionselector.cpp @@ -0,0 +1,101 @@ +/*************************************************************************** + qgsgenericprojectionselector.cpp + Set user defined CRS using projection selector widget + ------------------- + begin : May 28, 2004 + copyright : (C) 2004 by Gary E.Sherman + email : sherman at mrcc.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. * + * * + ***************************************************************************/ +/* $Id$ */ +#include "qgsgenericprojectionselector.h" +#include + +/** + * \class QgsGenericProjectionSelector + * \brief A generic dialog to prompt the user for a Coordinate Reference System + */ +QgsGenericProjectionSelector::QgsGenericProjectionSelector(QWidget *parent, + Qt::WFlags fl) + : QDialog(parent, fl) +{ + setupUi(this); + + + connect(pbnOK, SIGNAL(clicked()), this, SLOT( accept())); + //we will show this only when a message is set + textEdit->hide(); + QApplication::restoreOverrideCursor(); +} + +void QgsGenericProjectionSelector::setMessage(QString theMessage) +{ + //short term kludge to make the layer selector default to showing + //a layer projection selection message. If you want the selector + if (theMessage.isEmpty()) + { + // Set up text edit pane + QString format("

%1

%2 %3"); + QString header = tr("Define this layer's projection:"); + QString sentence1 = tr("This layer appears to have no projection specification."); + QString sentence2 = tr("By default, this layer will now have its projection set to that of the project" + ", but you may override this by selecting a different projection below."); + textEdit->setHtml(format.arg(header).arg(sentence1) + .arg(sentence2)); + } + else + { + textEdit->setHtml(theMessage); + } + textEdit->show(); + +} +//! Destructor +QgsGenericProjectionSelector::~QgsGenericProjectionSelector() +{} + +void QgsGenericProjectionSelector::setSelectedSRSName(QString theName) +{ + projectionSelector->setSelectedSRSName(theName); +} + +void QgsGenericProjectionSelector::setSelectedSRSID(long theID) +{ + projectionSelector->setSelectedSRSID(theID); +} + +void QgsGenericProjectionSelector::setSelectedEpsg(long theID) +{ + projectionSelector->setSelectedEpsg(theID); +} + +QString QgsGenericProjectionSelector::getSelectedProj4String() +{ + //@NOTE dont use getSelectedWKT as that just returns the name part! + return projectionSelector->getSelectedProj4String(); +} + +long QgsGenericProjectionSelector::getSelectedSRSID() +{ + //@NOTE dont use getSelectedWKT as that just returns the name part! + return projectionSelector->getSelectedSRSID(); +} + +long QgsGenericProjectionSelector::getSelectedEpsg() +{ + return projectionSelector->getSelectedEpsg(); +} + +void QgsGenericProjectionSelector::setOgcWmsCrsFilter(QSet crsFilter) +{ + projectionSelector->setOgcWmsCrsFilter(crsFilter); +} + diff --git a/src/gui/qgslayerprojectionselector.h b/src/gui/qgsgenericprojectionselector.h similarity index 69% rename from src/gui/qgslayerprojectionselector.h rename to src/gui/qgsgenericprojectionselector.h index c0749f2d537..711fb372376 100644 --- a/src/gui/qgslayerprojectionselector.h +++ b/src/gui/qgsgenericprojectionselector.h @@ -1,6 +1,6 @@ /*************************************************************************** - qgslayerprojectionselector.h - Set user layerprojectionselector and preferences + qgsgenericprojectionselector.h + Set user defined projection using projection selector widget ------------------- begin : May 28, 2004 copyright : (C) 2004 by Gary E.Sherman @@ -16,38 +16,43 @@ * * ***************************************************************************/ /* $Id$ */ -#ifndef QGSLAYERPROJECTIONSELECTOR_H -#define QGSLAYERPROJECTIONSELECTOR_H -#include "ui_qgslayerprojectionselectorbase.h" +#ifndef QGSGENERICPROJECTIONSELECTOR_H +#define QGSGENERICPROJECTIONSELECTOR_H +#include "ui_qgsgenericprojectionselectorbase.h" #include "qgisgui.h" #include /** - * \class QgsLayerProjectionSelector - * \brief Set Projection system for a layer + * \class QgsGenericProjectionSelector + * \brief A generic dialog to prompt the user for a Coordinate Reference System */ -class GUI_EXPORT QgsLayerProjectionSelector : public QDialog, private Ui::QgsLayerProjectionSelectorBase +class GUI_EXPORT QgsGenericProjectionSelector : public QDialog, private Ui::QgsGenericProjectionSelectorBase { Q_OBJECT; public: /** * Constructor */ - QgsLayerProjectionSelector(QWidget *parent = 0, + QgsGenericProjectionSelector(QWidget *parent = 0, Qt::WFlags fl = QgisGui::ModalDialogFlags); //! Destructor - ~QgsLayerProjectionSelector(); + ~QgsGenericProjectionSelector(); public slots: - QString getCurrentProj4String(); - long getCurrentSRSID(); - long getCurrentEpsg(); + /** If no paramter is passed, the message will be a generic + * 'define the CRS for this layer'. + */ + void setMessage(QString theMessage=""); + QString getSelectedProj4String(); + long getSelectedSRSID(); + long getSelectedEpsg(); void setSelectedSRSName(QString theName); void setSelectedSRSID(long theID); + void setSelectedEpsg(long theID); /** * \brief filters this dialog by the given CRSs diff --git a/src/gui/qgslayerprojectionselector.cpp b/src/gui/qgslayerprojectionselector.cpp deleted file mode 100644 index 0dfd5d83f3d..00000000000 --- a/src/gui/qgslayerprojectionselector.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/*************************************************************************** - qgslayerprojectionselector.cpp - Set user layerprojectionselector and preferences - ------------------- - begin : May 28, 2004 - copyright : (C) 2004 by Gary E.Sherman - email : sherman at mrcc.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. * - * * - ***************************************************************************/ -/* $Id$ */ -#include "qgslayerprojectionselector.h" -#include - -/** - * \class QgsLayerProjectionSelector - Set user layerprojectionselector and preferences - * Constructor - */ -QgsLayerProjectionSelector::QgsLayerProjectionSelector(QWidget *parent, - Qt::WFlags fl) - : QDialog(parent, fl) -{ - setupUi(this); - - // Set up text edit pane - QString format("

%1

%2 %3"); - QString header = tr("Define this layer's projection:"); - QString sentence1 = tr("This layer appears to have no projection specification."); - QString sentence2 = tr("By default, this layer will now have its projection set to that of the project" - ", but you may override this by selecting a different projection below."); - textEdit->setHtml(format.arg(header).arg(sentence1) - .arg(sentence2)); - - connect(pbnOK, SIGNAL(clicked()), this, SLOT( accept())); - - QApplication::restoreOverrideCursor(); -} - -//! Destructor -QgsLayerProjectionSelector::~QgsLayerProjectionSelector() -{} - -void QgsLayerProjectionSelector::setSelectedSRSName(QString theName) -{ - projectionSelector->setSelectedSRSName(theName); -} - -void QgsLayerProjectionSelector::setSelectedSRSID(long theID) -{ - projectionSelector->setSelectedSRSID(theID); -} - -QString QgsLayerProjectionSelector::getCurrentProj4String() -{ - //@NOTE dont use getSelectedWKT as that just returns the name part! - return projectionSelector->getCurrentProj4String(); -} - -long QgsLayerProjectionSelector::getCurrentSRSID() -{ - //@NOTE dont use getSelectedWKT as that just returns the name part! - return projectionSelector->getCurrentSRSID(); -} - -long QgsLayerProjectionSelector::getCurrentEpsg() -{ - return projectionSelector->getCurrentEpsg(); -} - -void QgsLayerProjectionSelector::setOgcWmsCrsFilter(QSet crsFilter) -{ - projectionSelector->setOgcWmsCrsFilter(crsFilter); -} - diff --git a/src/gui/qgsprojectionselector.cpp b/src/gui/qgsprojectionselector.cpp index 398e3c02b91..0ac98d4986d 100644 --- a/src/gui/qgsprojectionselector.cpp +++ b/src/gui/qgsprojectionselector.cpp @@ -20,6 +20,7 @@ #include "qgis.h" //magick numbers here #include "qgsapplication.h" #include "qgslogger.h" +#include //qt includes #include @@ -193,6 +194,10 @@ void QgsProjectionSelector::setSelectedSRSID(long theSRSID) // selection there } +void QgsProjectionSelector::setSelectedEpsg(long epsg) +{ + //QgsSpatial +} void QgsProjectionSelector::applySRSNameSelection() { @@ -264,7 +269,7 @@ QString QgsProjectionSelector::getSelectedName() } } // Returns the whole proj4 string for the selected projection node -QString QgsProjectionSelector::getCurrentProj4String() +QString QgsProjectionSelector::getSelectedProj4String() { // Only return the projection if there is a node in the tree // selected that has an srid. This prevents error if the user @@ -356,7 +361,7 @@ QString QgsProjectionSelector::getCurrentProj4String() } -long QgsProjectionSelector::getCurrentLongAttribute(QString attributeName) +long QgsProjectionSelector::getSelectedLongAttribute(QString attributeName) { // Only return the attribute if there is a node in the tree // selected that has an srs_id. This prevents error if the user @@ -382,7 +387,7 @@ long QgsProjectionSelector::getCurrentLongAttribute(QString attributeName) myFileInfo.setFile(myDatabaseFileName); if ( !myFileInfo.exists( ) ) { - std::cout << " QgsSpatialRefSys::createFromSrid failed : users qgis.db not found" << std::endl; + std::cout << " Projection selector : users qgis.db not found" << std::endl; return 0; } } @@ -416,14 +421,14 @@ long QgsProjectionSelector::getCurrentLongAttribute(QString attributeName) #endif rc = sqlite3_prepare(db, sql.toUtf8(), sql.length(), &ppStmt, &pzTail); // XXX Need to free memory from the error msg if one is set - QString mySrid; + QString myAttributeValue; if(rc == SQLITE_OK) { // get the first row of the result set if(sqlite3_step(ppStmt) == SQLITE_ROW) { - // get the wkt - mySrid = QString::fromUtf8((char *)sqlite3_column_text(ppStmt, 0)); + // get the attribute + myAttributeValue = QString::fromUtf8((char *)sqlite3_column_text(ppStmt, 0)); } } // close the statement @@ -431,7 +436,7 @@ long QgsProjectionSelector::getCurrentLongAttribute(QString attributeName) // close the database sqlite3_close(db); // return the srs wkt - return mySrid.toLong(); + return myAttributeValue.toLong(); } } @@ -440,19 +445,19 @@ long QgsProjectionSelector::getCurrentLongAttribute(QString attributeName) } -long QgsProjectionSelector::getCurrentSRID() +long QgsProjectionSelector::getSelectedSRID() { - return getCurrentLongAttribute("srid"); + return getSelectedLongAttribute("srid"); } -long QgsProjectionSelector::getCurrentEpsg() +long QgsProjectionSelector::getSelectedEpsg() { - return getCurrentLongAttribute("epsg"); + return getSelectedLongAttribute("epsg"); } -long QgsProjectionSelector::getCurrentSRSID() +long QgsProjectionSelector::getSelectedSRSID() { QTreeWidgetItem* item = lstCoordinateSystems->currentItem(); @@ -705,8 +710,8 @@ void QgsProjectionSelector::coordinateSystemSelected( QTreeWidgetItem * theItem) { // Found a real SRS QString myDescription; - emit sridSelected(QString::number(getCurrentSRSID())); - QString myProjString = getCurrentProj4String(); + emit sridSelected(QString::number(getSelectedSRSID())); + QString myProjString = getSelectedProj4String(); lstCoordinateSystems->scrollToItem(theItem); teProjection->setText(myProjString); } @@ -744,7 +749,7 @@ void QgsProjectionSelector::on_pbnFind_clicked() #endif //a name search is ambiguous, so we find the first srsid after the current seelcted srsid // each time the find button is pressed. This means we can loop through all matches. - if (myLargestSrsId <= getCurrentSRSID()) + if (myLargestSrsId <= getSelectedSRSID()) { //roll search around to the beginning mySql= "select srs_id from tbl_srs where description like '%" + mySearchString +"%'" + @@ -754,7 +759,7 @@ void QgsProjectionSelector::on_pbnFind_clicked() { // search ahead of the current postion mySql= "select srs_id from tbl_srs where description like '%" + mySearchString +"%'" + - " and srs_id > " + QString::number(getCurrentSRSID()) + " order by srs_id limit 1"; + " and srs_id > " + QString::number(getSelectedSRSID()) + " order by srs_id limit 1"; } } #ifdef QGISDEBUG diff --git a/src/gui/qgsprojectionselector.h b/src/gui/qgsprojectionselector.h index add998d3159..55fe9a67ce4 100644 --- a/src/gui/qgsprojectionselector.h +++ b/src/gui/qgsprojectionselector.h @@ -65,7 +65,7 @@ class GUI_EXPORT QgsProjectionSelector: public QWidget, private Ui::QgsProjectio const QString stringSQLSafe(const QString theSQL); //! Gets the current EPSG-style projection identifier - long getCurrentEpsg(); + long getSelectedEpsg(); public slots: void setSelectedSRSName(QString theSRSName); @@ -74,15 +74,15 @@ class GUI_EXPORT QgsProjectionSelector: public QWidget, private Ui::QgsProjectio void setSelectedSRSID(long theSRSID); - //void setSelectedEPSG(long epsg); + void setSelectedEpsg(long epsg); - QString getCurrentProj4String(); + QString getSelectedProj4String(); //! Gets the current PostGIS-style projection identifier - long getCurrentSRID(); + long getSelectedSRID(); //! Gets the current QGIS projection identfier - long getCurrentSRSID(); + long getSelectedSRSID(); /** * \brief filters this widget by the given CRSs @@ -153,7 +153,7 @@ class GUI_EXPORT QgsProjectionSelector: public QWidget, private Ui::QgsProjectio * * \param attributeName The sqlite3 column name, typically "srid" or "epsg" */ - long getCurrentLongAttribute(QString attributeName); + long getSelectedLongAttribute(QString attributeName); /** Show the user a warning if the srs database could not be found */ const void showDBMissingWarning(const QString theFileName); diff --git a/src/plugins/grass/qgsgrassnewmapset.cpp b/src/plugins/grass/qgsgrassnewmapset.cpp index e5aa0e680af..848e763b81a 100644 --- a/src/plugins/grass/qgsgrassnewmapset.cpp +++ b/src/plugins/grass/qgsgrassnewmapset.cpp @@ -449,7 +449,7 @@ void QgsGrassNewMapset::setGrassProjection() #endif setError ( mProjErrorLabel, ""); - QString proj4 = mProjectionSelector->getCurrentProj4String(); + QString proj4 = mProjectionSelector->getSelectedProj4String(); // Not defined if ( mNoProjRadioButton->isChecked() ) @@ -568,12 +568,12 @@ void QgsGrassNewMapset::setRegionPage() if ( mProjRadioButton->isChecked() ) { #ifdef QGISDEBUG - std::cerr << "getCurrentSRSID() = " << mProjectionSelector->getCurrentSRSID() << std::endl; + std::cerr << "getSelectedSRSID() = " << mProjectionSelector->getSelectedSRSID() << std::endl; #endif - if ( mProjectionSelector->getCurrentSRSID() > 0 ) + if ( mProjectionSelector->getSelectedSRSID() > 0 ) { - newSrs.createFromSrsId ( mProjectionSelector->getCurrentSRSID() ); + newSrs.createFromSrsId ( mProjectionSelector->getSelectedSRSID() ); if ( ! newSrs.isValid() ) { QMessageBox::warning( 0, tr("Warning"), @@ -691,7 +691,7 @@ void QgsGrassNewMapset::setGrassRegionDefaults() if ( extSet && ( mNoProjRadioButton->isChecked() || ( mProjRadioButton->isChecked() - && srsid == mProjectionSelector->getCurrentSRSID() ) + && srsid == mProjectionSelector->getSelectedSRSID() ) ) ) { @@ -915,7 +915,7 @@ void QgsGrassNewMapset::setSelectedRegion() // Warning: seems that crashes if source == dest - if ( mProjectionSelector->getCurrentSRSID() != 2585 ) + if ( mProjectionSelector->getSelectedSRSID() != 2585 ) { // Warning: QgsSpatialRefSys::EPSG is broken (using epsg_id) //QgsSpatialRefSys source ( 4326, QgsSpatialRefSys::EPSG ); @@ -928,7 +928,7 @@ void QgsGrassNewMapset::setSelectedRegion() return; } - QgsSpatialRefSys dest ( mProjectionSelector->getCurrentSRSID(), + QgsSpatialRefSys dest ( mProjectionSelector->getSelectedSRSID(), QgsSpatialRefSys::QGIS_SRSID ); if ( !dest.isValid() ) @@ -1141,9 +1141,9 @@ void QgsGrassNewMapset::drawRegion() points.push_back( QgsPoint( points[0] ) ); // close polygon // Warning: seems that crashes if source == dest - if ( mProjectionSelector->getCurrentSRSID() != 2585 ) + if ( mProjectionSelector->getSelectedSRSID() != 2585 ) { - QgsSpatialRefSys source ( mProjectionSelector->getCurrentSRSID(), + QgsSpatialRefSys source ( mProjectionSelector->getSelectedSRSID(), QgsSpatialRefSys::QGIS_SRSID ); if ( !source.isValid() ) diff --git a/src/plugins/wfs/qgswfssourceselect.cpp b/src/plugins/wfs/qgswfssourceselect.cpp index 9f548ce9b43..56556816060 100644 --- a/src/plugins/wfs/qgswfssourceselect.cpp +++ b/src/plugins/wfs/qgswfssourceselect.cpp @@ -18,7 +18,7 @@ #include "qgisinterface.h" #include "qgswfssourceselect.h" #include "qgsnewhttpconnection.h" -#include "qgslayerprojectionselector.h" +#include "qgsgenericprojectionselector.h" #include "qgshttptransaction.h" #include "qgscontexthelp.h" #include "qgsproject.h" @@ -47,7 +47,8 @@ QgsWFSSourceSelect::QgsWFSSourceSelect(QWidget* parent, QgisInterface* iface): Q connect(treeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)), this, SLOT(changeCRSFilter())); populateConnectionList(); - mProjectionSelector = new QgsLayerProjectionSelector(this); + mProjectionSelector = new QgsGenericProjectionSelector(this); + mProjectionSelector->setMessage(); } QgsWFSSourceSelect::~QgsWFSSourceSelect() @@ -354,7 +355,7 @@ void QgsWFSSourceSelect::addLayer() QString crsString; if(mProjectionSelector) { - long epsgNr = mProjectionSelector->getCurrentEpsg(); + long epsgNr = mProjectionSelector->getSelectedEpsg(); if(epsgNr != 0) { crsString = "&SRSNAME=EPSG:"+QString::number(epsgNr); @@ -372,7 +373,7 @@ void QgsWFSSourceSelect::changeCRS() { if(mProjectionSelector->exec()) { - QString crsString = "EPSG: " + QString::number(mProjectionSelector->getCurrentEpsg()); + QString crsString = "EPSG: " + QString::number(mProjectionSelector->getSelectedEpsg()); labelCoordRefSys->setText(crsString); } } diff --git a/src/plugins/wfs/qgswfssourceselect.h b/src/plugins/wfs/qgswfssourceselect.h index 5f8ab87f7cd..25c2accdace 100644 --- a/src/plugins/wfs/qgswfssourceselect.h +++ b/src/plugins/wfs/qgswfssourceselect.h @@ -21,7 +21,7 @@ #include "ui_qgswfssourceselectbase.h" class QgisInterface; -class QgsLayerProjectionSelector; +class QgsGenericProjectionSelector; class QgsWFSSourceSelect: public QDialog, private Ui::QgsWFSSourceSelectBase { @@ -42,7 +42,7 @@ class QgsWFSSourceSelect: public QDialog, private Ui::QgsWFSSourceSelectBase QgsWFSSourceSelect(); //default constructor is forbidden QgisInterface* mIface; //pointer to the QGIS interface object (needed to add WFS layers) QString mUri; //uri of the currently connected server - QgsLayerProjectionSelector* mProjectionSelector; + QgsGenericProjectionSelector* mProjectionSelector; /**Stores the available CRS for a server connections. The first string is the typename, the corresponding list stores the CRS for the typename in the form 'EPSG:XXXX'*/ diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index d83c00d95c3..1d5631716db 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -23,7 +23,7 @@ SET(QGIS_UIS qgshelpviewerbase.ui qgsidentifyresultsbase.ui qgslabeldialogbase.ui - qgslayerprojectionselectorbase.ui + qgsgenericprojectionselectorbase.ui qgsludialogbase.ui qgsmeasurebase.ui qgsmessageviewer.ui diff --git a/src/ui/qgslayerprojectionselectorbase.ui b/src/ui/qgsgenericprojectionselectorbase.ui similarity index 78% rename from src/ui/qgslayerprojectionselectorbase.ui rename to src/ui/qgsgenericprojectionselectorbase.ui index 8a9cc171317..81a2267bee4 100644 --- a/src/ui/qgslayerprojectionselectorbase.ui +++ b/src/ui/qgsgenericprojectionselectorbase.ui @@ -1,6 +1,6 @@ - QgsLayerProjectionSelectorBase - + QgsGenericProjectionSelectorBase + 0 @@ -10,7 +10,7 @@ - Layer Projection Selector + Projection Selector @@ -19,10 +19,22 @@ true - + 9 - + + 9 + + + 9 + + + 9 + + + 6 + + 6 @@ -31,9 +43,7 @@ - - 5 - 5 + 0 0