1 | /** @file
|
---|
2 | *
|
---|
3 | * VBox frontends: Qt GUI ("VirtualBox"):
|
---|
4 | * VirtualBox Qt extensions: QIWidgetValidator class declaration
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2006-2012 Oracle Corporation
|
---|
9 | *
|
---|
10 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
11 | * available from http://www.virtualbox.org. This file is free software;
|
---|
12 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
13 | * General Public License (GPL) as published by the Free Software
|
---|
14 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
15 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
16 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
17 | */
|
---|
18 |
|
---|
19 | #ifndef __QIWidgetValidator_h__
|
---|
20 | #define __QIWidgetValidator_h__
|
---|
21 |
|
---|
22 | /* Qt includes: */
|
---|
23 | #include <QValidator>
|
---|
24 |
|
---|
25 | /* Forward declarations: */
|
---|
26 | class UISettingsPage;
|
---|
27 |
|
---|
28 | /* Page validator prototype: */
|
---|
29 | class UIPageValidator : public QObject
|
---|
30 | {
|
---|
31 | Q_OBJECT;
|
---|
32 |
|
---|
33 | signals:
|
---|
34 |
|
---|
35 | /* Notifier: Validation stuff: */
|
---|
36 | void sigValidityChanged(UIPageValidator *pValidator);
|
---|
37 |
|
---|
38 | public:
|
---|
39 |
|
---|
40 | /* Constructor: */
|
---|
41 | UIPageValidator(QObject *pParent, UISettingsPage *pPage);
|
---|
42 |
|
---|
43 | /* API: Page stuff: */
|
---|
44 | UISettingsPage* page() const { return m_pPage; }
|
---|
45 |
|
---|
46 | /* API: Validity stuff: */
|
---|
47 | bool isValid() const { return m_fIsValid; }
|
---|
48 | void setValid(bool fIsValid) { m_fIsValid = fIsValid; }
|
---|
49 |
|
---|
50 | /* API: Message stuff: */
|
---|
51 | QString lastMessage() const { return m_strLastMessage; }
|
---|
52 | void setLastMessage(const QString &strLastMessage) { m_strLastMessage = strLastMessage; }
|
---|
53 |
|
---|
54 | public slots:
|
---|
55 |
|
---|
56 | /* API/Handler: Validation stuff: */
|
---|
57 | void revalidate();
|
---|
58 |
|
---|
59 | private:
|
---|
60 |
|
---|
61 | /* Variables: */
|
---|
62 | UISettingsPage *m_pPage;
|
---|
63 | bool m_fIsValid;
|
---|
64 | QString m_strLastMessage;
|
---|
65 | };
|
---|
66 |
|
---|
67 | class QIULongValidator : public QValidator
|
---|
68 | {
|
---|
69 | public:
|
---|
70 |
|
---|
71 | QIULongValidator (QObject *aParent)
|
---|
72 | : QValidator (aParent)
|
---|
73 | , mBottom (0), mTop (ULONG_MAX) {}
|
---|
74 |
|
---|
75 | QIULongValidator (ulong aMinimum, ulong aMaximum,
|
---|
76 | QObject *aParent)
|
---|
77 | : QValidator (aParent)
|
---|
78 | , mBottom (aMinimum), mTop (aMaximum) {}
|
---|
79 |
|
---|
80 | ~QIULongValidator() {}
|
---|
81 |
|
---|
82 | State validate (QString &aInput, int &aPos) const;
|
---|
83 | void setBottom (ulong aBottom) { setRange (aBottom, mTop); }
|
---|
84 | void setTop (ulong aTop) { setRange (mBottom, aTop); }
|
---|
85 | void setRange (ulong aBottom, ulong aTop) { mBottom = aBottom; mTop = aTop; }
|
---|
86 | ulong bottom() const { return mBottom; }
|
---|
87 | ulong top() const { return mTop; }
|
---|
88 |
|
---|
89 | private:
|
---|
90 |
|
---|
91 | ulong mBottom;
|
---|
92 | ulong mTop;
|
---|
93 | };
|
---|
94 |
|
---|
95 | #endif // __QIWidgetValidator_h__
|
---|