summaryrefslogtreecommitdiffabout
path: root/korganizer/ktimeedit.cpp
Unidiff
Diffstat (limited to 'korganizer/ktimeedit.cpp') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/ktimeedit.cpp1
1 files changed, 0 insertions, 1 deletions
diff --git a/korganizer/ktimeedit.cpp b/korganizer/ktimeedit.cpp
index f9720f6..cf07a1a 100644
--- a/korganizer/ktimeedit.cpp
+++ b/korganizer/ktimeedit.cpp
@@ -6,65 +6,64 @@
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qkeycode.h> 24#include <qkeycode.h>
25#include <qcombobox.h> 25#include <qcombobox.h>
26#include <qdatetime.h> 26#include <qdatetime.h>
27#include <qlineedit.h> 27#include <qlineedit.h>
28#include <qapplication.h> 28#include <qapplication.h>
29 29
30#include <kmessagebox.h> 30#include <kmessagebox.h>
31#include <kglobal.h> 31#include <kglobal.h>
32#include <kdebug.h> 32#include <kdebug.h>
33#include <klocale.h> 33#include <klocale.h>
34 34
35#include "ktimeedit.h" 35#include "ktimeedit.h"
36#include "koprefs.h" 36#include "koprefs.h"
37#include <qvalidator.h> 37#include <qvalidator.h>
38#include "ktimeedit.moc"
39 38
40// Validator for a time value with only hours and minutes (no seconds) 39// Validator for a time value with only hours and minutes (no seconds)
41// Mostly locale aware. Author: David Faure <faure@kde.org> 40// Mostly locale aware. Author: David Faure <faure@kde.org>
42class KOTimeValidator : public QValidator 41class KOTimeValidator : public QValidator
43{ 42{
44public: 43public:
45 KOTimeValidator(QWidget* parent, const char* name=0) : QValidator(parent, name) {} 44 KOTimeValidator(QWidget* parent, const char* name=0) : QValidator(parent, name) {}
46 45
47 virtual State validate(QString& str, int& /*cursorPos*/) const 46 virtual State validate(QString& str, int& /*cursorPos*/) const
48 { 47 {
49 return Acceptable; 48 return Acceptable;
50 bool ok = false; 49 bool ok = false;
51 // TODO use KLocale::WithoutSeconds in HEAD 50 // TODO use KLocale::WithoutSeconds in HEAD
52 /*QTime time =*/ KGlobal::locale()->readTime(str, &ok); 51 /*QTime time =*/ KGlobal::locale()->readTime(str, &ok);
53 if ( ok ) 52 if ( ok )
54 return Acceptable; 53 return Acceptable;
55 // readTime doesn't help knowing when the string is "Intermediate". 54 // readTime doesn't help knowing when the string is "Intermediate".
56 int length = str.length(); 55 int length = str.length();
57 if ( !str ) // empty string? 56 if ( !str ) // empty string?
58 return Invalid; // there should always be a ':' in it, right? 57 return Invalid; // there should always be a ':' in it, right?
59 // HACK. Not fully locale aware etc. (esp. the separator is '.' in sv_SE...) 58 // HACK. Not fully locale aware etc. (esp. the separator is '.' in sv_SE...)
60 QChar sep = ':'; 59 QChar sep = ':';
61 // I want to allow "HH:", ":MM" and ":" to make editing easier 60 // I want to allow "HH:", ":MM" and ":" to make editing easier
62 if ( str[0] == sep ) 61 if ( str[0] == sep )
63 { 62 {
64 if ( length == 1 ) // just ":" 63 if ( length == 1 ) // just ":"
65 return Intermediate; 64 return Intermediate;
66 QString minutes = str.mid(1); 65 QString minutes = str.mid(1);
67 int m = minutes.toInt(&ok); 66 int m = minutes.toInt(&ok);
68 if ( ok && m >= 0 && m < 60 ) 67 if ( ok && m >= 0 && m < 60 )
69 return Intermediate; 68 return Intermediate;
70 } else if ( str.at(str.length()-1) == sep ) 69 } else if ( str.at(str.length()-1) == sep )