Skip to content

Commit 0b6fdd9

Browse files
committedMar 22, 2019
Standardise API for deciding whether the datum transform dialog should be shown
1 parent fc4d9b8 commit 0b6fdd9

File tree

3 files changed

+21
-11
lines changed

3 files changed

+21
-11
lines changed
 

‎src/app/qgisapp.cpp

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7855,8 +7855,7 @@ QString QgisApp::saveAsVectorFileGeneral( QgsVectorLayer *vlayer, bool symbology
78557855
//ask user about datum transformation
78567856
QgsSettings settings;
78577857
QgsDatumTransformDialog dlg( vlayer->crs(), destCRS );
7858-
if ( dlg.availableTransformationCount() > 1 &&
7859-
settings.value( QStringLiteral( "Projections/showDatumTransformDialog" ), false ).toBool() )
7858+
if ( dlg.shouldAskUserForSelection() )
78607859
{
78617860
dlg.exec();
78627861
}
@@ -9912,6 +9911,7 @@ void QgisApp::projectCrsChanged()
99129911
}
99139912
else if ( transformsToAskFor.count() > 1 )
99149913
{
9914+
// TODO - this should actually loop through and ask for each in turn
99159915
bool ask = QgsSettings().value( QStringLiteral( "/Projections/showDatumTransformDialog" ), false ).toBool();
99169916
if ( ask )
99179917
{
@@ -9921,8 +9921,6 @@ void QgisApp::projectCrsChanged()
99219921
5 );
99229922
}
99239923
}
9924-
9925-
99269924
}
99279925

99289926
// toggle overview status
@@ -13736,14 +13734,9 @@ bool QgisApp::askUserForDatumTransform( const QgsCoordinateReferenceSystem &sour
1373613734
{
1373713735
//if several possibilities: present dialog
1373813736
QgsDatumTransformDialog dlg( sourceCrs, destinationCrs );
13739-
if ( dlg.availableTransformationCount() > 1 )
13737+
if ( dlg.shouldAskUserForSelection() )
1374013738
{
13741-
bool ask = QgsSettings().value( QStringLiteral( "/Projections/showDatumTransformDialog" ), false ).toBool();
13742-
if ( !ask )
13743-
{
13744-
ok = false;
13745-
}
13746-
else if ( dlg.exec() )
13739+
if ( dlg.exec() )
1374713740
{
1374813741
QPair< QPair<QgsCoordinateReferenceSystem, int>, QPair<QgsCoordinateReferenceSystem, int > > dt = dlg.selectedDatumTransforms();
1374913742
QgsCoordinateTransformContext context = QgsProject::instance()->transformContext();

‎src/gui/qgsdatumtransformdialog.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,16 @@ int QgsDatumTransformDialog::availableTransformationCount()
195195
return mDatumTransforms.count();
196196
}
197197

198+
bool QgsDatumTransformDialog::shouldAskUserForSelection()
199+
{
200+
if ( availableTransformationCount() > 1 )
201+
{
202+
return QgsSettings().value( QStringLiteral( "/Projections/showDatumTransformDialog" ), false ).toBool();
203+
}
204+
// TODO: show if transform grids are required, but missing
205+
return false;
206+
}
207+
198208
QPair<QPair<QgsCoordinateReferenceSystem, int>, QPair<QgsCoordinateReferenceSystem, int> > QgsDatumTransformDialog::selectedDatumTransforms()
199209
{
200210
int row = mDatumTransformTableWidget->currentRow();

‎src/gui/qgsdatumtransformdialog.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,13 @@ class GUI_EXPORT QgsDatumTransformDialog : public QDialog, private Ui::QgsDatumT
5454
*/
5555
int availableTransformationCount();
5656

57+
/**
58+
* Returns true if the dialog should be shown and the user prompted to make the transformation selection.
59+
*
60+
* \since QGIS 3.8
61+
*/
62+
bool shouldAskUserForSelection();
63+
5764
/**
5865
* Returns the source and destination transforms, each being a pair of QgsCoordinateReferenceSystems and datum transform code
5966
* \since 3.0

0 commit comments

Comments
 (0)
Please sign in to comment.