summaryrefslogtreecommitdiffabout
path: root/korganizer/koeventpopupmenu.cpp
Unidiff
Diffstat (limited to 'korganizer/koeventpopupmenu.cpp') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/koeventpopupmenu.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/korganizer/koeventpopupmenu.cpp b/korganizer/koeventpopupmenu.cpp
index 0b0fe8e..77322e7 100644
--- a/korganizer/koeventpopupmenu.cpp
+++ b/korganizer/koeventpopupmenu.cpp
@@ -16,146 +16,152 @@
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qcursor.h> 24#include <qcursor.h>
25 25
26#include <klocale.h> 26#include <klocale.h>
27#include <kdebug.h> 27#include <kdebug.h>
28#include <kiconloader.h> 28#include <kiconloader.h>
29 29
30#include <libkcal/event.h> 30#include <libkcal/event.h>
31 31
32#include "koeventpopupmenu.h" 32#include "koeventpopupmenu.h"
33#include "koprefs.h" 33#include "koprefs.h"
34 34
35KOEventPopupMenu::KOEventPopupMenu(): QPopupMenu() 35KOEventPopupMenu::KOEventPopupMenu(): QPopupMenu()
36{ 36{
37 mCurrentIncidence = 0; 37 mCurrentIncidence = 0;
38 mHasAdditionalItems = false; 38 mHasAdditionalItems = false;
39 39
40 40
41 mSingleOnlyItems.append( insertItem (i18n("&Show"),this,SLOT(popupShow()))); 41 mSingleOnlyItems.append( insertItem (i18n("&Show"),this,SLOT(popupShow())));
42 mEditOnlyItems.append(insertItem (i18n("&Edit..."),this,SLOT(popupEdit()))); 42 mEditOnlyItems.append(insertItem (i18n("&Edit..."),this,SLOT(popupEdit())));
43 mEditOnlyItems.append(insertItem (i18n("&Delete..."), 43 mEditOnlyItems.append(insertItem (i18n("&Delete..."),
44 this,SLOT(popupDelete()))); 44 this,SLOT(popupDelete())));
45 mEditOnlyItems.append(insertItem (i18n("&Clone..."), 45 mEditOnlyItems.append(insertItem (i18n("&Clone..."),
46 this,SLOT(popupClone()))); 46 this,SLOT(popupClone())));
47 mEditOnlyItems.append(insertItem (i18n("&Move..."), 47 mEditOnlyItems.append(insertItem (i18n("&Move..."),
48 this,SLOT(popupMove()))); 48 this,SLOT(popupMove())));
49#ifndef DESKTOP_VERSION 49#ifndef DESKTOP_VERSION
50 mEditOnlyItems.append(insertItem (i18n("&Beam..."), 50 mEditOnlyItems.append(insertItem (i18n("&Beam..."),
51 this,SLOT(popupBeam()))); 51 this,SLOT(popupBeam())));
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 ); 60 mCalPopup = new QPopupMenu ( this );
61 mCalPopup->setCheckable (true); 61 mCalPopup->setCheckable (true);
62 connect(mCalPopup,SIGNAL( aboutToShow ()), this ,SLOT( fillCalPopup())); 62 connect(mCalPopup,SIGNAL( aboutToShow ()), this ,SLOT( fillCalPopup()));
63 connect(mCalPopup,SIGNAL( activated ( int ) ), this ,SLOT( computeCalPopup( int ))); 63 connect(mCalPopup,SIGNAL( activated ( int ) ), this ,SLOT( computeCalPopup( int )));
64 mEditOnlyItems.append(insertItem (i18n("Categories"),mCatPopup )); 64 //mEditOnlyItems.append(insertItem (i18n("Categories"),mCatPopup ));
65 mEditOnlyItems.append(insertItem (i18n("Calendar"),mCalPopup )); 65 //mEditOnlyItems.append(insertItem (i18n("Calendar"),mCalPopup ));
66 insertItem (i18n("Categories"),mCatPopup );
67 insertItem (i18n("Calendar"),mCalPopup );
66 QValueList<int>::Iterator it; 68 QValueList<int>::Iterator it;
67 for( it = mEditOnlyItems.begin(); it != mEditOnlyItems.end(); ++it ) { 69 for( it = mEditOnlyItems.begin(); it != mEditOnlyItems.end(); ++it ) {
68 mSingleOnlyItems.append(*it); 70 mSingleOnlyItems.append(*it);
69 } 71 }
70 72
71} 73}
72void KOEventPopupMenu::enableDefault( bool enable ) 74void KOEventPopupMenu::enableDefault( bool enable )
73{ 75{
74 isDisabled = !enable; 76 isDisabled = !enable;
75 QValueList<int>::Iterator it; 77 QValueList<int>::Iterator it;
76 for( it = mSingleOnlyItems.begin(); it != mSingleOnlyItems.end(); ++it ) { 78 for( it = mSingleOnlyItems.begin(); it != mSingleOnlyItems.end(); ++it ) {
77 setItemEnabled(*it,enable); 79 setItemEnabled(*it,enable);
78 } 80 }
79 81
80} 82}
81 83
82void KOEventPopupMenu::fillCalPopup() // CAL 84void KOEventPopupMenu::fillCalPopup() // CAL
83{ 85{
84 mCalPopup->clear(); 86 mCalPopup->clear();
85 if (!mCurrentIncidence) return; 87 if (!mCurrentIncidence) return;
88 bool readO = mCurrentIncidence->isReadOnly()|| isDisabled;
86 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); 89 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
87 while ( kkf ) { 90 while ( kkf ) {
88 int index = mCalPopup->insertItem( kkf->mName, kkf->mCalNumber); 91 int index = mCalPopup->insertItem( kkf->mName, kkf->mCalNumber);
89 if ( kkf->mErrorOnLoad || kkf->isReadOnly ) 92 if ( kkf->mErrorOnLoad || kkf->isReadOnly || readO )
90 mCalPopup->setItemEnabled( index, false ); 93 mCalPopup->setItemEnabled( index, false );
91 mCalPopup->setItemChecked (index, kkf->mCalNumber == mCurrentIncidence->calID()); 94 mCalPopup->setItemChecked (index, kkf->mCalNumber == mCurrentIncidence->calID());
92 kkf = KOPrefs::instance()->mCalendars.next(); 95 kkf = KOPrefs::instance()->mCalendars.next();
93 } 96 }
94} 97}
95void KOEventPopupMenu::computeCalPopup( int index ) // CAL 98void KOEventPopupMenu::computeCalPopup( int index ) // CAL
96{ 99{
97 if (!mCurrentIncidence) return; 100 if (!mCurrentIncidence) return;
98 mCurrentIncidence->setCalID( index ); 101 mCurrentIncidence->setCalID( index );
99 emit categoryChanged( mCurrentIncidence ); 102 emit categoryChanged( mCurrentIncidence );
100} 103}
101void KOEventPopupMenu::fillCatPopup() 104void KOEventPopupMenu::fillCatPopup()
102{ 105{
103 mCatPopup->clear(); 106 mCatPopup->clear();
104 if (!mCurrentIncidence) return; 107 if (!mCurrentIncidence) return;
108 bool readO = mCurrentIncidence->isReadOnly() || isDisabled;
105 QStringList checkedCategories = mCurrentIncidence->categories(); 109 QStringList checkedCategories = mCurrentIncidence->categories();
106 int index = 0; 110 int index = 0;
107 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); 111 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin ();
108 it != KOPrefs::instance()->mCustomCategories.end (); 112 it != KOPrefs::instance()->mCustomCategories.end ();
109 ++it) { 113 ++it) {
110 mCatPopup->insertItem (*it, index ); 114 mCatPopup->insertItem (*it, index );
111 if (checkedCategories.find (*it) != checkedCategories.end ()) { 115 if (checkedCategories.find (*it) != checkedCategories.end ()) {
112 mCatPopup->setItemChecked (index, true); 116 mCatPopup->setItemChecked (index, true);
113 } 117 }
118 if ( readO )
119 mCatPopup->setItemEnabled( index, false );
114 ++index; 120 ++index;
115 } 121 }
116} 122}
117void KOEventPopupMenu::computeCatPopup( int index ) 123void KOEventPopupMenu::computeCatPopup( int index )
118{ 124{
119 if (!mCurrentIncidence) return; 125 if (!mCurrentIncidence) return;
120 QStringList categories = mCurrentIncidence->categories(); 126 QStringList categories = mCurrentIncidence->categories();
121 QString colcat = categories.first(); 127 QString colcat = categories.first();
122 if (categories.find (KOPrefs::instance()->mCustomCategories[index]) != categories.end ()) 128 if (categories.find (KOPrefs::instance()->mCustomCategories[index]) != categories.end ())
123 categories.remove (KOPrefs::instance()->mCustomCategories[index]); 129 categories.remove (KOPrefs::instance()->mCustomCategories[index]);
124 else 130 else
125 categories.insert (categories.end(), KOPrefs::instance()->mCustomCategories[index]); 131 categories.insert (categories.end(), KOPrefs::instance()->mCustomCategories[index]);
126 categories.sort (); 132 categories.sort ();
127 if ( !colcat.isEmpty() ) { 133 if ( !colcat.isEmpty() ) {
128 if ( categories.find ( colcat ) != categories.end () ) { 134 if ( categories.find ( colcat ) != categories.end () ) {
129 categories.remove( colcat ); 135 categories.remove( colcat );
130 categories.prepend( colcat ); 136 categories.prepend( colcat );
131 } 137 }
132 } 138 }
133 mCurrentIncidence->setCategories( categories ); 139 mCurrentIncidence->setCategories( categories );
134 emit categoryChanged( mCurrentIncidence ); 140 emit categoryChanged( mCurrentIncidence );
135} 141}
136void KOEventPopupMenu::showIncidencePopup(Incidence *incidence) 142void KOEventPopupMenu::showIncidencePopup(Incidence *incidence)
137{ 143{
138 if ( !incidence) return; 144 if ( !incidence) return;
139 mCurrentIncidence = incidence; 145 mCurrentIncidence = incidence;
140 146
141 if (mCurrentIncidence) { 147 if (mCurrentIncidence) {
142 // Enable/Disabled menu items only valid for editable events. 148 // Enable/Disabled menu items only valid for editable events.
143 if ( !isDisabled ) { 149 if ( !isDisabled ) {
144 QValueList<int>::Iterator it; 150 QValueList<int>::Iterator it;
145 for( it = mEditOnlyItems.begin(); it != mEditOnlyItems.end(); ++it ) { 151 for( it = mEditOnlyItems.begin(); it != mEditOnlyItems.end(); ++it ) {
146 setItemEnabled(*it,!mCurrentIncidence->isReadOnly()); 152 setItemEnabled(*it,!mCurrentIncidence->isReadOnly());
147 } 153 }
148 } 154 }
149 popup(QCursor::pos()); 155 popup(QCursor::pos());
150 } 156 }
151} 157}
152 158
153void KOEventPopupMenu::addAdditionalItem(const QIconSet &icon,const QString &text, 159void KOEventPopupMenu::addAdditionalItem(const QIconSet &icon,const QString &text,
154 const QObject *receiver, const char *member, 160 const QObject *receiver, const char *member,
155 bool editOnly) 161 bool editOnly)
156{ 162{
157 if (!mHasAdditionalItems) { 163 if (!mHasAdditionalItems) {
158 mHasAdditionalItems = true; 164 mHasAdditionalItems = true;
159 insertSeparator(); 165 insertSeparator();
160 } 166 }
161 int id = insertItem(icon,text,receiver,member); 167 int id = insertItem(icon,text,receiver,member);