Rename projection selection widgets and cleanup API

The current names for QgsProjectionSelector and
QgsGenericProjectionSelector are confusing
This commit is contained in:
Nyall Dawson 2017-02-27 16:58:04 +10:00
parent 887ca6f95a
commit 5312965e61
41 changed files with 396 additions and 501 deletions

View File

@ -257,6 +257,7 @@ should now call QgsCoordinateReferenceSystem::invalidateCache() and QgsCoordinat
- QgsFormAnnotationItem. Use QgsFormAnnotation instead.
- QgsHtmlAnnotationItem. Use QgsHtmlAnnotation instead.
- QgsHttpTransaction. This class was outdated and code should be ported to native Qt or Python implementations.
- QgsGenericProjectionSelector. Use QgsProjectionSelectionTreeWidget instead.
- QgsLabel and QgsLabelAttributes. Replaced by labeling based on PAL library, see QgsLabelingEngine.
- QgsLabelingEngineInterface. Replaced by QgsLabelingEngine.
- QgsLegendInterface was removed. It was replaced by layer tree API (QgsLayerTreeNode class and others).
@ -276,6 +277,7 @@ should now call QgsCoordinateReferenceSystem::invalidateCache() and QgsCoordinat
- QgsRendererV2DataDefinedMenus was removed. Use QgsPropertyOverrideButton instead.
- QgsSizeScaleWidget. Use QgsPropertyAssistantWidget instead.
- QgsLegacyHelpers.
- QgsProjectionSelector. Use QgsProjectionSelectionDialog instead.
- QgsProviderCountCalcEvent and QgsProviderExtentCalcEvent. These classes were unused in QGIS core and unmaintained.
- QgsWebviewWidgetWrapper was removed. Use QgsExternalResourceWidgetWrapper instead.
- QgsEditorWidgetConfig was removed. Use QVariantMap instead.

View File

@ -81,7 +81,6 @@
%Include qgsfloatingwidget.sip
%Include qgsfocuswatcher.sip
%Include qgsformannotation.sip
%Include qgsgenericprojectionselector.sip
%Include qgsgeometryrubberband.sip
%Include qgsgradientcolorrampdialog.sip
%Include qgsgradientstopeditor.sip
@ -138,8 +137,9 @@
%Include qgspluginmanagerinterface.sip
%Include qgspresetcolorrampdialog.sip
%Include qgsprevieweffect.sip
%Include qgsprojectionselectiondialog.sip
%Include qgsprojectionselectiontreewidget.sip
%Include qgsprojectionselectionwidget.sip
%Include qgsprojectionselector.sip
%Include qgspropertyassistantwidget.sip
%Include qgspropertyoverridebutton.sip
%Include qgsquerybuilder.sip

View File

@ -1,64 +0,0 @@
/**
* \ingroup gui
* A generic dialog to prompt the user for a Coordinate Reference System.
*
* Typically you will use this when you want to prompt the user for
* a coordinate system identifier e.g. from a plugin you might do this
* to get an epsg code:
* \code
* QgsGenericProjectionSelector mySelector( mQgisIface->mainWindow() );
* mySelector.setSelectedEpsg( mEpsgId );
* if ( mySelector.exec() )
* {
* mEpsgId = mySelector.selectedEpsg();
* }
* \endcode
*
* If you wish to embed the projection selector into an existing dialog
* the you probably want to look at QgsProjectionSelector rather.
*/
class QgsGenericProjectionSelector : QDialog //, private Ui::QgsGenericProjectionSelectorBase
{
%TypeHeaderCode
#include <qgsgenericprojectionselector.h>
%End
public:
/**
* Constructor
*/
QgsGenericProjectionSelector( QWidget *parent /TransferThis/ = 0,
const Qt::WindowFlags& fl = QgisGui::ModalDialogFlags );
//! Destructor
~QgsGenericProjectionSelector();
public slots:
/** If no parameter is passed, the message will be a generic
* 'define the CRS for this layer'.
*/
void setMessage( QString message = "" );
long selectedCrsId();
QString selectedAuthId();
void setSelectedCrsName( const QString& name );
void setSelectedCrsId( long theID );
void setSelectedAuthId( const QString& authId );
void on_mButtonBox_helpRequested();
/**
* \brief filters this dialog by the given CRSs
*
* Sets this dialog to filter the available projections to those listed
* by the given Coordinate Reference Systems.
*
* \param crsFilter a list of OGC Coordinate Reference Systems to filter the
* list of projections by. This is useful in (e.g.) WMS situations
* where you just want to offer what the WMS server can support.
*
* \warning This function's behavior is undefined if it is called after the dialog is shown.
*/
void setOgcWmsCrsFilter( const QSet<QString>& crsFilter );
};

View File

@ -0,0 +1,39 @@
class QgsProjectionSelectionDialog : QDialog //, private Ui::QgsGenericProjectionSelectorBase
{
%TypeHeaderCode
#include <qgsprojectionselectiondialog.h>
%End
public:
/**
* Constructor
*/
QgsProjectionSelectionDialog( QWidget *parent /TransferThis/ = 0,
const Qt::WindowFlags& fl = QgisGui::ModalDialogFlags );
//! Destructor
~QgsProjectionSelectionDialog();
QgsCoordinateReferenceSystem crs() const;
void setMessage( const QString& message );
public slots:
void setCrs( const QgsCoordinateReferenceSystem& crs );
/**
* \brief filters this dialog by the given CRSs
*
* Sets this dialog to filter the available projections to those listed
* by the given Coordinate Reference Systems.
*
* \param crsFilter a list of OGC Coordinate Reference Systems to filter the
* list of projections by. This is useful in (e.g.) WMS situations
* where you just want to offer what the WMS server can support.
*
* \warning This function's behavior is undefined if it is called after the dialog is shown.
*/
void setOgcWmsCrsFilter( const QSet<QString>& crsFilter );
};

View File

@ -0,0 +1,31 @@
class QgsProjectionSelectionTreeWidget : QWidget
{
%TypeHeaderCode
#include <qgsprojectionselectiontreewidget.h>
%End
public:
QgsProjectionSelectionTreeWidget( QWidget* parent /TransferThis/ );
~QgsProjectionSelectionTreeWidget();
QgsCoordinateReferenceSystem crs() const;
public slots:
void setCrs( const QgsCoordinateReferenceSystem& crs );
void setOgcWmsCrsFilter( const QSet<QString>& crsFilter );
void pushProjectionToFront();
signals:
void crsSelected();
void initialized();
void projectionDoubleClicked();
protected:
void showEvent( QShowEvent * event );
void resizeEvent( QResizeEvent * event );
};

View File

@ -30,7 +30,7 @@ class QgsProjectionSelectionWidget : QWidget
* Can be used to modify how the projection selector dialog behaves.
* @returns projection selector dialog
*/
QgsGenericProjectionSelector* dialog();
QgsProjectionSelectionDialog* dialog();
/** Returns the currently selected CRS for the widget
* @returns current CRS

View File

@ -1,111 +0,0 @@
/**
@author Tim Sutton
*/
class QgsProjectionSelector : QWidget
{
%TypeHeaderCode
#include <qgsprojectionselector.h>
%End
public:
QgsProjectionSelector( QWidget* parent /TransferThis/, const char *name = "", const Qt::WindowFlags& fl = 0 );
~QgsProjectionSelector();
/**
* \brief Populate the proj tree view with user defined projection names...
*
* \param crsFilter a list of OGC Coordinate Reference Systems to filter the
* list of projections by. This is useful in (e.g.) WMS situations
* where you just want to offer what the WMS server can support.
*
* \todo Should this be public?
*/
void loadUserCrsList( QSet<QString> *crsFilter = 0 );
/**
* \brief Populate the proj tree view with system projection names...
*
* \param crsFilter a list of OGC Coordinate Reference Systems to filter the
* list of projections by. This is useful in (e.g.) WMS situations
* where you just want to offer what the WMS server can support.
*
* \todo Should this be public?
*/
void loadCrsList( QSet<QString> *crsFilter = 0 );
/*!
* \brief Make the string safe for use in SQL statements.
* This involves escaping single quotes, double quotes, backslashes,
* and optionally, percentage symbols. Percentage symbols are used
* as wildcards sometimes and so when using the string as part of the
* LIKE phrase of a select statement, should be escaped.
* \arg const QString in The input string to make safe.
* \return The string made safe for SQL statements.
*/
const QString sqlSafeString( const QString& theSQL );
//! Gets the current authority-style projection identifier
QString selectedAuthId();
public slots:
void setSelectedCrsName( const QString& theCRSName );
QString selectedName();
void setSelectedCrsId( long theCRSID );
void setSelectedAuthId( const QString& authId );
QString selectedProj4String();
//! Gets the current PostGIS-style projection identifier
long selectedPostgresSrId();
//! Gets the current QGIS projection identfier
long selectedCrsId();
/**
* \brief filters this widget by the given CRSs
*
* Sets this widget to filter the available projections to those listed
* by the given Coordinate Reference Systems.
*
* \param crsFilter a list of OGC Coordinate Reference Systems to filter the
* list of projections by. This is useful in (e.g.) WMS situations
* where you just want to offer what the WMS server can support.
*
* \warning This function's behavior is undefined if it is called after the widget is shown.
*/
void setOgcWmsCrsFilter( const QSet<QString>& crsFilter );
void on_lstCoordinateSystems_currentItemChanged( QTreeWidgetItem *current, QTreeWidgetItem *prev );
void on_lstRecent_currentItemChanged( QTreeWidgetItem *current, QTreeWidgetItem *prev );
void on_cbxHideDeprecated_stateChanged();
void on_leSearch_textChanged( const QString & );
//! mark selected projection for push to front
void pushProjectionToFront();
protected:
/** Used to ensure the projection list view is actually populated */
void showEvent( QShowEvent * event );
/** Used to manage column sizes */
void resizeEvent( QResizeEvent * event );
signals:
void sridSelected( const QString& theSRID );
//! Refresh any listening canvases
void refresh();
//! Let listeners know if find has focus so they can adjust the default button
void searchBoxHasFocus( bool );
//! Notify others that the widget is now fully initialized, including deferred selection of projection
//! @note added in 2.4
void initialized();
//! Apply projection on double click
//! @note added in 2.14
void projectionDoubleClicked();
};

