summaryrefslogtreecommitdiffabout
path: root/korganizer/kotodoview.cpp
Unidiff
Diffstat (limited to 'korganizer/kotodoview.cpp') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/kotodoview.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp
index a12c43e..d79a9b9 100644
--- a/korganizer/kotodoview.cpp
+++ b/korganizer/kotodoview.cpp
@@ -492,49 +492,49 @@ KOQuickTodo::KOQuickTodo(QWidget *parent) :
492 QLineEdit(parent) 492 QLineEdit(parent)
493{ 493{
494 setText(i18n("Click to add new Todo")); 494 setText(i18n("Click to add new Todo"));
495 setFocusPolicy ( QWidget::ClickFocus ); 495 setFocusPolicy ( QWidget::ClickFocus );
496} 496}
497 497
498void KOQuickTodo::focusInEvent(QFocusEvent *ev) 498void KOQuickTodo::focusInEvent(QFocusEvent *ev)
499{ 499{
500 if ( text()==i18n("Click to add new Todo") ) 500 if ( text()==i18n("Click to add new Todo") )
501 setText(""); 501 setText("");
502 QLineEdit::focusInEvent(ev); 502 QLineEdit::focusInEvent(ev);
503} 503}
504 504
505void KOQuickTodo::focusOutEvent(QFocusEvent *ev) 505void KOQuickTodo::focusOutEvent(QFocusEvent *ev)
506{ 506{
507 setText(i18n("Click to add new Todo")); 507 setText(i18n("Click to add new Todo"));
508 QLineEdit::focusOutEvent(ev); 508 QLineEdit::focusOutEvent(ev);
509} 509}
510 510
511///////////////////////////////////////////////////////////////////////////// 511/////////////////////////////////////////////////////////////////////////////
512 512
513KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : 513KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) :
514 KOrg::BaseView(calendar,parent,name) 514 KOrg::BaseView(calendar,parent,name)
515{ 515{
516 516 mIsActiveWindow = false;
517 mCurItem = 0; 517 mCurItem = 0;
518 mCurItemRootParent = 0; 518 mCurItemRootParent = 0;
519 mCurItemParent = 0; 519 mCurItemParent = 0;
520 mCurItemAbove = 0; 520 mCurItemAbove = 0;
521 mActiveItem = 0; 521 mActiveItem = 0;
522 mCategoryPopupMenu = 0; 522 mCategoryPopupMenu = 0;
523 mPendingUpdateBeforeRepaint = false; 523 mPendingUpdateBeforeRepaint = false;
524 isFlatDisplay = false; 524 isFlatDisplay = false;
525 mNavigator = 0; 525 mNavigator = 0;
526 QBoxLayout *topLayout = new QVBoxLayout(this); 526 QBoxLayout *topLayout = new QVBoxLayout(this);
527 mName = QString ( name ); 527 mName = QString ( name );
528 mBlockUpdate = false; 528 mBlockUpdate = false;
529 mQuickBar = new QWidget( this ); 529 mQuickBar = new QWidget( this );
530 topLayout->addWidget(mQuickBar); 530 topLayout->addWidget(mQuickBar);
531 531
532 mQuickAdd = new KOQuickTodo(mQuickBar); 532 mQuickAdd = new KOQuickTodo(mQuickBar);
533 QBoxLayout *quickLayout = new QHBoxLayout(mQuickBar); 533 QBoxLayout *quickLayout = new QHBoxLayout(mQuickBar);
534 quickLayout->addWidget( mQuickAdd ); 534 quickLayout->addWidget( mQuickAdd );
535 mNewSubBut = new QPushButton( "sub",mQuickBar ); 535 mNewSubBut = new QPushButton( "sub",mQuickBar );
536 QPushButton * s_done = new QPushButton( "D",mQuickBar ); 536 QPushButton * s_done = new QPushButton( "D",mQuickBar );
537 QPushButton * s_run = new QPushButton( "R",mQuickBar ); 537 QPushButton * s_run = new QPushButton( "R",mQuickBar );
538 QPushButton * allopen = new QPushButton( "O",mQuickBar ); 538 QPushButton * allopen = new QPushButton( "O",mQuickBar );
539 QPushButton * allclose = new QPushButton( "C",mQuickBar ); 539 QPushButton * allclose = new QPushButton( "C",mQuickBar );
540 QPushButton * flat = new QPushButton( "F",mQuickBar ); 540 QPushButton * flat = new QPushButton( "F",mQuickBar );
@@ -929,48 +929,49 @@ void KOTodoView::updateView()
929 } 929 }
930 if ( next ) 930 if ( next )
931 todo = todoList.next(); 931 todo = todoList.next();
932 } 932 }
933 933
934 for(todo = todoList.first(); todo; todo = todoList.next()) { 934 for(todo = todoList.first(); todo; todo = todoList.next()) {
935 if (!mTodoMap.contains(todo) && checkTodo( todo ) ) 935 if (!mTodoMap.contains(todo) && checkTodo( todo ) )
936 { 936 {
937 insertTodoItem(todo); 937 insertTodoItem(todo);
938 } 938 }
939 } 939 }
940 // Restore opened/closed state 940 // Restore opened/closed state
941 mTodoListView->blockSignals( true ); 941 mTodoListView->blockSignals( true );
942 if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); 942 if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() );
943 mTodoListView->blockSignals( false ); 943 mTodoListView->blockSignals( false );
944 resetCurrentItem(); 944 resetCurrentItem();
945} 945}
946 946
947void KOTodoView::storeCurrentItem() 947void KOTodoView::storeCurrentItem()
948{ 948{
949 mCurItem = 0; 949 mCurItem = 0;
950 mCurItemRootParent = 0; 950 mCurItemRootParent = 0;
951 mCurItemParent = 0; 951 mCurItemParent = 0;
952 mCurItemAbove = 0; 952 mCurItemAbove = 0;
953 mIsActiveWindow = topLevelWidget()->isActiveWindow();
953 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 954 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
954 if (mActiveItem) { 955 if (mActiveItem) {
955 mCurItem = mActiveItem->todo(); 956 mCurItem = mActiveItem->todo();
956 KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove (); 957 KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove ();
957 if ( activeItemAbove ) 958 if ( activeItemAbove )
958 mCurItemAbove = activeItemAbove->todo(); 959 mCurItemAbove = activeItemAbove->todo();
959 mCurItemRootParent = mCurItem; 960 mCurItemRootParent = mCurItem;
960 mCurItemParent = mCurItemRootParent->relatedTo(); 961 mCurItemParent = mCurItemRootParent->relatedTo();
961 while ( mCurItemRootParent->relatedTo() != 0 ) 962 while ( mCurItemRootParent->relatedTo() != 0 )
962 mCurItemRootParent = mCurItemRootParent->relatedTo(); 963 mCurItemRootParent = mCurItemRootParent->relatedTo();
963 } 964 }
964 mActiveItem = 0; 965 mActiveItem = 0;
965} 966}
966 967
967void KOTodoView::resetCurrentItem() 968void KOTodoView::resetCurrentItem()
968{ 969{
969 //mTodoListView->setFocus(); 970 //mTodoListView->setFocus();
970 KOTodoViewItem* foundItem = 0; 971 KOTodoViewItem* foundItem = 0;
971 KOTodoViewItem* foundItemRoot = 0; 972 KOTodoViewItem* foundItemRoot = 0;
972 KOTodoViewItem* foundItemParent = 0; 973 KOTodoViewItem* foundItemParent = 0;
973 KOTodoViewItem* foundItemAbove = 0; 974 KOTodoViewItem* foundItemAbove = 0;
974 if ( mTodoListView->firstChild () ) { 975 if ( mTodoListView->firstChild () ) {
975 if ( mCurItem ) { 976 if ( mCurItem ) {
976 KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild (); 977 KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild ();
@@ -997,48 +998,49 @@ void KOTodoView::resetCurrentItem()
997 if ( foundItemRoot ) 998 if ( foundItemRoot )
998 foundItem = foundItemRoot; 999 foundItem = foundItemRoot;
999 else 1000 else
1000 foundItem = foundItemAbove; 1001 foundItem = foundItemAbove;
1001 } 1002 }
1002 } 1003 }
1003 } 1004 }
1004 if ( foundItem ) { 1005 if ( foundItem ) {
1005 mTodoListView->setSelected ( foundItem, true ); 1006 mTodoListView->setSelected ( foundItem, true );
1006 mTodoListView->setCurrentItem( foundItem ); 1007 mTodoListView->setCurrentItem( foundItem );
1007 mTodoListView->ensureItemVisible( foundItem ); 1008 mTodoListView->ensureItemVisible( foundItem );
1008 } else { 1009 } else {
1009 if ( mTodoListView->firstChild () ) { 1010 if ( mTodoListView->firstChild () ) {
1010 mTodoListView->setSelected ( mTodoListView->firstChild (), true ); 1011 mTodoListView->setSelected ( mTodoListView->firstChild (), true );
1011 mTodoListView->setCurrentItem( mTodoListView->firstChild () ); 1012 mTodoListView->setCurrentItem( mTodoListView->firstChild () );
1012 } 1013 }
1013 } 1014 }
1014 } 1015 }
1015 processSelectionChange(); 1016 processSelectionChange();
1016 if ( mName != "todolistsmall" ) 1017 if ( mName != "todolistsmall" )
1017 QTimer::singleShot( 100, this, SLOT ( resetFocusToList() )); 1018 QTimer::singleShot( 100, this, SLOT ( resetFocusToList() ));
1018} 1019}
1019void KOTodoView::resetFocusToList() 1020void KOTodoView::resetFocusToList()
1020{ 1021{
1022 if ( mIsActiveWindow )
1021 topLevelWidget()->setActiveWindow(); 1023 topLevelWidget()->setActiveWindow();
1022 mTodoListView->setFocus(); 1024 mTodoListView->setFocus();
1023} 1025}
1024//Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove; 1026//Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove;
1025bool KOTodoView::checkTodo( Todo * todo ) 1027bool KOTodoView::checkTodo( Todo * todo )
1026{ 1028{
1027 1029
1028 if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) 1030 if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() )
1029 return false; 1031 return false;
1030 if ( !todo->isCompleted() ) { 1032 if ( !todo->isCompleted() ) {
1031 if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() ) 1033 if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() )
1032 return true; 1034 return true;
1033 } 1035 }
1034 if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { 1036 if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) {
1035 if ( todo->hasStartDate() ) 1037 if ( todo->hasStartDate() )
1036 if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) 1038 if ( mNavigator->selectedDates().last() < todo->dtStart().date() )
1037 return false; 1039 return false;
1038 if ( todo->hasDueDate() ) 1040 if ( todo->hasDueDate() )
1039 if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) 1041 if ( mNavigator->selectedDates().first() > todo->dtDue().date() )
1040 return false; 1042 return false;
1041 } 1043 }
1042 return true; 1044 return true;
1043} 1045}
1044 1046