summaryrefslogtreecommitdiffabout
path: root/korganizer/ktimeedit.cpp
Unidiff
Diffstat (limited to 'korganizer/ktimeedit.cpp') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/ktimeedit.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/korganizer/ktimeedit.cpp b/korganizer/ktimeedit.cpp
index cf07a1a..f5a1c50 100644
--- a/korganizer/ktimeedit.cpp
+++ b/korganizer/ktimeedit.cpp
@@ -22,24 +22,25 @@
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#include <kpimglobalprefs.h>
34 35
35#include "ktimeedit.h" 36#include "ktimeedit.h"
36#include "koprefs.h" 37#include "koprefs.h"
37#include <qvalidator.h> 38#include <qvalidator.h>
38 39
39// Validator for a time value with only hours and minutes (no seconds) 40// Validator for a time value with only hours and minutes (no seconds)
40// Mostly locale aware. Author: David Faure <faure@kde.org> 41// Mostly locale aware. Author: David Faure <faure@kde.org>
41class KOTimeValidator : public QValidator 42class KOTimeValidator : public QValidator
42{ 43{
43public: 44public:
44 KOTimeValidator(QWidget* parent, const char* name=0) : QValidator(parent, name) {} 45 KOTimeValidator(QWidget* parent, const char* name=0) : QValidator(parent, name) {}
45 46
@@ -102,25 +103,25 @@ KOTimeEdit::KOTimeEdit(QWidget *parent, QTime qt, const char *name)
102 } while (!timeEntry.isNull()); 103 } while (!timeEntry.isNull());
103 // Add end of day. 104 // Add end of day.
104 insertItem( KGlobal::locale()->formatTime( QTime( 23, 59, 59 ) ) ); 105 insertItem( KGlobal::locale()->formatTime( QTime( 23, 59, 59 ) ) );
105 106
106 updateText(); 107 updateText();
107 setFocusPolicy(QWidget::StrongFocus); 108 setFocusPolicy(QWidget::StrongFocus);
108 109
109 connect(this, SIGNAL(activated(int)), this, SLOT(activ(int))); 110 connect(this, SIGNAL(activated(int)), this, SLOT(activ(int)));
110 connect(this, SIGNAL(highlighted(int)), this, SLOT(hilit(int))); 111 connect(this, SIGNAL(highlighted(int)), this, SLOT(hilit(int)));
111 connect(this,SIGNAL(textChanged(const QString&)),this,SLOT(changedText())); 112 connect(this,SIGNAL(textChanged(const QString&)),this,SLOT(changedText()));
112 QFontMetrics fm ( font() ); 113 QFontMetrics fm ( font() );
113 QString timeString = "24:00"; 114 QString timeString = "24:00";
114 if ( KOPrefs::instance()->mPreferredTime == 1 ) 115 if ( KPimGlobalPrefs::instance()->mPreferredTime == 1 )
115 timeString = "02:00pm"; 116 timeString = "02:00pm";
116 int addSpace = 32; 117 int addSpace = 32;
117 if ( QApplication::desktop()->width() > 320 ) 118 if ( QApplication::desktop()->width() > 320 )
118 timeString += ":00"; 119 timeString += ":00";
119 setFixedWidth(fm.width( timeString ) + 32 ); 120 setFixedWidth(fm.width( timeString ) + 32 );
120 121
121 // Highlight Background and Textcolor change from default 122 // Highlight Background and Textcolor change from default
122 QPalette palette = QWidget::palette(); 123 QPalette palette = QWidget::palette();
123 unsigned char red, green, blue; 124 unsigned char red, green, blue;
124 red = palette.color( QPalette::Normal , QColorGroup::Background ).red() - 10; 125 red = palette.color( QPalette::Normal , QColorGroup::Background ).red() - 10;
125 green = palette.color( QPalette::Normal , QColorGroup::Background ).green() - 10; 126 green = palette.color( QPalette::Normal , QColorGroup::Background ).green() - 10;
126 blue = palette.color( QPalette::Normal , QColorGroup::Background ).blue() - 10; 127 blue = palette.color( QPalette::Normal , QColorGroup::Background ).blue() - 10;
@@ -229,25 +230,25 @@ void KOTimeEdit::keyReleaseEvent(QKeyEvent *e)
229} 230}
230void KOTimeEdit::setSelect( int from, int to ) 231void KOTimeEdit::setSelect( int from, int to )
231{ 232{
232 if ( KOPrefs::instance()->mHightlightDateTimeEdit) 233 if ( KOPrefs::instance()->mHightlightDateTimeEdit)
233 lineEdit()->setSelection( from , to ); 234 lineEdit()->setSelection( from , to );
234} 235}
235 236
236 237
237void KOTimeEdit::keyPressEvent(QKeyEvent *e) 238void KOTimeEdit::keyPressEvent(QKeyEvent *e)
238{ 239{
239 240
240 qApp->processEvents(); 241 qApp->processEvents();
241 bool hour12Format = ( KOPrefs::instance()->mPreferredTime == 1 ); 242 bool hour12Format = ( KPimGlobalPrefs::instance()->mPreferredTime == 1 );
242 int maxpos = hour12Format?7:5; 243 int maxpos = hour12Format?7:5;
243 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 244 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
244 e->ignore(); 245 e->ignore();
245 // qDebug(" ignore %d",e->isAutoRepeat() ); 246 // qDebug(" ignore %d",e->isAutoRepeat() );
246 return; 247 return;
247 } 248 }
248 if (! e->isAutoRepeat() ) { 249 if (! e->isAutoRepeat() ) {
249 mFlagKeyPressed = true; 250 mFlagKeyPressed = true;
250 } 251 }
251 // Tap -> Focus Next Widget 252 // Tap -> Focus Next Widget
252 if ( e->key() == Key_Tab ) { 253 if ( e->key() == Key_Tab ) {
253 QComboBox::keyPressEvent(e); 254 QComboBox::keyPressEvent(e);