summaryrefslogtreecommitdiff
path: root/widgets/HintedSpinBox.cpp
diff options
context:
space:
mode:
authorChristoph Berg <myon@debian.org>2025-01-09 22:12:12 +0100
committerChristoph Berg <myon@debian.org>2025-01-09 22:12:12 +0100
commit98c02f78b26811ba5d9962ba27ec24cacf82bb22 (patch)
treedaaf609cde31d8fb3b6c3457c43663d14f0dda80 /widgets/HintedSpinBox.cpp
parent332d2ce88c2f0bc2908cacdc6707e2f9fa49f26d (diff)
parent992d4b4b8d3f3a630a2cf00d593ee4ce4dfa7ce8 (diff)
Update upstream source from tag 'upstream/2.7.0_rc8+repack'
Update to upstream version '2.7.0~rc8+repack' with Debian dir 6fce941c8282d35c8df23d3de779a42e27688bc1
Diffstat (limited to 'widgets/HintedSpinBox.cpp')
-rwxr-xr-xwidgets/HintedSpinBox.cpp110
1 files changed, 55 insertions, 55 deletions
diff --git a/widgets/HintedSpinBox.cpp b/widgets/HintedSpinBox.cpp
index 3b7d1336..25ffcc71 100755
--- 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
+ }
+}