-rw-r--r-- | korganizer/ktimeedit.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/korganizer/ktimeedit.cpp b/korganizer/ktimeedit.cpp index 5222ac9..61a0931 100644 --- a/korganizer/ktimeedit.cpp +++ b/korganizer/ktimeedit.cpp | |||
@@ -4,99 +4,101 @@ | |||
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
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 <qlistbox.h> | 28 | #include <qlistbox.h> |
29 | #include <qapplication.h> | 29 | #include <qapplication.h> |
30 | 30 | ||
31 | #include <kmessagebox.h> | 31 | #include <kmessagebox.h> |
32 | #include <kglobal.h> | 32 | #include <kglobal.h> |
33 | #include <kdebug.h> | 33 | #include <kdebug.h> |
34 | #include <klocale.h> | 34 | #include <klocale.h> |
35 | #include <kpimglobalprefs.h> | 35 | #include <kpimglobalprefs.h> |
36 | 36 | ||
37 | #include "ktimeedit.h" | 37 | #include "ktimeedit.h" |
38 | #include "koprefs.h" | 38 | #include "koprefs.h" |
39 | #include <qvalidator.h> | 39 | #include <qvalidator.h> |
40 | 40 | ||
41 | // Validator for a time value with only hours and minutes (no seconds) | 41 | // Validator for a time value with only hours and minutes (no seconds) |
42 | // Mostly locale aware. Author: David Faure <faure@kde.org> | 42 | // Mostly locale aware. Author: David Faure <faure@kde.org> |
43 | 43 | ||
44 | // KTimeWidget/QTimeEdit provide nicer editing, but don't provide a combobox. | 44 | // KTimeWidget/QTimeEdit provide nicer editing, but don't provide a combobox. |
45 | // Difficult to get all in one... | 45 | // Difficult to get all in one... |
46 | // But Qt-3.2 will offer QLineEdit::setMask, so a "99:99" mask would help. | 46 | // But Qt-3.2 will offer QLineEdit::setMask, so a "99:99" mask would help. |
47 | KOTimeEdit::KOTimeEdit(QWidget *parent, QTime qt, const char *name) | 47 | KOTimeEdit::KOTimeEdit(QWidget *parent, QTime qt, const char *name) |
48 | : QComboBox(TRUE, parent, name) | 48 | : QComboBox(TRUE, parent, name) |
49 | { | 49 | { |
50 | setInsertionPolicy(NoInsertion); | 50 | setInsertionPolicy(NoInsertion); |
51 | mFlagKeyPressed = false; | 51 | mFlagKeyPressed = false; |
52 | 52 | if ( QApplication::desktop()->height() <= 480 ) { | |
53 | if ( QApplication::desktop()->width() < 650 ) | ||
54 | setSizeLimit ( 6 ); | 53 | setSizeLimit ( 6 ); |
54 | } else { | ||
55 | setSizeLimit ( 12 ); | ||
56 | } | ||
55 | mTime = qt; | 57 | mTime = qt; |
56 | 58 | ||
57 | // mNoTimeString = i18n("No Time"); | 59 | // mNoTimeString = i18n("No Time"); |
58 | // insertItem( mNoTimeString ); | 60 | // insertItem( mNoTimeString ); |
59 | 61 | ||
60 | // Fill combo box with selection of times in localized format. | 62 | // Fill combo box with selection of times in localized format. |
61 | QTime timeEntry(0,0,0); | 63 | QTime timeEntry(0,0,0); |
62 | do { | 64 | do { |
63 | insertItem(KGlobal::locale()->formatTime(timeEntry)); | 65 | insertItem(KGlobal::locale()->formatTime(timeEntry)); |
64 | timeEntry = timeEntry.addSecs(60*15); | 66 | timeEntry = timeEntry.addSecs(60*15); |
65 | } while (!timeEntry.isNull()); | 67 | } while (!timeEntry.isNull()); |
66 | // Add end of day. | 68 | // Add end of day. |
67 | insertItem( KGlobal::locale()->formatTime( QTime( 23, 59, 59 ) ) ); | 69 | insertItem( KGlobal::locale()->formatTime( QTime( 23, 59, 59 ) ) ); |
68 | 70 | ||
69 | updateText(); | 71 | updateText(); |
70 | setFocusPolicy(QWidget::StrongFocus); | 72 | setFocusPolicy(QWidget::StrongFocus); |
71 | 73 | ||
72 | connect(this, SIGNAL(activated(int)), this, SLOT(activ(int))); | 74 | connect(this, SIGNAL(activated(int)), this, SLOT(activ(int))); |
73 | connect(this, SIGNAL(highlighted(int)), this, SLOT(hilit(int))); | 75 | connect(this, SIGNAL(highlighted(int)), this, SLOT(hilit(int))); |
74 | connect(this,SIGNAL(textChanged(const QString&)),this,SLOT(changedText())); | 76 | connect(this,SIGNAL(textChanged(const QString&)),this,SLOT(changedText())); |
75 | QFontMetrics fm ( font() ); | 77 | QFontMetrics fm ( font() ); |
76 | QString timeString = "24:00"; | 78 | QString timeString = "24:00"; |
77 | if ( KPimGlobalPrefs::instance()->mPreferredTime == 1 ) | 79 | if ( KPimGlobalPrefs::instance()->mPreferredTime == 1 ) |
78 | timeString = "02:00pm"; | 80 | timeString = "02:00pm"; |
79 | int addSpace = 32; | 81 | int addSpace = 32; |
80 | if ( QApplication::desktop()->width() > 320 ) | 82 | if ( QApplication::desktop()->width() > 320 ) |
81 | timeString += ":00"; | 83 | timeString += ":00"; |
82 | setFixedWidth(fm.width( timeString ) + 32 ); | 84 | setFixedWidth(fm.width( timeString ) + 32 ); |
83 | 85 | ||
84 | // Highlight Background and Textcolor change from default | 86 | // Highlight Background and Textcolor change from default |
85 | QPalette palette = QWidget::palette(); | 87 | QPalette palette = QWidget::palette(); |
86 | unsigned char red, green, blue; | 88 | unsigned char red, green, blue; |
87 | red = palette.color( QPalette::Normal , QColorGroup::Background ).red() - 10; | 89 | red = palette.color( QPalette::Normal , QColorGroup::Background ).red() - 10; |
88 | green = palette.color( QPalette::Normal , QColorGroup::Background ).green() - 10; | 90 | green = palette.color( QPalette::Normal , QColorGroup::Background ).green() - 10; |
89 | blue = palette.color( QPalette::Normal , QColorGroup::Background ).blue() - 10; | 91 | blue = palette.color( QPalette::Normal , QColorGroup::Background ).blue() - 10; |
90 | palette.setColor( QColorGroup::Highlight, QColor(red,green,blue) ); | 92 | palette.setColor( QColorGroup::Highlight, QColor(red,green,blue) ); |
91 | palette.setColor( QColorGroup::HighlightedText, palette.color( QPalette::Normal , QColorGroup::Foreground ) ); | 93 | palette.setColor( QColorGroup::HighlightedText, palette.color( QPalette::Normal , QColorGroup::Foreground ) ); |
92 | setPalette( palette ); | 94 | setPalette( palette ); |
93 | } | 95 | } |
94 | 96 | ||
95 | KOTimeEdit::~KOTimeEdit() | 97 | KOTimeEdit::~KOTimeEdit() |
96 | { | 98 | { |
97 | } | 99 | } |
98 | 100 | ||
99 | bool KOTimeEdit::hasTime() const | 101 | bool KOTimeEdit::hasTime() const |
100 | { | 102 | { |
101 | // Can't happen | 103 | // Can't happen |
102 | if ( currentText().isEmpty() ) return false; | 104 | if ( currentText().isEmpty() ) return false; |