Gui: Use std::numeric_limits and std::numbers instead of defines

This commit is contained in:
Benjamin Nauck
2025-03-27 18:59:58 +01:00
parent ae686942a7
commit 34bc1d45ea
33 changed files with 204 additions and 168 deletions

View File

@@ -238,7 +238,7 @@ UnsignedValidator::UnsignedValidator( QObject * parent )
: QValidator( parent )
{
b = 0;
t = UINT_MAX;
t = std::numeric_limits<unsigned>::max();
}
UnsignedValidator::UnsignedValidator( uint minimum, uint maximum, QObject * parent )
@@ -295,27 +295,31 @@ public:
uint mapToUInt( int v ) const
{
uint ui;
if ( v == INT_MIN ) {
if ( v == std::numeric_limits<int>::min() ) {
ui = 0;
} else if ( v == INT_MAX ) {
ui = UINT_MAX;
} else if ( v == std::numeric_limits<int>::max() ) {
ui = std::numeric_limits<unsigned>::max();
} else if ( v < 0 ) {
v -= INT_MIN; ui = (uint)v;
v -= std::numeric_limits<int>::min();
ui = static_cast<uint>(v);
} else {
ui = (uint)v; ui -= INT_MIN;
ui = static_cast<uint>(v);
ui -= std::numeric_limits<int>::min();
} return ui;
}
int mapToInt( uint v ) const
{
int in;
if ( v == UINT_MAX ) {
in = INT_MAX;
if ( v == std::numeric_limits<unsigned>::max() ) {
in = std::numeric_limits<int>::max();
} else if ( v == 0 ) {
in = INT_MIN;
} else if ( v > INT_MAX ) {
v += INT_MIN; in = (int)v;
in = std::numeric_limits<int>::min();
} else if ( v > std::numeric_limits<int>::max() ) {
v += std::numeric_limits<int>::min();
in = static_cast<int>(v);
} else {
in = v; in += INT_MIN;
in = v;
in += std::numeric_limits<int>::min();
} return in;
}
};