Skip to content

Commit

Permalink
Rename API for flexibility
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed May 11, 2021
1 parent 29a469f commit 7724b37
Show file tree
Hide file tree
Showing 14 changed files with 34 additions and 46 deletions.
24 changes: 8 additions & 16 deletions python/gui/auto_generated/qgsprojectionselectionwidget.sip.in
Expand Up @@ -83,30 +83,22 @@ passed, the message will be a generic
%End


bool showDatumEnsembleWarnings() const;
bool showAccuracyWarnings() const;
%Docstring
Returns ``True`` if the widget will show a warning to users when they select a CRS which uses
a datum ensemble.
Returns ``True`` if the widget will show a warning to users when they select a CRS which has
low accuracy.

.. warning::

Determining datum ensembles requires PROJ 8.0 or later.

.. seealso:: :py:func:`setShowDatumEnsembleWarnings`
.. seealso:: :py:func:`showAccuracyWarnings`

.. versionadded:: 3.20
%End

void setShowDatumEnsembleWarnings( bool showDatumEnsembleWarnings );
void showAccuracyWarnings( bool show );
%Docstring
Sets whether the widget will show a warning to users when they select a CRS which uses
a datum ensemble.

.. warning::

Determining datum ensembles requires PROJ 8.0 or later.
Sets whether the widget will ``show`` warnings to users when they select a CRS which has
low accuracy.

.. seealso:: :py:func:`showDatumEnsembleWarnings`
.. seealso:: :py:func:`showAccuracyWarnings`

.. versionadded:: 3.20
%End
Expand Down
2 changes: 1 addition & 1 deletion src/app/dwg/qgsdwgimportdialog.cpp
Expand Up @@ -81,7 +81,7 @@ QgsDwgImportDialog::QgsDwgImportDialog( QWidget *parent, Qt::WindowFlags f )

int crsid = s.value( QStringLiteral( "/DwgImport/lastCrs" ), QString::number( QgsProject::instance()->crs().srsid() ) ).toInt();

mCrsSelector->setShowDatumEnsembleWarnings( true );
mCrsSelector->showAccuracyWarnings( true );
QgsCoordinateReferenceSystem crs;
crs.createFromSrsId( crsid );
mCrsSelector->setCrs( crs );
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsalignrasterdialog.cpp
Expand Up @@ -84,7 +84,7 @@ QgsAlignRasterDialog::QgsAlignRasterDialog( QWidget *parent )
mAlign = new QgsAlignRaster;
mAlign->setProgressHandler( new QgsAlignRasterDialogProgress( mProgress ) );

mCrsSelector->setShowDatumEnsembleWarnings( true );
mCrsSelector->showAccuracyWarnings( true );

connect( mBtnAdd, &QAbstractButton::clicked, this, &QgsAlignRasterDialog::addLayer );
connect( mBtnRemove, &QAbstractButton::clicked, this, &QgsAlignRasterDialog::removeLayer );
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsdxfexportdialog.cpp
Expand Up @@ -491,7 +491,7 @@ QgsDxfExportDialog::QgsDxfExportDialog( QWidget *parent, Qt::WindowFlags f )
mCRS = QgsCoordinateReferenceSystem::fromSrsId( crsid );
mCrsSelector->setCrs( mCRS );
mCrsSelector->setLayerCrs( mCRS );
mCrsSelector->setShowDatumEnsembleWarnings( true );
mCrsSelector->showAccuracyWarnings( true );
mCrsSelector->setMessage( tr( "Select the coordinate reference system for the dxf file. "
"The data points will be transformed from the layer coordinate reference system." ) );

Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsrastercalcdialog.cpp
Expand Up @@ -80,7 +80,7 @@ QgsRasterCalcDialog::QgsRasterCalcDialog( QgsRasterLayer *rasterLayer, QWidget *
setExtentSize( rasterLayer->width(), rasterLayer->height(), rasterLayer->extent() );
mCrsSelector->setCrs( rasterLayer->crs() );
}
mCrsSelector->setShowDatumEnsembleWarnings( true );
mCrsSelector->showAccuracyWarnings( true );