View File

@ -56,7 +56,7 @@ from qgis.gui import (
QgsFieldComboBox,
QgsFieldExpressionWidget,
QgsFieldProxyModel,
QgsGenericProjectionSelector,
QgsProjectionSelectionDialog,
QgsMapLayerComboBox,
QgsProjectionSelectionWidget,
)
@ -311,13 +311,13 @@ class CrsWidgetWrapper(WidgetWrapper):
return widget
def selectProjection(self):
dialog = QgsGenericProjectionSelector(self.widget)
dialog = QgsProjectionSelectionDialog(self.widget)
current_crs = QgsCoordinateReferenceSystem(self.combo.currentText())
if current_crs.isValid():
dialog.setSelectedCrsId(current_crs.srsid())
dialog.setCrs(current_crs)
if dialog.exec_():
self.setValue(dialog.selectedAuthId())
self.setValue(dialog.crs().authid())
def setValue(self, value):
if self.dialogType == DIALOG_MODELER:

View File

@ -22,7 +22,7 @@
#include "qgsproject.h"
#include "qgssymbollayerutils.h"
#include "qgsstyle.h"
#include "qgsgenericprojectionselector.h"
#include "qgsprojectionselectiondialog.h"
#include "qgscomposition.h"
#include "qgsmapsettings.h"
#include "qgsexpressionbuilderdialog.h"
@ -1033,18 +1033,16 @@ void QgsComposerMapGridWidget::on_mMapGridCRSButton_clicked()
return;
}
QgsGenericProjectionSelector crsDialog( this );
QgsProjectionSelectionDialog crsDialog( this );
QgsCoordinateReferenceSystem crs = mComposerMapGrid->crs();
QString currentAuthId = crs.isValid() ? crs.authid() : mComposerMap->crs().authid();
crsDialog.setSelectedAuthId( currentAuthId );
crsDialog.setCrs( crs.isValid() ? crs : mComposerMap->crs() );
if ( crsDialog.exec() == QDialog::Accepted )
{
mComposerMap->beginCommand( tr( "Grid CRS changed" ) );
QString selectedAuthId = crsDialog.selectedAuthId();
mComposerMapGrid->setCrs( QgsCoordinateReferenceSystem( selectedAuthId ) );
mComposerMapGrid->setCrs( crsDialog.crs() );
mComposerMap->updateBoundingRect();
mMapGridCRSButton->setText( selectedAuthId );
mMapGridCRSButton->setText( crsDialog.crs().authid() );
mComposerMap->endCommand();
}
}

View File

@ -38,7 +38,7 @@
#include "qgslinesymbollayer.h"
#include "qgspallabeling.h"
#include "qgsmapcanvas.h"
#include "qgsgenericprojectionselector.h"
#include "qgsprojectionselectiondialog.h"
#include "qgsmessagelog.h"
#include "qgslogger.h"
#include "qgsproperty.h"

View File

@ -17,7 +17,7 @@
***************************************************************************/
#include "qgslogger.h"
#include "qgsvectorlayersaveasdialog.h"
#include "qgsgenericprojectionselector.h"
#include "qgsprojectionselectiondialog.h"
#include "qgsvectordataprovider.h"
#include "qgscoordinatereferencesystem.h"
#include "qgseditorwidgetfactory.h"

View File

