FACT++  1.0
SpinBox4ns.h
Go to the documentation of this file.
1 #ifndef FACT_SpinBox4ns
2 #define FACT_SpinBox4ns
3 
4 #include <QSpinBox>
5 
6 class SpinBox4ns : public QSpinBox
7 {
8 public:
9  SpinBox4ns(QWidget *p) : QSpinBox(p)
10  {
11  }
12 
13  QValidator::State validate(QString &input, int &p) const
14  {
15  const QValidator::State rc = QSpinBox::validate(input, p);
16  if (rc!=QValidator::Acceptable)
17  return rc;
18 
19  const int pf = prefix().length();
20  const int sf = suffix().length();
21  const int len = input.length();
22 
23  return input.mid(pf, len-sf-pf).toUInt()%4==0 ? QValidator::Acceptable : QValidator::Intermediate;
24  }
25 
26  void fixup(QString &input) const
27  {
28  const int pf = prefix().length();
29  const int sf = suffix().length();
30  const int len = input.length();
31 
32  const uint i = input.mid(pf, len-pf-sf).toUInt()+2;
33  input = QString::number((i/4)*4);
34  }
35 };
36 
37 #endif
38 
39 // **************************************************************************
45 // **************************************************************************
int i
Definition: db_dim_client.c:21
A QSpinBox which only accepts values dividable by 4.
Definition: SpinBox4ns.h:6
void fixup(QString &input) const
Definition: SpinBox4ns.h:26
SpinBox4ns(QWidget *p)
Definition: SpinBox4ns.h:9
QValidator::State validate(QString &input, int &p) const
Definition: SpinBox4ns.h:13