VirtualBox

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

Last change on this file since 9576 was 8170, checked in by vboxsync, 17 years ago

Rebranding: replacing more innotek strings.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.9 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 QString warningText() const;
49
50 void setOtherValid (bool aValid) { mOtherValid = aValid; }
51 bool isOtherValid() const { return mOtherValid; }
52
53signals:
54
55 void validityChanged (const QIWidgetValidator *aValidator);
56 void isValidRequested (QIWidgetValidator *aValidator);
57
58public slots:
59
60 void revalidate() { doRevalidate(); }
61
62private:
63
64 QString mCaption;
65 QWidget *mWidget;
66 bool mOtherValid;
67
68 struct Watched
69 {
70 Watched()
71 : widget (NULL), buddy (NULL)
72 , state (QValidator::Acceptable) {}
73
74 QWidget *widget;
75 QWidget *buddy;
76 QValidator::State state;
77 };
78
79 QList <Watched> mWatched;
80 Watched mLastInvalid;
81
82private slots:
83
84 void doRevalidate() { emit validityChanged (this); }
85};
86
87class QIULongValidator : public QValidator
88{
89public:
90
91 QIULongValidator (QObject *aParent)
92 : QValidator (aParent)
93 , mBottom (0), mTop (ULONG_MAX) {}
94
95 QIULongValidator (ulong aMinimum, ulong aMaximum,
96 QObject *aParent)
97 : QValidator (aParent)
98 , mBottom (aMinimum), mTop (aMaximum) {}
99
100 ~QIULongValidator() {}
101
102 State validate (QString &aInput, int &aPos) const;
103 void setBottom (ulong aBottom) { setRange (aBottom, mTop); }
104 void setTop (ulong aTop) { setRange (mBottom, aTop); }
105 void setRange (ulong aBottom, ulong aTop) { mBottom = aBottom; mTop = aTop; }
106 ulong bottom() const { return mBottom; }
107 ulong top() const { return mTop; }
108
109private:
110
111 ulong mBottom;
112 ulong mTop;
113};
114
115#endif // __QIWidgetValidator_h__
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