Removes QIntValidator and uses setRange

Replaces the usage of `QIntValidator` with the `setRange` function available in the PDM framework for limiting integer input in UI fields.
This approach provides a more direct and maintainable way to specify value ranges for UI elements.

This change simplifies the code and reduces dependencies.
This commit is contained in:
Magne Sjaastad
2025-12-22 10:17:00 +01:00
parent 4488a7215d
commit 405a32e2da
16 changed files with 42 additions and 143 deletions
@@ -15,6 +15,7 @@
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RimWellPathCompletionSettings.h"
#include "RiaStdStringTools.h"
@@ -101,6 +102,8 @@ RimWellPathCompletionSettings::RimWellPathCompletionSettings()
"WellBoreFluidPvtTable",
0,
"Wellbore Fluid PVT table" );
m_wellBoreFluidPVTTable.setMinValue( 0 );
CAF_PDM_InitScriptableFieldNoDefault( &m_hydrostaticDensity, "HydrostaticDensity", "Hydrostatic Density" );
CAF_PDM_InitScriptableField( &m_fluidInPlaceRegion, "FluidInPlaceRegion", 0, "Fluid In-Place Region" );
@@ -409,28 +412,6 @@ void RimWellPathCompletionSettings::fieldChangedByUi( const caf::PdmFieldHandle*
m_mswParameters->fieldChangedByUi( changedField, oldValue, newValue );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellPathCompletionSettings::defineEditorAttribute( const caf::PdmFieldHandle* field,
QString uiConfigName,
caf::PdmUiEditorAttribute* attribute )
{
caf::PdmUiLineEditorAttribute* lineEditorAttr = dynamic_cast<caf::PdmUiLineEditorAttribute*>( attribute );
if ( field == &m_wellBoreFluidPVTTable && lineEditorAttr )
{
// Positive integer
QIntValidator* validator = new QIntValidator( 0, std::numeric_limits<int>::max(), nullptr );
lineEditorAttr->validator = validator;
}
else if ( field == &m_fluidInPlaceRegion && lineEditorAttr )
{
// Any integer
QIntValidator* validator = new QIntValidator( -std::numeric_limits<int>::max(), std::numeric_limits<int>::max(), nullptr );
lineEditorAttr->validator = validator;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------