Skip to content

Commit

Permalink
qgsprojectelevationsettingswidget: Check elevation range values
Browse files Browse the repository at this point in the history
Make the widget invalid if the elevation lower value if greater than
the upper one.
  • Loading branch information
ptitjano committed Nov 21, 2024
1 parent a27eb86 commit 5645514
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/app/project/qgsprojectelevationsettingswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ QgsProjectElevationSettingsWidget::QgsProjectElevationSettingsWidget( QWidget *p
else
whileBlocking( mElevationUpperSpin )->clear();

connect( mElevationLowerSpin, qOverload<double>( &QgsDoubleSpinBox::valueChanged ), this, &QgsProjectElevationSettingsWidget::validate );
connect( mElevationUpperSpin, qOverload<double>( &QgsDoubleSpinBox::valueChanged ), this, &QgsProjectElevationSettingsWidget::validate );

updateVerticalCrsOptions();
connect( QgsProject::instance(), &QgsProject::crsChanged, this, &QgsProjectElevationSettingsWidget::updateVerticalCrsOptions );

Expand Down Expand Up @@ -241,6 +244,15 @@ bool QgsProjectElevationSettingsWidget::validate()
mMessageBar->pushMessage( tr( "An elevation layer must be selected for a mesh terrain" ), Qgis::MessageLevel::Critical );
}
}

// Show an error message if the lower value is greater than the upper one
// However, do not show the error message if one of the values is not set
if ( !mElevationLowerSpin->isCleared() && !mElevationUpperSpin->isCleared() && ( mElevationLowerSpin->value() >= mElevationUpperSpin->value() ) )
{
valid = false;
mMessageBar->pushMessage( tr( "Upper elevation range must be greater than the lower one" ), Qgis::MessageLevel::Critical );
}

return valid;
}

Expand Down

0 comments on commit 5645514

Please sign in to comment.