File: HintedSpinBox.hpp

package info (click to toggle)
wsjtx-improved 3.0.0%2B250924%2Brepack-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 86,260 kB
  • sloc: cpp: 105,882; f90: 60,117; python: 27,241; ansic: 13,372; fortran: 2,382; makefile: 197; sh: 135
file content (53 lines) | stat: -rwxr-xr-x 1,419 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#ifndef HINTED_SPIN_BOX_HPP_
#define HINTED_SPIN_BOX_HPP_

#include <vector>

#include <QSpinBox>

//
// HintedSpinBox - QSpinBox refinement with an optional sequence of
//                 discrete hints
//
//  The  hint  sequence  values  are  used  as  step  values  and  can
//  optionally  define the  minimum and  maximum value.   Intermediate
//  values are  allowed but  the step  up/down arrows  and accelerator
//  keys will only use the hints.
//
//  Ensure that the default minimum  and maximum values are sufficient
//  to allow initial initialization if done before the hints are set.
//
class HintedSpinBox
  : public QSpinBox
{
public:
  typedef std::vector<int> values_type;

  HintedSpinBox (QWidget * parent = nullptr)
    : QSpinBox {parent}
  {
  }

  // Initialize sequence of values allowed.
  //
  // This  spin box  behaves exactly  as  a standard  QSpinBox if  the
  // sequence of values is empty.
  //
  // The minimum and  maximum are automatically set to  the lowest and
  // highest value provided if required.
  //
  // Returns the previous sequence.
  values_type values (values_type values, bool set_min_max = true);

  // Read access to the values.
  values_type const& values () const {return values_;}

protected:
  // override the QSpinBox stepping
  void stepBy (int steps) override;

private:
  values_type values_;
};

#endif