mButtonBox->button( QDialogButtonBox::Ok )->setEnabled( false );

Expand Down
2 changes: 1 addition & 1 deletion src/gui/ogr/qgsvectorlayersaveasdialog.cpp
Expand Up @@ -201,7 +201,7 @@ void QgsVectorLayerSaveAsDialog::setup()
mButtonBox->button( QDialogButtonBox::Ok )->setEnabled( !filePath.isEmpty() );
} );

mCrsSelector->setShowDatumEnsembleWarnings( true );
mCrsSelector->showAccuracyWarnings( true );
}

QList<QPair<QLabel *, QWidget *> > QgsVectorLayerSaveAsDialog::createControls( const QMap<QString, QgsVectorFileWriter::Option *> &options )
Expand Down
2 changes: 1 addition & 1 deletion src/gui/processing/qgsprocessingwidgetwrapperimpl.cpp
Expand Up @@ -254,7 +254,7 @@ QgsProcessingCrsParameterDefinitionWidget::QgsProcessingCrsParameterDefinitionWi
mCrsSelector = new QgsProjectionSelectionWidget();

// possibly we should expose this for parameter by parameter control
mCrsSelector->setShowDatumEnsembleWarnings( true );
mCrsSelector->showAccuracyWarnings( true );

if ( const QgsProcessingParameterCrs *crsParam = dynamic_cast<const QgsProcessingParameterCrs *>( definition ) )
mCrsSelector->setCrs( QgsProcessingParameters::parameterAsCrs( crsParam, crsParam->defaultValueForGui(), context ) );
Expand Down
2 changes: 1 addition & 1 deletion src/gui/qgsnewgeopackagelayerdialog.cpp
Expand Up @@ -100,7 +100,7 @@ QgsNewGeoPackageLayerDialog::QgsNewGeoPackageLayerDialog( QWidget *parent, Qt::W
mFeatureIdColumnEdit->setPlaceholderText( QStringLiteral( DEFAULT_OGR_FID_COLUMN_TITLE ) );
mCheckBoxCreateSpatialIndex->setEnabled( false );
mCrsSelector->setEnabled( false );
mCrsSelector->setShowDatumEnsembleWarnings( true );
mCrsSelector->showAccuracyWarnings( true );

mFieldTypeBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconFieldText.svg" ) ), tr( "Text Data" ), "text" );
mFieldTypeBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconFieldInteger.svg" ) ), tr( "Whole Number (integer)" ), "integer" );
Expand Down
2 changes: 1 addition & 1 deletion src/gui/qgsnewmemorylayerdialog.cpp
Expand Up @@ -80,7 +80,7 @@ QgsNewMemoryLayerDialog::QgsNewMemoryLayerDialog( QWidget *parent, Qt::WindowFla
mGeometryWithZCheckBox->setEnabled( false );
mGeometryWithMCheckBox->setEnabled( false );
mCrsSelector->setEnabled( false );
mCrsSelector->setShowDatumEnsembleWarnings( true );
mCrsSelector->showAccuracyWarnings( true );

mTypeBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconFieldText.svg" ) ), tr( "Text" ), "string" );
mTypeBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconFieldInteger.svg" ) ), tr( "Whole Number" ), "integer" );
Expand Down
2 changes: 1 addition & 1 deletion src/gui/qgsnewvectorlayerdialog.cpp
Expand Up @@ -87,7 +87,7 @@ QgsNewVectorLayerDialog::QgsNewVectorLayerDialog( QWidget *parent, Qt::WindowFla
mFileFormatLabel->setVisible( false );
}

mCrsSelector->setShowDatumEnsembleWarnings( true );
mCrsSelector->showAccuracyWarnings( true );

mFileFormatComboBox->setCurrentIndex( 0 );

Expand Down
2 changes: 1 addition & 1 deletion src/gui/qgsnewvectortabledialog.cpp
Expand Up @@ -137,7 +137,7 @@ QgsNewVectorTableDialog::QgsNewVectorTableDialog( QgsAbstractDatabaseProviderCon
validate();
} );

mCrs->setShowDatumEnsembleWarnings( true );
mCrs->showAccuracyWarnings( true );

// geometry types
const bool hasSinglePart { conn->geometryColumnCapabilities().testFlag( QgsAbstractDatabaseProviderConnection::GeometryColumnCapability::SinglePart ) };
Expand Down
12 changes: 6 additions & 6 deletions src/gui/qgsprojectionselectionwidget.cpp
Expand Up @@ -289,15 +289,15 @@ void QgsProjectionSelectionWidget::dropEvent( QDropEvent *event )
update();
}

