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.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/korganizer/koeventpopupmenu.cpp b/korganizer/koeventpopupmenu.cpp
index 90caaf4..41d331a 100644
--- a/korganizer/koeventpopupmenu.cpp
+++ b/korganizer/koeventpopupmenu.cpp
@@ -54,13 +54,18 @@ KOEventPopupMenu::KOEventPopupMenu(): QPopupMenu()
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 )));
+ mCalPopup = new QPopupMenu ( this );
+ mCalPopup->setCheckable (true);
+ connect(mCalPopup,SIGNAL( aboutToShow ()), this ,SLOT( fillCalPopup()));
+ connect(mCalPopup,SIGNAL( activated ( int ) ), this ,SLOT( computeCalPopup( int )));
mEditOnlyItems.append(insertItem (i18n("Categories"),mCatPopup ));
+ mEditOnlyItems.append(insertItem (i18n("Calendar"),mCalPopup ));
QValueList<int>::Iterator it;
for( it = mEditOnlyItems.begin(); it != mEditOnlyItems.end(); ++it ) {
mSingleOnlyItems.append(*it);
}
}
@@ -71,15 +76,35 @@ void KOEventPopupMenu::enableDefault( bool enable )
for( it = mSingleOnlyItems.begin(); it != mSingleOnlyItems.end(); ++it ) {
setItemEnabled(*it,enable);
}
}
+void KOEventPopupMenu::fillCalPopup() // CAL
+{
+ mCalPopup->clear();
+ if (!mCurrentIncidence) return;
+ KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
+ while ( kkf ) {
+ int index = mCalPopup->insertItem( kkf->mName, kkf->mCalNumber);
+ if ( kkf->mErrorOnLoad || kkf->isReadOnly )
+ mCalPopup->setItemEnabled( index, false );
+ mCalPopup->setItemChecked (index, kkf->mCalNumber == mCurrentIncidence->calID());
+ kkf = KOPrefs::instance()->mCalendars.next();
+ }
+}
+void KOEventPopupMenu::computeCalPopup( int index ) // CAL
+{
+ if (!mCurrentIncidence) return;
+ mCurrentIncidence->setCalID( index );
+ emit categoryChanged( mCurrentIncidence );
+}
void KOEventPopupMenu::fillCatPopup()
{
mCatPopup->clear();
+ if (!mCurrentIncidence) return;
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 );
@@ -88,12 +113,13 @@ void KOEventPopupMenu::fillCatPopup()
}
++index;
}
}
void KOEventPopupMenu::computeCatPopup( int index )
{
+ if (!mCurrentIncidence) return;
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]);
@@ -106,12 +132,13 @@ void KOEventPopupMenu::computeCatPopup( int index )
}
mCurrentIncidence->setCategories( categories );
emit categoryChanged( mCurrentIncidence );
}
void KOEventPopupMenu::showIncidencePopup(Incidence *incidence)
{
+ if ( !incidence) return;
mCurrentIncidence = incidence;
if (mCurrentIncidence) {
// Enable/Disabled menu items only valid for editable events.
if ( !isDisabled ) {
QValueList<int>::Iterator it;