VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox4/include/QIWidgetValidator.h@ 14339

Last change on this file since 14339 was 14339, checked in by vboxsync, 16 years ago

FE/Qt4: 2405: Stricter RAM size checks. Feature implemented.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.2 KB
Line 
1/** @file
2 *
3 * VBox frontends: Qt GUI ("VirtualBox"):
4 * VirtualBox Qt extensions: QIWidgetValidator class declaration
5 */
6
7/*
8 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
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 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
19 * Clara, CA 95054 USA or visit http://www.sun.com if you need
20 * additional information or have any questions.
21 */
22
23#ifndef __QIWidgetValidator_h__
24#define __QIWidgetValidator_h__
25
26#include <limits.h>
27
28/* Qt includes */
29#include <QObject>
30#include <QValidator>
31#include <QList>
32
33class QIWidgetValidator : public QObject
34{
35 Q_OBJECT
36
37public:
38
39 QIWidgetValidator (QWidget *aWidget, QObject *aParent = 0);
40 QIWidgetValidator (const QString &aCaption,
41 QWidget *aWidget, QObject *aParent = 0);
42 ~QIWidgetValidator();
43
44 QWidget *widget() const { return mWidget; }
45 bool isValid() const;
46 void rescan();
47
48 void setCaption (const QString& aCaption) { mCaption = aCaption; }
49 QString caption() const { return mCaption; }
50
51 QString warningText() const;
52
53 QString lastWarning() const { return mLastWarning; }
54 void setLastWarning (const QString &aLastWarning) { mLastWarning = aLastWarning; }
55
56 void setOtherValid (bool aValid) { mOtherValid = aValid; }
57 bool isOtherValid() const { return mOtherValid; }
58
59signals:
60
61 void validityChanged (const QIWidgetValidator *aValidator);
62 void isValidRequested (QIWidgetValidator *aValidator);
63
64public slots:
65
66 void revalidate() { doRevalidate(); }
67
68private:
69
70 QString mLastWarning;
71 QString mCaption;
72 QWidget *mWidget;
73 bool mOtherValid;
74
75 struct Watched
76 {
77 Watched()
78 : widget (NULL), buddy (NULL)
79 , state (QValidator::Acceptable) {}
80
81 QWidget *widget;
82 QWidget *buddy;
83 QValidator::State state;
84 };
85
86 QList <Watched> mWatched;
87 Watched mLastInvalid;
88
89private slots:
90
91 void doRevalidate() { emit validityChanged (this); }
92};
93
94class QIULongValidator : public QValidator
95{
96public:
97
98 QIULongValidator (QObject *aParent)
99 : QValidator (aParent)
100 , mBottom (0), mTop (ULONG_MAX) {}
101
102 QIULongValidator (ulong aMinimum, ulong aMaximum,
103 QObject *aParent)
104 : QValidator (aParent)
105 , mBottom (aMinimum), mTop (aMaximum) {}
106
107 ~QIULongValidator() {}
108
109 State validate (QString &aInput, int &aPos) const;
110 void setBottom (ulong aBottom) { setRange (aBottom, mTop); }
111 void setTop (ulong aTop) { setRange (mBottom, aTop); }
112 void setRange (ulong aBottom, ulong aTop) { mBottom = aBottom; mTop = aTop; }
113 ulong bottom() const { return mBottom; }
114 ulong top() const { return mTop; }
115
116private:
117
118 ulong mBottom;
119 ulong mTop;
120};
121
122#endif // __QIWidgetValidator_h__
123
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette