Főoldal | Osztályhierarchia | Osztálylista | Fájllista | Osztálytagok | Fájlelemek | Kapcsolódó lapok

precisetimevalidator.cc

00001 /*
00002  * SubTimer source file
00003  *  Copyright (C) 2005 Peter Salvi
00004  *   Last modification: <2005.03.23., 16:17:50>
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; either version 2 of the License, or
00009  *  (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License
00017  *  along with this program; if not, write to the Free Software
00018  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
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 }

Projekt: SubTimer Készült: Wed Mar 23 22:06:53 2005 Készítette: doxygen 1.3.6