From df0200487afbfa59b80a79e548d70b5203019003 Mon Sep 17 00:00:00 2001 From: zautrix Date: Wed, 05 Jan 2005 14:17:14 +0000 Subject: todo enhancements/fixes --- (limited to 'korganizer/kotodoview.cpp') diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index 9cafc60..5d7b066 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp @@ -332,6 +332,7 @@ void KOQuickTodo::focusOutEvent(QFocusEvent *ev) KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : KOrg::BaseView(calendar,parent,name) { + mNavigator = 0; QBoxLayout *topLayout = new QVBoxLayout(this); mName = QString ( name ); mBlockUpdate = false; @@ -352,11 +353,18 @@ KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : mTodoListView->addColumn(i18n("Prio")); mTodoListView->setColumnAlignment(1,AlignHCenter); mTodoListView->addColumn(i18n("Complete")); - mTodoListView->setColumnAlignment(2,AlignHCenter); + mTodoListView->setColumnAlignment(2,AlignCenter); + mTodoListView->addColumn(i18n("Due Date")); mTodoListView->setColumnAlignment(3,AlignLeft); mTodoListView->addColumn(i18n("Due Time")); mTodoListView->setColumnAlignment(4,AlignHCenter); + + mTodoListView->addColumn(i18n("Start Date")); + mTodoListView->setColumnAlignment(5,AlignLeft); + mTodoListView->addColumn(i18n("Start Time")); + mTodoListView->setColumnAlignment(6,AlignHCenter); + mTodoListView->addColumn(i18n("Cancelled")); mTodoListView->addColumn(i18n("Categories")); #if 0 @@ -375,10 +383,9 @@ KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : mTodoListView->setColumnWidthMode(4, QListView::Manual); mTodoListView->setColumnWidthMode(5, QListView::Manual); mTodoListView->setColumnWidthMode(6, QListView::Manual); - mTodoListView->setColumnAlignment( 2, AlignCenter ); -#if 0 - mTodoListView->setColumnWidthMode(6, QListView::Manual); -#endif + mTodoListView->setColumnWidthMode(7, QListView::Manual); + mTodoListView->setColumnWidthMode(8, QListView::Manual); + mPriorityPopupMenu = new QPopupMenu(this); for (int i = 1; i <= 5; i++) { @@ -428,6 +435,8 @@ KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : this, SLOT( toggleCompleted() ),0, 33 ); mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), this, SLOT( toggleQuickTodo() ),0, 34 ); + mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), + this, SLOT( toggleRunning() ),0, 35 ); mPopupMenu = new QPopupMenu(this); mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, @@ -438,10 +447,24 @@ KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : this, SLOT( toggleCompleted() ),0,3 ); mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), this, SLOT( toggleQuickTodo() ),0,4 ); + mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), + this, SLOT( toggleRunning() ),0,5 ); mDocPrefs = new DocPrefs( name ); mPopupMenu->setCheckable( true ); mItemPopupMenu->setCheckable( true ); + + + mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); + mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); + + mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); + mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); + + mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); + mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); + + // Double clicking conflicts with opening/closing the subtree connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), SLOT( editItem( QListViewItem *) ) ); @@ -476,11 +499,6 @@ KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : SLOT( processSelectionChange() ) ); connect( mQuickAdd, SIGNAL( returnPressed () ), SLOT( addQuickTodo() ) ); -// if ( QApplication::desktop()->width() < 480 ) { -// setNarrow(); - // mTodoListView->setColumnWidth( 0, 100 ); - - // } } @@ -497,16 +515,6 @@ void KOTodoView::jumpToDate () // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); } -void KOTodoView::setNarrow() -{ - //mTodoListView->setColumnWidth( 0, 120 ); - mTodoListView->setColumnWidth( 1, 35 ); - mTodoListView->setColumnWidth( 2, 40 ); - mTodoListView->setColumnWidth( 3, 80 ); - mTodoListView->setColumnWidth( 4, 40 ); - mTodoListView->setColumnWidth( 5, 90 ); - -} void KOTodoView::updateView() { pendingSubtodo = 0; @@ -587,7 +595,7 @@ void KOTodoView::updateView() // } //qDebug("for "); for(todo = todoList.first(); todo; todo = todoList.next()) { - if (!mTodoMap.contains(todo) && ( KOPrefs::instance()->mShowCompletedTodo || !todo->isCompleted() ) ) + if (!mTodoMap.contains(todo) && checkTodo( todo ) ) { insertTodoItem(todo); } @@ -601,6 +609,22 @@ void KOTodoView::updateView() processSelectionChange(); } +bool KOTodoView::checkTodo( Todo * todo ) +{ + + if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) + return false; + if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { + if ( todo->hasStartDate() ) + if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) + return false; + if ( todo->hasDueDate() ) + if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) + return false; + } + return true; +} + void KOTodoView::restoreItemState( QListViewItem *item ) { pendingSubtodo = 0; @@ -616,6 +640,7 @@ void KOTodoView::restoreItemState( QListViewItem *item ) QMap::ConstIterator KOTodoView::insertTodoItem(Todo *todo) { + // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; // TODO: Check, if dynmaic cast is necessary @@ -718,7 +743,7 @@ void KOTodoView::popupMenu(QListViewItem *item,const QPoint &,int column) case 3: moveTodo(); break; - case 6: + case 8: getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break; default: mItemPopupMenu->popup(QCursor::pos()); @@ -995,6 +1020,15 @@ void KOTodoView::toggleQuickTodo() mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); } + +void KOTodoView::toggleRunning() +{ + KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos; + mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); + mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); + updateView(); +} + void KOTodoView::toggleCompleted() { KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo; -- cgit v0.9.0.2