-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 @@ -266,5 +266,20 @@ void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) } +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; @@ -291,3 +306,2 @@ void KOTodoListView::keyPressEvent ( QKeyEvent * e ) - // qDebug("KOTodoListView::keyPressEvent "); if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { @@ -600,2 +614,3 @@ void KOTodoView::updateView() } + storeCurrentItem(); //qDebug("KOTodoView::updateView() %x", this); @@ -603,2 +618,3 @@ void KOTodoView::updateView() displayAllFlat(); + resetCurrentItem(); return; @@ -608,6 +624,3 @@ void KOTodoView::updateView() QFont fo = KOPrefs::instance()->mTodoViewFont; - Incidence* oldInc = 0; - mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); - if (mActiveItem) - oldInc = mActiveItem->todo(); + @@ -693,20 +706,3 @@ void KOTodoView::updateView() 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(); @@ -714,2 +710,58 @@ void KOTodoView::updateView() +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 ) @@ -1241,4 +1293,5 @@ void KOTodoView::addQuickTodo() } + void KOTodoView::keyPressEvent ( QKeyEvent * e ) -{ +{ // e->ignore(); |