-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathformvalidator.h
50 lines (38 loc) · 1.01 KB
/
formvalidator.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
47
48
49
50
#ifndef INPUTVIEWVALIDATOR_H
#define INPUTVIEWVALIDATOR_H
#include <QObject>
#include <QVector>
class QWidget;
class QSpinBox;
class QLineEdit;
class QComboBox;
class ValidityRule {
public:
virtual bool isValid(const QWidget* widget) const = 0;
};
typedef QVector<ValidityRule*> ValidityRules;
class FormValidatorPrivate;
// TODO: rename to FormValidator
class FormValidator : public QObject
{
Q_OBJECT
public:
FormValidator();
~FormValidator();
bool isValidationEnabled() const;
void setAutoFocusEnabled(bool enabled);
bool isAutoFocusEnabled() const;
void appendView(QSpinBox* w, ValidityRules rules);
void appendView(QLineEdit* w, ValidityRules rules);
void appendView(QComboBox* w, ValidityRules rules);
bool validate(QWidget* widget);
public Q_SLOTS:
bool validateAll();
void stopValidation();
void startValidation();
private:
FormValidatorPrivate* d_ptr;
Q_DECLARE_PRIVATE(FormValidator)
Q_DISABLE_COPY(FormValidator)
};
#endif // INPUTVIEWVALIDATOR_H