summaryrefslogtreecommitdiffabout
path: root/korganizer/kotodoview.cpp
Unidiff
Diffstat (limited to 'korganizer/kotodoview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kotodoview.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp
index 3483e95..5e8ea27 100644
--- a/korganizer/kotodoview.cpp
+++ b/korganizer/kotodoview.cpp
@@ -596,24 +596,29 @@ void KOTodoView::updateView()
596 if ( !isVisible() ) { 596 if ( !isVisible() ) {
597 mPendingUpdateBeforeRepaint = true; 597 mPendingUpdateBeforeRepaint = true;
598 return; 598 return;
599 } 599 }
600 //qDebug("KOTodoView::updateView() %x", this); 600 //qDebug("KOTodoView::updateView() %x", this);
601 if ( isFlatDisplay ) { 601 if ( isFlatDisplay ) {
602 displayAllFlat(); 602 displayAllFlat();
603 return; 603 return;
604 } 604 }
605 //qDebug("update "); 605 //qDebug("update ");
606// kdDebug() << "KOTodoView::updateView()" << endl; 606// kdDebug() << "KOTodoView::updateView()" << endl;
607 QFont fo = KOPrefs::instance()->mTodoViewFont; 607 QFont fo = KOPrefs::instance()->mTodoViewFont;
608 Incidence* oldInc = 0;
609 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
610 if (mActiveItem)
611 oldInc = mActiveItem->todo();
612
608 mTodoListView->clear(); 613 mTodoListView->clear();
609 if ( mName == "todolistsmall" ) { 614 if ( mName == "todolistsmall" ) {
610 if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { 615 if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) {
611 int ps = fo.pointSize() -2; 616 int ps = fo.pointSize() -2;
612 if ( ps > 12 ) 617 if ( ps > 12 )
613 ps -= 2; 618 ps -= 2;
614 fo.setPointSize( ps ); 619 fo.setPointSize( ps );
615 } 620 }
616 } 621 }
617 622
618 mTodoListView->setFont( fo ); 623 mTodoListView->setFont( fo );
619 // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); 624 // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont );
@@ -677,24 +682,41 @@ void KOTodoView::updateView()
677 for(todo = todoList.first(); todo; todo = todoList.next()) { 682 for(todo = todoList.first(); todo; todo = todoList.next()) {
678 if (!mTodoMap.contains(todo) && checkTodo( todo ) ) 683 if (!mTodoMap.contains(todo) && checkTodo( todo ) )
679 { 684 {
680 insertTodoItem(todo); 685 insertTodoItem(todo);
681 } 686 }
682 } 687 }
683 //qDebug("for end "); 688 //qDebug("for end ");
684 // Restore opened/closed state 689 // Restore opened/closed state
685 mTodoListView->blockSignals( true ); 690 mTodoListView->blockSignals( true );
686 if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); 691 if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() );
687 mTodoListView->blockSignals( false ); 692 mTodoListView->blockSignals( false );
688 mTodoListView->setFocus(); 693 mTodoListView->setFocus();
694 if ( mTodoListView->firstChild () ) {
695 if ( oldInc ) {
696 KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild ();
697 while ( item ) {
698 if ( item->todo() == oldInc ) {
699 mTodoListView->setCurrentItem( item );
700 mTodoListView->ensureItemVisible( item );
701 break;
702 }
703 item = (KOTodoViewItem*)item->itemBelow();
704 }
705 if ( ! item )
706 mTodoListView->setCurrentItem( mTodoListView->firstChild () );
707 } else {
708 mTodoListView->setCurrentItem( mTodoListView->firstChild () );
709 }
710 }
689 processSelectionChange(); 711 processSelectionChange();
690} 712}
691 713
692bool KOTodoView::checkTodo( Todo * todo ) 714bool KOTodoView::checkTodo( Todo * todo )
693{ 715{
694 716
695 if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) 717 if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() )
696 return false; 718 return false;
697 if ( !todo->isCompleted() ) { 719 if ( !todo->isCompleted() ) {
698 if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() ) 720 if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() )
699 return true; 721 return true;
700 } 722 }