author | zautrix <zautrix> | 2005-07-01 06:04:54 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-07-01 06:04:54 (UTC) |
commit | a7924287e231b461585c4121f6ee2ce32f955089 (patch) (side-by-side diff) | |
tree | 992d503b50212e72d69d845bd8d27cb8f8518c30 /korganizer/koeventpopupmenu.cpp | |
parent | 7da83cbf37b406a523e36a948039941840d48fb1 (diff) | |
download | kdepimpi-a7924287e231b461585c4121f6ee2ce32f955089.zip kdepimpi-a7924287e231b461585c4121f6ee2ce32f955089.tar.gz kdepimpi-a7924287e231b461585c4121f6ee2ce32f955089.tar.bz2 |
fixxx
Diffstat (limited to 'korganizer/koeventpopupmenu.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | korganizer/koeventpopupmenu.cpp | 44 |
1 files changed, 41 insertions, 3 deletions
diff --git a/korganizer/koeventpopupmenu.cpp b/korganizer/koeventpopupmenu.cpp index 17ef81e..90caaf4 100644 --- a/korganizer/koeventpopupmenu.cpp +++ b/korganizer/koeventpopupmenu.cpp @@ -31,6 +31,7 @@ #include "koeventpopupmenu.h" +#include "koprefs.h" -KOEventPopupMenu::KOEventPopupMenu() +KOEventPopupMenu::KOEventPopupMenu(): QPopupMenu() { mCurrentIncidence = 0; @@ -53,8 +54,14 @@ KOEventPopupMenu::KOEventPopupMenu() this,SLOT(popupCancel()))); isDisabled = false; + mCatPopup = new QPopupMenu ( this ); + mCatPopup->setCheckable (true); + connect(mCatPopup,SIGNAL( aboutToShow ()), this ,SLOT( fillCatPopup())); + connect(mCatPopup,SIGNAL( activated ( int ) ), this ,SLOT( computeCatPopup( int ))); + mEditOnlyItems.append(insertItem (i18n("Categories"),mCatPopup )); QValueList<int>::Iterator it; for( it = mEditOnlyItems.begin(); it != mEditOnlyItems.end(); ++it ) { mSingleOnlyItems.append(*it); } + } void KOEventPopupMenu::enableDefault( bool enable ) @@ -68,4 +75,37 @@ void KOEventPopupMenu::enableDefault( bool enable ) } +void KOEventPopupMenu::fillCatPopup() +{ + mCatPopup->clear(); + QStringList checkedCategories = mCurrentIncidence->categories(); + int index = 0; + for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); + it != KOPrefs::instance()->mCustomCategories.end (); + ++it) { + mCatPopup->insertItem (*it, index ); + if (checkedCategories.find (*it) != checkedCategories.end ()) { + mCatPopup->setItemChecked (index, true); + } + ++index; + } +} +void KOEventPopupMenu::computeCatPopup( int index ) +{ + QStringList categories = mCurrentIncidence->categories(); + QString colcat = categories.first(); + if (categories.find (KOPrefs::instance()->mCustomCategories[index]) != categories.end ()) + categories.remove (KOPrefs::instance()->mCustomCategories[index]); + else + categories.insert (categories.end(), KOPrefs::instance()->mCustomCategories[index]); + categories.sort (); + if ( !colcat.isEmpty() ) { + if ( categories.find ( colcat ) != categories.end () ) { + categories.remove( colcat ); + categories.prepend( colcat ); + } + } + mCurrentIncidence->setCategories( categories ); + emit categoryChanged( mCurrentIncidence ); +} void KOEventPopupMenu::showIncidencePopup(Incidence *incidence) { @@ -81,6 +121,4 @@ void KOEventPopupMenu::showIncidencePopup(Incidence *incidence) } popup(QCursor::pos()); - } else { - kdDebug() << "KOEventPopupMenu::showEventPopup(): No event selected" << endl; } } |