summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kotodoview.cpp26
-rw-r--r--korganizer/kotodoview.h1
2 files changed, 17 insertions, 10 deletions
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp
index 8d354c8..e2966f8 100644
--- a/korganizer/kotodoview.cpp
+++ b/korganizer/kotodoview.cpp
@@ -739,31 +739,30 @@ void KOTodoView::paintEvent(QPaintEvent * pevent)
739} 739}
740 740
741void KOTodoView::updateView() 741void KOTodoView::updateView()
742{ 742{
743 pendingSubtodo = 0; 743 pendingSubtodo = 0;
744 if ( mBlockUpdate ) { 744 if ( mBlockUpdate ) {
745 return; 745 return;
746 } 746 }
747 if ( !isVisible() ) { 747 if ( !isVisible() ) {
748 mPendingUpdateBeforeRepaint = true; 748 mPendingUpdateBeforeRepaint = true;
749 return; 749 return;
750 } 750 }
751 storeCurrentItem();
752 //qDebug("KOTodoView::updateView() %x", this); 751 //qDebug("KOTodoView::updateView() %x", this);
753 if ( isFlatDisplay ) { 752 if ( isFlatDisplay ) {
754 displayAllFlat(); 753 displayAllFlat();
755 resetCurrentItem();
756 return; 754 return;
757 } 755 }
756 storeCurrentItem();
758 //qDebug("update "); 757 //qDebug("update ");
759// kdDebug() << "KOTodoView::updateView()" << endl; 758// kdDebug() << "KOTodoView::updateView()" << endl;
760 QFont fo = KOPrefs::instance()->mTodoViewFont; 759 QFont fo = KOPrefs::instance()->mTodoViewFont;
761 760
762 761
763 mTodoListView->clear(); 762 mTodoListView->clear();
764 if ( mName == "todolistsmall" ) { 763 if ( mName == "todolistsmall" ) {
765 if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { 764 if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) {
766 int ps = fo.pointSize() -2; 765 int ps = fo.pointSize() -2;
767 if ( ps > 12 ) 766 if ( ps > 12 )
768 ps -= 2; 767 ps -= 2;
769 fo.setPointSize( ps ); 768 fo.setPointSize( ps );
@@ -826,50 +825,49 @@ void KOTodoView::updateView()
826 825
827 for(todo = todoList.first(); todo; todo = todoList.next()) { 826 for(todo = todoList.first(); todo; todo = todoList.next()) {
828 if (!mTodoMap.contains(todo) && checkTodo( todo ) ) 827 if (!mTodoMap.contains(todo) && checkTodo( todo ) )
829 { 828 {
830 insertTodoItem(todo); 829 insertTodoItem(todo);
831 } 830 }
832 } 831 }
833 // Restore opened/closed state 832 // Restore opened/closed state
834 mTodoListView->blockSignals( true ); 833 mTodoListView->blockSignals( true );
835 if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); 834 if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() );
836 mTodoListView->blockSignals( false ); 835 mTodoListView->blockSignals( false );
837 resetCurrentItem(); 836 resetCurrentItem();
838 processSelectionChange();
839} 837}
840 838
841void KOTodoView::storeCurrentItem() 839void KOTodoView::storeCurrentItem()
842{ 840{
843 mCurItem = 0; 841 mCurItem = 0;
844 mCurItemRootParent = 0; 842 mCurItemRootParent = 0;
845 mCurItemParent = 0; 843 mCurItemParent = 0;
846 mCurItemAbove = 0; 844 mCurItemAbove = 0;
847 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 845 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
848 if (mActiveItem) { 846 if (mActiveItem) {
849 mCurItem = mActiveItem->todo(); 847 mCurItem = mActiveItem->todo();
850 KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove (); 848 KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove ();
851 if ( activeItemAbove ) 849 if ( activeItemAbove )
852 mCurItemAbove = activeItemAbove->todo(); 850 mCurItemAbove = activeItemAbove->todo();
853 mCurItemRootParent = mCurItem; 851 mCurItemRootParent = mCurItem;
854 mCurItemParent = mCurItemRootParent->relatedTo(); 852 mCurItemParent = mCurItemRootParent->relatedTo();
855 while ( mCurItemRootParent->relatedTo() != 0 ) 853 while ( mCurItemRootParent->relatedTo() != 0 )
856 mCurItemRootParent = mCurItemRootParent->relatedTo(); 854 mCurItemRootParent = mCurItemRootParent->relatedTo();
857 } 855 }
858 mActiveItem = 0; 856 mActiveItem = 0;
859} 857}
860 858
861void KOTodoView::resetCurrentItem() 859void KOTodoView::resetCurrentItem()
862{ 860{
863 mTodoListView->setFocus(); 861 //mTodoListView->setFocus();
864 KOTodoViewItem* foundItem = 0; 862 KOTodoViewItem* foundItem = 0;
865 KOTodoViewItem* foundItemRoot = 0; 863 KOTodoViewItem* foundItemRoot = 0;
866 KOTodoViewItem* foundItemParent = 0; 864 KOTodoViewItem* foundItemParent = 0;
867 KOTodoViewItem* foundItemAbove = 0; 865 KOTodoViewItem* foundItemAbove = 0;
868 if ( mTodoListView->firstChild () ) { 866 if ( mTodoListView->firstChild () ) {
869 if ( mCurItem ) { 867 if ( mCurItem ) {
870 KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild (); 868 KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild ();
871 while ( item ) { 869 while ( item ) {
872 if ( item->todo() == mCurItem ) { 870 if ( item->todo() == mCurItem ) {
873 foundItem = item; 871 foundItem = item;
874 break; 872 break;
875 } else if ( item->todo() == mCurItemAbove ) { 873 } else if ( item->todo() == mCurItemAbove ) {
@@ -887,30 +885,40 @@ void KOTodoView::resetCurrentItem()
887 if ( ! foundItem ) { 885 if ( ! foundItem ) {
888 if ( foundItemParent ) { 886 if ( foundItemParent ) {
889 foundItem = foundItemParent; 887 foundItem = foundItemParent;
890 } else { 888 } else {
891 if ( foundItemRoot ) 889 if ( foundItemRoot )
892 foundItem = foundItemRoot; 890 foundItem = foundItemRoot;
893 else 891 else
894 foundItem = foundItemAbove; 892 foundItem = foundItemAbove;
895 } 893 }
896 } 894 }
897 } 895 }
898 if ( foundItem ) { 896 if ( foundItem ) {
897 mTodoListView->setSelected ( foundItem, true );
899 mTodoListView->setCurrentItem( foundItem ); 898 mTodoListView->setCurrentItem( foundItem );
900 mTodoListView->ensureItemVisible( foundItem ); 899 mTodoListView->ensureItemVisible( foundItem );
901 } else { 900 } else {
902 mTodoListView->setCurrentItem( mTodoListView->firstChild () ); 901 if ( mTodoListView->firstChild () ) {
902 mTodoListView->setSelected ( mTodoListView->firstChild (), true );
903 mTodoListView->setCurrentItem( mTodoListView->firstChild () );
904 }
903 } 905 }
904 } 906 }
907 processSelectionChange();
908 QTimer::singleShot( 100, this, SLOT ( resetFocusToList() ));
909}
910void KOTodoView::resetFocusToList()
911{
912 topLevelWidget()->setActiveWindow();
905 mTodoListView->setFocus(); 913 mTodoListView->setFocus();
906} 914}
907//Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove; 915//Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove;
908bool KOTodoView::checkTodo( Todo * todo ) 916bool KOTodoView::checkTodo( Todo * todo )
909{ 917{
910 918
911 if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) 919 if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() )
912 return false; 920 return false;
913 if ( !todo->isCompleted() ) { 921 if ( !todo->isCompleted() ) {
914 if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() ) 922 if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() )
915 return true; 923 return true;
916 } 924 }
@@ -1395,53 +1403,51 @@ void KOTodoView::setAllClose()
1395void KOTodoView::setOpen( QListViewItem* item, bool setOpenI) 1403void KOTodoView::setOpen( QListViewItem* item, bool setOpenI)
1396{ 1404{
1397 1405
1398 while ( item ) { 1406 while ( item ) {
1399 setOpen( item->firstChild(), setOpenI ); 1407 setOpen( item->firstChild(), setOpenI );
1400 item->setOpen( setOpenI ); 1408 item->setOpen( setOpenI );
1401 item = item->nextSibling(); 1409 item = item->nextSibling();
1402 } 1410 }
1403} 1411}
1404 1412
1405void KOTodoView::displayAllFlat() 1413void KOTodoView::displayAllFlat()
1406{ 1414{
1415 storeCurrentItem();
1407 pendingSubtodo = 0; 1416 pendingSubtodo = 0;
1408 if ( mBlockUpdate ) { 1417 if ( mBlockUpdate ) {
1409 return; 1418 return;
1410 } 1419 }
1411 mPopupMenu->setItemChecked( 8,true ); 1420 mPopupMenu->setItemChecked( 8,true );
1412 isFlatDisplay = true; 1421 isFlatDisplay = true;
1413 QPtrList<Todo> todoList = calendar()->todos(); 1422 QPtrList<Todo> todoList = calendar()->todos();
1414 mTodoMap.clear(); 1423 mTodoMap.clear();
1415 mTodoListView->clear(); 1424 mTodoListView->clear();
1416 Todo *todo; 1425 Todo *todo;
1417 for(todo = todoList.first(); todo; todo = todoList.next()) { 1426 for(todo = todoList.first(); todo; todo = todoList.next()) {
1418 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); 1427 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this);
1419 mTodoMap.insert(todo,todoItem); 1428 mTodoMap.insert(todo,todoItem);
1420 } 1429 }
1421 mTodoListView->setFocus(); 1430 resetCurrentItem();
1422 processSelectionChange();
1423} 1431}
1424 1432
1425void KOTodoView::setAllFlat() 1433void KOTodoView::setAllFlat()
1426{ 1434{
1427 if ( isFlatDisplay ) { 1435 if ( isFlatDisplay ) {
1428 isFlatDisplay = false; 1436 isFlatDisplay = false;
1429 mPopupMenu->setItemChecked( 8,false ); 1437 mPopupMenu->setItemChecked( 8,false );
1430 updateView(); 1438 updateView();
1431 return; 1439 return;
1432 } 1440 }
1433 storeCurrentItem();
1434 displayAllFlat(); 1441 displayAllFlat();
1435 resetCurrentItem();
1436} 1442}
1437 1443
1438void KOTodoView::purgeCompleted() 1444void KOTodoView::purgeCompleted()
1439{ 1445{
1440 emit purgeCompletedSignal(); 1446 emit purgeCompletedSignal();
1441 1447
1442} 1448}
1443void KOTodoView::toggleQuickTodo() 1449void KOTodoView::toggleQuickTodo()
1444{ 1450{
1445 if ( mQuickAdd->isVisible() ) { 1451 if ( mQuickAdd->isVisible() ) {
1446 mQuickAdd->hide(); 1452 mQuickAdd->hide();
1447 KOPrefs::instance()->mEnableQuickTodo = false; 1453 KOPrefs::instance()->mEnableQuickTodo = false;
diff --git a/korganizer/kotodoview.h b/korganizer/kotodoview.h
index 1b31d0d..9ae7f53 100644
--- a/korganizer/kotodoview.h
+++ b/korganizer/kotodoview.h
@@ -215,24 +215,25 @@ class KOTodoView : public KOrg::BaseView
215 void displayAllFlat(); 215 void displayAllFlat();
216 216
217 void purgeCompleted(); 217 void purgeCompleted();
218 void toggleCompleted(); 218 void toggleCompleted();
219 void toggleRunning(); 219 void toggleRunning();
220 void toggleQuickTodo(); 220 void toggleQuickTodo();
221 void updateTodo( Todo *, int ); 221 void updateTodo( Todo *, int );
222 222
223 void itemClicked(QListViewItem *); 223 void itemClicked(QListViewItem *);
224 void itemStateChanged(QListViewItem *); 224 void itemStateChanged(QListViewItem *);
225 void modified(bool); 225 void modified(bool);
226 void itemDoubleClicked(QListViewItem *item); 226 void itemDoubleClicked(QListViewItem *item);
227 void resetFocusToList();
227 228
228 signals: 229 signals:
229 void newTodoSignal(); 230 void newTodoSignal();
230 void newSubTodoSignal(Todo *); 231 void newSubTodoSignal(Todo *);
231 void unparentTodoSignal(Todo *); 232 void unparentTodoSignal(Todo *);
232 void reparentTodoSignal( Todo *,Todo * ); 233 void reparentTodoSignal( Todo *,Todo * );
233 void showTodoSignal(Todo *); 234 void showTodoSignal(Todo *);
234 235
235 void editTodoSignal(Todo *); 236 void editTodoSignal(Todo *);
236 void deleteTodoSignal(Todo *); 237 void deleteTodoSignal(Todo *);
237 void todoModifiedSignal (Todo *, int); 238 void todoModifiedSignal (Todo *, int);
238 239