Skip to content
Permalink
Browse files

Standardise API for deciding whether the datum transform dialog shoul…

…d be shown
  • Loading branch information
nyalldawson committed Mar 12, 2019
1 parent fc4d9b8 commit 0b6fdd9b09f5da874b8c499be2e6192849fd8f06
Showing with 21 additions and 11 deletions.
  1. +4 −11 src/app/qgisapp.cpp
  2. +10 −0 src/gui/qgsdatumtransformdialog.cpp
  3. +7 −0 src/gui/qgsdatumtransformdialog.h
@@ -7855,8 +7855,7 @@ QString QgisApp::saveAsVectorFileGeneral( QgsVectorLayer *vlayer, bool symbology
//ask user about datum transformation
QgsSettings settings;
QgsDatumTransformDialog dlg( vlayer->crs(), destCRS );
if ( dlg.availableTransformationCount() > 1 &&
settings.value( QStringLiteral( "Projections/showDatumTransformDialog" ), false ).toBool() )
if ( dlg.shouldAskUserForSelection() )
{
dlg.exec();
}
@@ -9912,6 +9911,7 @@ void QgisApp::projectCrsChanged()
}
else if ( transformsToAskFor.count() > 1 )
{
// TODO - this should actually loop through and ask for each in turn
bool ask = QgsSettings().value( QStringLiteral( "/Projections/showDatumTransformDialog" ), false ).toBool();
if ( ask )
{
@@ -9921,8 +9921,6 @@ void QgisApp::projectCrsChanged()
5 );
}
}


}

// toggle overview status
@@ -13736,14 +13734,9 @@ bool QgisApp::askUserForDatumTransform( const QgsCoordinateReferenceSystem &sour
{
//if several possibilities: present dialog
QgsDatumTransformDialog dlg( sourceCrs, destinationCrs );
if ( dlg.availableTransformationCount() > 1 )
if ( dlg.shouldAskUserForSelection() )
{
bool ask = QgsSettings().value( QStringLiteral( "/Projections/showDatumTransformDialog" ), false ).toBool();
if ( !ask )
{
ok = false;
}
else if ( dlg.exec() )
if ( dlg.exec() )
{
QPair< QPair<QgsCoordinateReferenceSystem, int>, QPair<QgsCoordinateReferenceSystem, int > > dt = dlg.selectedDatumTransforms();
QgsCoordinateTransformContext context = QgsProject::instance()->transformContext();
@@ -195,6 +195,16 @@ int QgsDatumTransformDialog::availableTransformationCount()
return mDatumTransforms.count();
}

bool QgsDatumTransformDialog::shouldAskUserForSelection()
{
if ( availableTransformationCount() > 1 )
{
return QgsSettings().value( QStringLiteral( "/Projections/showDatumTransformDialog" ), false ).toBool();
}
// TODO: show if transform grids are required, but missing
return false;
}

QPair<QPair<QgsCoordinateReferenceSystem, int>, QPair<QgsCoordinateReferenceSystem, int> > QgsDatumTransformDialog::selectedDatumTransforms()
{
int row = mDatumTransformTableWidget->currentRow();
@@ -54,6 +54,13 @@ class GUI_EXPORT QgsDatumTransformDialog : public QDialog, private Ui::QgsDatumT
*/
int availableTransformationCount();

/**
* Returns true if the dialog should be shown and the user prompted to make the transformation selection.
*
* \since QGIS 3.8
*/
bool shouldAskUserForSelection();

/**
* Returns the source and destination transforms, each being a pair of QgsCoordinateReferenceSystems and datum transform code
* \since 3.0

0 comments on commit 0b6fdd9

Please sign in to comment.
You can’t perform that action at this time.