author | zautrix <zautrix> | 2005-03-31 23:55:51 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-31 23:55:51 (UTC) |
commit | b76ad1e7e329051a47e28c9d132ce3fcd0b25c5c (patch) (side-by-side diff) | |
tree | b0b3d0eb7a3d29981c183275aadeed0cbbef0007 /korganizer/kotodoview.cpp | |
parent | c0fa26aa3b33c293853bdd7d028ddb0545e33c85 (diff) | |
download | kdepimpi-b76ad1e7e329051a47e28c9d132ce3fcd0b25c5c.zip kdepimpi-b76ad1e7e329051a47e28c9d132ce3fcd0b25c5c.tar.gz kdepimpi-b76ad1e7e329051a47e28c9d132ce3fcd0b25c5c.tar.bz2 |
fixes
-rw-r--r-- | korganizer/kotodoview.cpp | 103 |
1 files changed, 78 insertions, 25 deletions
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index e008625..ccc4b01 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp @@ -264,9 +264,24 @@ void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) } #endif } +void KOTodoListView::keyReleaseEvent ( QKeyEvent *e ) +{ + if ( !e->isAutoRepeat() ) { + mFlagKeyPressed = false; + } +} + + void KOTodoListView::keyPressEvent ( QKeyEvent * e ) { - + qApp->processEvents(); + if ( e->isAutoRepeat() && !mFlagKeyPressed ) { + e->ignore(); + // qDebug(" ignore %d",e->isAutoRepeat() ); + return; + } + if (! e->isAutoRepeat() ) + mFlagKeyPressed = true; QListViewItem* cn; if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { cn = currentItem(); @@ -289,7 +304,6 @@ void KOTodoListView::keyPressEvent ( QKeyEvent * e ) return; } - // qDebug("KOTodoListView::keyPressEvent "); if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { switch ( e->key() ) { case Qt::Key_Down: @@ -598,18 +612,17 @@ void KOTodoView::updateView() mPendingUpdateBeforeRepaint = true; return; } + storeCurrentItem(); //qDebug("KOTodoView::updateView() %x", this); if ( isFlatDisplay ) { displayAllFlat(); + resetCurrentItem(); return; } //qDebug("update "); // kdDebug() << "KOTodoView::updateView()" << endl; QFont fo = KOPrefs::instance()->mTodoViewFont; - Incidence* oldInc = 0; - mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); - if (mActiveItem) - oldInc = mActiveItem->todo(); + mTodoListView->clear(); if ( mName == "todolistsmall" ) { @@ -691,27 +704,66 @@ void KOTodoView::updateView() mTodoListView->blockSignals( true ); if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); mTodoListView->blockSignals( false ); - mTodoListView->setFocus(); - if ( mTodoListView->firstChild () ) { - if ( oldInc ) { - KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild (); - while ( item ) { - if ( item->todo() == oldInc ) { - mTodoListView->setCurrentItem( item ); - mTodoListView->ensureItemVisible( item ); - break; - } - item = (KOTodoViewItem*)item->itemBelow(); - } - if ( ! item ) - mTodoListView->setCurrentItem( mTodoListView->firstChild () ); - } else { - mTodoListView->setCurrentItem( mTodoListView->firstChild () ); - } - } + resetCurrentItem(); processSelectionChange(); } +void KOTodoView::storeCurrentItem() +{ + mCurItem = 0; + mCurItemRootParent = 0; + mCurItemAbove = 0; + mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); + if (mActiveItem) { + mCurItem = mActiveItem->todo(); + KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove (); + if ( activeItemAbove ) + mCurItemAbove = activeItemAbove->todo(); + while ( mActiveItem->parent() != 0 ) + mActiveItem = (KOTodoViewItem*)mActiveItem->parent(); + mCurItemRootParent = mActiveItem->todo(); + } + mActiveItem = 0; +} + +void KOTodoView::resetCurrentItem() +{ + mTodoListView->setFocus(); + KOTodoViewItem* foundItem = 0; + KOTodoViewItem* foundItemRoot = 0; + KOTodoViewItem* foundItemAbove = 0; + if ( mTodoListView->firstChild () ) { + if ( mCurItem ) { + KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild (); + while ( item ) { + if ( item->todo() == mCurItem ) { + foundItem = item; + break; + } else if ( item->todo() == mCurItemAbove ) { + foundItemAbove = item; + + } else if ( item->todo() == mCurItemRootParent ) { + foundItemRoot = item; + } + item = (KOTodoViewItem*)item->itemBelow(); + } + if ( ! foundItem ) { + if ( foundItemAbove ) + foundItem = foundItemAbove; + else + foundItem = foundItemRoot; + } + } + if ( foundItem ) { + mTodoListView->setCurrentItem( foundItem ); + mTodoListView->ensureItemVisible( foundItem ); + } else { + mTodoListView->setCurrentItem( mTodoListView->firstChild () ); + } + } + mTodoListView->setFocus(); +} +//Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove; bool KOTodoView::checkTodo( Todo * todo ) { @@ -1239,8 +1291,9 @@ void KOTodoView::addQuickTodo() todoModified (todo, KOGlobals::EVENTADDED ); updateView(); } + void KOTodoView::keyPressEvent ( QKeyEvent * e ) -{ +{ // e->ignore(); //return; //qDebug("KOTodoView::keyPressEvent "); |