-
Notifications
You must be signed in to change notification settings - Fork 0
/
IntRangeLineEdit.h
46 lines (38 loc) · 1.05 KB
/
IntRangeLineEdit.h
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
#ifndef INTRANGELINEEDIT_H
#define INTRANGELINEEDIT_H
#include <QString>
#include <QFocusEvent>
#include <QIntValidator>
#include <QWidget>
#include <QLineEdit>
enum IntRangeLineEditFocusType {
Out,
In,
Both
};
class IntRangeLineEdit : public QLineEdit
{
Q_OBJECT
public:
IntRangeLineEdit (QWidget *parent = 0,
IntRangeLineEditFocusType focusType = IntRangeLineEditFocusType::Out,
QString id = nullptr, int defaultValue = 0, int lower = 0, int upper = 1);
~IntRangeLineEdit ();
QString getValidationError();
int getLastValue();
void setNewValue(int newValue);
QString *getId();
int getIntValue();
unsigned long getLongValue();
signals:
void focussed(IntRangeLineEdit *le, bool hasFocus, int value);
protected:
virtual void focusInEvent(QFocusEvent *e);
virtual void focusOutEvent(QFocusEvent *e);
private:
int lower, upper, lastValue;
QString *id;
QString *cachedError = nullptr;
IntRangeLineEditFocusType focusType;
};
#endif // INTRANGELINEEDIT_H