Skip to content
Permalink
Browse files

Merge pull request #9880 from troopa81/fix_pointpick_precision

Fix point picking precision for point parameters in processing dialog
  • Loading branch information
luipir committed Apr 30, 2019
2 parents a665eac + 9cfaf10 commit 0f01359b90f869f2f1a3fcda0c4543910d42c677
Showing with 21 additions and 14 deletions.
  1. +4 −1 src/gui/processing/qgsprocessingwidgetwrapperimpl.cpp
  2. +17 −13 tests/src/gui/testprocessinggui.cpp
@@ -2205,7 +2205,10 @@ void QgsProcessingPointPanel::clear()

void QgsProcessingPointPanel::setValue( const QgsPointXY &point, const QgsCoordinateReferenceSystem &crs )
{
QString newText = QStringLiteral( "%1,%2" ).arg( point.x() ).arg( point.y() );
QString newText = QStringLiteral( "%1,%2" )
.arg( QString::number( point.x(), 'f' ) )
.arg( QString::number( point.y(), 'f' ) );

mCrs = crs;
if ( mCrs.isValid() )
{
@@ -2834,26 +2834,30 @@ void TestProcessingGui::testPointPanel()
QSignalSpy spy( panel.get(), &QgsProcessingPointPanel::changed );

panel->setValue( QgsPointXY( 100, 150 ), QgsCoordinateReferenceSystem() );
QCOMPARE( panel->value().toString(), QStringLiteral( "100,150" ) );
QCOMPARE( panel->value().toString(), QStringLiteral( "100.000000,150.000000" ) );
QCOMPARE( spy.count(), 1 );

panel->setValue( QgsPointXY( 200, 250 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3111" ) ) );
QCOMPARE( panel->value().toString(), QStringLiteral( "200,250 [EPSG:3111]" ) );
QCOMPARE( panel->value().toString(), QStringLiteral( "200.000000,250.000000 [EPSG:3111]" ) );
QCOMPARE( spy.count(), 2 );

panel->setValue( QgsPointXY( 123456.123456789, 654321.987654321 ), QgsCoordinateReferenceSystem() );
QCOMPARE( panel->value().toString(), QStringLiteral( "123456.123457,654321.987654" ) );
QCOMPARE( spy.count(), 3 );

QVERIFY( !panel->mLineEdit->showClearButton() );
panel->setAllowNull( true );
QVERIFY( panel->mLineEdit->showClearButton() );
panel->clear();
QVERIFY( !panel->value().isValid() );
QCOMPARE( spy.count(), 3 );
QCOMPARE( spy.count(), 4 );

QgsMapCanvas canvas;
canvas.setDestinationCrs( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:28356" ) ) );
panel->setMapCanvas( &canvas );
panel->updatePoint( QgsPointXY( 1.5, -3.5 ) );
QCOMPARE( panel->value().toString(), QStringLiteral( "1.5,-3.5 [EPSG:28356]" ) );
QCOMPARE( spy.count(), 4 );
QCOMPARE( panel->value().toString(), QStringLiteral( "1.500000,-3.500000 [EPSG:28356]" ) );
QCOMPARE( spy.count(), 5 );

panel.reset();
}
@@ -2875,8 +2879,8 @@ void TestProcessingGui::testPointWrapper()
QCOMPARE( spy.count(), 1 );
if ( type != QgsProcessingGui::Modeler )
{
QCOMPARE( wrapper.widgetValue().toString(), QStringLiteral( "1,2" ) );
QCOMPARE( static_cast< QgsProcessingPointPanel * >( wrapper.wrappedWidget() )->mLineEdit->text(), QStringLiteral( "1,2" ) );
QCOMPARE( wrapper.widgetValue().toString(), QStringLiteral( "1.000000,2.000000" ) );
QCOMPARE( static_cast< QgsProcessingPointPanel * >( wrapper.wrappedWidget() )->mLineEdit->text(), QStringLiteral( "1.000000,2.000000" ) );
}
else
{
@@ -2887,8 +2891,8 @@ void TestProcessingGui::testPointWrapper()
QCOMPARE( spy.count(), 2 );
if ( type != QgsProcessingGui::Modeler )
{
QCOMPARE( wrapper.widgetValue().toString(), QStringLiteral( "1,2 [EPSG:3111]" ) );
QCOMPARE( static_cast< QgsProcessingPointPanel * >( wrapper.wrappedWidget() )->mLineEdit->text(), QStringLiteral( "1,2 [EPSG:3111]" ) );
QCOMPARE( wrapper.widgetValue().toString(), QStringLiteral( "1.000000,2.000000 [EPSG:3111]" ) );
QCOMPARE( static_cast< QgsProcessingPointPanel * >( wrapper.wrappedWidget() )->mLineEdit->text(), QStringLiteral( "1.000000,2.000000 [EPSG:3111]" ) );
}
else
{
@@ -2935,8 +2939,8 @@ void TestProcessingGui::testPointWrapper()
QCOMPARE( spy2.count(), 1 );
if ( type != QgsProcessingGui::Modeler )
{
QCOMPARE( static_cast< QgsProcessingPointPanel * >( wrapper2.wrappedWidget() )->mLineEdit->text(), QStringLiteral( "1,2" ) );
QCOMPARE( wrapper2.widgetValue().toString(), QStringLiteral( "1,2" ) );
QCOMPARE( static_cast< QgsProcessingPointPanel * >( wrapper2.wrappedWidget() )->mLineEdit->text(), QStringLiteral( "1.000000,2.000000" ) );
QCOMPARE( wrapper2.widgetValue().toString(), QStringLiteral( "1.000000,2.000000" ) );
}
else
{
@@ -2948,8 +2952,8 @@ void TestProcessingGui::testPointWrapper()
QCOMPARE( spy2.count(), 2 );
if ( type != QgsProcessingGui::Modeler )
{
QCOMPARE( wrapper2.widgetValue().toString(), QStringLiteral( "1,2 [EPSG:3111]" ) );
QCOMPARE( static_cast< QgsProcessingPointPanel * >( wrapper2.wrappedWidget() )->mLineEdit->text(), QStringLiteral( "1,2 [EPSG:3111]" ) );
QCOMPARE( wrapper2.widgetValue().toString(), QStringLiteral( "1.000000,2.000000 [EPSG:3111]" ) );
QCOMPARE( static_cast< QgsProcessingPointPanel * >( wrapper2.wrappedWidget() )->mLineEdit->text(), QStringLiteral( "1.000000,2.000000 [EPSG:3111]" ) );
}
else
{

0 comments on commit 0f01359

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