1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
|
/*
This file is part of KOrganizer.
Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
As a special exception, permission is given to link this program
with any edition of TQt, and distribute the resulting executable,
without including the source code for TQt in the source distribution.
*/
#include <tqcursor.h>
#include <tdeactioncollection.h>
#include <tdelocale.h>
#include <kdebug.h>
#include <kiconloader.h>
#include <kurl.h>
#include <libkcal/event.h>
#include "koglobals.h"
#include <korganizer/baseview.h>
#include "koeventpopupmenu.h"
#include "koeventpopupmenu.moc"
#include "kocorehelper.h"
#include "actionmanager.h"
#ifndef KORG_NOPRINTER
#include "calprinter.h"
#endif
KOEventPopupMenu::KOEventPopupMenu()
{
mCalendar = 0;
mCurrentIncidence = 0;
mCurrentDate = TQDate();
mHasAdditionalItems = false;
insertItem( i18n("&Show"), this, TQT_SLOT( popupShow() ) );
mEditOnlyItems.append(
insertItem(i18n("&Edit..."), this, TQT_SLOT( popupEdit() ) ) );
#ifndef KORG_NOPRINTER
insertItem( KOGlobals::self()->smallIcon("printer1"), i18n("&Print..."),
this, TQT_SLOT( print() ) );
#endif
//------------------------------------------------------------------------
mEditOnlyItems.append( insertSeparator() );
mEditOnlyItems.append(
insertItem( KOGlobals::self()->smallIcon("editcut"), i18n("&Cut"),
this, TQT_SLOT( popupCut() ) ) );
mEditOnlyItems.append(
insertItem( KOGlobals::self()->smallIcon("editcopy"), i18n("&Copy"),
this, TQT_SLOT( popupCopy() ) ) );
// paste is always possible
insertItem( KOGlobals::self()->smallIcon("editpaste"), i18n("&Paste"),
this, TQT_SLOT( popupPaste() ) );
mEditOnlyItems.append(
insertItem( KOGlobals::self()->smallIcon("editdelete"), i18n("&Delete"),
this, TQT_SLOT( popupDelete() ) ) );
//------------------------------------------------------------------------
mEditOnlyItems.append( insertSeparator() );
mEditOnlyItems.append(
insertItem( KOGlobals::self()->smallIcon("bell"), i18n("&Toggle Reminder"),
this, TQT_SLOT( popupAlarm() ) ) );
//------------------------------------------------------------------------
mRecurrenceItems.append( insertSeparator() );
mRecurrenceItems.append(
insertItem( i18n("&Dissociate This Occurrence"),
this, TQT_SLOT( dissociateOccurrence() ) ) );
mRecurrenceItems.append(
insertItem( i18n("&Dissociate Future Occurrences"),
this, TQT_SLOT( dissociateFutureOccurrence() ) ) );
insertSeparator();
insertItem( KOGlobals::self()->smallIcon("mail_forward"), i18n( "Send as iCalendar..."),
this, TQT_SLOT(forward()) );
}
void KOEventPopupMenu::showIncidencePopup( Calendar *cal, Incidence *incidence, const TQDate &qd )
{
mCalendar = cal;
mCurrentIncidence = incidence;
mCurrentDate = qd;
if (mCurrentIncidence) {
// Enable/Disabled menu items only valid for editable events.
TQValueList<int>::Iterator it;
for( it = mEditOnlyItems.begin(); it != mEditOnlyItems.end(); ++it ) {
setItemEnabled(*it,!mCurrentIncidence->isReadOnly());
}
for ( it = mRecurrenceItems.begin(); it != mRecurrenceItems.end(); ++it ) {
setItemVisible( *it, mCurrentIncidence->doesRecur() );
}
popup(TQCursor::pos());
} else {
kdDebug(5850) << "KOEventPopupMenu::showEventPopup(): No event selected" << endl;
}
}
void KOEventPopupMenu::addAdditionalItem(const TQIconSet &icon,const TQString &text,
const TQObject *receiver, const char *member,
bool editOnly)
{
if (!mHasAdditionalItems) {
mHasAdditionalItems = true;
insertSeparator();
}
int id = insertItem(icon,text,receiver,member);
if (editOnly) mEditOnlyItems.append(id);
}
void KOEventPopupMenu::popupShow()
{
if ( mCurrentIncidence ) {
emit showIncidenceSignal( mCurrentIncidence, mCurrentDate );
}
}
void KOEventPopupMenu::popupEdit()
{
if ( mCurrentIncidence ) {
emit editIncidenceSignal( mCurrentIncidence, mCurrentDate );
}
}
void KOEventPopupMenu::print()
{
#ifndef KORG_NOPRINTER
KOCoreHelper helper;
CalPrinter printer( this, mCalendar, &helper );
connect( this, TQT_SIGNAL(configChanged()), &printer, TQT_SLOT(updateConfig()) );
Incidence::List selectedIncidences;
selectedIncidences.append( mCurrentIncidence );
printer.print( KOrg::CalPrinterBase::Incidence,
mCurrentDate, mCurrentDate, selectedIncidences );
#endif
}
void KOEventPopupMenu::popupDelete()
{
if (mCurrentIncidence) emit deleteIncidenceSignal(mCurrentIncidence);
}
void KOEventPopupMenu::popupCut()
{
if (mCurrentIncidence) emit cutIncidenceSignal(mCurrentIncidence);
}
void KOEventPopupMenu::popupCopy()
{
if (mCurrentIncidence) emit copyIncidenceSignal(mCurrentIncidence);
}
void KOEventPopupMenu::popupPaste()
{
emit pasteIncidenceSignal();
}
void KOEventPopupMenu::popupAlarm()
{
if (mCurrentIncidence) emit toggleAlarmSignal( mCurrentIncidence );
}
void KOEventPopupMenu::dissociateOccurrence()
{
if ( mCurrentIncidence )
emit dissociateOccurrenceSignal( mCurrentIncidence, mCurrentDate );
}
void KOEventPopupMenu::dissociateFutureOccurrence()
{
if ( mCurrentIncidence )
emit dissociateFutureOccurrenceSignal( mCurrentIncidence, mCurrentDate );
}
void KOEventPopupMenu::forward()
{
KOrg::MainWindow *w = ActionManager::findInstance( KURL() );
if ( !w || !mCurrentIncidence )
return;
TDEActionCollection *ac = w->getActionCollection();
TDEAction *action = ac->action( "schedule_forward" );
action->activate();
}
|