Diffstat (limited to 'korganizer/koeventpopupmenu.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | korganizer/koeventpopupmenu.cpp | 27 |
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 | |||
@@ -52,50 +52,76 @@ KOEventPopupMenu::KOEventPopupMenu(): QPopupMenu() | |||
52 | #endif | 52 | #endif |
53 | mEditOnlyItems.append(insertItem (i18n("&Toggle Cancel"), | 53 | mEditOnlyItems.append(insertItem (i18n("&Toggle Cancel"), |
54 | this,SLOT(popupCancel()))); | 54 | this,SLOT(popupCancel()))); |
55 | isDisabled = false; | 55 | isDisabled = false; |
56 | mCatPopup = new QPopupMenu ( this ); | 56 | mCatPopup = new QPopupMenu ( this ); |
57 | mCatPopup->setCheckable (true); | 57 | mCatPopup->setCheckable (true); |
58 | connect(mCatPopup,SIGNAL( aboutToShow ()), this ,SLOT( fillCatPopup())); | 58 | connect(mCatPopup,SIGNAL( aboutToShow ()), this ,SLOT( fillCatPopup())); |
59 | connect(mCatPopup,SIGNAL( activated ( int ) ), this ,SLOT( computeCatPopup( int ))); | 59 | connect(mCatPopup,SIGNAL( activated ( int ) ), this ,SLOT( computeCatPopup( int ))); |
60 | mCalPopup = new QPopupMenu ( this ); | ||
61 | mCalPopup->setCheckable (true); | ||
62 | connect(mCalPopup,SIGNAL( aboutToShow ()), this ,SLOT( fillCalPopup())); | ||
63 | connect(mCalPopup,SIGNAL( activated ( int ) ), this ,SLOT( computeCalPopup( int ))); | ||
60 | mEditOnlyItems.append(insertItem (i18n("Categories"),mCatPopup )); | 64 | mEditOnlyItems.append(insertItem (i18n("Categories"),mCatPopup )); |
65 | mEditOnlyItems.append(insertItem (i18n("Calendar"),mCalPopup )); | ||
61 | QValueList<int>::Iterator it; | 66 | QValueList<int>::Iterator it; |
62 | for( it = mEditOnlyItems.begin(); it != mEditOnlyItems.end(); ++it ) { | 67 | for( it = mEditOnlyItems.begin(); it != mEditOnlyItems.end(); ++it ) { |
63 | mSingleOnlyItems.append(*it); | 68 | mSingleOnlyItems.append(*it); |
64 | } | 69 | } |
65 | 70 | ||
66 | } | 71 | } |
67 | void KOEventPopupMenu::enableDefault( bool enable ) | 72 | void KOEventPopupMenu::enableDefault( bool enable ) |
68 | { | 73 | { |
69 | isDisabled = !enable; | 74 | isDisabled = !enable; |
70 | QValueList<int>::Iterator it; | 75 | QValueList<int>::Iterator it; |
71 | for( it = mSingleOnlyItems.begin(); it != mSingleOnlyItems.end(); ++it ) { | 76 | for( it = mSingleOnlyItems.begin(); it != mSingleOnlyItems.end(); ++it ) { |
72 | setItemEnabled(*it,enable); | 77 | setItemEnabled(*it,enable); |
73 | } | 78 | } |
74 | 79 | ||
75 | } | 80 | } |
76 | 81 | ||
82 | void KOEventPopupMenu::fillCalPopup() // CAL | ||
83 | { | ||
84 | mCalPopup->clear(); | ||
85 | if (!mCurrentIncidence) return; | ||
86 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); | ||
87 | while ( kkf ) { | ||
88 | int index = mCalPopup->insertItem( kkf->mName, kkf->mCalNumber); | ||
89 | if ( kkf->mErrorOnLoad || kkf->isReadOnly ) | ||
90 | mCalPopup->setItemEnabled( index, false ); | ||
91 | mCalPopup->setItemChecked (index, kkf->mCalNumber == mCurrentIncidence->calID()); | ||
92 | kkf = KOPrefs::instance()->mCalendars.next(); | ||
93 | } | ||
94 | } | ||
95 | void KOEventPopupMenu::computeCalPopup( int index ) // CAL | ||
96 | { | ||
97 | if (!mCurrentIncidence) return; | ||
98 | mCurrentIncidence->setCalID( index ); | ||
99 | emit categoryChanged( mCurrentIncidence ); | ||
100 | } | ||
77 | void KOEventPopupMenu::fillCatPopup() | 101 | void KOEventPopupMenu::fillCatPopup() |
78 | { | 102 | { |
79 | mCatPopup->clear(); | 103 | mCatPopup->clear(); |
104 | if (!mCurrentIncidence) return; | ||
80 | QStringList checkedCategories = mCurrentIncidence->categories(); | 105 | QStringList checkedCategories = mCurrentIncidence->categories(); |
81 | int index = 0; | 106 | int index = 0; |
82 | for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); | 107 | for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); |
83 | it != KOPrefs::instance()->mCustomCategories.end (); | 108 | it != KOPrefs::instance()->mCustomCategories.end (); |
84 | ++it) { | 109 | ++it) { |
85 | mCatPopup->insertItem (*it, index ); | 110 | mCatPopup->insertItem (*it, index ); |
86 | if (checkedCategories.find (*it) != checkedCategories.end ()) { | 111 | if (checkedCategories.find (*it) != checkedCategories.end ()) { |
87 | mCatPopup->setItemChecked (index, true); | 112 | mCatPopup->setItemChecked (index, true); |
88 | } | 113 | } |
89 | ++index; | 114 | ++index; |
90 | } | 115 | } |
91 | } | 116 | } |
92 | void KOEventPopupMenu::computeCatPopup( int index ) | 117 | void KOEventPopupMenu::computeCatPopup( int index ) |
93 | { | 118 | { |
119 | if (!mCurrentIncidence) return; | ||
94 | QStringList categories = mCurrentIncidence->categories(); | 120 | QStringList categories = mCurrentIncidence->categories(); |
95 | QString colcat = categories.first(); | 121 | QString colcat = categories.first(); |
96 | if (categories.find (KOPrefs::instance()->mCustomCategories[index]) != categories.end ()) | 122 | if (categories.find (KOPrefs::instance()->mCustomCategories[index]) != categories.end ()) |
97 | categories.remove (KOPrefs::instance()->mCustomCategories[index]); | 123 | categories.remove (KOPrefs::instance()->mCustomCategories[index]); |
98 | else | 124 | else |
99 | categories.insert (categories.end(), KOPrefs::instance()->mCustomCategories[index]); | 125 | categories.insert (categories.end(), KOPrefs::instance()->mCustomCategories[index]); |
100 | categories.sort (); | 126 | categories.sort (); |
101 | if ( !colcat.isEmpty() ) { | 127 | if ( !colcat.isEmpty() ) { |
@@ -104,16 +130,17 @@ void KOEventPopupMenu::computeCatPopup( int index ) | |||
104 | categories.prepend( colcat ); | 130 | categories.prepend( colcat ); |
105 | } | 131 | } |
106 | } | 132 | } |
107 | mCurrentIncidence->setCategories( categories ); | 133 | mCurrentIncidence->setCategories( categories ); |
108 | emit categoryChanged( mCurrentIncidence ); | 134 | emit categoryChanged( mCurrentIncidence ); |
109 | } | 135 | } |
110 | void KOEventPopupMenu::showIncidencePopup(Incidence *incidence) | 136 | void KOEventPopupMenu::showIncidencePopup(Incidence *incidence) |
111 | { | 137 | { |
138 | if ( !incidence) return; | ||
112 | mCurrentIncidence = incidence; | 139 | mCurrentIncidence = incidence; |
113 | 140 | ||
114 | if (mCurrentIncidence) { | 141 | if (mCurrentIncidence) { |
115 | // Enable/Disabled menu items only valid for editable events. | 142 | // Enable/Disabled menu items only valid for editable events. |
116 | if ( !isDisabled ) { | 143 | if ( !isDisabled ) { |
117 | QValueList<int>::Iterator it; | 144 | QValueList<int>::Iterator it; |
118 | for( it = mEditOnlyItems.begin(); it != mEditOnlyItems.end(); ++it ) { | 145 | for( it = mEditOnlyItems.begin(); it != mEditOnlyItems.end(); ++it ) { |
119 | setItemEnabled(*it,!mCurrentIncidence->isReadOnly()); | 146 | setItemEnabled(*it,!mCurrentIncidence->isReadOnly()); |