bool QgsProjectionSelectionWidget::showDatumEnsembleWarnings() const
bool QgsProjectionSelectionWidget::showAccuracyWarnings() const
{
return mShowDatumEnsembleWarnings;
return mShowAccuracyWarnings;
}

void QgsProjectionSelectionWidget::setShowDatumEnsembleWarnings( bool showDatumEnsembleWarnings )
void QgsProjectionSelectionWidget::showAccuracyWarnings( bool show )
{
mShowDatumEnsembleWarnings = showDatumEnsembleWarnings;
if ( !mShowDatumEnsembleWarnings )
mShowAccuracyWarnings = show;
if ( !mShowAccuracyWarnings )
mWarningLabelContainer->hide();
else
updateWarning();
Expand Down Expand Up @@ -343,7 +343,7 @@ void QgsProjectionSelectionWidget::comboIndexChanged( int idx )

void QgsProjectionSelectionWidget::updateWarning()
{
if ( !mShowDatumEnsembleWarnings )
if ( !mShowAccuracyWarnings )
{
if ( mWarningLabelContainer->isVisible() )
mWarningLabelContainer->hide();
Expand Down
22 changes: 9 additions & 13 deletions src/gui/qgsprojectionselectionwidget.h
Expand Up @@ -102,26 +102,22 @@ class GUI_EXPORT QgsProjectionSelectionWidget : public QWidget
static QString crsOptionText( const QgsCoordinateReferenceSystem &crs ) SIP_SKIP;

/**
* Returns TRUE if the widget will show a warning to users when they select a CRS which uses
* a datum ensemble.
* Returns TRUE if the widget will show a warning to users when they select a CRS which has
* low accuracy.
*
* \warning Determining datum ensembles requires PROJ 8.0 or later.
*
* \see setShowDatumEnsembleWarnings()
* \see showAccuracyWarnings()
* \since QGIS 3.20
*/
bool showDatumEnsembleWarnings() const;
bool showAccuracyWarnings() const;

/**
* Sets whether the widget will show a warning to users when they select a CRS which uses
* a datum ensemble.
*
* \warning Determining datum ensembles requires PROJ 8.0 or later.
* Sets whether the widget will \a show warnings to users when they select a CRS which has
* low accuracy.
*
* \see showDatumEnsembleWarnings()
* \see showAccuracyWarnings()
* \since QGIS 3.20
*/
void setShowDatumEnsembleWarnings( bool showDatumEnsembleWarnings );
void showAccuracyWarnings( bool show );

signals:

Expand Down Expand Up @@ -174,7 +170,7 @@ class GUI_EXPORT QgsProjectionSelectionWidget : public QWidget
QString mNotSetText;
QString mMessage;

bool mShowDatumEnsembleWarnings = false;
bool mShowAccuracyWarnings = false;
QWidget *mWarningLabelContainer = nullptr;
QLabel *mWarningLabel = nullptr;

Expand Down
2 changes: 1 addition & 1 deletion src/gui/qgsrasterlayersaveasdialog.cpp
Expand Up @@ -140,7 +140,7 @@ QgsRasterLayerSaveAsDialog::QgsRasterLayerSaveAsDialog( QgsRasterLayer *rasterLa
// don't restore nodata, it needs user input
// pyramids are not necessarily built every time

mCrsSelector->setShowDatumEnsembleWarnings( true );
mCrsSelector->showAccuracyWarnings( true );

mCrsSelector->setLayerCrs( mLayerCrs );
//default to layer CRS - see https://github.com/qgis/QGIS/issues/22211 for discussion
Expand Down

0 comments on commit 7724b37

Please sign in to comment.