summaryrefslogtreecommitdiffabout
path: root/korganizer/koeventpopupmenu.cpp
Side-by-side diff
Diffstat (limited to 'korganizer/koeventpopupmenu.cpp') (more/less context) (ignore 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
@@ -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;
}
}