VirtualBox

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

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

Compile VirtualBox with qt4 on linux.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.8 KB
Line 
1/** @file
2 *
3 * VBox frontends: Qt GUI ("VirtualBox"):
4 * innotek Qt extensions: QIWidgetValidator class declaration
5 */
6
7/*
8 * Copyright (C) 2006-2007 innotek GmbH
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#include <qobject.h>
25#include <qvalidator.h>
26#include <q3valuelist.h>
27
28class QIWidgetValidator : public QObject
29{
30 Q_OBJECT
31
32public:
33
34 QIWidgetValidator (QWidget *aWidget, QObject *aParent = 0,
35 const char *aName = 0);
36 QIWidgetValidator (const QString &aCaption,
37 QWidget *aWidget, QObject *aParent = 0,
38 const char *aName = 0);
39 ~QIWidgetValidator();
40
41 QWidget *widget() const { return mWidget; }
42 bool isValid() const;
43 void rescan();
44
45 QString warningText() const;
46
47 void setOtherValid (bool aValid) { mOtherValid = aValid; }
48 bool isOtherValid() const { return mOtherValid; }
49
50signals:
51
52 void validityChanged (const QIWidgetValidator *aValidator);
53 void isValidRequested (QIWidgetValidator *aValidator);
54
55public slots:
56
57 void revalidate() { doRevalidate(); }
58
59private:
60
61 QString mCaption;
62 QWidget *mWidget;
63 bool mOtherValid;
64
65 struct Watched
66 {
67 Watched()
68 : widget (NULL), buddy (NULL)
69 , state (QValidator::Acceptable) {}
70
71 QWidget *widget;
72 QWidget *buddy;
73 QValidator::State state;
74 };
75
76 Q3ValueList <Watched> mWatched;
77 Watched mLastInvalid;
78
79private slots:
80
81 void doRevalidate() { emit validityChanged (this); }
82};
83
84class QIULongValidator : public QValidator
85{
86public:
87
88 QIULongValidator (QObject *aParent, const char *aName = 0)
89 : QValidator (aParent)
90 , mBottom (0), mTop (ULONG_MAX) {}
91
92 QIULongValidator (ulong aMinimum, ulong aMaximum,
93 QObject *aParent, const char *aName = 0)
94 : QValidator (aParent)
95 , mBottom (aMinimum), mTop (aMaximum) {}
96
97 ~QIULongValidator() {}
98
99 State validate (QString &aInput, int &aPos) const;
100 void setBottom (ulong aBottom) { setRange (aBottom, mTop); }
101 void setTop (ulong aTop) { setRange (mBottom, aTop); }
102 void setRange (ulong aBottom, ulong aTop) { mBottom = aBottom; mTop = aTop; }
103 ulong bottom() const { return mBottom; }
104 ulong top() const { return mTop; }
105
106private:
107
108 ulong mBottom;
109 ulong mTop;
110};
111
112#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