-rw-r--r-- | korganizer/kotodoview.cpp | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index 1bfdef9..873a776 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp @@ -499,2 +499,3 @@ KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : { + mCategoryPopupMenu = 0; mPendingUpdateBeforeRepaint = false; @@ -1160,18 +1161,18 @@ QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem) { - QPopupMenu* tempMenu = new QPopupMenu (this); - 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); - mCategory[index] = *it; - if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true); - } - - connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); - return tempMenu; - - + if ( !mCategoryPopupMenu ) { + mCategoryPopupMenu = new QPopupMenu (this); + mCategoryPopupMenu->setCheckable (true); + connect (mCategoryPopupMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); + } + mCategoryPopupMenu->clear(); + QStringList checkedCategories = todoItem->todo()->categories (); + + for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); + it != KOPrefs::instance()->mCustomCategories.end (); + ++it) { + int index = mCategoryPopupMenu->insertItem (*it); + mCategory[index] = *it; + if (checkedCategories.find (*it) != checkedCategories.end ()) mCategoryPopupMenu->setItemChecked (index, true); + } + return mCategoryPopupMenu; } |