From f647d78463c1250ce9c99af664615fafccf5e959 Mon Sep 17 00:00:00 2001 From: Christoph Berg Date: Tue, 7 Apr 2026 19:02:45 +0200 Subject: New upstream version 3.0.0 --- widgets/HintedSpinBox.cpp | 110 +++++++++++++++++++++++----------------------- 1 file changed, 55 insertions(+), 55 deletions(-) mode change 100755 => 100644 widgets/HintedSpinBox.cpp (limited to 'widgets/HintedSpinBox.cpp') diff --git a/widgets/HintedSpinBox.cpp b/widgets/HintedSpinBox.cpp old mode 100755 new mode 100644 index 3b7d1336..25ffcc71 --- a/widgets/HintedSpinBox.cpp +++ b/widgets/HintedSpinBox.cpp @@ -1,55 +1,55 @@ -#include "HintedSpinBox.hpp" - -#include - -auto HintedSpinBox::values (values_type values, bool set_min_max) -> values_type -{ - // replace any prior values - std::swap (values, values_); - - // sort values and make unique - std::sort (values_.begin (), values_.end ()); - auto last = std::unique (values_.begin (), values_.end ()); - values_.erase (last, values_.end ()); - if (set_min_max) - { - setMinimum (values_.front ()); - setMaximum (values_.back ()); - } - return values; // return old values -} - -void HintedSpinBox::stepBy (int steps) -{ - if (values_.size ()) - { - if (steps > 0) - { - auto p = std::upper_bound (values_.begin (), values_.end (), value ()); - if (p != values_.end () && *p <= maximum ()) - { - setValue (*p); - } - else if (wrapping ()) - { - setValue (values_.front ()); - } - } - else if (steps < 0) - { - auto p = std::lower_bound (values_.begin (), values_.end (), value ()); - if (p != values_.begin () && *(p - 1) >= minimum ()) - { - setValue (*(p - 1)); - } - else if (wrapping ()) - { - setValue (values_.back ()); - } - } - } - else - { - QSpinBox::stepBy (steps); // no values so revert to QSpinBox behaviour - } -} +#include "HintedSpinBox.hpp" + +#include + +auto HintedSpinBox::values (values_type values, bool set_min_max) -> values_type +{ + // replace any prior values + std::swap (values, values_); + + // sort values and make unique + std::sort (values_.begin (), values_.end ()); + auto last = std::unique (values_.begin (), values_.end ()); + values_.erase (last, values_.end ()); + if (set_min_max) + { + setMinimum (values_.front ()); + setMaximum (values_.back ()); + } + return values; // return old values +} + +void HintedSpinBox::stepBy (int steps) +{ + if (values_.size ()) + { + if (steps > 0) + { + auto p = std::upper_bound (values_.begin (), values_.end (), value ()); + if (p != values_.end () && *p <= maximum ()) + { + setValue (*p); + } + else if (wrapping ()) + { + setValue (values_.front ()); + } + } + else if (steps < 0) + { + auto p = std::lower_bound (values_.begin (), values_.end (), value ()); + if (p != values_.begin () && *(p - 1) >= minimum ()) + { + setValue (*(p - 1)); + } + else if (wrapping ()) + { + setValue (values_.back ()); + } + } + } + else + { + QSpinBox::stepBy (steps); // no values so revert to QSpinBox behaviour + } +} -- cgit v1.2.3