- Timestamp:
- Aug 23, 2007 6:58:03 PM (17 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/include/QIWidgetValidator.h
r4071 r4323 20 20 #define __QIWidgetValidator_h__ 21 21 22 #include <limits.h> 23 22 24 #include <qobject.h> 25 #include <qvalidator.h> 23 26 24 27 class QIWidgetValidator : public QObject … … 52 55 }; 53 56 57 class QIULongValidator : public QValidator 58 { 59 public: 60 61 QIULongValidator (QObject *aParent, const char *aName = 0) 62 : mBottom (0), mTop (ULONG_MAX) 63 , QValidator (aParent, aName) {} 64 65 QIULongValidator (ulong aMinimum, ulong aMaximum, 66 QObject *aParent, const char *aName = 0) 67 : mBottom (aMinimum), mTop (aMaximum) 68 , QValidator (aParent, aName) {} 69 70 ~QIULongValidator() {} 71 72 State validate (QString &aInput, int &aPos) const; 73 void setBottom (ulong aBottom) { setRange (aBottom, mTop); } 74 void setTop (ulong aTop) { setRange (mBottom, aTop); } 75 void setRange (ulong aBottom, ulong aTop) { mBottom = aBottom; mTop = aTop; } 76 ulong bottom() const { return mBottom; } 77 ulong top() const { return mTop; } 78 79 private: 80 81 ulong mBottom; 82 ulong mTop; 83 }; 84 54 85 #endif // __QIWidgetValidator_h__ -
trunk/src/VBox/Frontends/VirtualBox/src/QIWidgetValidator.cpp
r4071 r4323 233 233 */ 234 234 235 236 /** @class QIULongValidator 237 * 238 * The QIULongValidator class is a QIntValidator-like class to validate 239 * unsigned integer numbers. As opposed to QIntValidator, this class accepts 240 * all three integer number formats: decimal, hexadecimal (the string starts 241 * with "0x") and octal (the string starts with "0"). 242 */ 243 244 QValidator::State QIULongValidator::validate (QString &aInput, int &aPos) const 245 { 246 Q_UNUSED (aPos); 247 248 QString stripped = aInput.stripWhiteSpace(); 249 250 if (stripped.isEmpty() || 251 stripped.upper() == QString ("0x").upper()) 252 return Intermediate; 253 254 bool ok; 255 ulong entered = aInput.toULong (&ok, 0); 256 257 if (!ok) 258 return Invalid; 259 260 if (entered >= mBottom && entered <= mTop) 261 return Acceptable; 262 263 return (entered > mTop ) ? Invalid : Intermediate; 264 }
Note:
See TracChangeset
for help on using the changeset viewer.