VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIWidgetValidator.h@ 35740

Last change on this file since 35740 was 28800, checked in by vboxsync, 14 years ago

Automated rebranding to Oracle copyright/license strings via filemuncher

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.0 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 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#include <limits.h>
23
24/* Qt includes */
25#include <QObject>
26#include <QValidator>
27#include <QList>
28
29class QIWidgetValidator : public QObject
30{
31 Q_OBJECT
32
33public:
34
35 QIWidgetValidator (QWidget *aWidget, QObject *aParent = 0);
36 QIWidgetValidator (const QString &aCaption,
37 QWidget *aWidget, QObject *aParent = 0);
38 ~QIWidgetValidator();
39
40 QWidget *widget() const { return mWidget; }
41 bool isValid() const;
42 void rescan();
43
44 void setCaption (const QString& aCaption) { mCaption = aCaption; }
45 QString caption() const { return mCaption; }
46
47 QString warningText() const;
48
49 QString lastWarning() const { return mLastWarning; }
50 void setLastWarning (const QString &aLastWarning) { mLastWarning = aLastWarning; }
51
52 void setOtherValid (bool aValid) { mOtherValid = aValid; }
53 bool isOtherValid() const { return mOtherValid; }
54
55signals:
56
57 void validityChanged (const QIWidgetValidator *aValidator);
58 void isValidRequested (QIWidgetValidator *aValidator);
59
60public slots:
61
62 void revalidate() { doRevalidate(); }
63
64private:
65
66 QString mLastWarning;
67 QString mCaption;
68 QWidget *mWidget;
69 bool mOtherValid;
70
71 struct Watched
72 {
73 Watched()
74 : widget (NULL), buddy (NULL)
75 , state (QValidator::Acceptable) {}
76
77 QWidget *widget;
78 QWidget *buddy;
79 QValidator::State state;
80 };
81
82 QList <Watched> mWatched;
83 Watched mLastInvalid;
84
85private slots:
86
87 void doRevalidate() { emit validityChanged (this); }
88};
89
90class QIULongValidator : public QValidator
91{
92public:
93
94 QIULongValidator (QObject *aParent)
95 : QValidator (aParent)
96 , mBottom (0), mTop (ULONG_MAX) {}
97
98 QIULongValidator (ulong aMinimum, ulong aMaximum,
99 QObject *aParent)
100 : QValidator (aParent)
101 , mBottom (aMinimum), mTop (aMaximum) {}
102
103 ~QIULongValidator() {}
104
105 State validate (QString &aInput, int &aPos) const;
106 void setBottom (ulong aBottom) { setRange (aBottom, mTop); }
107 void setTop (ulong aTop) { setRange (mBottom, aTop); }
108 void setRange (ulong aBottom, ulong aTop) { mBottom = aBottom; mTop = aTop; }
109 ulong bottom() const { return mBottom; }
110 ulong top() const { return mTop; }
111
112private:
113
114 ulong mBottom;
115 ulong mTop;
116};
117
118#endif // __QIWidgetValidator_h__
119
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use