summaryrefslogtreecommitdiffabout
path: root/korganizer/koeventpopupmenu.cpp
Unidiff
Diffstat (limited to 'korganizer/koeventpopupmenu.cpp') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/koeventpopupmenu.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/korganizer/koeventpopupmenu.cpp b/korganizer/koeventpopupmenu.cpp
index fc4d9a4..81047c1 100644
--- a/korganizer/koeventpopupmenu.cpp
+++ b/korganizer/koeventpopupmenu.cpp
@@ -1,101 +1,104 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
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//Added by qt3to4:
26#include <Q3ValueList>
27#include <Q3PopupMenu>
25 28
26#include <klocale.h> 29#include <klocale.h>
27#include <kdebug.h> 30#include <kdebug.h>
28#include <kiconloader.h> 31#include <kiconloader.h>
29 32
30#include <libkcal/event.h> 33#include <libkcal/event.h>
31 34
32#include "koeventpopupmenu.h" 35#include "koeventpopupmenu.h"
33#include "koprefs.h" 36#include "koprefs.h"
34 37
35KOEventPopupMenu::KOEventPopupMenu(): QPopupMenu() 38KOEventPopupMenu::KOEventPopupMenu(): Q3PopupMenu()
36{ 39{
37 mCurrentIncidence = 0; 40 mCurrentIncidence = 0;
38 mHasAdditionalItems = false; 41 mHasAdditionalItems = false;
39 42
40 43
41 mSingleOnlyItems.append( insertItem (i18n("&Show"),this,SLOT(popupShow()))); 44 mSingleOnlyItems.append( insertItem (i18n("&Show"),this,SLOT(popupShow())));
42 mEditOnlyItems.append(insertItem (i18n("&Edit..."),this,SLOT(popupEdit()))); 45 mEditOnlyItems.append(insertItem (i18n("&Edit..."),this,SLOT(popupEdit())));
43 mEditOnlyItems.append(insertItem (i18n("&Delete..."), 46 mEditOnlyItems.append(insertItem (i18n("&Delete..."),
44 this,SLOT(popupDelete()))); 47 this,SLOT(popupDelete())));
45 mEditOnlyItems.append(insertItem (i18n("&Clone..."), 48 mEditOnlyItems.append(insertItem (i18n("&Clone..."),
46 this,SLOT(popupClone()))); 49 this,SLOT(popupClone())));
47 mEditOnlyItems.append(insertItem (i18n("&Move..."), 50 mEditOnlyItems.append(insertItem (i18n("&Move..."),
48 this,SLOT(popupMove()))); 51 this,SLOT(popupMove())));
49#ifndef DESKTOP_VERSION 52#ifndef DESKTOP_VERSION
50 mEditOnlyItems.append(insertItem (i18n("&Beam..."), 53 mEditOnlyItems.append(insertItem (i18n("&Beam..."),
51 this,SLOT(popupBeam()))); 54 this,SLOT(popupBeam())));
52#endif 55#endif
53 mEditOnlyItems.append(insertItem (i18n("&Toggle Cancel"), 56 mEditOnlyItems.append(insertItem (i18n("&Toggle Cancel"),
54 this,SLOT(popupCancel()))); 57 this,SLOT(popupCancel())));
55 isDisabled = false; 58 isDisabled = false;
56 mCatPopup = new QPopupMenu ( this ); 59 mCatPopup = new Q3PopupMenu ( this );
57 mCatPopup->setCheckable (true); 60 mCatPopup->setCheckable (true);
58 connect(mCatPopup,SIGNAL( aboutToShow ()), this ,SLOT( fillCatPopup())); 61 connect(mCatPopup,SIGNAL( aboutToShow ()), this ,SLOT( fillCatPopup()));
59 connect(mCatPopup,SIGNAL( activated ( int ) ), this ,SLOT( computeCatPopup( int ))); 62 connect(mCatPopup,SIGNAL( activated ( int ) ), this ,SLOT( computeCatPopup( int )));
60 mCalPopup = new QPopupMenu ( this ); 63 mCalPopup = new Q3PopupMenu ( this );
61 mCalPopup->setCheckable (true); 64 mCalPopup->setCheckable (true);
62 connect(mCalPopup,SIGNAL( aboutToShow ()), this ,SLOT( fillCalPopup())); 65 connect(mCalPopup,SIGNAL( aboutToShow ()), this ,SLOT( fillCalPopup()));
63 connect(mCalPopup,SIGNAL( activated ( int ) ), this ,SLOT( computeCalPopup( int ))); 66 connect(mCalPopup,SIGNAL( activated ( int ) ), this ,SLOT( computeCalPopup( int )));
64 //mEditOnlyItems.append(insertItem (i18n("Categories"),mCatPopup )); 67 //mEditOnlyItems.append(insertItem (i18n("Categories"),mCatPopup ));
65 //mEditOnlyItems.append(insertItem (i18n("Calendar"),mCalPopup )); 68 //mEditOnlyItems.append(insertItem (i18n("Calendar"),mCalPopup ));
66 insertItem (i18n("Categories"),mCatPopup ); 69 insertItem (i18n("Categories"),mCatPopup );
67 insertItem (i18n("Calendar"),mCalPopup ); 70 insertItem (i18n("Calendar"),mCalPopup );
68 QValueList<int>::Iterator it; 71 Q3ValueList<int>::Iterator it;
69 for( it = mEditOnlyItems.begin(); it != mEditOnlyItems.end(); ++it ) { 72 for( it = mEditOnlyItems.begin(); it != mEditOnlyItems.end(); ++it ) {
70 mSingleOnlyItems.append(*it); 73 mSingleOnlyItems.append(*it);
71 } 74 }
72 75
73} 76}
74void KOEventPopupMenu::enableDefault( bool enable ) 77void KOEventPopupMenu::enableDefault( bool enable )
75{ 78{
76 isDisabled = !enable; 79 isDisabled = !enable;
77 QValueList<int>::Iterator it; 80 Q3ValueList<int>::Iterator it;
78 for( it = mSingleOnlyItems.begin(); it != mSingleOnlyItems.end(); ++it ) { 81 for( it = mSingleOnlyItems.begin(); it != mSingleOnlyItems.end(); ++it ) {
79 setItemEnabled(*it,enable); 82 setItemEnabled(*it,enable);
80 } 83 }
81} 84}
82 85
83void KOEventPopupMenu::fillCalPopup() // CAL 86void KOEventPopupMenu::fillCalPopup() // CAL
84{ 87{
85 mCalPopup->clear(); 88 mCalPopup->clear();
86 if (!mCurrentIncidence) return; 89 if (!mCurrentIncidence) return;
87 bool readO = mCurrentIncidence->isReadOnly()|| isDisabled; 90 bool readO = mCurrentIncidence->isReadOnly()|| isDisabled;
88 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); 91 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
89 while ( kkf ) { 92 while ( kkf ) {
90 int index = mCalPopup->insertItem( kkf->mName, kkf->mCalNumber); 93 int index = mCalPopup->insertItem( kkf->mName, kkf->mCalNumber);
91 if ( kkf->mErrorOnLoad || kkf->isReadOnly || readO ) 94 if ( kkf->mErrorOnLoad || kkf->isReadOnly || readO )
92 mCalPopup->setItemEnabled( index, false ); 95 mCalPopup->setItemEnabled( index, false );
93 mCalPopup->setItemChecked (index, kkf->mCalNumber == mCurrentIncidence->calID()); 96 mCalPopup->setItemChecked (index, kkf->mCalNumber == mCurrentIncidence->calID());
94 kkf = KOPrefs::instance()->mCalendars.next(); 97 kkf = KOPrefs::instance()->mCalendars.next();
95 } 98 }
96} 99}
97void KOEventPopupMenu::computeCalPopup( int index ) // CAL 100void KOEventPopupMenu::computeCalPopup( int index ) // CAL
98{ 101{
99 if (!mCurrentIncidence) return; 102 if (!mCurrentIncidence) return;
100 mCurrentIncidence->setCalID( index ); 103 mCurrentIncidence->setCalID( index );
101 emit categoryChanged( mCurrentIncidence ); 104 emit categoryChanged( mCurrentIncidence );
@@ -125,58 +128,58 @@ void KOEventPopupMenu::computeCatPopup( int index )
125 QStringList categories = mCurrentIncidence->categories(); 128 QStringList categories = mCurrentIncidence->categories();
126 QString colcat = categories.first(); 129 QString colcat = categories.first();
127 if (categories.find (KOPrefs::instance()->mCustomCategories[index]) != categories.end ()) 130 if (categories.find (KOPrefs::instance()->mCustomCategories[index]) != categories.end ())
128 categories.remove (KOPrefs::instance()->mCustomCategories[index]); 131 categories.remove (KOPrefs::instance()->mCustomCategories[index]);
129 else 132 else
130 categories.insert (categories.end(), KOPrefs::instance()->mCustomCategories[index]); 133 categories.insert (categories.end(), KOPrefs::instance()->mCustomCategories[index]);
131 categories.sort (); 134 categories.sort ();
132 if ( !colcat.isEmpty() ) { 135 if ( !colcat.isEmpty() ) {
133 if ( categories.find ( colcat ) != categories.end () ) { 136 if ( categories.find ( colcat ) != categories.end () ) {
134 categories.remove( colcat ); 137 categories.remove( colcat );
135 categories.prepend( colcat ); 138 categories.prepend( colcat );
136 } 139 }
137 } 140 }
138 mCurrentIncidence->setCategories( categories ); 141 mCurrentIncidence->setCategories( categories );
139 emit categoryChanged( mCurrentIncidence ); 142 emit categoryChanged( mCurrentIncidence );
140} 143}
141void KOEventPopupMenu::showIncidencePopup(Incidence *incidence) 144void KOEventPopupMenu::showIncidencePopup(Incidence *incidence)
142{ 145{
143 if ( !incidence) return; 146 if ( !incidence) return;
144 mCurrentIncidence = incidence; 147 mCurrentIncidence = incidence;
145 148
146 if (mCurrentIncidence) { 149 if (mCurrentIncidence) {
147 // Enable/Disabled menu items only valid for editable events. 150 // Enable/Disabled menu items only valid for editable events.
148 if ( !isDisabled ) { 151 if ( !isDisabled ) {
149 QValueList<int>::Iterator it; 152 Q3ValueList<int>::Iterator it;
150 for( it = mEditOnlyItems.begin(); it != mEditOnlyItems.end(); ++it ) { 153 for( it = mEditOnlyItems.begin(); it != mEditOnlyItems.end(); ++it ) {
151 setItemEnabled(*it,!mCurrentIncidence->isReadOnly()); 154 setItemEnabled(*it,!mCurrentIncidence->isReadOnly());
152 } 155 }
153 } 156 }
154 popup(QCursor::pos()); 157 popup(QCursor::pos());
155 } 158 }
156} 159}
157 160
158void KOEventPopupMenu::addAdditionalItem(const QIconSet &icon,const QString &text, 161void KOEventPopupMenu::addAdditionalItem(const QIcon &icon,const QString &text,
159 const QObject *receiver, const char *member, 162 const QObject *receiver, const char *member,
160 bool editOnly) 163 bool editOnly)
161{ 164{
162 if (!mHasAdditionalItems) { 165 if (!mHasAdditionalItems) {
163 mHasAdditionalItems = true; 166 mHasAdditionalItems = true;
164 insertSeparator(); 167 insertSeparator();
165 } 168 }
166 int id = insertItem(icon,text,receiver,member); 169 int id = insertItem(icon,text,receiver,member);
167 if (editOnly) mEditOnlyItems.append(id); 170 if (editOnly) mEditOnlyItems.append(id);
168} 171}
169 172
170void KOEventPopupMenu::popupShow() 173void KOEventPopupMenu::popupShow()
171{ 174{
172 if (mCurrentIncidence) emit showIncidenceSignal(mCurrentIncidence); 175 if (mCurrentIncidence) emit showIncidenceSignal(mCurrentIncidence);
173} 176}
174 177
175void KOEventPopupMenu::popupEdit() 178void KOEventPopupMenu::popupEdit()
176{ 179{
177 if (mCurrentIncidence) emit editIncidenceSignal(mCurrentIncidence); 180 if (mCurrentIncidence) emit editIncidenceSignal(mCurrentIncidence);
178} 181}
179 182
180void KOEventPopupMenu::popupDelete() 183void KOEventPopupMenu::popupDelete()
181{ 184{
182 if (mCurrentIncidence) emit deleteIncidenceSignal(mCurrentIncidence); 185 if (mCurrentIncidence) emit deleteIncidenceSignal(mCurrentIncidence);