From b76ad1e7e329051a47e28c9d132ce3fcd0b25c5c Mon Sep 17 00:00:00 2001 From: zautrix Date: Thu, 31 Mar 2005 23:55:51 +0000 Subject: fixes --- (limited to 'korganizer/kotodoview.cpp') 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 "); -- cgit v0.9.0.2