author | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
commit | a08aff328d4393031d5ba7d622c2b05705a89d73 (patch) (side-by-side diff) | |
tree | 8ee90d686081c52e7c69b5ce946e9b1a7d690001 /korganizer/ktimeedit.cpp | |
parent | 11edc920afe4f274c0964436633aa632c8288a40 (diff) | |
download | kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.zip kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.gz kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.bz2 |
initial public commit of qt4 portp1
-rw-r--r-- | korganizer/ktimeedit.cpp | 89 |
1 files changed, 46 insertions, 43 deletions
diff --git a/korganizer/ktimeedit.cpp b/korganizer/ktimeedit.cpp index df9b2fc..e2ae4a6 100644 --- a/korganizer/ktimeedit.cpp +++ b/korganizer/ktimeedit.cpp @@ -16,22 +16,25 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ -#include <qkeycode.h> +#include <qnamespace.h> #include <qcombobox.h> #include <qdatetime.h> #include <qlineedit.h> -#include <qlistbox.h> +#include <q3listbox.h> #include <qapplication.h> +#include <QDesktopWidget> +//Added by qt3to4: +#include <QKeyEvent> #include <kmessagebox.h> #include <kglobal.h> #include <kdebug.h> #include <klocale.h> #include <kpimglobalprefs.h> #include "ktimeedit.h" @@ -40,17 +43,17 @@ // Validator for a time value with only hours and minutes (no seconds) // Mostly locale aware. Author: David Faure <faure@kde.org> // KTimeWidget/QTimeEdit provide nicer editing, but don't provide a combobox. // Difficult to get all in one... // But Qt-3.2 will offer QLineEdit::setMask, so a "99:99" mask would help. KOTimeEdit::KOTimeEdit(QWidget *parent, QTime qt, const char *name) - : QComboBox(TRUE, parent, name) + : Q3ComboBox(TRUE, parent, name) { setInsertionPolicy(NoInsertion); mFlagKeyPressed = false; if ( QApplication::desktop()->height() <= 480 ) { setSizeLimit ( 6 ); } else { setSizeLimit ( 12 ); } @@ -59,22 +62,22 @@ KOTimeEdit::KOTimeEdit(QWidget *parent, QTime qt, const char *name) // mNoTimeString = i18n("No Time"); // insertItem( mNoTimeString ); // Fill combo box with selection of times in localized format. QTime timeEntry(0,0,0); do { insertItem(KGlobal::locale()->formatTime(timeEntry)); timeEntry = timeEntry.addSecs(60*15); - } while (!timeEntry.isNull()); + } while ( !( timeEntry.hour() || timeEntry.minute() ) ); // Add end of day. insertItem( KGlobal::locale()->formatTime( QTime( 23, 59, 59 ) ) ); updateText(); - setFocusPolicy(QWidget::StrongFocus); + setFocusPolicy(Qt::StrongFocus); connect(this, SIGNAL(activated(int)), this, SLOT(activ(int))); connect(this, SIGNAL(highlighted(int)), this, SLOT(hilit(int))); connect(this,SIGNAL(textChanged(const QString&)),this,SLOT(changedText())); QFontMetrics fm ( font() ); QString timeString = "24:00"; if ( KPimGlobalPrefs::instance()->mPreferredTime == 1 ) timeString = "02:00pm"; @@ -203,34 +206,34 @@ void KOTimeEdit::keyPressEvent(QKeyEvent *e) e->ignore(); // qDebug(" ignore %d",e->isAutoRepeat() ); return; } if (! e->isAutoRepeat() ) { mFlagKeyPressed = true; } // Tap -> Focus Next Widget - if ( e->key() == Key_Tab ) { - QComboBox::keyPressEvent(e); + if ( e->key() == Qt::Key_Tab ) { + Q3ComboBox::keyPressEvent(e); return; } // save Text from QLineEdit and CursorPosition QString text = lineEdit()->text(); int cpos = lineEdit()->cursorPosition(); // qDebug("cpos %d ", cpos); // Switch for arrows, backspace and escape switch(e->key()) { - case Key_Escape: + case Qt::Key_Escape: lineEdit()->deselect(); - case Key_Tab: - QComboBox::keyPressEvent(e); + case Qt::Key_Tab: + Q3ComboBox::keyPressEvent(e); break; - case Key_Up: + case Qt::Key_Up: if ( e->state () == Qt::ControlButton ) { addTime(QTime(0,15,0), false ); lineEdit()->setCursorPosition(3); setSelect( 3 , 2 ); } else if ( e->state () == Qt::ShiftButton ) { addTime(QTime(1,0,0), false ); @@ -262,17 +265,17 @@ void KOTimeEdit::keyPressEvent(QKeyEvent *e) lineEdit()->setCursorPosition(--cpos); case 1: case 0: addTime(QTime(1,0,0), false ); setSelect ( 0, 2 ); break; } break; - case Key_Down: + case Qt::Key_Down: if ( e->state () == Qt::ControlButton ) { subTime(QTime(0,15,0), false ); lineEdit()->setCursorPosition(3); setSelect( 3 , 2 ); } else if ( e->state () == Qt::ShiftButton ) { subTime(QTime(1,0,0), false ); @@ -305,138 +308,138 @@ void KOTimeEdit::keyPressEvent(QKeyEvent *e) case 1: case 0: subTime(QTime(1,0,0), false ); setSelect ( 0 , 2 ); break; } break; // set cursor to correct place - case Key_Left: + case Qt::Key_Left: if ( cpos == 3 ) --cpos; if ( cpos > 0) { lineEdit()->setCursorPosition(--cpos); setSelect ( cpos , 1 ); } else setSelect ( 0 , 1 ); break; // set cursor to correct place - case Key_Right: + case Qt::Key_Right: if ( cpos == 1 ) ++cpos; if ( cpos < maxpos ) { lineEdit()->setCursorPosition(++cpos); setSelect ( cpos , 1 ); } break; // rest - case Key_Prior: + case Qt::Key_Prior: subTime(QTime(1,0,0)); break; - case Key_Next: + case Qt::Key_Next: addTime(QTime(1,0,0)); break; - case Key_Backspace: + case Qt::Key_Backspace: if ( cpos > 0) { if ( cpos == 3 ) --cpos; if ( cpos > 5) cpos = 5; - text.at( cpos-1 ) = '0'; + text[ cpos-1 ] = '0'; lineEdit()->setText( text ); lineEdit()->setCursorPosition(--cpos); setSelect ( cpos , 1 ); changedText(); } break; } // switch arrows // if cursor at string end, alltext market and keyEvent don't ArrowLeft -> deselect and cpos - if( cpos > 4 && lineEdit()->markedText().length() == 5 && e->key() != Key_Left ) { + if( cpos > 4 && lineEdit()->markedText().length() == 5 && e->key() != Qt::Key_Left ) { lineEdit()->deselect(); cpos = 0; lineEdit()->setCursorPosition(cpos); setSelect(cpos , 1); } if ( cpos == 2 ) { lineEdit()->setCursorPosition(++cpos); } // num keys when cursorPos preEnd if ( cpos < 5 ) { // switch another keys switch(e->key()) { - case Key_Delete: - text.at( cpos ) = '0'; + case Qt::Key_Delete: + text[ cpos ] = '0'; lineEdit()->setText( text ); lineEdit()->setCursorPosition(cpos); setSelect ( cpos , 1 ); changedText(); break; - case Key_9: - case Key_8: - case Key_7: - case Key_6: + case Qt::Key_9: + case Qt::Key_8: + case Qt::Key_7: + case Qt::Key_6: if ( !(cpos == 1 || cpos == 4) ) return; if ( cpos == 1 && text.at( 0 ) > '1') - text.at( 0 ) = '1'; - case Key_5: - case Key_4: - case Key_3: + text[ 0 ] = '1'; + case Qt::Key_5: + case Qt::Key_4: + case Qt::Key_3: if ( cpos < 1 ) return; if ( hour12Format && cpos == 1 ) return; - case Key_2: + case Qt::Key_2: if ( hour12Format && cpos == 0 ) return; if ( cpos == 0 && text.at( 1 ) > '3') - text.at( 1 ) = '3'; - case Key_1: - case Key_0: + text[ 1 ] = '3'; + case Qt::Key_1: + case Qt::Key_0: if ( hour12Format ) { - if ( e->key() == Key_0 && cpos == 1 && text.at( 0 ) == '0' ) + if ( e->key() == Qt::Key_0 && cpos == 1 && text.at( 0 ) == '0' ) return; - if ( e->key() == Key_0 && cpos == 0 && text.at( 1 ) == '0' ) - text.at( 1 ) = '1'; + if ( e->key() == Qt::Key_0 && cpos == 0 && text.at( 1 ) == '0' ) + text[ 1 ] = '1'; } - text.at( cpos ) = QChar ( e->key() ); + text[ cpos ] = QChar ( e->key() ); lineEdit()->setText( text ); if ( cpos == 1 ) ++cpos; if ( cpos < 5) lineEdit()->setCursorPosition(++cpos); setSelect( cpos , 1 ); changedText(); break; - case Key_Home: + case Qt::Key_Home: lineEdit()->setCursorPosition(0); setSelect( cpos , 1 ); break; - case Key_End: + case Qt::Key_End: lineEdit()->setCursorPosition(5); lineEdit()->deselect(); break; default: // QComboBox::keyPressEvent(e); break; } // switch num keys } else if ( cpos == 5 ) {// if cpos < 5 if ( hour12Format ) { - if ( e->key() == Key_A ) { - text.at( 5 ) = 'a'; + if ( e->key() == Qt::Key_A ) { + text[ 5 ] = 'a'; lineEdit()->setText( text ); lineEdit()->setCursorPosition(5); - } else if ( e->key() == Key_P ) { - text.at( 5 ) = 'p'; + } else if ( e->key() == Qt::Key_P ) { + text[ 5 ] = 'p'; lineEdit()->setText( text ); lineEdit()->setCursorPosition(5); } } } |