summaryrefslogtreecommitdiffabout
path: root/korganizer/koeventpopupmenu.cpp
Side-by-side diff
Diffstat (limited to 'korganizer/koeventpopupmenu.cpp') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/koeventpopupmenu.cpp44
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
@@ -32,4 +32,5 @@
#include "koeventpopupmenu.h"
+#include "koprefs.h"
-KOEventPopupMenu::KOEventPopupMenu()
+KOEventPopupMenu::KOEventPopupMenu(): QPopupMenu()
{
@@ -54,2 +55,7 @@ KOEventPopupMenu::KOEventPopupMenu()
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;
@@ -58,2 +64,3 @@ KOEventPopupMenu::KOEventPopupMenu()
}
+
}
@@ -69,2 +76,35 @@ 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)
@@ -82,4 +122,2 @@ void KOEventPopupMenu::showIncidencePopup(Incidence *incidence)
popup(QCursor::pos());
- } else {
- kdDebug() << "KOEventPopupMenu::showEventPopup(): No event selected" << endl;
}