source: trunk/FACT++/gui/SpinBox4ns.h@ 10483

Last change on this file since 10483 was 10468, checked in by tbretz, 13 years ago
Just code cosmetics.
File size: 842 bytes
Line 
1#include <QtGui/QSpinBox>
2
3class SpinBox4ns : public QSpinBox
4{
5public:
6 SpinBox4ns(QWidget *p) : QSpinBox(p)
7 {
8 }
9
10 QValidator::State validate(QString &input, int &p) const
11 {
12 const QValidator::State rc = QSpinBox::validate(input, p);
13 if (rc!=QValidator::Acceptable)
14 return rc;
15
16 const int pf = prefix().length();
17 const int sf = suffix().length();
18 const int len = input.length();
19
20 return input.mid(pf, len-sf-pf).toUInt()%4==0 ? QValidator::Acceptable : QValidator::Intermediate;
21 }
22
23 void fixup(QString &input) const
24 {
25 const int pf = prefix().length();
26 const int sf = suffix().length();
27 const int len = input.length();
28
29 const uint i = input.mid(pf, len-pf-sf).toUInt()+2;
30 input = QString::number((i/4)*4);
31 }
32};
Note: See TracBrowser for help on using the repository browser.