@ -167,7 +167,7 @@
#include "qgsfieldformatterregistry.h"
#include "qgsformannotation.h"
#include "qgshtmlannotation.h"
#include "qgsgenericprojectionselector.h"
#include "qgsprojectionselectiondialog.h"
#include "qgsgpsinformationwidget.h"
#include "qgsguivectorlayertools.h"
#include "qgslabelingwidget.h"
@ -525,7 +525,7 @@ void QgisApp::validateCrs( QgsCoordinateReferenceSystem &srs )
// @note this class is not a descendent of QWidget so we can't pass
// it in the ctor of the layer projection selector
QgsGenericProjectionSelector *mySelector = new QgsGenericProjectionSelector();
QgsProjectionSelectionDialog *mySelector = new QgsProjectionSelectionDialog();
mySelector->setMessage( srs.validationHint() ); //shows a generic message, if not specified
if ( sAuthId.isNull() )
sAuthId = QgisApp::instance()->mapCanvas()->mapSettings().destinationCrs().authid();
@ -533,7 +533,7 @@ void QgisApp::validateCrs( QgsCoordinateReferenceSystem &srs )
QgsCoordinateReferenceSystem defaultCrs = QgsCoordinateReferenceSystem::fromOgcWmsCrs( sAuthId );
if ( defaultCrs.isValid() )
{
mySelector->setSelectedCrsId( defaultCrs.srsid() );
mySelector->setCrs( defaultCrs );
}
bool waiting = QApplication::overrideCursor() && QApplication::overrideCursor()->shape() == Qt::WaitCursor;
@ -542,9 +542,9 @@ void QgisApp::validateCrs( QgsCoordinateReferenceSystem &srs )
if ( mySelector->exec() )
{
QgsDebugMsg( "Layer srs set from dialog: " + QString::number( mySelector->selectedCrsId() ) );
sAuthId = mySelector->selectedAuthId();
srs.createFromOgcWmsCrs( mySelector->selectedAuthId() );
QgsDebugMsg( "Layer srs set from dialog: " + QString::number( mySelector->crs().srsid() ) );
srs = mySelector->crs();
sAuthId = srs.authid();
}
if ( waiting )
@ -8740,16 +8740,16 @@ void QgisApp::setLayerCrs()
return;
}
QgsGenericProjectionSelector mySelector( this );
mySelector.setSelectedCrsId( mLayerTreeView->currentLayer()->crs().srsid() );
mySelector.setMessage();
QgsProjectionSelectionDialog mySelector( this );
mySelector.setCrs( mLayerTreeView->currentLayer()->crs() );
mySelector.setMessage( QString() );
if ( !mySelector.exec() )
{
QApplication::restoreOverrideCursor();
return;
}
QgsCoordinateReferenceSystem crs = QgsCoordinateReferenceSystem::fromSrsId( mySelector.selectedCrsId() );
QgsCoordinateReferenceSystem crs = mySelector.crs();
Q_FOREACH ( QgsLayerTreeNode* node, mLayerTreeView->selectedNodes() )
{
@ -8897,15 +8897,15 @@ void QgisApp::legendGroupSetCrs()
if ( !currentGroup )
return;
QgsGenericProjectionSelector mySelector( this );
mySelector.setMessage();
QgsProjectionSelectionDialog mySelector( this );
mySelector.setMessage( QString() );
if ( !mySelector.exec() )
{
QApplication::restoreOverrideCursor();
return;
}
QgsCoordinateReferenceSystem crs = QgsCoordinateReferenceSystem::fromSrsId( mySelector.selectedCrsId() );
QgsCoordinateReferenceSystem crs = mySelector.crs();
Q_FOREACH ( QgsLayerTreeLayer* nodeLayer, currentGroup->findLayers() )
{
if ( nodeLayer->layer() )

View File

@ -23,7 +23,7 @@
#include "qgisapp.h" //<--theme icons
#include "qgsapplication.h"
#include "qgslogger.h"
#include "qgsgenericprojectionselector.h"
#include "qgsprojectionselectiondialog.h"
#include "qgscrscache.h"
//qt includes
@ -369,12 +369,10 @@ void QgsCustomProjectionDialog::on_leNameList_currentItemChanged( QTreeWidgetIte
void QgsCustomProjectionDialog::on_pbnCopyCRS_clicked()
{
QgsGenericProjectionSelector *mySelector = new QgsGenericProjectionSelector( this );
QgsProjectionSelectionDialog *mySelector = new QgsProjectionSelectionDialog( this );
if ( mySelector->exec() )
{
QgsCoordinateReferenceSystem srs;
QString id = mySelector->selectedAuthId();
srs.createFromOgcWmsCrs( id );
QgsCoordinateReferenceSystem srs = mySelector->crs();
if ( leNameList->topLevelItemCount() == 0 )
{
on_pbnAdd_clicked();

View File

@ -28,7 +28,7 @@
#include "qgslayertreemapcanvasbridge.h"
#include "qgsmapthemecollection.h"
#include "qgsmapcanvas.h"
#include "qgsgenericprojectionselector.h"
#include "qgsprojectionselectiondialog.h"
#include "qgscrscache.h"
#include <QFileDialog>

View File

@ -27,7 +27,7 @@
#include "qgsvectorlayer.h"
#include "qgsproject.h"
#include "qgscoordinatereferencesystem.h"
#include "qgsgenericprojectionselector.h"
#include "qgsprojectionselectiondialog.h"
#include "qgsslconnect.h"
#include "qgslogger.h"
@ -236,14 +236,14 @@ void QgsNewSpatialiteLayerDialog::on_pbnFindSRID_clicked()
}
// prepare projection selector
QgsGenericProjectionSelector *mySelector = new QgsGenericProjectionSelector( this );
mySelector->setMessage();
QgsProjectionSelectionDialog *mySelector = new QgsProjectionSelectionDialog( this );
mySelector->setMessage( QString() );
mySelector->setOgcWmsCrsFilter( myCRSs );
mySelector->setSelectedAuthId( mCrsId );
mySelector->setCrs( QgsCoordinateReferenceSystem::fromOgcWmsCrs( mCrsId ) );
if ( mySelector->exec() )
{
QgsCoordinateReferenceSystem srs = QgsCoordinateReferenceSystem::fromOgcWmsCrs( mySelector->selectedAuthId() );
QgsCoordinateReferenceSystem srs = mySelector->crs();
QString crsId = srs.authid();
if ( crsId != mCrsId )
{

View File

@ -23,7 +23,7 @@
#include "qgisappstylesheet.h"
#include "qgshighlight.h"
#include "qgsmapcanvas.h"
#include "qgsgenericprojectionselector.h"
#include "qgsprojectionselectiondialog.h"
#include "qgscoordinatereferencesystem.h"
#include "qgstolerance.h"
#include "qgsscaleutils.h"

View File

@ -34,7 +34,7 @@
#include "qgsvectorlayer.h"
#include "qgsvectordataprovider.h"
#include "qgsscaleutils.h"
#include "qgsgenericprojectionselector.h"
#include "qgsprojectionselectiondialog.h"
#include "qgsstyle.h"
#include "qgssymbol.h"
#include "qgsstylemanagerdialog.h"
@ -106,8 +106,8 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *pa
connect( buttonBox->button( QDialogButtonBox::Apply ), SIGNAL( clicked() ), this, SLOT( apply() ) );
connect( this, SIGNAL( accepted() ), this, SLOT( apply() ) );
connect( projectionSelector, SIGNAL( sridSelected( QString ) ), this, SLOT( srIdUpdated() ) );
connect( projectionSelector, SIGNAL( initialized() ), this, SLOT( projectionSelectorInitialized() ) );
connect( projectionSelector, &QgsProjectionSelectionTreeWidget::crsSelected, this, &QgsProjectProperties::srIdUpdated );
connect( projectionSelector, &QgsProjectionSelectionTreeWidget::initialized, this, &QgsProjectProperties::projectionSelectorInitialized );
connect( cmbEllipsoid, SIGNAL( currentIndexChanged( int ) ), this, SLOT( updateEllipsoidUI( int ) ) );
@ -130,7 +130,7 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *pa
updateGuiForMapUnits( srs.mapUnits() );
QgsDebugMsg( "Read project CRSID: " + QString::number( mProjectSrsId ) );
projectionSelector->setSelectedCrsId( mProjectSrsId );
projectionSelector->setCrs( srs );
mMapTileRenderingCheckBox->setChecked( mMapCanvas->mapSettings().testFlag( QgsMapSettings::RenderMapTile ) );
@ -776,14 +776,14 @@ 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 myCRSID = projectionSelector->selectedCrsId();
long myCRSID = projectionSelector->crs().srsid();
if ( myCRSID )
{
QgsCoordinateReferenceSystem srs = QgsCoordinateReferenceSystem::fromSrsId( myCRSID );
mMapCanvas->setDestinationCrs( srs );
QgsDebugMsg( QString( "Selected CRS " ) + srs.description() );
// write the currently selected projections _proj string_ to project settings
QgsDebugMsg( QString( "SpatialRefSys/ProjectCRSProj4String: %1" ).arg( projectionSelector->selectedProj4String() ) );
QgsDebugMsg( QString( "SpatialRefSys/ProjectCRSProj4String: %1" ).arg( projectionSelector->crs().toProj4() ) );
QgsProject::instance()->setCrs( srs );
// Set the map units to the projected coordinates if we are projecting
@ -1212,20 +1212,22 @@ void QgsProjectProperties::on_cbxProjectionEnabled_toggled( bool onFlyEnabled )
// reset projection to default
const QMap<QString, QgsMapLayer*> &mapLayers = QgsProject::instance()->mapLayers();
QgsCoordinateReferenceSystem crs;
if ( mMapCanvas->currentLayer() )
{
mLayerSrsId = mMapCanvas->currentLayer()->crs().srsid();
crs = mMapCanvas->currentLayer()->crs();
}
else if ( !mapLayers.isEmpty() )
{
mLayerSrsId = mapLayers.begin().value()->crs().srsid();
crs = mapLayers.begin().value()->crs();
}
else
{
mLayerSrsId = mProjectSrsId;
crs = QgsCoordinateReferenceSystem::fromSrsId( mProjectSrsId );
}
mLayerSrsId = crs.srsid();
mProjectSrsId = mLayerSrsId;
projectionSelector->setSelectedCrsId( mLayerSrsId );
projectionSelector->setCrs( crs );
// unset ellipsoid
mEllipsoidIndex = 0;
@ -1234,9 +1236,9 @@ void QgsProjectProperties::on_cbxProjectionEnabled_toggled( bool onFlyEnabled )
{
if ( !mLayerSrsId )
{
mLayerSrsId = projectionSelector->selectedCrsId();
mLayerSrsId = projectionSelector->crs().srsid();
}
projectionSelector->setSelectedCrsId( mProjectSrsId );
projectionSelector->setCrs( QgsCoordinateReferenceSystem::fromSrsId( mProjectSrsId ) );
}
srIdUpdated();
@ -1303,11 +1305,10 @@ void QgsProjectProperties::updateGuiForMapUnits( QgsUnitTypes::DistanceUnit unit
void QgsProjectProperties::srIdUpdated()
{
long myCRSID = projectionSelector->selectedCrsId();
if ( !isProjected() || !myCRSID )
QgsCoordinateReferenceSystem srs = projectionSelector->crs();
if ( !isProjected() || !srs.isValid() )
return;
QgsCoordinateReferenceSystem srs = QgsCoordinateReferenceSystem::fromSrsId( myCRSID );
//set radio button to crs map unit type
QgsUnitTypes::DistanceUnit units = srs.mapUnits();
@ -1354,15 +1355,15 @@ void QgsProjectProperties::on_pbnWMSExtCanvas_clicked()
void QgsProjectProperties::on_pbnWMSAddSRS_clicked()
{
QgsGenericProjectionSelector *mySelector = new QgsGenericProjectionSelector( this );
mySelector->setMessage();
QgsProjectionSelectionDialog *mySelector = new QgsProjectionSelectionDialog( this );
mySelector->setMessage( QString() );
if ( mWMSList->count() > 0 )
{
mySelector->setSelectedAuthId( mWMSList->item( mWMSList->count() - 1 )->text() );
mySelector->setCrs( QgsCoordinateReferenceSystem::fromOgcWmsCrs( mWMSList->item( mWMSList->count() - 1 )->text() ) );
}
if ( mySelector->exec() && mySelector->selectedCrsId() != 0 )
if ( mySelector->exec() && mySelector->crs().isValid() )
{
QString authid = mySelector->selectedAuthId();
QString authid = mySelector->crs().authid();
QList<QListWidgetItem *> items = mWMSList->findItems( authid.mid( 5 ), Qt::MatchFixedString );
if ( items.isEmpty() )
@ -1400,7 +1401,7 @@ void QgsProjectProperties::on_pbnWMSSetUsedSRS_clicked()
if ( cbxProjectionEnabled->isChecked() )
{
QgsCoordinateReferenceSystem srs = QgsCoordinateReferenceSystem::fromSrsId( projectionSelector->selectedCrsId() );
QgsCoordinateReferenceSystem srs = projectionSelector->crs();
crsList << srs.authid();
}

View File

@ -26,7 +26,7 @@
#include "qgscontrastenhancement.h"
#include "qgscoordinatetransform.h"
#include "qgscubicrasterresampler.h"
#include "qgsgenericprojectionselector.h"
#include "qgsprojectionselectiondialog.h"
#include "qgslogger.h"
#include "qgsmapcanvas.h"
#include "qgsmaplayerstyleguiutils.h"

View File

@ -33,7 +33,7 @@
#include "qgsfieldcalculator.h"
#include "qgsfieldsproperties.h"
#include "qgslabelingwidget.h"
#include "qgsgenericprojectionselector.h"
#include "qgsprojectionselectiondialog.h"
#include "qgslogger.h"
#include "qgsmapcanvas.h"
#include "qgsmaplayerconfigwidgetfactory.h"

View File

@ -223,7 +223,6 @@ SET(QGIS_GUI_SRCS
qgsfloatingwidget.cpp
qgsfocuswatcher.cpp
qgsformannotation.cpp
qgsgenericprojectionselector.cpp
qgsgeometryrubberband.cpp
qgsgradientcolorrampdialog.cpp
qgsgradientstopeditor.cpp
@ -281,8 +280,9 @@ SET(QGIS_GUI_SRCS
qgspluginmanagerinterface.cpp
qgspresetcolorrampdialog.cpp
qgsprevieweffect.cpp
qgsprojectionselectiondialog.cpp
qgsprojectionselectionwidget.cpp
qgsprojectionselector.cpp
qgsprojectionselectiontreewidget.cpp
qgspropertyassistantwidget.cpp
qgspropertyoverridebutton.cpp
qgsquerybuilder.cpp
@ -375,7 +375,6 @@ SET(QGIS_GUI_MOC_HDRS
qgsfloatingwidget.h
qgsfocuswatcher.h
qgsformannotation.h
qgsgenericprojectionselector.h
qgsgradientcolorrampdialog.h
qgsgradientstopeditor.h
qgsgroupwmsdatadialog.h
@ -426,8 +425,9 @@ SET(QGIS_GUI_MOC_HDRS
qgspluginmanagerinterface.h
qgspresetcolorrampdialog.h
qgsprevieweffect.h
qgsprojectionselectiondialog.h
qgsprojectionselectionwidget.h
qgsprojectionselector.h
qgsprojectionselectiontreewidget.h
qgspropertyassistantwidget.h
qgspropertyoverridebutton.h
qgsquerybuilder.h

View File

@ -25,7 +25,7 @@
#include "qgsvectorlayer.h"
#include "qgsproject.h"
#include "qgscoordinatereferencesystem.h"
#include "qgsgenericprojectionselector.h"
#include "qgsprojectionselectiondialog.h"
#include "qgslogger.h"

View File

@ -24,7 +24,7 @@
#include "qgscontexthelp.h"
#include "qgscoordinatereferencesystem.h"
#include "qgsdatasourceuri.h"
#include "qgsgenericprojectionselector.h"
#include "qgsprojectionselectiondialog.h"
#include "qgslogger.h"
#include "qgsmanageconnectionsdialog.h"
#include "qgsmessageviewer.h"
@ -376,20 +376,20 @@ void QgsOWSSourceSelect::on_mChangeCRSButton_clicked()
layers << layer;
}
QgsGenericProjectionSelector * mySelector = new QgsGenericProjectionSelector( this );
mySelector->setMessage();
QgsProjectionSelectionDialog * mySelector = new QgsProjectionSelectionDialog( this );
mySelector->setMessage( QString() );
mySelector->setOgcWmsCrsFilter( mSelectedLayersCRSs );
QgsCoordinateReferenceSystem defaultCRS = QgsProject::instance()->crs();
if ( defaultCRS.isValid() )
{
mySelector->setSelectedCrsId( defaultCRS.srsid() );
mySelector->setCrs( defaultCRS );
}
if ( !mySelector->exec() )
return;
mSelectedCRS = mySelector->selectedAuthId();
mSelectedCRS = mySelector->crs().authid();
delete mySelector;
mSelectedCRSLabel->setText( descriptionForAuthId( mSelectedCRS ) );

View File

@ -17,15 +17,11 @@
***************************************************************************/
#include "qgsapplication.h"
#include <qgsgenericprojectionselector.h>
#include "qgsprojectionselectiondialog.h"
#include <QApplication>
#include <QSettings>
/**
* \class QgsGenericProjectionSelector
* \brief A generic dialog to prompt the user for a Coordinate Reference System
*/
QgsGenericProjectionSelector::QgsGenericProjectionSelector( QWidget *parent,
QgsProjectionSelectionDialog::QgsProjectionSelectionDialog( QWidget *parent,
Qt::WindowFlags fl )
: QDialog( parent, fl )
{
@ -38,14 +34,15 @@ QgsGenericProjectionSelector::QgsGenericProjectionSelector( QWidget *parent,
textEdit->hide();
//apply selected projection upon double click on item
connect( projectionSelector, SIGNAL( projectionDoubleClicked() ), this, SLOT( accept() ) );
connect( projectionSelector, &QgsProjectionSelectionTreeWidget::projectionDoubleClicked, this, &QgsProjectionSelectionDialog::accept );
}
void QgsGenericProjectionSelector::setMessage( QString message )
void QgsProjectionSelectionDialog::setMessage( const QString& message )
{
QString m = message;
//short term kludge to make the layer selector default to showing
//a layer projection selection message. If you want the selector
if ( message.isEmpty() )
if ( m.isEmpty() )
{
// Set up text edit pane
QString format( QStringLiteral( "<h1>%1</h1>%2 %3" ) );
@ -53,48 +50,32 @@ void QgsGenericProjectionSelector::setMessage( QString message )
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." );
message = format.arg( header, sentence1, sentence2 );
m = format.arg( header, sentence1, sentence2 );
}
QString myStyle = QgsApplication::reportStyleSheet();
message = "<head><style>" + myStyle + "</style></head><body>" + message + "</body>";
textEdit->setHtml( message );
m = "<head><style>" + myStyle + "</style></head><body>" + m + "</body>";
textEdit->setHtml( m );
textEdit->show();
}
QgsGenericProjectionSelector::~QgsGenericProjectionSelector()
QgsProjectionSelectionDialog::~QgsProjectionSelectionDialog()
{
QSettings settings;
settings.setValue( QStringLiteral( "/Windows/ProjectionSelector/geometry" ), saveGeometry() );
}
void QgsGenericProjectionSelector::setSelectedCrsName( const QString& name )
QgsCoordinateReferenceSystem QgsProjectionSelectionDialog::crs() const
{
projectionSelector->setSelectedCrsName( name );
return projectionSelector->crs();
}
void QgsGenericProjectionSelector::setSelectedCrsId( long theID )
void QgsProjectionSelectionDialog::setCrs( const QgsCoordinateReferenceSystem& crs )
{
projectionSelector->setSelectedCrsId( theID );
projectionSelector->setCrs( crs );
}
void QgsGenericProjectionSelector::setSelectedAuthId( const QString& theID )
{
projectionSelector->setSelectedAuthId( theID );
}
long QgsGenericProjectionSelector::selectedCrsId()
{
//@note don't use getSelectedWkt as that just returns the name part!
return projectionSelector->selectedCrsId();
}
QString QgsGenericProjectionSelector::selectedAuthId()
{
return projectionSelector->selectedAuthId();
}
void QgsGenericProjectionSelector::setOgcWmsCrsFilter( const QSet<QString>& crsFilter )
void QgsProjectionSelectionDialog::setOgcWmsCrsFilter( const QSet<QString>& crsFilter )
{
projectionSelector->setOgcWmsCrsFilter( crsFilter );
}

View File

@ -24,8 +24,10 @@
#include "qgscontexthelp.h"
#include "qgis_gui.h"
#include "qgscoordinatereferencesystem.h"
/**
* \class QgsProjectionSelectionDialog
* \ingroup gui
* A generic dialog to prompt the user for a Coordinate Reference System.
*
@ -33,46 +35,55 @@
* a coordinate system identifier e.g. from a plugin you might do this
* to get an epsg code:
* \code
* QgsGenericProjectionSelector mySelector( mQGisIface->mainWindow() );
* mySelector.setSelectedEpsg( mEpsgId );
* QgsProjectionSelectionDialog mySelector( mQGisIface->mainWindow() );
* mySelector.setCrs( crs );
* if ( mySelector.exec() )
* {
* mEpsgId = mySelector.selectedEpsg();
* mCrs = mySelector.crs();
* }
* \endcode
*
* If you wish to embed the projection selector into an existing dialog
* the you probably want to look at QgsProjectionSelector rather.
* the you probably want to look at QgsProjectionSelectionWidget instead.
* @note added in QGIS 3.0
*/
class GUI_EXPORT QgsGenericProjectionSelector : public QDialog, private Ui::QgsGenericProjectionSelectorBase
class GUI_EXPORT QgsProjectionSelectionDialog : public QDialog, private Ui::QgsGenericProjectionSelectorBase
{
Q_OBJECT
public:
/**
* Constructor
* Constructor for QgsProjectionSelectionDialog.
*/
QgsGenericProjectionSelector( QWidget *parent = nullptr,
QgsProjectionSelectionDialog( QWidget *parent = nullptr,
Qt::WindowFlags fl = QgisGui::ModalDialogFlags );
~QgsGenericProjectionSelector();
~QgsProjectionSelectionDialog();
/**
* Returns the CRS currently selected in the widget.
* @note added in QGIS 3.0
* @see setCrs()
*/
QgsCoordinateReferenceSystem crs() const;
/**
* Sets a \a message to show in the dialog. If an empty string is
* passed, the message will be a generic
* 'define the CRS for this layer'.
*/
void setMessage( const QString& message );
public slots:
/** If no parameter is passed, the message will be a generic
* 'define the CRS for this layer'.
/**
* Sets the initial \a crs to show within the dialog.
* @note added in QGIS 3.0
* @see crs()
*/
void setMessage( QString message = QStringLiteral( "" ) );
long selectedCrsId();
QString selectedAuthId();
void setSelectedCrsName( const QString& name );
void setSelectedCrsId( long theID );
void setSelectedAuthId( const QString& authId );
void on_mButtonBox_helpRequested() { QgsContextHelp::run( metaObject()->className() ); }
void setCrs( const QgsCoordinateReferenceSystem& crs );
/**
* \brief filters this dialog by the given CRSs
@ -87,6 +98,10 @@ class GUI_EXPORT QgsGenericProjectionSelector : public QDialog, private Ui::QgsG
* \warning This function's behavior is undefined if it is called after the dialog is shown.
*/
void setOgcWmsCrsFilter( const QSet<QString>& crsFilter );
private slots:
void on_mButtonBox_helpRequested() { QgsContextHelp::run( metaObject()->className() ); }
};
#endif // #ifndef QGSLAYERCRSSELECTOR_H

View File

@ -8,7 +8,7 @@
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
#include <qgsprojectionselector.h>
#include "qgsprojectionselectiontreewidget.h"
//standard includes
#include <sqlite3.h>
@ -27,24 +27,23 @@
#include <QMessageBox>
#include <QSettings>
QgsProjectionSelector::QgsProjectionSelector( QWidget* parent, const char *name, Qt::WindowFlags fl )
: QWidget( parent, fl )
QgsProjectionSelectionTreeWidget::QgsProjectionSelectionTreeWidget( QWidget* parent )
: QWidget( parent )
, mUserProjList( nullptr )
, mGeoList( nullptr )
, mProjList( nullptr )
, mProjListDone( false )
, mUserProjListDone( false )
, mRecentProjListDone( false )
, mSearchColumn( QgsProjectionSelector::None )
, mSearchColumn( QgsProjectionSelectionTreeWidget::None )
, mPushProjectionToFront( false )
{
Q_UNUSED( name );
setupUi( this );
if ( qobject_cast<QDialog*>( parent ) )
if ( QDialog* dlg = qobject_cast<QDialog*>( parent ) )
{
// mark selected projection for push to front if parent dialog is accepted
connect( parent, SIGNAL( accepted() ), this, SLOT( pushProjectionToFront() ) );
connect( dlg, &QDialog::accepted, this, &QgsProjectionSelectionTreeWidget::pushProjectionToFront );
}
// Get the full path name to the sqlite3 spatial reference database.
@ -67,7 +66,7 @@ QgsProjectionSelector::QgsProjectionSelector( QWidget* parent, const char *name,
mRecentProjections = QgsCoordinateReferenceSystem::recentProjections();
}
QgsProjectionSelector::~QgsProjectionSelector()
QgsProjectionSelectionTreeWidget::~QgsProjectionSelectionTreeWidget()
{
if ( !mPushProjectionToFront )
{
@ -112,7 +111,7 @@ QgsProjectionSelector::~QgsProjectionSelector()
settings.setValue( QStringLiteral( "/UI/recentProjectionsAuthId" ), projectionsAuthId );
}
void QgsProjectionSelector::resizeEvent( QResizeEvent * event )
void QgsProjectionSelectionTreeWidget::resizeEvent( QResizeEvent * event )
{
lstCoordinateSystems->header()->resizeSection( NameColumn, event->size().width() - 240 );
lstCoordinateSystems->header()->resizeSection( AuthidColumn, 240 );
@ -123,7 +122,7 @@ void QgsProjectionSelector::resizeEvent( QResizeEvent * event )
lstRecent->header()->resizeSection( QgisCrsIdColumn, 0 );
}
void QgsProjectionSelector::showEvent( QShowEvent * event )
void QgsProjectionSelectionTreeWidget::showEvent( QShowEvent * event )
{
// ensure the projection list view is actually populated
// before we show this widget
@ -146,7 +145,7 @@ void QgsProjectionSelector::showEvent( QShowEvent * event )
QWidget::showEvent( event );
}
QString QgsProjectionSelector::ogcWmsCrsFilterAsSqlExpression( QSet<QString> * crsFilter )
QString QgsProjectionSelectionTreeWidget::ogcWmsCrsFilterAsSqlExpression( QSet<QString> * crsFilter )
{
QString sqlExpression = QStringLiteral( "1" ); // it's "SQL" for "true"
QMap<QString, QStringList> authParts;
@ -204,22 +203,7 @@ QString QgsProjectionSelector::ogcWmsCrsFilterAsSqlExpression( QSet<QString> * c
return sqlExpression;
}
void QgsProjectionSelector::setSelectedCrsName( const QString& theCRSName )
{
applySelection( NameColumn, theCRSName );
}
void QgsProjectionSelector::setSelectedCrsId( long theCRSID )
{
applySelection( QgisCrsIdColumn, QString::number( theCRSID ) );
}
void QgsProjectionSelector::setSelectedAuthId( const QString& id )
{
applySelection( AuthidColumn, id );
}
void QgsProjectionSelector::applySelection( int column, QString value )
void QgsProjectionSelectionTreeWidget::applySelection( int column, QString value )
{
if ( !mProjListDone || !mUserProjListDone )
{
@ -229,17 +213,17 @@ void QgsProjectionSelector::applySelection( int column, QString value )
return;
}
if ( column == QgsProjectionSelector::None )
if ( column == QgsProjectionSelectionTreeWidget::None )
{
// invoked deferred selection
column = mSearchColumn;
value = mSearchValue;
mSearchColumn = QgsProjectionSelector::None;
mSearchColumn = QgsProjectionSelectionTreeWidget::None;
mSearchValue.clear();
}
if ( column == QgsProjectionSelector::None )
if ( column == QgsProjectionSelectionTreeWidget::None )
return;
QList<QTreeWidgetItem*> nodes = lstCoordinateSystems->findItems( value, Qt::MatchExactly | Qt::MatchRecursive, column );
@ -259,7 +243,7 @@ void QgsProjectionSelector::applySelection( int column, QString value )
}
}
void QgsProjectionSelector::insertRecent( long crsId )
void QgsProjectionSelectionTreeWidget::insertRecent( long crsId )
{
if ( !mProjListDone || !mUserProjListDone )
return;
@ -275,15 +259,20 @@ void QgsProjectionSelector::insertRecent( long crsId )
}
//note this line just returns the projection name!
QString QgsProjectionSelector::selectedName()
QString QgsProjectionSelectionTreeWidget::selectedName()
{
// return the selected wkt name from the list view
QTreeWidgetItem *lvi = lstCoordinateSystems->currentItem();
return lvi ? lvi->text( NameColumn ) : QString::null;
}
void QgsProjectionSelectionTreeWidget::setCrs( const QgsCoordinateReferenceSystem& crs )
{
applySelection( AuthidColumn, crs.authid() );
}
// Returns the whole proj4 string for the selected projection node
QString QgsProjectionSelector::selectedProj4String()
QString QgsProjectionSelectionTreeWidget::selectedProj4String()
{
// Only return the projection if there is a node in the tree
// selected that has an srid. This prevents error if the user
@ -351,7 +340,7 @@ QString QgsProjectionSelector::selectedProj4String()
return projString;
}
QString QgsProjectionSelector::getSelectedExpression( const QString& expression )
QString QgsProjectionSelectionTreeWidget::getSelectedExpression( const QString& expression ) const
{
// Only return the attribute if there is a node in the tree
// selected that has an srs_id. This prevents error if the user
@ -391,7 +380,9 @@ QString QgsProjectionSelector::getSelectedExpression( const QString& expression
int rc = sqlite3_open_v2( databaseFileName.toUtf8().data(), &database, SQLITE_OPEN_READONLY, nullptr );
if ( rc )
{
showDBMissingWarning( databaseFileName );
QgsMessageLog::logMessage( tr( "Resource Location Error" ), tr( "Error reading database file from: \n %1\n"
"Because of this the projection selector will not work..." ).arg( databaseFileName ),
QgsMessageLog::CRITICAL );
return QString();
}
@ -421,23 +412,16 @@ QString QgsProjectionSelector::getSelectedExpression( const QString& expression
return attributeValue;
}
long QgsProjectionSelector::selectedPostgresSrId()
{
return getSelectedExpression( QStringLiteral( "srid" ) ).toLong();
}
QString QgsProjectionSelector::selectedAuthId()
QgsCoordinateReferenceSystem QgsProjectionSelectionTreeWidget::crs() const
{
int srid = getSelectedExpression( QStringLiteral( "srs_id" ) ).toLong();
if ( srid >= USER_CRS_START_ID )
return QStringLiteral( "USER:%1" ).arg( srid );
return QgsCoordinateReferenceSystem::fromOgcWmsCrs( QString( "USER:%1" ).arg( srid ) );
else
return getSelectedExpression( QStringLiteral( "upper(auth_name||':'||auth_id)" ) );
return QgsCoordinateReferenceSystem::fromOgcWmsCrs( getSelectedExpression( QStringLiteral( "upper(auth_name||':'||auth_id)" ) ) );
}
long QgsProjectionSelector::selectedCrsId()
long QgsProjectionSelectionTreeWidget::selectedCrsId()
{
QTreeWidgetItem* item = lstCoordinateSystems->currentItem();
@ -448,7 +432,7 @@ long QgsProjectionSelector::selectedCrsId()
}
void QgsProjectionSelector::setOgcWmsCrsFilter( const QSet<QString>& crsFilter )
void QgsProjectionSelectionTreeWidget::setOgcWmsCrsFilter( const QSet<QString>& crsFilter )
{
mCrsFilter = crsFilter;
mProjListDone = false;
@ -456,7 +440,7 @@ void QgsProjectionSelector::setOgcWmsCrsFilter( const QSet<QString>& crsFilter )
lstCoordinateSystems->clear();
}
void QgsProjectionSelector::loadUserCrsList( QSet<QString> *crsFilter )
void QgsProjectionSelectionTreeWidget::loadUserCrsList( QSet<QString> *crsFilter )
{
if ( mUserProjListDone )
return;
@ -532,7 +516,7 @@ void QgsProjectionSelector::loadUserCrsList( QSet<QString> *crsFilter )
mUserProjListDone = true;
}
void QgsProjectionSelector::loadCrsList( QSet<QString> *crsFilter )
void QgsProjectionSelectionTreeWidget::loadCrsList( QSet<QString> *crsFilter )
{
if ( mProjListDone )
return;
@ -674,7 +658,7 @@ void QgsProjectionSelector::loadCrsList( QSet<QString> *crsFilter )
}
// New coordinate system selected from the list
void QgsProjectionSelector::on_lstCoordinateSystems_currentItemChanged( QTreeWidgetItem *current, QTreeWidgetItem * )
void QgsProjectionSelectionTreeWidget::on_lstCoordinateSystems_currentItemChanged( QTreeWidgetItem *current, QTreeWidgetItem * )
{
QgsDebugMsg( "Entered." );
@ -691,7 +675,7 @@ void QgsProjectionSelector::on_lstCoordinateSystems_currentItemChanged( QTreeWid
if ( current->childCount() == 0 )
{
// Found a real CRS
emit sridSelected( QString::number( selectedCrsId() ) );
emit crsSelected();
teProjection->setText( selectedProj4String() );
teSelected->setText( selectedName() );
@ -719,7 +703,7 @@ void QgsProjectionSelector::on_lstCoordinateSystems_currentItemChanged( QTreeWid
}
}
void QgsProjectionSelector::on_lstCoordinateSystems_itemDoubleClicked( QTreeWidgetItem *current, int column )
void QgsProjectionSelectionTreeWidget::on_lstCoordinateSystems_itemDoubleClicked( QTreeWidgetItem *current, int column )
{
Q_UNUSED( column );
@ -737,7 +721,7 @@ void QgsProjectionSelector::on_lstCoordinateSystems_itemDoubleClicked( QTreeWidg
emit projectionDoubleClicked();
}
void QgsProjectionSelector::on_lstRecent_currentItemChanged( QTreeWidgetItem *current, QTreeWidgetItem * )
void QgsProjectionSelectionTreeWidget::on_lstRecent_currentItemChanged( QTreeWidgetItem *current, QTreeWidgetItem * )
{
QgsDebugMsg( "Entered." );
@ -754,7 +738,7 @@ void QgsProjectionSelector::on_lstRecent_currentItemChanged( QTreeWidgetItem *cu
lstCoordinateSystems->setCurrentItem( nodes.first() );
}
void QgsProjectionSelector::on_lstRecent_itemDoubleClicked( QTreeWidgetItem *current, int column )
void QgsProjectionSelectionTreeWidget::on_lstRecent_itemDoubleClicked( QTreeWidgetItem *current, int column )
{
Q_UNUSED( column );
@ -771,7 +755,7 @@ void QgsProjectionSelector::on_lstRecent_itemDoubleClicked( QTreeWidgetItem *cur
emit projectionDoubleClicked();
}
void QgsProjectionSelector::hideDeprecated( QTreeWidgetItem *item )
void QgsProjectionSelectionTreeWidget::hideDeprecated( QTreeWidgetItem *item )
{
if ( item->data( 0, Qt::UserRole ).toBool() )
{
@ -788,13 +772,13 @@ void QgsProjectionSelector::hideDeprecated( QTreeWidgetItem *item )
hideDeprecated( item->child( i ) );
}
void QgsProjectionSelector::on_cbxHideDeprecated_stateChanged()
void QgsProjectionSelectionTreeWidget::on_cbxHideDeprecated_stateChanged()
{
for ( int i = 0; i < lstCoordinateSystems->topLevelItemCount(); i++ )
hideDeprecated( lstCoordinateSystems->topLevelItem( i ) );
}
void QgsProjectionSelector::on_leSearch_textChanged( const QString & filterTxt )
void QgsProjectionSelectionTreeWidget::on_leSearch_textChanged( const QString & filterTxt )
{
QString filterTxtCopy = filterTxt;
filterTxtCopy.replace( QRegExp( "\\s+" ), QStringLiteral( ".*" ) );
@ -864,14 +848,14 @@ void QgsProjectionSelector::on_leSearch_textChanged( const QString & filterTxt )
}
void QgsProjectionSelector::pushProjectionToFront()
void QgsProjectionSelectionTreeWidget::pushProjectionToFront()
{
// set flag to push selected projection to front in destructor
mPushProjectionToFront = true;
}
long QgsProjectionSelector::getLargestCrsIdMatch( const QString& sql )
long QgsProjectionSelectionTreeWidget::getLargestCrsIdMatch( const QString& sql )
{
long srsId = 0;
@ -940,7 +924,7 @@ long QgsProjectionSelector::getLargestCrsIdMatch( const QString& sql )
return srsId;
}
QStringList QgsProjectionSelector::authorities()
QStringList QgsProjectionSelectionTreeWidget::authorities()
{
sqlite3 *database = nullptr;
const char *tail = nullptr;
@ -983,7 +967,7 @@ QStringList QgsProjectionSelector::authorities()
* \arg const QString in The input string to make safe.
* \return The string made safe for SQL statements.
*/
const QString QgsProjectionSelector::sqlSafeString( const QString& theSQL )
const QString QgsProjectionSelectionTreeWidget::sqlSafeString( const QString& theSQL )
{
QString retval = theSQL;
retval.replace( '\\', QLatin1String( "\\\\" ) );
@ -993,7 +977,7 @@ const QString QgsProjectionSelector::sqlSafeString( const QString& theSQL )
return retval;
}
void QgsProjectionSelector::showDBMissingWarning( const QString& fileName )
void QgsProjectionSelectionTreeWidget::showDBMissingWarning( const QString& fileName )
{
QMessageBox::critical( this, tr( "Resource Location Error" ),

View File

@ -18,74 +18,52 @@
#include "qgis.h"
#include "qgis_gui.h"
#include "qgscoordinatereferencesystem.h"
class QResizeEvent;
/** \ingroup gui
* A widget for selecting a Coordinate reference system from a tree.
* @see QgsGenericProjectionSelector.
@author Tim Sutton
*/
class GUI_EXPORT QgsProjectionSelector : public QWidget, private Ui::QgsProjectionSelectorBase
/**
* \class QgsProjectionSelectionTreeWidget
* \ingroup gui
* A widget for selecting a coordinate reference system from a tree.
*
* This widget implements a tree view of projections, as seen in the
* QgsProjectionSelectionDialog dialog. In most cases it is more
* suitable to use the compact QgsProjectionSelectionWidget widget.
*
* \see QgsProjectionSelectionDialog.
* \see QgsProjectionSelectionWidget
* \note added in QGIS 3.0
*/
class GUI_EXPORT QgsProjectionSelectionTreeWidget : public QWidget, private Ui::QgsProjectionSelectorBase
{
Q_OBJECT
public:
QgsProjectionSelector( QWidget* parent, const char *name = "", Qt::WindowFlags fl = 0 );
~QgsProjectionSelector();
/**
* \brief Populate the proj tree view with user defined projection names...
*
* \param crsFilter a list of OGC Coordinate Reference Systems to filter the
* list of projections by. This is useful in (e.g.) WMS situations
* where you just want to offer what the WMS server can support.
*
* \todo Should this be public?
* Constructor for QgsProjectionSelectionTreeWidget.
*/
void loadUserCrsList( QSet<QString> *crsFilter = nullptr );
QgsProjectionSelectionTreeWidget( QWidget* parent = nullptr );
~QgsProjectionSelectionTreeWidget();
/**
* \brief Populate the proj tree view with system projection names...
*
* \param crsFilter a list of OGC Coordinate Reference Systems to filter the
* list of projections by. This is useful in (e.g.) WMS situations
* where you just want to offer what the WMS server can support.
*
* \todo Should this be public?
* Returns the CRS currently selected in the widget.
* @note added in QGIS 3.0
* @see setCrs()
*/
void loadCrsList( QSet<QString> *crsFilter = nullptr );
/*!
* \brief Make the string safe for use in SQL statements.
* This involves escaping single quotes, double quotes, backslashes,
* and optionally, percentage symbols. Percentage symbols are used
* as wildcards sometimes and so when using the string as part of the
* LIKE phrase of a select statement, should be escaped.
* \arg const QString in The input string to make safe.
* \return The string made safe for SQL statements.
*/
const QString sqlSafeString( const QString& theSQL );
//! Gets the current authority-style projection identifier
QString selectedAuthId();
QgsCoordinateReferenceSystem crs() const;
public slots:
void setSelectedCrsName( const QString& theCRSName );
QString selectedName();
void setSelectedCrsId( long theCRSID );
void setSelectedAuthId( const QString& authId );
QString selectedProj4String();
//! Gets the current PostGIS-style projection identifier
long selectedPostgresSrId();
//! Gets the current QGIS projection identfier
long selectedCrsId();
/**
* Sets the initial \a crs to show within the dialog.
* @note added in QGIS 3.0
* @see crs()
*/
void setCrs( const QgsCoordinateReferenceSystem& crs );
/**
* \brief filters this widget by the given CRSs
@ -100,14 +78,31 @@ class GUI_EXPORT QgsProjectionSelector : public QWidget, private Ui::QgsProjecti
* \warning This function's behavior is undefined if it is called after the widget is shown.
*/
void setOgcWmsCrsFilter( const QSet<QString>& crsFilter );
void on_lstCoordinateSystems_currentItemChanged( QTreeWidgetItem *current, QTreeWidgetItem *prev );
void on_lstRecent_currentItemChanged( QTreeWidgetItem *current, QTreeWidgetItem *prev );
void on_cbxHideDeprecated_stateChanged();
void on_leSearch_textChanged( const QString & );
//! mark selected projection for push to front
/**
* Marks the current selected projection for push to front of recent projections list.
*/
void pushProjectionToFront();
signals:
/**
* Emitted when a projection is selected in the widget.
*/
void crsSelected();
/**
* Notifies others that the widget is now fully initialized, including deferred selection of projection.
* @note added in 2.4
*/
void initialized();
/**
* Emitted when a projection is double clicked in the list.
* @note added in 2.14
*/
void projectionDoubleClicked();
protected:
// Used to ensure the projection list view is actually populated
void showEvent( QShowEvent * event ) override;
@ -117,6 +112,35 @@ class GUI_EXPORT QgsProjectionSelector : public QWidget, private Ui::QgsProjecti
private:
/**
* \brief Populate the proj tree view with user defined projection names...
*
* \param crsFilter a list of OGC Coordinate Reference Systems to filter the
* list of projections by. This is useful in (e.g.) WMS situations
* where you just want to offer what the WMS server can support.
*/
void loadUserCrsList( QSet<QString> *crsFilter = nullptr );
/**
* \brief Populate the proj tree view with system projection names...
*
* \param crsFilter a list of OGC Coordinate Reference Systems to filter the
* list of projections by. This is useful in (e.g.) WMS situations
* where you just want to offer what the WMS server can support.
*/
void loadCrsList( QSet<QString> *crsFilter = nullptr );
/*!
* \brief Make the string safe for use in SQL statements.
* This involves escaping single quotes, double quotes, backslashes,
* and optionally, percentage symbols. Percentage symbols are used
* as wildcards sometimes and so when using the string as part of the
* LIKE phrase of a select statement, should be escaped.
* \arg const QString in The input string to make safe.
* \return The string made safe for SQL statements.
*/
const QString sqlSafeString( const QString& theSQL );
/**
* \brief converts the CRS group to a SQL expression fragment
*
@ -140,14 +164,21 @@ class GUI_EXPORT QgsProjectionSelector : public QWidget, private Ui::QgsProjecti
* 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 applySelection( int column = QgsProjectionSelector::None, QString value = QString::null );
void applySelection( int column = QgsProjectionSelectionTreeWidget::None, QString value = QString::null );
/**
* \brief gets an arbitrary sqlite3 expression from the selection
*
* \param e The sqlite3 expression (typically "srid" or "sridid")
*/
QString getSelectedExpression( const QString& e );
QString getSelectedExpression( const QString& e ) const;
QString selectedName();
QString selectedProj4String();
//! Gets the current QGIS projection identfier
long selectedCrsId();
//! Show the user a warning if the srs database could not be found
void showDBMissingWarning( const QString& fileName );
@ -204,19 +235,10 @@ class GUI_EXPORT QgsProjectionSelector : public QWidget, private Ui::QgsProjecti
//! Apply projection on double click
void on_lstCoordinateSystems_itemDoubleClicked( QTreeWidgetItem *current, int column );
void on_lstRecent_itemDoubleClicked( QTreeWidgetItem *current, int column );
signals:
void sridSelected( const QString& theSRID );
//! Refresh any listening canvases
void refresh();
//! Let listeners know if find has focus so they can adjust the default button
void searchBoxHasFocus( bool );
//! Notify others that the widget is now fully initialized, including deferred selection of projection
//! @note added in 2.4
void initialized();
//! Apply projection on double click
//! @note added in 2.14
void projectionDoubleClicked();
void on_lstCoordinateSystems_currentItemChanged( QTreeWidgetItem *current, QTreeWidgetItem *prev );
void on_lstRecent_currentItemChanged( QTreeWidgetItem *current, QTreeWidgetItem *prev );
void on_cbxHideDeprecated_stateChanged();
void on_leSearch_textChanged( const QString & );
};
#endif

View File

@ -18,14 +18,14 @@
#include "qgsprojectionselectionwidget.h"
#include "qgsapplication.h"
#include "qgsgenericprojectionselector.h"
#include "qgsprojectionselectiondialog.h"
#include "qgsproject.h"
#include <QSettings>
QgsProjectionSelectionWidget::QgsProjectionSelectionWidget( QWidget *parent )
: QWidget( parent )
{
mDialog = new QgsGenericProjectionSelector( this );
mDialog = new QgsProjectionSelectionDialog( this );
QHBoxLayout* layout = new QHBoxLayout();
layout->setContentsMargins( 0, 0, 0, 0 );
@ -66,7 +66,7 @@ QgsProjectionSelectionWidget::QgsProjectionSelectionWidget( QWidget *parent )
setFocusPolicy( Qt::StrongFocus );
setFocusProxy( mButton );
connect( mButton, SIGNAL( clicked() ), this, SLOT( selectCrs() ) );
connect( mButton, &QToolButton::clicked, this, &QgsProjectionSelectionWidget::selectCrs );
connect( mCrsComboBox, SIGNAL( currentIndexChanged( int ) ), this, SLOT( comboIndexChanged( int ) ) );
}
@ -173,7 +173,7 @@ void QgsProjectionSelectionWidget::selectCrs()
//find out crs id of current proj4 string
if ( mCrs.isValid() )
{
mDialog->setSelectedCrsId( mCrs.srsid() );
mDialog->setCrs( mCrs );
}
if ( mDialog->exec() )
@ -181,7 +181,7 @@ void QgsProjectionSelectionWidget::selectCrs()
mCrsComboBox->blockSignals( true );
mCrsComboBox->setCurrentIndex( mCrsComboBox->findData( QgsProjectionSelectionWidget::CurrentCrs ) );
mCrsComboBox->blockSignals( false );
QgsCoordinateReferenceSystem crs = QgsCoordinateReferenceSystem::fromOgcWmsCrs( mDialog->selectedAuthId() );
QgsCoordinateReferenceSystem crs = mDialog->crs();
setCrs( crs );
emit crsChanged( crs );
}

View File

@ -25,7 +25,7 @@
#include "qgscoordinatereferencesystem.h"
#include "qgis_gui.h"
class QgsGenericProjectionSelector;
class QgsProjectionSelectionDialog;
/**
* \class QgsProjectionSelectionWidget
@ -56,7 +56,7 @@ class GUI_EXPORT QgsProjectionSelectionWidget : public QWidget
* Can be used to modify how the projection selector dialog behaves.
* @returns projection selector dialog
*/
QgsGenericProjectionSelector* dialog() { return mDialog; }
QgsProjectionSelectionDialog* dialog() { return mDialog; }
/** Returns the currently selected CRS for the widget
* @returns current CRS
@ -121,7 +121,7 @@ class GUI_EXPORT QgsProjectionSelectionWidget : public QWidget
QgsCoordinateReferenceSystem mDefaultCrs;
QComboBox* mCrsComboBox = nullptr;
QToolButton* mButton = nullptr;
QgsGenericProjectionSelector* mDialog = nullptr;
QgsProjectionSelectionDialog* mDialog = nullptr;
QString mNotSetText;
void addNotSetOption();

View File

@ -21,7 +21,7 @@
#include "qgsrasterformatsaveoptionswidget.h"
#include "qgsrasterrenderer.h"
#include "qgsrastertransparency.h"
#include "qgsgenericprojectionselector.h"
#include "qgsprojectionselectiondialog.h"
#include "gdal.h"

View File

@ -18,7 +18,7 @@
#include "qgssourceselectdialog.h"
#include "qgsowsconnection.h"
#include "qgsnewhttpconnection.h"
#include "qgsgenericprojectionselector.h"
#include "qgsprojectionselectiondialog.h"
#include "qgsexpressionbuilderdialog.h"
#include "qgscontexthelp.h"
#include "qgsproject.h"
@ -74,8 +74,8 @@ QgsSourceSelectDialog::QgsSourceSelectDialog( const QString& serviceName, Servic
connect( btnChangeSpatialRefSys, SIGNAL( clicked() ), this, SLOT( changeCrs() ) );
connect( lineFilter, SIGNAL( textChanged( QString ) ), this, SLOT( filterChanged( QString ) ) );
populateConnectionList();
mProjectionSelector = new QgsGenericProjectionSelector( this );
mProjectionSelector->setMessage();
mProjectionSelector = new QgsProjectionSelectionDialog( this );
mProjectionSelector->setMessage( QString() );
treeView->setItemDelegate( new QgsSourceSelectItemDelegate( treeView ) );
@ -367,7 +367,7 @@ void QgsSourceSelectDialog::changeCrs()
{
if ( mProjectionSelector->exec() )
{
QString crsString = mProjectionSelector->selectedAuthId();
QString crsString = mProjectionSelector->crs().authid();
labelCoordRefSys->setText( crsString );
}
}
@ -397,7 +397,7 @@ void QgsSourceSelectDialog::changeCrsFilter()
if ( !preferredCRS.isEmpty() )
{
QgsCoordinateReferenceSystem refSys = QgsCoordinateReferenceSystem::fromOgcWmsCrs( preferredCRS );
mProjectionSelector->setSelectedCrsId( refSys.srsid() );
mProjectionSelector->setCrs( refSys );
labelCoordRefSys->setText( preferredCRS );
}

View File

@ -23,7 +23,7 @@
class QStandardItemModel;
class QSortFilterProxyModel;
class QgsGenericProjectionSelector;
class QgsProjectionSelectionDialog;
class QgsOwsConnection;
/** \ingroup gui
@ -53,7 +53,7 @@ class GUI_EXPORT QgsSourceSelectDialog : public QDialog, protected Ui::QgsSource
protected:
QString mServiceName;
ServiceType mServiceType;
QgsGenericProjectionSelector* mProjectionSelector = nullptr;
QgsProjectionSelectionDialog* mProjectionSelector = nullptr;
// Available CRS for a server connection, key=typename, value=list("EPSG:XXXX")
QMap<QString, QStringList> mAvailableCRS;
QStandardItemModel* mModel = nullptr;

View File

@ -27,7 +27,7 @@
#include <qgis.h>
#include <qgscoordinatereferencesystem.h>
#include <qgscoordinatetransform.h>
#include <qgsgenericprojectionselector.h>
#include <qgsprojectionselectiondialog.h>
#include "qgsdockwidget.h"
#include "coordinatecapture.h"
@ -184,11 +184,11 @@ void CoordinateCapture::help()
void CoordinateCapture::setCRS()
{
QgsGenericProjectionSelector mySelector( mQGisIface->mainWindow() );
mySelector.setSelectedCrsId( mCrs.srsid() );
QgsProjectionSelectionDialog mySelector( mQGisIface->mainWindow() );
mySelector.setCrs( mCrs );
if ( mySelector.exec() )
{
mCrs.createFromSrsId( mySelector.selectedCrsId() );
mCrs = mySelector.crs();
mTransform.setDestinationCrs( mCrs );
mUserCrsDisplayPrecision = ( mCrs.mapUnits() == QgsUnitTypes::DistanceDegrees ) ? 5 : 3; //precision depends on CRS units
}

View File

@ -18,7 +18,7 @@
#include <QMessageBox>
#include <QSettings>
#include "qgsprojectionselector.h"
#include "qgsprojectionselectiontreewidget.h"
#include "qgsapplication.h"
#include "qgsrasterlayer.h"

View File

@ -25,7 +25,7 @@
#include "qgslogger.h"
#include "qgsmapcanvas.h"
#include "qgsproject.h"
#include "qgsprojectionselector.h"
#include "qgsprojectionselectiontreewidget.h"
#include "qgslocalec.h"
#include "qgscsexception.h"
@ -354,9 +354,8 @@ void QgsGrassNewMapset::setProjectionPage()
setGrassProjection();
}
void QgsGrassNewMapset::sridSelected( QString theSRID )
void QgsGrassNewMapset::sridSelected()
{
Q_UNUSED( theSRID );
projectionSelected();
}
@ -383,7 +382,7 @@ void QgsGrassNewMapset::setGrassProjection()
{
setError( mProjErrorLabel );
QString proj4 = mProjectionSelector->selectedProj4String();
QString proj4 = mProjectionSelector->crs().toProj4();
// Not defined
if ( mNoProjRadioButton->isChecked() )
@ -481,11 +480,11 @@ void QgsGrassNewMapset::setRegionPage()
QgsCoordinateReferenceSystem newCrs;
if ( mProjRadioButton->isChecked() )
{
QgsDebugMsg( QString( "selectedCrsId() = %1" ).arg( mProjectionSelector->selectedCrsId() ) );
QgsDebugMsg( QString( "selectedCrsId() = %1" ).arg( mProjectionSelector->crs().srsid() ) );
if ( mProjectionSelector->selectedCrsId() > 0 )
if ( mProjectionSelector->crs().srsid() > 0 )
{
newCrs.createFromSrsId( mProjectionSelector->selectedCrsId() );
newCrs = mProjectionSelector->crs();
if ( ! newCrs.isValid() )
{
QgsGrass::warning( tr( "Cannot create projection." ) );
@ -592,7 +591,7 @@ void QgsGrassNewMapset::setGrassRegionDefaults()
if ( extSet &&
( mNoProjRadioButton->isChecked() ||
( mProjRadioButton->isChecked()
&& srs.srsid() == mProjectionSelector->selectedCrsId() )
&& srs.srsid() == mProjectionSelector->crs().srsid() )
)
)
{
@ -814,7 +813,7 @@ void QgsGrassNewMapset::setSelectedRegion()
// Warning: seems that crashes if source == dest
if ( mProjectionSelector->selectedCrsId() != GEOCRS_ID )
if ( mProjectionSelector->crs().srsid() != GEOCRS_ID )
{
// Warning: QgsCoordinateReferenceSystem::EpsgCrsId is broken (using epsg_id)
//QgsCoordinateReferenceSystem source ( 4326, QgsCoordinateReferenceSystem::EpsgCrsId );
@ -826,7 +825,7 @@ void QgsGrassNewMapset::setSelectedRegion()
return;
}
QgsCoordinateReferenceSystem dest = QgsCoordinateReferenceSystem::fromSrsId( mProjectionSelector->selectedCrsId() );
QgsCoordinateReferenceSystem dest = mProjectionSelector->crs();
if ( !dest.isValid() )
{
@ -1024,9 +1023,9 @@ void QgsGrassNewMapset::drawRegion()
points << points[0]; // close polygon
// Warning: seems that crashes if source == dest
if ( mProjectionSelector->selectedCrsId() != GEOCRS_ID )
if ( mProjectionSelector->crs().srsid() != GEOCRS_ID )
{
QgsCoordinateReferenceSystem source = QgsCoordinateReferenceSystem::fromSrsId( mProjectionSelector->selectedCrsId() );
QgsCoordinateReferenceSystem source = mProjectionSelector->crs();
if ( !source.isValid() )
{
@ -1358,21 +1357,21 @@ void QgsGrassNewMapset::pageSelected( int index )
{
QGridLayout *projectionLayout = new QGridLayout( mProjectionFrame );
mProjectionSelector = new QgsProjectionSelector( mProjectionFrame, "Projection", 0 );
mProjectionSelector = new QgsProjectionSelectionTreeWidget( mProjectionFrame );
mProjectionSelector->setEnabled( false );
projectionLayout->addWidget( mProjectionSelector, 0, 0 );
mProjectionSelector->show();
connect( mProjectionSelector, SIGNAL( sridSelected( QString ) ),
this, SLOT( sridSelected( QString ) ) );
connect( mProjectionSelector, &QgsProjectionSelectionTreeWidget::crsSelected,
this, &QgsGrassNewMapset::sridSelected );
QgsCoordinateReferenceSystem srs = mIface->mapCanvas()->mapSettings().destinationCrs();
QgsDebugMsg( "srs = " + srs.toWkt() );
if ( srs.isValid() )
{
mProjectionSelector->setSelectedCrsId( srs.srsid() );
mProjectionSelector->setCrs( srs );
mProjRadioButton->setChecked( true );
projRadioSwitched();
}

View File

@ -22,7 +22,7 @@
class QgsGrassPlugin;
class QgisInterface;
class QgsPoint;
class QgsProjectionSelector;
class QgsProjectionSelectionTreeWidget;
extern "C"
{
@ -109,7 +109,7 @@ class QgsGrassNewMapset : public QWizard, private Ui::QgsGrassNewMapsetBase
void setProjectionPage();
//! Projection selected
void sridSelected( QString );
void sridSelected();
void projectionSelected();
//! Location radio switched
@ -200,7 +200,7 @@ class QgsGrassNewMapset : public QWizard, private Ui::QgsGrassNewMapsetBase
static bool sRunning;
//! Projection selector
QgsProjectionSelector *mProjectionSelector = nullptr;
QgsProjectionSelectionTreeWidget *mProjectionSelector = nullptr;
//! GRASS projection
struct Cell_head mCellHead;

View File

@ -22,7 +22,7 @@ email : hugo dot mercier at oslandia dot com
#include <qgsvectorlayer.h>
#include <qgsvectordataprovider.h>
#include <qgsproject.h>
#include <qgsgenericprojectionselector.h>
#include <qgsprojectionselectiondialog.h>
#include <layertree/qgslayertreemodel.h>
#include <layertree/qgslayertreegroup.h>
#include <layertree/qgslayertreelayer.h>
@ -176,14 +176,14 @@ void QgsVirtualLayerSourceSelect::onLayerComboChanged( int idx )
void QgsVirtualLayerSourceSelect::onBrowseCRS()
{
QgsGenericProjectionSelector crsSelector( this );
QgsProjectionSelectionDialog crsSelector( this );
QgsCoordinateReferenceSystem crs( mSrid );
crsSelector.setSelectedCrsId( crs.srsid() ); // convert postgis srid to internal id
crsSelector.setMessage();
crsSelector.setCrs( crs );
crsSelector.setMessage( QString() );
if ( crsSelector.exec() )
{
mCRS->setText( crsSelector.selectedAuthId() );
QgsCoordinateReferenceSystem newCrs = QgsCoordinateReferenceSystem::fromSrsId( crsSelector.selectedCrsId() );
mCRS->setText( crsSelector.crs().authid() );
QgsCoordinateReferenceSystem newCrs = crsSelector.crs();
mSrid = newCrs.postgisSrid();
}
}

View File

@ -23,7 +23,7 @@
#include "qgswfsdatasourceuri.h"
#include "qgswfsutils.h"
#include "qgsnewhttpconnection.h"
#include "qgsgenericprojectionselector.h"
#include "qgsprojectionselectiondialog.h"
#include "qgscontexthelp.h"
#include "qgsproject.h"
#include "qgscoordinatereferencesystem.h"
@ -82,8 +82,8 @@ QgsWFSSourceSelect::QgsWFSSourceSelect( QWidget* parent, Qt::WindowFlags fl, boo
connect( btnChangeSpatialRefSys, SIGNAL( clicked() ), this, SLOT( changeCRS() ) );
connect( lineFilter, SIGNAL( textChanged( QString ) ), this, SLOT( filterChanged( QString ) ) );
populateConnectionList();
mProjectionSelector = new QgsGenericProjectionSelector( this );
mProjectionSelector->setMessage();
mProjectionSelector = new QgsProjectionSelectionDialog( this );
mProjectionSelector->setMessage( QString() );
mItemDelegate = new QgsWFSItemDelegate( treeView );
treeView->setItemDelegate( mItemDelegate );
@ -677,7 +677,7 @@ void QgsWFSSourceSelect::changeCRS()
{
if ( mProjectionSelector->exec() )
{
QString crsString = mProjectionSelector->selectedAuthId();
QString crsString = mProjectionSelector->crs().authid();
labelCoordRefSys->setText( crsString );
}
}
@ -704,7 +704,7 @@ void QgsWFSSourceSelect::changeCRSFilter()
if ( !preferredCRS.isEmpty() )
{
QgsCoordinateReferenceSystem refSys = QgsCoordinateReferenceSystem::fromOgcWmsCrs( preferredCRS );
mProjectionSelector->setSelectedCrsId( refSys.srsid() );
mProjectionSelector->setCrs( refSys );
labelCoordRefSys->setText( preferredCRS );
}

View File

@ -26,7 +26,7 @@
#include <QStandardItemModel>
#include <QSortFilterProxyModel>
class QgsGenericProjectionSelector;
class QgsProjectionSelectionDialog;
class QgsWfsCapabilities;
class QgsSQLComposerDialog;
@ -56,7 +56,7 @@ class QgsWFSSourceSelect: public QDialog, private Ui::QgsWFSSourceSelectBase
private:
QgsWFSSourceSelect(); //default constructor is forbidden
QgsGenericProjectionSelector* mProjectionSelector = nullptr;
QgsProjectionSelectionDialog* mProjectionSelector = nullptr;
/** Stores the available CRS for a server connections.
The first string is the typename, the corresponding list

View File

@ -23,7 +23,7 @@
#include "qgscontexthelp.h"
#include "qgscoordinatereferencesystem.h"
#include "qgsdatasourceuri.h"
#include "qgsgenericprojectionselector.h"
#include "qgsprojectionselectiondialog.h"
#include "qgslogger.h"
#include "qgsmanageconnectionsdialog.h"
#include "qgsmessageviewer.h"
@ -617,20 +617,20 @@ void QgsWMSSourceSelect::on_btnChangeSpatialRefSys_clicked()
layers << layer;
}
QgsGenericProjectionSelector * mySelector = new QgsGenericProjectionSelector( this );
mySelector->setMessage();
QgsProjectionSelectionDialog * mySelector = new QgsProjectionSelectionDialog( this );
mySelector->setMessage( QString() );
mySelector->setOgcWmsCrsFilter( mCRSs );
QgsCoordinateReferenceSystem defaultCRS = QgsProject::instance()->crs();
if ( defaultCRS.isValid() )
{
mySelector->setSelectedCrsId( defaultCRS.srsid() );
mySelector->setCrs( defaultCRS );
}
if ( !mySelector->exec() )
return;
mCRS = mySelector->selectedAuthId();
mCRS = mySelector->crs().authid();
delete mySelector;
labelCoordRefSys->setText( descriptionForAuthId( mCRS ) );

View File

@ -54,7 +54,7 @@
</widget>
</item>
<item row="1" column="0">
<widget class="QgsProjectionSelector" name="projectionSelector" native="true"/>
<widget class="QgsProjectionSelectionTreeWidget" name="projectionSelector" native="true"/>
</item>
<item row="2" column="0">
<widget class="QDialogButtonBox" name="mButtonBox">
@ -71,9 +71,9 @@
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
<customwidget>
<class>QgsProjectionSelector</class>
<class>QgsProjectionSelectionTreeWidget</class>
<extends>QWidget</extends>
<header>qgsprojectionselector.h</header>
<header>qgsprojectionselectiontreewidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>

View File

@ -770,7 +770,7 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout_21">
<item>
<widget class="QgsProjectionSelector" name="projectionSelector" native="true"/>
<widget class="QgsProjectionSelectionTreeWidget" name="projectionSelector" native="true"/>
</item>
</layout>
</widget>
@ -2604,9 +2604,9 @@
<container>1</container>
</customwidget>
<customwidget>
<class>QgsProjectionSelector</class>
<class>QgsProjectionSelectionTreeWidget</class>
<extends>QWidget</extends>
<header>qgsprojectionselector.h</header>
<header>qgsprojectionselectiontreewidget.h</header>
<container>1</container>
</customwidget>
<customwidget>