Diffstat (limited to 'korganizer/koeventpopupmenu.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | korganizer/koeventpopupmenu.cpp | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/korganizer/koeventpopupmenu.cpp b/korganizer/koeventpopupmenu.cpp new file mode 100644 index 0000000..410bceb --- a/dev/null +++ b/korganizer/koeventpopupmenu.cpp | |||
@@ -0,0 +1,114 @@ | |||
1 | /* | ||
2 | This file is part of KOrganizer. | ||
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | ||
4 | |||
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 | ||
7 | the Free Software Foundation; either version 2 of the License, or | ||
8 | (at your option) any later version. | ||
9 | |||
10 | This program is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | ||
14 | |||
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 | ||
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
18 | |||
19 | As a special exception, permission is given to link this program | ||
20 | with any edition of Qt, and distribute the resulting executable, | ||
21 | without including the source code for Qt in the source distribution. | ||
22 | */ | ||
23 | |||
24 | #include <qcursor.h> | ||
25 | |||
26 | #include <klocale.h> | ||
27 | #include <kdebug.h> | ||
28 | #include <kiconloader.h> | ||
29 | |||
30 | #include <libkcal/event.h> | ||
31 | |||
32 | #include "koeventpopupmenu.h" | ||
33 | #include "koeventpopupmenu.moc" | ||
34 | |||
35 | KOEventPopupMenu::KOEventPopupMenu() | ||
36 | { | ||
37 | mCurrentIncidence = 0; | ||
38 | mHasAdditionalItems = false; | ||
39 | |||
40 | insertItem (i18n("&Show"),this,SLOT(popupShow())); | ||
41 | mEditOnlyItems.append(insertItem (i18n("&Edit..."),this,SLOT(popupEdit()))); | ||
42 | mEditOnlyItems.append(insertItem (i18n("&Delete"), | ||
43 | this,SLOT(popupDelete()))); | ||
44 | mEditOnlyItems.append(insertItem (i18n("&Clone..."), | ||
45 | this,SLOT(popupClone()))); | ||
46 | mEditOnlyItems.append(insertItem (i18n("&Move..."), | ||
47 | this,SLOT(popupMove()))); | ||
48 | #ifndef DESKTOP_VERSION | ||
49 | mEditOnlyItems.append(insertItem (i18n("&Beam..."), | ||
50 | this,SLOT(popupBeam()))); | ||
51 | #endif | ||
52 | mEditOnlyItems.append(insertItem (i18n("&Toggle Cancel"), | ||
53 | this,SLOT(popupCancel()))); | ||
54 | } | ||
55 | |||
56 | void KOEventPopupMenu::showIncidencePopup(Incidence *incidence) | ||
57 | { | ||
58 | mCurrentIncidence = incidence; | ||
59 | |||
60 | if (mCurrentIncidence) { | ||
61 | // Enable/Disabled menu items only valid for editable events. | ||
62 | QValueList<int>::Iterator it; | ||
63 | for( it = mEditOnlyItems.begin(); it != mEditOnlyItems.end(); ++it ) { | ||
64 | setItemEnabled(*it,!mCurrentIncidence->isReadOnly()); | ||
65 | } | ||
66 | popup(QCursor::pos()); | ||
67 | } else { | ||
68 | kdDebug() << "KOEventPopupMenu::showEventPopup(): No event selected" << endl; | ||
69 | } | ||
70 | } | ||
71 | |||
72 | void KOEventPopupMenu::addAdditionalItem(const QIconSet &icon,const QString &text, | ||
73 | const QObject *receiver, const char *member, | ||
74 | bool editOnly) | ||
75 | { | ||
76 | if (!mHasAdditionalItems) { | ||
77 | mHasAdditionalItems = true; | ||
78 | insertSeparator(); | ||
79 | } | ||
80 | int id = insertItem(icon,text,receiver,member); | ||
81 | if (editOnly) mEditOnlyItems.append(id); | ||
82 | } | ||
83 | |||
84 | void KOEventPopupMenu::popupShow() | ||
85 | { | ||
86 | if (mCurrentIncidence) emit showIncidenceSignal(mCurrentIncidence); | ||
87 | } | ||
88 | |||
89 | void KOEventPopupMenu::popupEdit() | ||
90 | { | ||
91 | if (mCurrentIncidence) emit editIncidenceSignal(mCurrentIncidence); | ||
92 | } | ||
93 | |||
94 | void KOEventPopupMenu::popupDelete() | ||
95 | { | ||
96 | if (mCurrentIncidence) emit deleteIncidenceSignal(mCurrentIncidence); | ||
97 | } | ||
98 | void KOEventPopupMenu::popupClone() | ||
99 | { | ||
100 | if (mCurrentIncidence) emit cloneIncidenceSignal(mCurrentIncidence); | ||
101 | } | ||
102 | void KOEventPopupMenu::popupCancel() | ||
103 | { | ||
104 | if (mCurrentIncidence) emit cancelIncidenceSignal(mCurrentIncidence); | ||
105 | } | ||
106 | void KOEventPopupMenu::popupMove() | ||
107 | { | ||
108 | if (mCurrentIncidence) emit moveIncidenceSignal(mCurrentIncidence); | ||
109 | } | ||
110 | |||
111 | void KOEventPopupMenu::popupBeam() | ||
112 | { | ||
113 | if (mCurrentIncidence) emit beamIncidenceSignal(mCurrentIncidence); | ||
114 | } | ||