-rw-r--r-- | korganizer/kotodoview.cpp | 53 |
1 files changed, 41 insertions, 12 deletions
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index e2966f8..4f42c83 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp @@ -567,9 +567,21 @@ KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); + mCategoryPopupMenu = new QPopupMenu (this); + mCategoryPopupMenu->setCheckable (true); + connect (mCategoryPopupMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); + connect (mCategoryPopupMenu, SIGNAL (aboutToShow ()), SLOT (fillCategories ())); + + mCalPopupMenu = new QPopupMenu (this); + mCalPopupMenu->setCheckable (true); + connect (mCalPopupMenu, SIGNAL (activated (int)), SLOT (changedCal (int))); + connect (mCalPopupMenu, SIGNAL (aboutToShow ()), SLOT (fillCal ())); + + + mItemPopupMenu = new QPopupMenu(this); - mItemPopupMenu->insertItem(i18n("Show..."), this, + mItemPopupMenu->insertItem(i18n("Show"), this, SLOT (showTodo())); mItemPopupMenu->insertItem(i18n("Edit..."), this, SLOT (editTodo())); @@ -585,6 +597,8 @@ KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : #endif mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, SLOT (cancelTodo())); + mItemPopupMenu->insertItem( i18n("Categories"), mCategoryPopupMenu); + mItemPopupMenu->insertItem( i18n("Calendar"), mCalPopupMenu); mItemPopupMenu->insertSeparator(); mItemPopupMenu->insertItem( i18n("Start/Stop todo..."), this, SLOT (toggleRunningItem())); @@ -1053,7 +1067,9 @@ void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column) moveTodo(); break; case 8: - getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break; + mCategoryPopupMenu->popup(QCursor::pos ()); break; + case 9: + mCalPopupMenu->popup(QCursor::pos ()); break; default: mItemPopupMenu->popup(QCursor::pos()); } @@ -1164,17 +1180,11 @@ void KOTodoView::setNewPercentage(int index) } } - -QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem) +void KOTodoView::fillCategories () { - if ( !mCategoryPopupMenu ) { - mCategoryPopupMenu = new QPopupMenu (this); - mCategoryPopupMenu->setCheckable (true); - connect (mCategoryPopupMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); - } mCategoryPopupMenu->clear(); - QStringList checkedCategories = todoItem->todo()->categories (); - + if ( ! mActiveItem ) return; + QStringList checkedCategories = mActiveItem->todo()->categories (); for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); it != KOPrefs::instance()->mCustomCategories.end (); ++it) { @@ -1182,7 +1192,26 @@ QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem) mCategory[index] = *it; if (checkedCategories.find (*it) != checkedCategories.end ()) mCategoryPopupMenu->setItemChecked (index, true); } - return mCategoryPopupMenu; +} +void KOTodoView::fillCal () +{ + mCalPopupMenu->clear(); + if (!mActiveItem) return; + bool readO = mActiveItem->todo()->isReadOnly(); + KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); + while ( kkf ) { + int index = mCalPopupMenu->insertItem( kkf->mName, kkf->mCalNumber); + if ( kkf->mErrorOnLoad || kkf->isReadOnly || readO ) + mCalPopupMenu->setItemEnabled( index, false ); + mCalPopupMenu->setItemChecked (index, kkf->mCalNumber == mActiveItem->todo()->calID()); + kkf = KOPrefs::instance()->mCalendars.next(); + } +} +void KOTodoView::changedCal (int index ) +{ + if (!mActiveItem) return; + mActiveItem->todo()->setCalID( index ); + mActiveItem->construct(); } void KOTodoView::changedCategories(int index) { |