summaryrefslogtreecommitdiff
path: root/widgets/HintedSpinBox.cpp
diff options
context:
space:
mode:
authorChristoph Berg <christoph.berg@credativ.de>2022-08-23 10:23:31 +0200
committerChristoph Berg <christoph.berg@credativ.de>2022-08-23 10:23:31 +0200
commit0e579a45e2e5823f90e2632073749583cd15fa0d (patch)
tree5e709e13d41c8ea0da0968fb6c4566057b4b7909 /widgets/HintedSpinBox.cpp
parent28d1767618141cd6481de2e93e36e3dfa555d4b4 (diff)
parent2d1068e60bce7ae1fff11623454900e8cee956b1 (diff)
Update upstream source from tag 'upstream/2.6.0_rc3+repack'
Update to upstream version '2.6.0~rc3+repack' with Debian dir 9ee8bc3a4b60bb88f4d57c7d1f2d37dbc1632144
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 25ffcc71..3b7d1336 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
+ }
+}