-rw-r--r-- | korganizer/kotodoview.cpp | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index 1bfdef9..873a776 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp @@ -492,16 +492,17 @@ void KOQuickTodo::focusOutEvent(QFocusEvent *ev) QLineEdit::focusOutEvent(ev); } ///////////////////////////////////////////////////////////////////////////// KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : KOrg::BaseView(calendar,parent,name) { + mCategoryPopupMenu = 0; mPendingUpdateBeforeRepaint = false; isFlatDisplay = false; mNavigator = 0; QBoxLayout *topLayout = new QVBoxLayout(this); mName = QString ( name ); mBlockUpdate = false; mQuickAdd = new KOQuickTodo(this); topLayout->addWidget(mQuickAdd); @@ -1153,32 +1154,32 @@ void KOTodoView::setNewPercentage(int index) todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); } } QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem) { - QPopupMenu* tempMenu = new QPopupMenu (this); + if ( !mCategoryPopupMenu ) { + mCategoryPopupMenu = new QPopupMenu (this); + mCategoryPopupMenu->setCheckable (true); + connect (mCategoryPopupMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); + } + mCategoryPopupMenu->clear(); QStringList checkedCategories = todoItem->todo()->categories (); - tempMenu->setCheckable (true); for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); it != KOPrefs::instance()->mCustomCategories.end (); ++it) { - int index = tempMenu->insertItem (*it); + int index = mCategoryPopupMenu->insertItem (*it); mCategory[index] = *it; - if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true); + if (checkedCategories.find (*it) != checkedCategories.end ()) mCategoryPopupMenu->setItemChecked (index, true); } - - connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); - return tempMenu; - - + return mCategoryPopupMenu; } void KOTodoView::changedCategories(int index) { if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { QStringList categories = mActiveItem->todo()->categories (); QString colcat = categories.first(); if (categories.find (mCategory[index]) != categories.end ()) categories.remove (mCategory[index]); |