-rw-r--r-- | microkde/kdatetbl.cpp | 32 |
1 files changed, 10 insertions, 22 deletions
diff --git a/microkde/kdatetbl.cpp b/microkde/kdatetbl.cpp index 4271b55..353f78d 100644 --- a/microkde/kdatetbl.cpp +++ b/microkde/kdatetbl.cpp @@ -240,47 +240,35 @@ KDateTable::keyPressEvent( QKeyEvent *e ) int temp=firstday+date.day()-dayoff; int pos = temp; bool irgnore = true; + int add = 0; if ( e->state() != Qt::ControlButton ) { if ( e->key() == Qt::Key_Up ) { - pos -= 7; + add -= 7; irgnore = false; } if ( e->key() == Qt::Key_Down ) { - pos += 7; + add += 7; irgnore = false; } if ( e->key() == Qt::Key_Left ) { - pos--; + --add; irgnore = false; } if ( e->key() == Qt::Key_Right ) { - pos++; + ++add; irgnore = false; } } - if ( irgnore ) + if ( irgnore ) { e->ignore(); - - if(pos+dayoff<=firstday) - { // this day is in the previous month - KNotifyClient::beep(); - return; - } - if(firstday+numdays<pos+dayoff) - { // this date is in the next month - KNotifyClient::beep(i18n( "Month not long enough" )); - return; - } - - if ( pos == temp ) return; + } - setDate(QDate(date.year(), date.month(), pos-firstday+dayoff)); + pos += add; + setDate(date.addDays( add )); updateCell(temp/7+1, temp%7); // Update the previously selected cell updateCell(pos/7+1, pos%7); // Update the selected cell - assert(QDate(date.year(), date.month(), pos-firstday+dayoff).isValid()); - - + } void |