diff options
| author | tony mancill <tmancill@debian.org> | 2026-04-12 08:46:47 -0700 |
|---|---|---|
| committer | tony mancill <tmancill@debian.org> | 2026-04-12 08:46:47 -0700 |
| commit | cd2dad3bc7ae0ee0a18b7b20a945009362ec3851 (patch) | |
| tree | 5a622ec4193e9bc899f6499f936848a661be29cb /widgets/HintedSpinBox.cpp | |
| parent | 558c0b9d6ecf70c5222e2069ece1fea3656c75d7 (diff) | |
| parent | 291b3817bf0c7a742e9e17d42c94fc8c9530e40d (diff) | |
Merge branch 'debian/latest' into debian/trixie-backports
Diffstat (limited to 'widgets/HintedSpinBox.cpp')
| -rw-r--r--[-rwxr-xr-x] | widgets/HintedSpinBox.cpp | 110 |
1 files changed, 55 insertions, 55 deletions
diff --git a/widgets/HintedSpinBox.cpp b/widgets/HintedSpinBox.cpp index 3b7d1336..25ffcc71 100755..100644 --- a/widgets/HintedSpinBox.cpp +++ b/widgets/HintedSpinBox.cpp @@ -1,55 +1,55 @@ -#include "HintedSpinBox.hpp"
-
-#include <algorithm>
-
-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 <algorithm> + +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 + } +} |
