00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "precisetimevalidator.hh"
00022
00023 PreciseTimeValidator::PreciseTimeValidator(QObject *parent, const char *name)
00024 : QValidator(parent, name)
00025 {
00026 }
00027
00028 PreciseTimeValidator::~PreciseTimeValidator()
00029 {
00030 }
00031
00032 QValidator::State
00033 PreciseTimeValidator::validate(QString &input, int &) const
00034 {
00035 bool ok, temp;
00036 ok = input[0].isDigit(); ok &= input[1].isDigit();
00037 ok &= (input.mid(0, 2).toInt(&temp) < 24); ok &= temp & (input[2] == ':');
00038 ok &= input[3].isDigit(); ok &= input[4].isDigit();
00039 ok &= (input.mid(3, 2).toInt(&temp) < 60); ok &= temp & (input[5] == ':');
00040 ok &= input[6].isDigit(); ok &= input[7].isDigit();
00041 ok &= (input.mid(6, 2).toInt(&temp) < 60); ok &= temp & (input[8] == '.');
00042 ok &= input[9].isDigit(); ok &= input[10].isDigit();
00043 ok &= input[11].isDigit();
00044 input.mid(9, 3).toInt(&temp); ok &= temp;
00045 if(ok)
00046 return Valid;
00047 else
00048 return Invalid;
00049 }