-rw-r--r-- | korganizer/incomingdialog.cpp | 14 | ||||
-rw-r--r-- | korganizer/koagendaview.cpp | 14 | ||||
-rw-r--r-- | korganizer/koeditorrecurrence.cpp | 2 | ||||
-rw-r--r-- | korganizer/koeventviewerdialog.cpp | 12 | ||||
-rw-r--r-- | korganizer/komonthview.cpp | 4 | ||||
-rw-r--r-- | korganizer/outgoingdialog.cpp | 12 | ||||
-rw-r--r-- | libkcal/alarm.cpp | 4 |
7 files changed, 31 insertions, 31 deletions
diff --git a/korganizer/incomingdialog.cpp b/korganizer/incomingdialog.cpp index 50e3077..fe78356 100644 --- a/korganizer/incomingdialog.cpp +++ b/korganizer/incomingdialog.cpp | |||
@@ -1,528 +1,528 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 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 | 19 | ||
20 | #include <qlistview.h> | 20 | #include <qlistview.h> |
21 | #include <qfile.h> | 21 | #include <qfile.h> |
22 | #include <qdir.h> | 22 | #include <qdir.h> |
23 | #include <qmap.h> | 23 | #include <qmap.h> |
24 | 24 | ||
25 | #include <kglobal.h> | 25 | #include <kglobal.h> |
26 | #include <klocale.h> | 26 | #include <klocale.h> |
27 | #include <kdebug.h> | 27 | #include <kdebug.h> |
28 | #include <kstandarddirs.h> | 28 | #include <kstandarddirs.h> |
29 | #include <kmessagebox.h> | 29 | #include <kmessagebox.h> |
30 | 30 | ||
31 | #include <libkcal/incidence.h> | 31 | #include <libkcal/incidence.h> |
32 | #include <libkcal/event.h> | 32 | #include <libkcal/event.h> |
33 | #include <libkcal/calendar.h> | 33 | #include <libkcal/calendar.h> |
34 | #include <libkcal/freebusy.h> | 34 | #include <libkcal/freebusy.h> |
35 | #include <libkcal/attendee.h> | 35 | #include <libkcal/attendee.h> |
36 | #include <libkcal/calendarresources.h> | 36 | #include <libkcal/calendarresources.h> |
37 | #include <libkcal/resourcecalendar.h> | 37 | #include <libkcal/resourcecalendar.h> |
38 | #include <kresources/resourceselectdialog.h> | 38 | #include <kresources/resourceselectdialog.h> |
39 | 39 | ||
40 | #ifndef KORG_NOMAIL | 40 | #ifndef KORG_NOMAIL |
41 | #include "mailscheduler.h" | 41 | #include "mailscheduler.h" |
42 | #else | 42 | #else |
43 | #include <libkcal/dummyscheduler.h> | 43 | #include <libkcal/dummyscheduler.h> |
44 | #endif | 44 | #endif |
45 | 45 | ||
46 | 46 | ||
47 | #include "incomingdialog.h" | 47 | #include "incomingdialog.h" |
48 | #include "koeventviewerdialog.h" | 48 | #include "koeventviewerdialog.h" |
49 | #include "kocounterdialog.h" | 49 | #include "kocounterdialog.h" |
50 | #include "koprefs.h" | 50 | #include "koprefs.h" |
51 | 51 | ||
52 | #ifndef KORG_NOKABC | 52 | #ifndef KORG_NOKABC |
53 | #define KORG_NOKABC | 53 | #define KORG_NOKABC |
54 | //#include <kabc/stdaddressbook.h> | 54 | //#include <kabc/stdaddressbook.h> |
55 | #define size count | 55 | #define size count |
56 | #endif | 56 | #endif |
57 | 57 | ||
58 | 58 | ||
59 | ScheduleItemIn::ScheduleItemIn(QListView *parent,IncidenceBase *ev, | 59 | ScheduleItemIn::ScheduleItemIn(QListView *parent,IncidenceBase *ev, |
60 | Scheduler::Method method,ScheduleMessage::Status status) | 60 | Scheduler::Method method,ScheduleMessage::Status status) |
61 | : QListViewItem(parent) | 61 | : QListViewItem(parent) |
62 | { | 62 | { |
63 | mIncidence = ev; | 63 | mIncidence = ev; |
64 | mMethod = method; | 64 | mMethod = method; |
65 | mStatus = status; | 65 | mStatus = status; |
66 | setText(6,Scheduler::translatedMethodName(mMethod)+" "); | 66 | setText(6,Scheduler::translatedMethodName(mMethod)+" "); |
67 | setText(7,ScheduleMessage::statusName(status)); | 67 | setText(7,ScheduleMessage::statusName(status)); |
68 | } | 68 | } |
69 | 69 | ||
70 | 70 | ||
71 | /* Visitor */ | 71 | /* Visitor */ |
72 | ScheduleItemVisitor::ScheduleItemVisitor(ScheduleItemIn *item) | 72 | ScheduleItemVisitor::ScheduleItemVisitor(ScheduleItemIn *item) |
73 | { | 73 | { |
74 | mItem = item; | 74 | mItem = item; |
75 | } | 75 | } |
76 | 76 | ||
77 | ScheduleItemVisitor::~ScheduleItemVisitor() | 77 | ScheduleItemVisitor::~ScheduleItemVisitor() |
78 | { | 78 | { |
79 | } | 79 | } |
80 | 80 | ||
81 | bool ScheduleItemVisitor::visit(Event *e) | 81 | bool ScheduleItemVisitor::visit(Event *e) |
82 | { | 82 | { |
83 | mItem->setText(0,e->summary()); | 83 | mItem->setText(0,e->summary()); |
84 | mItem->setText(1,e->dtStartDateStr()); | 84 | mItem->setText(1,e->dtStartDateStr()); |
85 | if (e->doesFloat()) { | 85 | if (e->doesFloat()) { |
86 | mItem->setText(2,i18n("no time ")); | 86 | mItem->setText(2,i18n("no time ")); |
87 | mItem->setText(4,i18n("no time ")); | 87 | mItem->setText(4,i18n("no time ")); |
88 | } | 88 | } |
89 | else { | 89 | else { |
90 | mItem->setText(2,e->dtStartTimeStr()); | 90 | mItem->setText(2,e->dtStartTimeStr()); |
91 | mItem->setText(4,e->dtEndTimeStr()); | 91 | mItem->setText(4,e->dtEndTimeStr()); |
92 | } | 92 | } |
93 | if (e->hasEndDate()) { | 93 | if (e->hasEndDate()) { |
94 | mItem->setText(3,e->dtEndDateStr()); | 94 | mItem->setText(3,e->dtEndDateStr()); |
95 | } | 95 | } |
96 | else { | 96 | else { |
97 | mItem->setText(3,""); | 97 | mItem->setText(3,""); |
98 | } | 98 | } |
99 | mItem->setText(5,e->organizer()+" "); | 99 | mItem->setText(5,e->organizer()+" "); |
100 | 100 | ||
101 | return true; | 101 | return true; |
102 | } | 102 | } |
103 | 103 | ||
104 | bool ScheduleItemVisitor::visit(Todo *e) | 104 | bool ScheduleItemVisitor::visit(Todo *e) |
105 | { | 105 | { |
106 | mItem->setText(0,e->summary()); | 106 | mItem->setText(0,e->summary()); |
107 | if (e->hasStartDate()) { | 107 | if (e->hasStartDate()) { |
108 | mItem->setText(1,e->dtStartDateStr()); | 108 | mItem->setText(1,e->dtStartDateStr()); |
109 | if (!e->doesFloat()) { | 109 | if (!e->doesFloat()) { |
110 | mItem->setText(2,e->dtStartTimeStr()); | 110 | mItem->setText(2,e->dtStartTimeStr()); |
111 | } | 111 | } |
112 | } | 112 | } |
113 | if (e->hasDueDate()) { | 113 | if (e->hasDueDate()) { |
114 | mItem->setText(1,e->dtDueDateStr()); | 114 | mItem->setText(1,e->dtDueDateStr()); |
115 | if (!e->doesFloat()) { | 115 | if (!e->doesFloat()) { |
116 | mItem->setText(2,e->dtDueTimeStr()); | 116 | mItem->setText(2,e->dtDueTimeStr()); |
117 | } | 117 | } |
118 | } | 118 | } |
119 | mItem->setText(5,e->organizer()+" "); | 119 | mItem->setText(5,e->organizer()+" "); |
120 | 120 | ||
121 | return true; | 121 | return true; |
122 | } | 122 | } |
123 | 123 | ||
124 | bool ScheduleItemVisitor::visit(Journal *) | 124 | bool ScheduleItemVisitor::visit(Journal *) |
125 | { | 125 | { |
126 | return false; | 126 | return false; |
127 | } | 127 | } |
128 | 128 | ||
129 | 129 | ||
130 | /* | 130 | /* |
131 | * Constructs a IncomingDialog which is a child of 'parent', with the | 131 | * Constructs a IncomingDialog which is a child of 'parent', with the |
132 | * name 'name' and widget flags set to 'f' | 132 | * name 'name' and widget flags set to 'f' |
133 | * | 133 | * |
134 | * The dialog will by default be modeless, unless you set 'modal' to | 134 | * The dialog will by default be modeless, unless you set 'modal' to |
135 | * TRUE to construct a modal dialog. | 135 | * TRUE to construct a modal dialog. |
136 | */ | 136 | */ |
137 | IncomingDialog::IncomingDialog(Calendar *calendar,OutgoingDialog *outgoing, | 137 | IncomingDialog::IncomingDialog(Calendar *calendar,OutgoingDialog *outgoing, |
138 | QWidget* parent,const char* name,bool modal,WFlags fl) : | 138 | QWidget* parent,const char* name,bool modal,WFlags fl) : |
139 | IncomingDialog_base(parent,name,modal,fl) | 139 | IncomingDialog_base(parent,name,modal,fl) |
140 | { | 140 | { |
141 | mCalendar = calendar; | 141 | mCalendar = calendar; |
142 | mOutgoing = outgoing; | 142 | mOutgoing = outgoing; |
143 | #ifndef KORG_NOMAIL | 143 | #ifndef KORG_NOMAIL |
144 | mScheduler = new MailScheduler(mCalendar); | 144 | mScheduler = new MailScheduler(mCalendar); |
145 | #else | 145 | #else |
146 | mScheduler = new DummyScheduler(mCalendar); | 146 | mScheduler = new DummyScheduler(mCalendar); |
147 | #endif | 147 | #endif |
148 | mMessageListView->setColumnAlignment(1,AlignHCenter); | 148 | mMessageListView->setColumnAlignment(1,AlignHCenter); |
149 | mMessageListView->setColumnAlignment(2,AlignHCenter); | 149 | mMessageListView->setColumnAlignment(2,AlignHCenter); |
150 | mMessageListView->setColumnAlignment(3,AlignHCenter); | 150 | mMessageListView->setColumnAlignment(3,AlignHCenter); |
151 | mMessageListView->setColumnAlignment(4,AlignHCenter); | 151 | mMessageListView->setColumnAlignment(4,AlignHCenter); |
152 | QObject::connect(mMessageListView,SIGNAL(doubleClicked(QListViewItem *)), | 152 | QObject::connect(mMessageListView,SIGNAL(doubleClicked(QListViewItem *)), |
153 | this,SLOT(showEvent(QListViewItem *))); | 153 | this,SLOT(showEvent(QListViewItem *))); |
154 | retrieve(); | 154 | retrieve(); |
155 | } | 155 | } |
156 | 156 | ||
157 | /* | 157 | /* |
158 | * Destroys the object and frees any allocated resources | 158 | * Destroys the object and frees any allocated resources |
159 | */ | 159 | */ |
160 | IncomingDialog::~IncomingDialog() | 160 | IncomingDialog::~IncomingDialog() |
161 | { | 161 | { |
162 | // no need to delete child widgets, Qt does it all for us | 162 | // no need to delete child widgets, Qt does it all for us |
163 | } | 163 | } |
164 | 164 | ||
165 | void IncomingDialog::setOutgoingDialog(OutgoingDialog *outgoing) | 165 | void IncomingDialog::setOutgoingDialog(OutgoingDialog *outgoing) |
166 | { | 166 | { |
167 | mOutgoing = outgoing; | 167 | mOutgoing = outgoing; |
168 | } | 168 | } |
169 | 169 | ||
170 | void IncomingDialog::retrieve() | 170 | void IncomingDialog::retrieve() |
171 | { | 171 | { |
172 | QPtrList <ScheduleMessage> messages = mScheduler->retrieveTransactions(); | 172 | QPtrList <ScheduleMessage> messages = mScheduler->retrieveTransactions(); |
173 | 173 | ||
174 | ScheduleMessage *message; | 174 | ScheduleMessage *message; |
175 | for(message = messages.first();message;message = messages.next()) { | 175 | for(message = messages.first();message;message = messages.next()) { |
176 | IncidenceBase *inc = message->event(); | 176 | IncidenceBase *inc = message->event(); |
177 | Scheduler::Method method = (Scheduler::Method)message->method(); | 177 | Scheduler::Method method = (Scheduler::Method)message->method(); |
178 | ScheduleMessage::Status status = message->status(); | 178 | ScheduleMessage::Status status = message->status(); |
179 | 179 | ||
180 | ScheduleItemIn *item = new ScheduleItemIn(mMessageListView,inc,method,status); | 180 | ScheduleItemIn *item = new ScheduleItemIn(mMessageListView,inc,method,status); |
181 | if(inc->type()!="FreeBusy") { | 181 | if(inc->typeID() != freebusyID ) { |
182 | Incidence *incidence = static_cast<Incidence *>(inc); | 182 | Incidence *incidence = static_cast<Incidence *>(inc); |
183 | ScheduleItemVisitor v(item); | 183 | ScheduleItemVisitor v(item); |
184 | if (!incidence->accept(v)) delete item; | 184 | if (!incidence->accept(v)) delete item; |
185 | } else { | 185 | } else { |
186 | FreeBusy *fb = static_cast<FreeBusy *>(item->event()); | 186 | FreeBusy *fb = static_cast<FreeBusy *>(item->event()); |
187 | item->setText(0, "FreeBusy"); | 187 | item->setText(0, "FreeBusy"); |
188 | item->setText(1, KGlobal::locale()->formatDate( fb->dtStart().date() ) ); | 188 | item->setText(1, KGlobal::locale()->formatDate( fb->dtStart().date() ) ); |
189 | item->setText(2, KGlobal::locale()->formatTime( fb->dtStart().time() ) ); | 189 | item->setText(2, KGlobal::locale()->formatTime( fb->dtStart().time() ) ); |
190 | item->setText(3, KGlobal::locale()->formatDate( fb->dtEnd().date() ) ); | 190 | item->setText(3, KGlobal::locale()->formatDate( fb->dtEnd().date() ) ); |
191 | item->setText(4, KGlobal::locale()->formatTime( fb->dtEnd().time() ) ); | 191 | item->setText(4, KGlobal::locale()->formatTime( fb->dtEnd().time() ) ); |
192 | item->setText(5, fb->organizer()); | 192 | item->setText(5, fb->organizer()); |
193 | } | 193 | } |
194 | automaticAction(item); | 194 | automaticAction(item); |
195 | } | 195 | } |
196 | emit numMessagesChanged(mMessageListView->childCount()); | 196 | emit numMessagesChanged(mMessageListView->childCount()); |
197 | } | 197 | } |
198 | 198 | ||
199 | void IncomingDialog::acceptAllMessages() | 199 | void IncomingDialog::acceptAllMessages() |
200 | { | 200 | { |
201 | bool success = false; | 201 | bool success = false; |
202 | 202 | ||
203 | ScheduleItemIn *item = (ScheduleItemIn *)mMessageListView->firstChild(); | 203 | ScheduleItemIn *item = (ScheduleItemIn *)mMessageListView->firstChild(); |
204 | while(item) { | 204 | while(item) { |
205 | ScheduleItemIn *nextitem = (ScheduleItemIn *)(item->nextSibling()); | 205 | ScheduleItemIn *nextitem = (ScheduleItemIn *)(item->nextSibling()); |
206 | if (acceptMessage(item)) success = true; | 206 | if (acceptMessage(item)) success = true; |
207 | item = nextitem; | 207 | item = nextitem; |
208 | } | 208 | } |
209 | 209 | ||
210 | if (success) emit calendarUpdated(); | 210 | if (success) emit calendarUpdated(); |
211 | } | 211 | } |
212 | 212 | ||
213 | void IncomingDialog::acceptMessage() | 213 | void IncomingDialog::acceptMessage() |
214 | { | 214 | { |
215 | ScheduleItemIn *item = (ScheduleItemIn *)mMessageListView->selectedItem(); | 215 | ScheduleItemIn *item = (ScheduleItemIn *)mMessageListView->selectedItem(); |
216 | if (item) { | 216 | if (item) { |
217 | if (acceptMessage(item)) emit calendarUpdated(); | 217 | if (acceptMessage(item)) emit calendarUpdated(); |
218 | } | 218 | } |
219 | } | 219 | } |
220 | 220 | ||
221 | bool IncomingDialog::acceptMessage(ScheduleItemIn *item) | 221 | bool IncomingDialog::acceptMessage(ScheduleItemIn *item) |
222 | { | 222 | { |
223 | switch (item->method()) { | 223 | switch (item->method()) { |
224 | case Scheduler::Refresh: | 224 | case Scheduler::Refresh: |
225 | return incomeRefresh(item); | 225 | return incomeRefresh(item); |
226 | break; | 226 | break; |
227 | case Scheduler::Counter: | 227 | case Scheduler::Counter: |
228 | return incomeCounter(item); | 228 | return incomeCounter(item); |
229 | break; | 229 | break; |
230 | case Scheduler::Declinecounter: | 230 | case Scheduler::Declinecounter: |
231 | return incomeDeclineCounter(item); | 231 | return incomeDeclineCounter(item); |
232 | break; | 232 | break; |
233 | case Scheduler::Add: | 233 | case Scheduler::Add: |
234 | return incomeAdd(item); | 234 | return incomeAdd(item); |
235 | break; | 235 | break; |
236 | case Scheduler::Request: | 236 | case Scheduler::Request: |
237 | return incomeRequest(item); | 237 | return incomeRequest(item); |
238 | break; | 238 | break; |
239 | default: | 239 | default: |
240 | return incomeDefault(item); | 240 | return incomeDefault(item); |
241 | } | 241 | } |
242 | return false; | 242 | return false; |
243 | } | 243 | } |
244 | 244 | ||
245 | void IncomingDialog::rejectMessage() | 245 | void IncomingDialog::rejectMessage() |
246 | { | 246 | { |
247 | ScheduleItemIn *item = (ScheduleItemIn *)mMessageListView->selectedItem(); | 247 | ScheduleItemIn *item = (ScheduleItemIn *)mMessageListView->selectedItem(); |
248 | if (item) { | 248 | if (item) { |
249 | mScheduler->deleteTransaction(item->event()); | 249 | mScheduler->deleteTransaction(item->event()); |
250 | delete item; | 250 | delete item; |
251 | emit numMessagesChanged(mMessageListView->childCount()); | 251 | emit numMessagesChanged(mMessageListView->childCount()); |
252 | } | 252 | } |
253 | } | 253 | } |
254 | 254 | ||
255 | void IncomingDialog::showEvent(QListViewItem *item) | 255 | void IncomingDialog::showEvent(QListViewItem *item) |
256 | { | 256 | { |
257 | IncidenceBase *incidence = ((ScheduleItemIn *)item)->event(); | 257 | IncidenceBase *incidence = ((ScheduleItemIn *)item)->event(); |
258 | if( incidence && incidence->type() == "Event" ) { | 258 | if( incidence && incidence->typeID() == eventID ) { |
259 | Event *event = static_cast<Event *>(incidence); | 259 | Event *event = static_cast<Event *>(incidence); |
260 | KOEventViewerDialog *eventViewer = new KOEventViewerDialog(this); | 260 | KOEventViewerDialog *eventViewer = new KOEventViewerDialog(this); |
261 | eventViewer->setEvent(event); | 261 | eventViewer->setEvent(event); |
262 | eventViewer->show(); | 262 | eventViewer->show(); |
263 | } | 263 | } |
264 | } | 264 | } |
265 | 265 | ||
266 | bool IncomingDialog::incomeRefresh(ScheduleItemIn *item) | 266 | bool IncomingDialog::incomeRefresh(ScheduleItemIn *item) |
267 | { | 267 | { |
268 | Event *ev = mCalendar->event(item->event()->uid()); | 268 | Event *ev = mCalendar->event(item->event()->uid()); |
269 | if (ev) { | 269 | if (ev) { |
270 | //user interaction before?? | 270 | //user interaction before?? |
271 | Attendee *att; | 271 | Attendee *att; |
272 | QPtrList<Attendee> attlist = ev->attendees(); | 272 | QPtrList<Attendee> attlist = ev->attendees(); |
273 | for (att=attlist.first(); att; att=attlist.next()) { | 273 | for (att=attlist.first(); att; att=attlist.next()) { |
274 | Event *event = new Event(*ev); | 274 | Event *event = new Event(*ev); |
275 | mOutgoing->addMessage(event,Scheduler::Request,att->email()); | 275 | mOutgoing->addMessage(event,Scheduler::Request,att->email()); |
276 | delete(event); | 276 | delete(event); |
277 | } | 277 | } |
278 | mScheduler->deleteTransaction(item->event()); | 278 | mScheduler->deleteTransaction(item->event()); |
279 | delete item; | 279 | delete item; |
280 | emit numMessagesChanged(mMessageListView->childCount()); | 280 | emit numMessagesChanged(mMessageListView->childCount()); |
281 | return true; | 281 | return true; |
282 | } | 282 | } |
283 | mScheduler->deleteTransaction(item->event()); | 283 | mScheduler->deleteTransaction(item->event()); |
284 | delete item; | 284 | delete item; |
285 | emit numMessagesChanged(mMessageListView->childCount()); | 285 | emit numMessagesChanged(mMessageListView->childCount()); |
286 | return false; | 286 | return false; |
287 | } | 287 | } |
288 | 288 | ||
289 | bool IncomingDialog::incomeCounter(ScheduleItemIn *item) | 289 | bool IncomingDialog::incomeCounter(ScheduleItemIn *item) |
290 | { | 290 | { |
291 | IncidenceBase *incidence = ((ScheduleItemIn *)item)->event(); | 291 | IncidenceBase *incidence = ((ScheduleItemIn *)item)->event(); |
292 | // currently only events supportet - attetion at insertion below! | 292 | // currently only events supportet - attetion at insertion below! |
293 | if ( incidence->type() != "Event" ) return false; | 293 | if ( incidence->typeID() != eventID ) return false; |
294 | 294 | ||
295 | Event *counterEvent = static_cast<Event *>( incidence ); | 295 | Event *counterEvent = static_cast<Event *>( incidence ); |
296 | 296 | ||
297 | Event *even = mCalendar->event(counterEvent->uid()); | 297 | Event *even = mCalendar->event(counterEvent->uid()); |
298 | 298 | ||
299 | KOCounterDialog *eventViewer = new KOCounterDialog(this); | 299 | KOCounterDialog *eventViewer = new KOCounterDialog(this); |
300 | eventViewer->addText(i18n("counter proposal event","<b>Counter-event:</b><p>")); | 300 | eventViewer->addText(i18n("counter proposal event","<b>Counter-event:</b><p>")); |
301 | eventViewer->addEvent(counterEvent); | 301 | eventViewer->addEvent(counterEvent); |
302 | eventViewer->addText("<hr>"); | 302 | eventViewer->addText("<hr>"); |
303 | eventViewer->addText(i18n("<b>Original event:</b><p>")); | 303 | eventViewer->addText(i18n("<b>Original event:</b><p>")); |
304 | if (even) eventViewer->addEvent(even); | 304 | if (even) eventViewer->addEvent(even); |
305 | else eventViewer->addText(i18n("A corresponding event is missing in your calendar!")); | 305 | else eventViewer->addText(i18n("A corresponding event is missing in your calendar!")); |
306 | eventViewer->addText("<hr>"); | 306 | eventViewer->addText("<hr>"); |
307 | eventViewer->addText(i18n("If this counter-event is a good proposal for your event, press 'Accept'. All Attendees will then get the new version of this event")); | 307 | eventViewer->addText(i18n("If this counter-event is a good proposal for your event, press 'Accept'. All Attendees will then get the new version of this event")); |
308 | eventViewer->show(); | 308 | eventViewer->show(); |
309 | 309 | ||
310 | eventViewer->exec(); | 310 | eventViewer->exec(); |
311 | if (eventViewer->result()) { | 311 | if (eventViewer->result()) { |
312 | kdDebug() << "IncomingDialog::Counter:Accept" << endl; | 312 | kdDebug() << "IncomingDialog::Counter:Accept" << endl; |
313 | int revision = 0; | 313 | int revision = 0; |
314 | if (even) { | 314 | if (even) { |
315 | revision = even->revision(); | 315 | revision = even->revision(); |
316 | mCalendar->deleteEvent(even); | 316 | mCalendar->deleteEvent(even); |
317 | } | 317 | } |
318 | mCalendar->addIncidence(counterEvent); | 318 | mCalendar->addIncidence(counterEvent); |
319 | 319 | ||
320 | even = mCalendar->event(item->event()->uid()); | 320 | even = mCalendar->event(item->event()->uid()); |
321 | if (even) { | 321 | if (even) { |
322 | if (revision < even->revision()) | 322 | if (revision < even->revision()) |
323 | even->setRevision(even->revision()+1); | 323 | even->setRevision(even->revision()+1); |
324 | else | 324 | else |
325 | even->setRevision(revision+1); | 325 | even->setRevision(revision+1); |
326 | Event *ev = new Event(*even); | 326 | Event *ev = new Event(*even); |
327 | mOutgoing->addMessage(ev,Scheduler::Request); | 327 | mOutgoing->addMessage(ev,Scheduler::Request); |
328 | delete(ev); | 328 | delete(ev); |
329 | } | 329 | } |
330 | mScheduler->deleteTransaction(item->event()); | 330 | mScheduler->deleteTransaction(item->event()); |
331 | delete item; | 331 | delete item; |
332 | emit numMessagesChanged(mMessageListView->childCount()); | 332 | emit numMessagesChanged(mMessageListView->childCount()); |
333 | return true; | 333 | return true; |
334 | } else { | 334 | } else { |
335 | kdDebug() << "IncomingDialog::Counter:Decline" << endl; | 335 | kdDebug() << "IncomingDialog::Counter:Decline" << endl; |
336 | //the counter-sender's email is missing... | 336 | //the counter-sender's email is missing... |
337 | //now every attendee gets an declinecounter :-( | 337 | //now every attendee gets an declinecounter :-( |
338 | mOutgoing->addMessage(counterEvent,Scheduler::Declinecounter); | 338 | mOutgoing->addMessage(counterEvent,Scheduler::Declinecounter); |
339 | delete item; | 339 | delete item; |
340 | emit numMessagesChanged(mMessageListView->childCount()); | 340 | emit numMessagesChanged(mMessageListView->childCount()); |
341 | mScheduler->deleteTransaction(item->event()); | 341 | mScheduler->deleteTransaction(item->event()); |
342 | delete item; | 342 | delete item; |
343 | emit numMessagesChanged(mMessageListView->childCount()); | 343 | emit numMessagesChanged(mMessageListView->childCount()); |
344 | return true; | 344 | return true; |
345 | } | 345 | } |
346 | //mScheduler->deleteTransaction(item->event()); | 346 | //mScheduler->deleteTransaction(item->event()); |
347 | delete item; | 347 | delete item; |
348 | emit numMessagesChanged(mMessageListView->childCount()); | 348 | emit numMessagesChanged(mMessageListView->childCount()); |
349 | return false; | 349 | return false; |
350 | } | 350 | } |
351 | 351 | ||
352 | bool IncomingDialog::incomeDeclineCounter(ScheduleItemIn *item) | 352 | bool IncomingDialog::incomeDeclineCounter(ScheduleItemIn *item) |
353 | { | 353 | { |
354 | Event *even = mCalendar->event(item->event()->uid()); | 354 | Event *even = mCalendar->event(item->event()->uid()); |
355 | if (even) { | 355 | if (even) { |
356 | mOutgoing->addMessage(even,Scheduler::Refresh); | 356 | mOutgoing->addMessage(even,Scheduler::Refresh); |
357 | mScheduler->deleteTransaction(item->event()); | 357 | mScheduler->deleteTransaction(item->event()); |
358 | delete item; | 358 | delete item; |
359 | emit numMessagesChanged(mMessageListView->childCount()); | 359 | emit numMessagesChanged(mMessageListView->childCount()); |
360 | return true; | 360 | return true; |
361 | } | 361 | } |
362 | mScheduler->deleteTransaction(item->event()); | 362 | mScheduler->deleteTransaction(item->event()); |
363 | delete item; | 363 | delete item; |
364 | emit numMessagesChanged(mMessageListView->childCount()); | 364 | emit numMessagesChanged(mMessageListView->childCount()); |
365 | return false; | 365 | return false; |
366 | } | 366 | } |
367 | 367 | ||
368 | bool IncomingDialog::incomeAdd(ScheduleItemIn *item) | 368 | bool IncomingDialog::incomeAdd(ScheduleItemIn *item) |
369 | { | 369 | { |
370 | IncidenceBase *incidence = ((ScheduleItemIn *)item)->event(); | 370 | IncidenceBase *incidence = ((ScheduleItemIn *)item)->event(); |
371 | if (incidence->type() == "Event" ) { | 371 | if (incidence->typeID() == eventID ) { |
372 | Event *refr = static_cast<Event *>( incidence ); | 372 | Event *refr = static_cast<Event *>( incidence ); |
373 | mOutgoing->addMessage(refr,Scheduler::Refresh); | 373 | mOutgoing->addMessage(refr,Scheduler::Refresh); |
374 | mScheduler->deleteTransaction( incidence ); | 374 | mScheduler->deleteTransaction( incidence ); |
375 | delete item; | 375 | delete item; |
376 | emit numMessagesChanged(mMessageListView->childCount()); | 376 | emit numMessagesChanged(mMessageListView->childCount()); |
377 | return true; | 377 | return true; |
378 | } | 378 | } |
379 | else { | 379 | else { |
380 | kdDebug() << "IncomingDialog::incomeAdd - only Events are supportet yet" << endl; | 380 | kdDebug() << "IncomingDialog::incomeAdd - only Events are supportet yet" << endl; |
381 | mScheduler->deleteTransaction( incidence ); | 381 | mScheduler->deleteTransaction( incidence ); |
382 | delete item; | 382 | delete item; |
383 | emit numMessagesChanged(mMessageListView->childCount()); | 383 | emit numMessagesChanged(mMessageListView->childCount()); |
384 | return false; | 384 | return false; |
385 | } | 385 | } |
386 | } | 386 | } |
387 | 387 | ||
388 | bool IncomingDialog::incomeDefault(ScheduleItemIn *item) | 388 | bool IncomingDialog::incomeDefault(ScheduleItemIn *item) |
389 | { | 389 | { |
390 | if (mScheduler->acceptTransaction(item->event(),item->method(),item->status())) { | 390 | if (mScheduler->acceptTransaction(item->event(),item->method(),item->status())) { |
391 | delete item; | 391 | delete item; |
392 | emit numMessagesChanged(mMessageListView->childCount()); | 392 | emit numMessagesChanged(mMessageListView->childCount()); |
393 | return true; | 393 | return true; |
394 | } | 394 | } |
395 | else { | 395 | else { |
396 | KMessageBox::error(this,i18n("Unable to accept the IMIP-message. It may be a problem with the email addresses.")); | 396 | KMessageBox::error(this,i18n("Unable to accept the IMIP-message. It may be a problem with the email addresses.")); |
397 | kdDebug() << "IncomingDialog::acceptMessage(): Error!" << endl; | 397 | kdDebug() << "IncomingDialog::acceptMessage(): Error!" << endl; |
398 | return false; | 398 | return false; |
399 | } | 399 | } |
400 | return false; | 400 | return false; |
401 | } | 401 | } |
402 | 402 | ||
403 | bool IncomingDialog::incomeRequest(ScheduleItemIn *item) | 403 | bool IncomingDialog::incomeRequest(ScheduleItemIn *item) |
404 | { | 404 | { |
405 | if (item->event()->type()=="FreeBusy") { | 405 | if (item->event()->typeID() == freebusyID ) { |
406 | //handel freebusy request | 406 | //handel freebusy request |
407 | IncidenceBase *inc = item->event(); | 407 | IncidenceBase *inc = item->event(); |
408 | QDateTime start = inc->dtStart(); | 408 | QDateTime start = inc->dtStart(); |
409 | QDateTime end = start.addDays(inc->duration()/86400); | 409 | QDateTime end = start.addDays(inc->duration()/86400); |
410 | 410 | ||
411 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); | 411 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); |
412 | freebusy->setOrganizer(inc->organizer()); | 412 | freebusy->setOrganizer(inc->organizer()); |
413 | Attendee *att = new Attendee(KOPrefs::instance()->fullName(), | 413 | Attendee *att = new Attendee(KOPrefs::instance()->fullName(), |
414 | KOPrefs::instance()->email()); | 414 | KOPrefs::instance()->email()); |
415 | freebusy->addAttendee(att); | 415 | freebusy->addAttendee(att); |
416 | 416 | ||
417 | kdDebug() << "calendarview: schedule_publish_freebusy: startDate: " | 417 | kdDebug() << "calendarview: schedule_publish_freebusy: startDate: " |
418 | << KGlobal::locale()->formatDateTime( start ) << " End Date: " | 418 | << KGlobal::locale()->formatDateTime( start ) << " End Date: " |
419 | << KGlobal::locale()->formatDateTime( end ) << endl; | 419 | << KGlobal::locale()->formatDateTime( end ) << endl; |
420 | 420 | ||
421 | if (mOutgoing->addMessage(freebusy,Scheduler::Reply)) { | 421 | if (mOutgoing->addMessage(freebusy,Scheduler::Reply)) { |
422 | delete item; | 422 | delete item; |
423 | emit numMessagesChanged(mMessageListView->childCount()); | 423 | emit numMessagesChanged(mMessageListView->childCount()); |
424 | delete(freebusy); | 424 | delete(freebusy); |
425 | return true; | 425 | return true; |
426 | } | 426 | } |
427 | return false; | 427 | return false; |
428 | } else { | 428 | } else { |
429 | return incomeDefault(item); | 429 | return incomeDefault(item); |
430 | } | 430 | } |
431 | return false; | 431 | return false; |
432 | } | 432 | } |
433 | 433 | ||
434 | bool IncomingDialog::automaticAction(ScheduleItemIn *item) | 434 | bool IncomingDialog::automaticAction(ScheduleItemIn *item) |
435 | { | 435 | { |
436 | bool autoAction = false; | 436 | bool autoAction = false; |
437 | IncidenceBase *inc = item->event(); | 437 | IncidenceBase *inc = item->event(); |
438 | Scheduler::Method method = item->method(); | 438 | Scheduler::Method method = item->method(); |
439 | 439 | ||
440 | if( inc->type()=="FreeBusy" ) { | 440 | if( inc->typeID() == freebusyID ) { |
441 | if ( method==Scheduler::Request ) { | 441 | if ( method==Scheduler::Request ) { |
442 | if ( KOPrefs::instance()->mIMIPAutoFreeBusy==KOPrefs::addressbookAuto ) { | 442 | if ( KOPrefs::instance()->mIMIPAutoFreeBusy==KOPrefs::addressbookAuto ) { |
443 | // reply freebusy information | 443 | // reply freebusy information |
444 | if ( checkOrganizerInAddressbook(inc->organizer()) ) { | 444 | if ( checkOrganizerInAddressbook(inc->organizer()) ) { |
445 | incomeRequest(item); | 445 | incomeRequest(item); |
446 | } | 446 | } |
447 | } else return false; | 447 | } else return false; |
448 | } else { | 448 | } else { |
449 | 449 | ||
450 | if ( method==Scheduler::Reply ) { | 450 | if ( method==Scheduler::Reply ) { |
451 | if ( KOPrefs::instance()->mIMIPAutoFreeBusy==KOPrefs::addressbookAuto ) { | 451 | if ( KOPrefs::instance()->mIMIPAutoFreeBusy==KOPrefs::addressbookAuto ) { |
452 | // insert freebusy information | 452 | // insert freebusy information |
453 | //if ( checkAttendeesInAddressbook(inc) ) | 453 | //if ( checkAttendeesInAddressbook(inc) ) |
454 | 454 | ||
455 | } else return false; | 455 | } else return false; |
456 | } else { | 456 | } else { |
457 | if ( method==Scheduler::Publish) { | 457 | if ( method==Scheduler::Publish) { |
458 | if ( KOPrefs::instance()->mIMIPAutoFreeBusy==KOPrefs::addressbookAuto ) { | 458 | if ( KOPrefs::instance()->mIMIPAutoFreeBusy==KOPrefs::addressbookAuto ) { |
459 | // insert freebusy information | 459 | // insert freebusy information |
460 | //if ( checkOrganizerInAddressbook(inc->organizer()) ) | 460 | //if ( checkOrganizerInAddressbook(inc->organizer()) ) |
461 | 461 | ||
462 | } | 462 | } |
463 | } else return false; | 463 | } else return false; |
464 | } | 464 | } |
465 | } | 465 | } |
466 | } | 466 | } |
467 | 467 | ||
468 | if ( inc->type()=="Event" ) { | 468 | if ( inc->typeID() == eventID ) { |
469 | if ( method==Scheduler::Request || method==Scheduler::Publish ) { | 469 | if ( method==Scheduler::Request || method==Scheduler::Publish ) { |
470 | if ( KOPrefs::instance()->mIMIPAutoInsertRequest==KOPrefs::addressbookAuto ) { | 470 | if ( KOPrefs::instance()->mIMIPAutoInsertRequest==KOPrefs::addressbookAuto ) { |
471 | // insert event | 471 | // insert event |
472 | if ( checkOrganizerInAddressbook(inc->organizer()) ) | 472 | if ( checkOrganizerInAddressbook(inc->organizer()) ) |
473 | autoAction = acceptMessage(item); | 473 | autoAction = acceptMessage(item); |
474 | } else return false; | 474 | } else return false; |
475 | } else { | 475 | } else { |
476 | 476 | ||
477 | if ( method==Scheduler::Reply ) { | 477 | if ( method==Scheduler::Reply ) { |
478 | if ( KOPrefs::instance()->mIMIPAutoInsertReply==KOPrefs::addressbookAuto ) { | 478 | if ( KOPrefs::instance()->mIMIPAutoInsertReply==KOPrefs::addressbookAuto ) { |
479 | // update event information | 479 | // update event information |
480 | if ( checkAttendeesInAddressbook(inc) ) | 480 | if ( checkAttendeesInAddressbook(inc) ) |
481 | autoAction = acceptMessage(item); | 481 | autoAction = acceptMessage(item); |
482 | } else return false; | 482 | } else return false; |
483 | } else { | 483 | } else { |
484 | 484 | ||
485 | if ( method==Scheduler::Refresh ) { | 485 | if ( method==Scheduler::Refresh ) { |
486 | if ( KOPrefs::instance()->mIMIPAutoRefresh==KOPrefs::addressbookAuto ) { | 486 | if ( KOPrefs::instance()->mIMIPAutoRefresh==KOPrefs::addressbookAuto ) { |
487 | // send refresh-information | 487 | // send refresh-information |
488 | if ( checkAttendeesInAddressbook(inc) ) | 488 | if ( checkAttendeesInAddressbook(inc) ) |
489 | autoAction = acceptMessage(item); | 489 | autoAction = acceptMessage(item); |
490 | else return false; | 490 | else return false; |
491 | } else return false; | 491 | } else return false; |
492 | } else return false; | 492 | } else return false; |
493 | } | 493 | } |
494 | } | 494 | } |
495 | } | 495 | } |
496 | return autoAction; | 496 | return autoAction; |
497 | } | 497 | } |
498 | 498 | ||
499 | bool IncomingDialog::checkOrganizerInAddressbook(QString organizer) | 499 | bool IncomingDialog::checkOrganizerInAddressbook(QString organizer) |
500 | { | 500 | { |
501 | bool inBook = false; | 501 | bool inBook = false; |
502 | #ifndef KORG_NOKABC | 502 | #ifndef KORG_NOKABC |
503 | KABC::AddressBook *add_book = KABC::StdAddressBook::self(); | 503 | KABC::AddressBook *add_book = KABC::StdAddressBook::self(); |
504 | KABC::Addressee::List addressList; | 504 | KABC::Addressee::List addressList; |
505 | addressList = add_book->findByEmail(organizer); | 505 | addressList = add_book->findByEmail(organizer); |
506 | if ( addressList.size()>0 ) inBook = true; | 506 | if ( addressList.size()>0 ) inBook = true; |
507 | #endif | 507 | #endif |
508 | return inBook; | 508 | return inBook; |
509 | } | 509 | } |
510 | 510 | ||
511 | bool IncomingDialog::checkAttendeesInAddressbook(IncidenceBase *inc) | 511 | bool IncomingDialog::checkAttendeesInAddressbook(IncidenceBase *inc) |
512 | { | 512 | { |
513 | bool inBook = false; | 513 | bool inBook = false; |
514 | #ifndef KORG_NOKABC | 514 | #ifndef KORG_NOKABC |
515 | KABC::AddressBook *add_book = KABC::StdAddressBook::self(); | 515 | KABC::AddressBook *add_book = KABC::StdAddressBook::self(); |
516 | KABC::Addressee::List addressList; | 516 | KABC::Addressee::List addressList; |
517 | QPtrList <Attendee> attendees; | 517 | QPtrList <Attendee> attendees; |
518 | Attendee *att; | 518 | Attendee *att; |
519 | attendees = inc->attendees(); | 519 | attendees = inc->attendees(); |
520 | for (att=attendees.first();att;att=attendees.next()) { | 520 | for (att=attendees.first();att;att=attendees.next()) { |
521 | addressList = add_book->findByEmail(att->email()); | 521 | addressList = add_book->findByEmail(att->email()); |
522 | if (addressList.size()>0 ) inBook = true; | 522 | if (addressList.size()>0 ) inBook = true; |
523 | } | 523 | } |
524 | #endif | 524 | #endif |
525 | return inBook; | 525 | return inBook; |
526 | } | 526 | } |
527 | 527 | ||
528 | //#include "incomingdialog.moc" | 528 | //#include "incomingdialog.moc" |
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index 1320a2e..b2b136a 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp | |||
@@ -392,385 +392,385 @@ KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : | |||
392 | expandPix = SmallIcon("1leftrightarrow" ); | 392 | expandPix = SmallIcon("1leftrightarrow" ); |
393 | } | 393 | } |
394 | 394 | ||
395 | QBoxLayout *topLayout = new QVBoxLayout(this); | 395 | QBoxLayout *topLayout = new QVBoxLayout(this); |
396 | 396 | ||
397 | // Create day name labels for agenda columns | 397 | // Create day name labels for agenda columns |
398 | // Create agenda splitter | 398 | // Create agenda splitter |
399 | 399 | ||
400 | mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); | 400 | mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); |
401 | mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 401 | mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
402 | topLayout->addWidget( mSplitterAgenda ); | 402 | topLayout->addWidget( mSplitterAgenda ); |
403 | mAllDayFrame = new QHBox(mSplitterAgenda); | 403 | mAllDayFrame = new QHBox(mSplitterAgenda); |
404 | mAllDayFrame->setFocusPolicy(NoFocus); | 404 | mAllDayFrame->setFocusPolicy(NoFocus); |
405 | QWidget *agendaFrame = new QWidget(mSplitterAgenda); | 405 | QWidget *agendaFrame = new QWidget(mSplitterAgenda); |
406 | agendaFrame->setFocusPolicy(NoFocus); | 406 | agendaFrame->setFocusPolicy(NoFocus); |
407 | 407 | ||
408 | // Create all-day agenda widget | 408 | // Create all-day agenda widget |
409 | mDummyAllDayLeft = new QVBox( mAllDayFrame ); | 409 | mDummyAllDayLeft = new QVBox( mAllDayFrame ); |
410 | 410 | ||
411 | mExpandButton = new QPushButton(mDummyAllDayLeft); | 411 | mExpandButton = new QPushButton(mDummyAllDayLeft); |
412 | mExpandButton->setPixmap( expandPix ); | 412 | mExpandButton->setPixmap( expandPix ); |
413 | int widebut = mExpandButton->sizeHint().width()+4; | 413 | int widebut = mExpandButton->sizeHint().width()+4; |
414 | int heibut = mExpandButton->sizeHint().height()+4; | 414 | int heibut = mExpandButton->sizeHint().height()+4; |
415 | if ( heibut > widebut ) | 415 | if ( heibut > widebut ) |
416 | widebut = heibut ; | 416 | widebut = heibut ; |
417 | 417 | ||
418 | //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, | 418 | //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, |
419 | // QSizePolicy::Fixed ) ); | 419 | // QSizePolicy::Fixed ) ); |
420 | mExpandButton->setFixedSize( widebut, widebut); | 420 | mExpandButton->setFixedSize( widebut, widebut); |
421 | connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); | 421 | connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); |
422 | mExpandButton->setFocusPolicy(NoFocus); | 422 | mExpandButton->setFocusPolicy(NoFocus); |
423 | mAllDayAgenda = new KOAgenda(1,mAllDayFrame); | 423 | mAllDayAgenda = new KOAgenda(1,mAllDayFrame); |
424 | mAllDayAgenda->setFocusPolicy(NoFocus); | 424 | mAllDayAgenda->setFocusPolicy(NoFocus); |
425 | QLabel *dummyAllDayRight = new QLabel (mAllDayFrame); | 425 | QLabel *dummyAllDayRight = new QLabel (mAllDayFrame); |
426 | 426 | ||
427 | // Create event context menu for all day agenda | 427 | // Create event context menu for all day agenda |
428 | //mAllDayAgendaPopup = eventPopup(); | 428 | //mAllDayAgendaPopup = eventPopup(); |
429 | 429 | ||
430 | // Create agenda frame | 430 | // Create agenda frame |
431 | QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3); | 431 | QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3); |
432 | // QHBox *agendaFrame = new QHBox(splitterAgenda); | 432 | // QHBox *agendaFrame = new QHBox(splitterAgenda); |
433 | 433 | ||
434 | // create event indicator bars | 434 | // create event indicator bars |
435 | mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); | 435 | mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); |
436 | #ifndef DESKTOP_VERSION | 436 | #ifndef DESKTOP_VERSION |
437 | mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); | 437 | mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); |
438 | #endif | 438 | #endif |
439 | mDayLabelsFrame = new QHBox(agendaFrame); | 439 | mDayLabelsFrame = new QHBox(agendaFrame); |
440 | //topLayout->addWidget(mDayLabelsFrame); | 440 | //topLayout->addWidget(mDayLabelsFrame); |
441 | mDayLabels = new QFrame (mDayLabelsFrame); | 441 | mDayLabels = new QFrame (mDayLabelsFrame); |
442 | mLayoutDayLabels = new QHBoxLayout(mDayLabels); | 442 | mLayoutDayLabels = new QHBoxLayout(mDayLabels); |
443 | agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2); | 443 | agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2); |
444 | agendaLayout->addWidget(mEventIndicatorTop,1,1); | 444 | agendaLayout->addWidget(mEventIndicatorTop,1,1); |
445 | 445 | ||
446 | mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, | 446 | mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, |
447 | agendaFrame); | 447 | agendaFrame); |
448 | agendaLayout->addWidget(mEventIndicatorBottom,3,1); | 448 | agendaLayout->addWidget(mEventIndicatorBottom,3,1); |
449 | QWidget *dummyAgendaRight = new QWidget(agendaFrame); | 449 | QWidget *dummyAgendaRight = new QWidget(agendaFrame); |
450 | agendaLayout->addWidget(dummyAgendaRight,1,2); | 450 | agendaLayout->addWidget(dummyAgendaRight,1,2); |
451 | 451 | ||
452 | // Create time labels | 452 | // Create time labels |
453 | mTimeLabels = new TimeLabels(24,agendaFrame); | 453 | mTimeLabels = new TimeLabels(24,agendaFrame); |
454 | agendaLayout->addWidget(mTimeLabels,2,0); | 454 | agendaLayout->addWidget(mTimeLabels,2,0); |
455 | connect(mTimeLabels,SIGNAL( scaleChanged()), | 455 | connect(mTimeLabels,SIGNAL( scaleChanged()), |
456 | this,SLOT(updateConfig())); | 456 | this,SLOT(updateConfig())); |
457 | 457 | ||
458 | // Create agenda | 458 | // Create agenda |
459 | mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); | 459 | mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); |
460 | agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2); | 460 | agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2); |
461 | agendaLayout->setColStretch(1,1); | 461 | agendaLayout->setColStretch(1,1); |
462 | mAgenda->setFocusPolicy(NoFocus); | 462 | mAgenda->setFocusPolicy(NoFocus); |
463 | // Create event context menu for agenda | 463 | // Create event context menu for agenda |
464 | mAllAgendaPopup = eventPopup(); | 464 | mAllAgendaPopup = eventPopup(); |
465 | 465 | ||
466 | #if 0 | 466 | #if 0 |
467 | mAllAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), | 467 | mAllAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), |
468 | i18n("Toggle Alarm"),mAgenda, | 468 | i18n("Toggle Alarm"),mAgenda, |
469 | SLOT(popupAlarm()),true); | 469 | SLOT(popupAlarm()),true); |
470 | 470 | ||
471 | #endif | 471 | #endif |
472 | connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), | 472 | connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), |
473 | mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); | 473 | mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); |
474 | 474 | ||
475 | connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), | 475 | connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), |
476 | mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); | 476 | mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); |
477 | mAgenda->setPopup( mAllAgendaPopup ); | 477 | mAgenda->setPopup( mAllAgendaPopup ); |
478 | mAllDayAgenda->setPopup( mAllAgendaPopup ); | 478 | mAllDayAgenda->setPopup( mAllAgendaPopup ); |
479 | // make connections between dependent widgets | 479 | // make connections between dependent widgets |
480 | mTimeLabels->setAgenda(mAgenda); | 480 | mTimeLabels->setAgenda(mAgenda); |
481 | 481 | ||
482 | // Update widgets to reflect user preferences | 482 | // Update widgets to reflect user preferences |
483 | // updateConfig(); | 483 | // updateConfig(); |
484 | 484 | ||
485 | // createDayLabels(); | 485 | // createDayLabels(); |
486 | 486 | ||
487 | // these blank widgets make the All Day Event box line up with the agenda | 487 | // these blank widgets make the All Day Event box line up with the agenda |
488 | dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); | 488 | dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); |
489 | dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); | 489 | dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); |
490 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); | 490 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); |
491 | 491 | ||
492 | // Scrolling | 492 | // Scrolling |
493 | connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), | 493 | connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), |
494 | mTimeLabels, SLOT(positionChanged())); | 494 | mTimeLabels, SLOT(positionChanged())); |
495 | connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), | 495 | connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), |
496 | SLOT(setContentsPos(int))); | 496 | SLOT(setContentsPos(int))); |
497 | 497 | ||
498 | connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int ))); | 498 | connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int ))); |
499 | connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) )); | 499 | connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) )); |
500 | 500 | ||
501 | // Create/Show/Edit/Delete Event | 501 | // Create/Show/Edit/Delete Event |
502 | connect(mAgenda,SIGNAL(newEventSignal(int,int)), | 502 | connect(mAgenda,SIGNAL(newEventSignal(int,int)), |
503 | SLOT(newEvent(int,int))); | 503 | SLOT(newEvent(int,int))); |
504 | connect(mAgenda,SIGNAL(newTodoSignal(int,int)), | 504 | connect(mAgenda,SIGNAL(newTodoSignal(int,int)), |
505 | SLOT(newTodo(int,int))); | 505 | SLOT(newTodo(int,int))); |
506 | connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), | 506 | connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), |
507 | SLOT(newEvent(int,int,int,int))); | 507 | SLOT(newEvent(int,int,int,int))); |
508 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), | 508 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), |
509 | SLOT(newEventAllDay(int,int))); | 509 | SLOT(newEventAllDay(int,int))); |
510 | connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), | 510 | connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), |
511 | SLOT(newTodoAllDay(int,int))); | 511 | SLOT(newTodoAllDay(int,int))); |
512 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), | 512 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), |
513 | SLOT(newEventAllDay(int,int))); | 513 | SLOT(newEventAllDay(int,int))); |
514 | connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), | 514 | connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), |
515 | SLOT(newTimeSpanSelected(int,int,int,int))); | 515 | SLOT(newTimeSpanSelected(int,int,int,int))); |
516 | connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), | 516 | connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), |
517 | SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); | 517 | SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); |
518 | connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); | 518 | connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); |
519 | connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); | 519 | connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); |
520 | 520 | ||
521 | connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), | 521 | connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), |
522 | SIGNAL(editIncidenceSignal(Incidence *))); | 522 | SIGNAL(editIncidenceSignal(Incidence *))); |
523 | connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), | 523 | connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), |
524 | SIGNAL(editIncidenceSignal(Incidence *))); | 524 | SIGNAL(editIncidenceSignal(Incidence *))); |
525 | connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), | 525 | connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), |
526 | SIGNAL(showIncidenceSignal(Incidence *))); | 526 | SIGNAL(showIncidenceSignal(Incidence *))); |
527 | connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), | 527 | connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), |
528 | SIGNAL(showIncidenceSignal(Incidence *))); | 528 | SIGNAL(showIncidenceSignal(Incidence *))); |
529 | connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), | 529 | connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), |
530 | SIGNAL(deleteIncidenceSignal(Incidence *))); | 530 | SIGNAL(deleteIncidenceSignal(Incidence *))); |
531 | connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), | 531 | connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), |
532 | SIGNAL(deleteIncidenceSignal(Incidence *))); | 532 | SIGNAL(deleteIncidenceSignal(Incidence *))); |
533 | 533 | ||
534 | connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), | 534 | connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), |
535 | SLOT(updateEventDates(KOAgendaItem *, int ))); | 535 | SLOT(updateEventDates(KOAgendaItem *, int ))); |
536 | connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), | 536 | connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), |
537 | SLOT(updateEventDates(KOAgendaItem *, int))); | 537 | SLOT(updateEventDates(KOAgendaItem *, int))); |
538 | 538 | ||
539 | // event indicator update | 539 | // event indicator update |
540 | connect(mAgenda,SIGNAL(lowerYChanged(int)), | 540 | connect(mAgenda,SIGNAL(lowerYChanged(int)), |
541 | SLOT(updateEventIndicatorTop(int))); | 541 | SLOT(updateEventIndicatorTop(int))); |
542 | connect(mAgenda,SIGNAL(upperYChanged(int)), | 542 | connect(mAgenda,SIGNAL(upperYChanged(int)), |
543 | SLOT(updateEventIndicatorBottom(int))); | 543 | SLOT(updateEventIndicatorBottom(int))); |
544 | // drag signals | 544 | // drag signals |
545 | /* | 545 | /* |
546 | connect(mAgenda,SIGNAL(startDragSignal(Event *)), | 546 | connect(mAgenda,SIGNAL(startDragSignal(Event *)), |
547 | SLOT(startDrag(Event *))); | 547 | SLOT(startDrag(Event *))); |
548 | connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), | 548 | connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), |
549 | SLOT(startDrag(Event *))); | 549 | SLOT(startDrag(Event *))); |
550 | */ | 550 | */ |
551 | // synchronize selections | 551 | // synchronize selections |
552 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 552 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
553 | mAllDayAgenda, SLOT( deselectItem() ) ); | 553 | mAllDayAgenda, SLOT( deselectItem() ) ); |
554 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 554 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
555 | mAgenda, SLOT( deselectItem() ) ); | 555 | mAgenda, SLOT( deselectItem() ) ); |
556 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 556 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
557 | SIGNAL( incidenceSelected( Incidence * ) ) ); | 557 | SIGNAL( incidenceSelected( Incidence * ) ) ); |
558 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 558 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
559 | SIGNAL( incidenceSelected( Incidence * ) ) ); | 559 | SIGNAL( incidenceSelected( Incidence * ) ) ); |
560 | connect( mAgenda, SIGNAL( resizedSignal() ), | 560 | connect( mAgenda, SIGNAL( resizedSignal() ), |
561 | SLOT( updateConfig( ) ) ); | 561 | SLOT( updateConfig( ) ) ); |
562 | connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), | 562 | connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), |
563 | SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); | 563 | SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); |
564 | connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), | 564 | connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), |
565 | SLOT( addToCalSlot(Incidence * , Incidence *) ) ); | 565 | SLOT( addToCalSlot(Incidence * , Incidence *) ) ); |
566 | // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); | 566 | // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); |
567 | //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); | 567 | //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); |
568 | 568 | ||
569 | connect( mAllDayAgenda, SIGNAL( signalClearSelection() ),mAgenda, SLOT( slotClearSelection()) ); | 569 | connect( mAllDayAgenda, SIGNAL( signalClearSelection() ),mAgenda, SLOT( slotClearSelection()) ); |
570 | connect( mAgenda, SIGNAL( signalClearSelection() ),mAllDayAgenda, SLOT( slotClearSelection()) ); | 570 | connect( mAgenda, SIGNAL( signalClearSelection() ),mAllDayAgenda, SLOT( slotClearSelection()) ); |
571 | 571 | ||
572 | } | 572 | } |
573 | 573 | ||
574 | void KOAgendaView::toggleAllDay() | 574 | void KOAgendaView::toggleAllDay() |
575 | { | 575 | { |
576 | if ( mSplitterAgenda->firstHandle() ) | 576 | if ( mSplitterAgenda->firstHandle() ) |
577 | mSplitterAgenda->firstHandle()->toggle(); | 577 | mSplitterAgenda->firstHandle()->toggle(); |
578 | } | 578 | } |
579 | void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) | 579 | void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) |
580 | { | 580 | { |
581 | calendar()->addIncidence( inc ); | 581 | calendar()->addIncidence( inc ); |
582 | 582 | ||
583 | if ( incOld ) { | 583 | if ( incOld ) { |
584 | if ( incOld->type() == "Todo" ) | 584 | if ( incOld->typeID() == todoID ) |
585 | emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); | 585 | emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); |
586 | else | 586 | else |
587 | emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); | 587 | emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); |
588 | } | 588 | } |
589 | 589 | ||
590 | } | 590 | } |
591 | 591 | ||
592 | KOAgendaView::~KOAgendaView() | 592 | KOAgendaView::~KOAgendaView() |
593 | { | 593 | { |
594 | delete mAllAgendaPopup; | 594 | delete mAllAgendaPopup; |
595 | //delete mAllDayAgendaPopup; | 595 | //delete mAllDayAgendaPopup; |
596 | delete KOAgendaItem::paintPix(); | 596 | delete KOAgendaItem::paintPix(); |
597 | delete KOAgendaItem::paintPixSel(); | 597 | delete KOAgendaItem::paintPixSel(); |
598 | } | 598 | } |
599 | void KOAgendaView::resizeEvent( QResizeEvent* e ) | 599 | void KOAgendaView::resizeEvent( QResizeEvent* e ) |
600 | { | 600 | { |
601 | //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); | 601 | //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); |
602 | bool uc = false; | 602 | bool uc = false; |
603 | int ow = e->oldSize().width(); | 603 | int ow = e->oldSize().width(); |
604 | int oh = e->oldSize().height(); | 604 | int oh = e->oldSize().height(); |
605 | int w = e->size().width(); | 605 | int w = e->size().width(); |
606 | int h = e->size().height(); | 606 | int h = e->size().height(); |
607 | if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { | 607 | if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { |
608 | if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) | 608 | if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) |
609 | uc = true; | 609 | uc = true; |
610 | //qDebug("view changed %d %d %d %d ", ow, oh , w , h); | 610 | //qDebug("view changed %d %d %d %d ", ow, oh , w , h); |
611 | } | 611 | } |
612 | mUpcomingWidth = e->size().width() ; | 612 | mUpcomingWidth = e->size().width() ; |
613 | if ( mBlockUpdating || uc ) { | 613 | if ( mBlockUpdating || uc ) { |
614 | mBlockUpdating = false; | 614 | mBlockUpdating = false; |
615 | //mAgenda->setMinimumSize(800 , 600 ); | 615 | //mAgenda->setMinimumSize(800 , 600 ); |
616 | //qDebug("mAgenda->resize+++++++++++++++ "); | 616 | //qDebug("mAgenda->resize+++++++++++++++ "); |
617 | updateConfig(); | 617 | updateConfig(); |
618 | //qDebug("KOAgendaView::Updating now possible "); | 618 | //qDebug("KOAgendaView::Updating now possible "); |
619 | } else | 619 | } else |
620 | createDayLabels(); | 620 | createDayLabels(); |
621 | //qDebug("resizeEvent end "); | 621 | //qDebug("resizeEvent end "); |
622 | 622 | ||
623 | } | 623 | } |
624 | void KOAgendaView::slotDaylabelClicked( int num ) | 624 | void KOAgendaView::slotDaylabelClicked( int num ) |
625 | { | 625 | { |
626 | 626 | ||
627 | QDate firstDate = mSelectedDates.first(); | 627 | QDate firstDate = mSelectedDates.first(); |
628 | if ( num == -1 ) | 628 | if ( num == -1 ) |
629 | emit showDateView( 6, firstDate ); | 629 | emit showDateView( 6, firstDate ); |
630 | else if (num >= 0 ) { | 630 | else if (num >= 0 ) { |
631 | if ( mSelectedDates.count() == 1) | 631 | if ( mSelectedDates.count() == 1) |
632 | emit showDateView( 9, firstDate.addDays( num ) ); | 632 | emit showDateView( 9, firstDate.addDays( num ) ); |
633 | else | 633 | else |
634 | emit showDateView( 3, firstDate.addDays( num ) ); | 634 | emit showDateView( 3, firstDate.addDays( num ) ); |
635 | } | 635 | } |
636 | else | 636 | else |
637 | showDateView( 10, firstDate.addDays(1) ); | 637 | showDateView( 10, firstDate.addDays(1) ); |
638 | } | 638 | } |
639 | 639 | ||
640 | KOAgendaButton* KOAgendaView::getNewDaylabel() | 640 | KOAgendaButton* KOAgendaView::getNewDaylabel() |
641 | { | 641 | { |
642 | 642 | ||
643 | KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); | 643 | KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); |
644 | connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); | 644 | connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); |
645 | mDayLabelsList.append( dayLabel ); | 645 | mDayLabelsList.append( dayLabel ); |
646 | mLayoutDayLabels->addWidget(dayLabel); | 646 | mLayoutDayLabels->addWidget(dayLabel); |
647 | return dayLabel ; | 647 | return dayLabel ; |
648 | } | 648 | } |
649 | 649 | ||
650 | void KOAgendaView::createDayLabels() | 650 | void KOAgendaView::createDayLabels() |
651 | { | 651 | { |
652 | 652 | ||
653 | if ( mBlockUpdating || globalFlagBlockLabel == 1) { | 653 | if ( mBlockUpdating || globalFlagBlockLabel == 1) { |
654 | // qDebug(" KOAgendaView::createDayLabels() blocked "); | 654 | // qDebug(" KOAgendaView::createDayLabels() blocked "); |
655 | return; | 655 | return; |
656 | 656 | ||
657 | } | 657 | } |
658 | int newHight; | 658 | int newHight; |
659 | if ( !mSelectedDates.count()) | 659 | if ( !mSelectedDates.count()) |
660 | return; | 660 | return; |
661 | 661 | ||
662 | // ### Before deleting and recreating we could check if mSelectedDates changed... | 662 | // ### Before deleting and recreating we could check if mSelectedDates changed... |
663 | // It would remove some flickering and gain speed (since this is called by | 663 | // It would remove some flickering and gain speed (since this is called by |
664 | // each updateView() call) | 664 | // each updateView() call) |
665 | 665 | ||
666 | int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2; | 666 | int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2; |
667 | mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); | 667 | mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); |
668 | if ( maxWid < 20 ) | 668 | if ( maxWid < 20 ) |
669 | maxWid = 20; | 669 | maxWid = 20; |
670 | 670 | ||
671 | QFont dlf = KOPrefs::instance()->mTimeLabelsFont; | 671 | QFont dlf = KOPrefs::instance()->mTimeLabelsFont; |
672 | QFontMetrics fm ( dlf ); | 672 | QFontMetrics fm ( dlf ); |
673 | int selCount = mSelectedDates.count(); | 673 | int selCount = mSelectedDates.count(); |
674 | int widModulo = maxWid - (mAgenda->gridSpacingX() * selCount)+1; | 674 | int widModulo = maxWid - (mAgenda->gridSpacingX() * selCount)+1; |
675 | QString dayTest = "Mon 20"; | 675 | QString dayTest = "Mon 20"; |
676 | //QString dayTest = "Mon 20"; | 676 | //QString dayTest = "Mon 20"; |
677 | int wid = fm.width( dayTest ); | 677 | int wid = fm.width( dayTest ); |
678 | //maxWid -= ( selCount * 3 ); //working for QLabels | 678 | //maxWid -= ( selCount * 3 ); //working for QLabels |
679 | if ( QApplication::desktop()->width() <= 320 ) | 679 | if ( QApplication::desktop()->width() <= 320 ) |
680 | maxWid -= ( selCount * 3 ); //working for QPushButton | 680 | maxWid -= ( selCount * 3 ); //working for QPushButton |
681 | else | 681 | else |
682 | maxWid -= ( selCount * 3 ); //working for QPushButton | 682 | maxWid -= ( selCount * 3 ); //working for QPushButton |
683 | if ( maxWid < 0 ) | 683 | if ( maxWid < 0 ) |
684 | maxWid = 20; | 684 | maxWid = 20; |
685 | int needWid = wid * selCount; | 685 | int needWid = wid * selCount; |
686 | //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); | 686 | //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); |
687 | //if ( needWid > maxWid ) | 687 | //if ( needWid > maxWid ) |
688 | // qDebug("DAYLABELS TOOOOOOO BIG "); | 688 | // qDebug("DAYLABELS TOOOOOOO BIG "); |
689 | while ( needWid > maxWid ) { | 689 | while ( needWid > maxWid ) { |
690 | dayTest = dayTest.left( dayTest.length() - 1 ); | 690 | dayTest = dayTest.left( dayTest.length() - 1 ); |
691 | wid = fm.width( dayTest ); | 691 | wid = fm.width( dayTest ); |
692 | needWid = wid * selCount; | 692 | needWid = wid * selCount; |
693 | } | 693 | } |
694 | int maxLen = dayTest.length(); | 694 | int maxLen = dayTest.length(); |
695 | int fontPoint = dlf.pointSize(); | 695 | int fontPoint = dlf.pointSize(); |
696 | if ( maxLen < 2 ) { | 696 | if ( maxLen < 2 ) { |
697 | int fontPoint = dlf.pointSize(); | 697 | int fontPoint = dlf.pointSize(); |
698 | while ( fontPoint > 4 ) { | 698 | while ( fontPoint > 4 ) { |
699 | --fontPoint; | 699 | --fontPoint; |
700 | dlf.setPointSize( fontPoint ); | 700 | dlf.setPointSize( fontPoint ); |
701 | QFontMetrics f( dlf ); | 701 | QFontMetrics f( dlf ); |
702 | wid = f.width( "30" ); | 702 | wid = f.width( "30" ); |
703 | needWid = wid * selCount; | 703 | needWid = wid * selCount; |
704 | if ( needWid < maxWid ) | 704 | if ( needWid < maxWid ) |
705 | break; | 705 | break; |
706 | } | 706 | } |
707 | maxLen = 2; | 707 | maxLen = 2; |
708 | } | 708 | } |
709 | //qDebug("Max len %d ", dayTest.length() ); | 709 | //qDebug("Max len %d ", dayTest.length() ); |
710 | 710 | ||
711 | QFontMetrics tempF( dlf ); | 711 | QFontMetrics tempF( dlf ); |
712 | newHight = tempF.height(); | 712 | newHight = tempF.height(); |
713 | mDayLabels->setFont( dlf ); | 713 | mDayLabels->setFont( dlf ); |
714 | // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; | 714 | // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; |
715 | // mLayoutDayLabels->addSpacing(mTimeLabels->width()); | 715 | // mLayoutDayLabels->addSpacing(mTimeLabels->width()); |
716 | //mLayoutDayLabels->addSpacing( 2 ); | 716 | //mLayoutDayLabels->addSpacing( 2 ); |
717 | // QFont lFont = dlf; | 717 | // QFont lFont = dlf; |
718 | bool appendLabels = false; | 718 | bool appendLabels = false; |
719 | KOAgendaButton *dayLabel; | 719 | KOAgendaButton *dayLabel; |
720 | dayLabel = mDayLabelsList.first(); | 720 | dayLabel = mDayLabelsList.first(); |
721 | if ( !dayLabel ) { | 721 | if ( !dayLabel ) { |
722 | appendLabels = true; | 722 | appendLabels = true; |
723 | dayLabel = getNewDaylabel(); | 723 | dayLabel = getNewDaylabel(); |
724 | } | 724 | } |
725 | dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() ); | 725 | dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() ); |
726 | dayLabel->setFont( dlf ); | 726 | dayLabel->setFont( dlf ); |
727 | dayLabel->setNum( -1 ); | 727 | dayLabel->setNum( -1 ); |
728 | //dayLabel->setAlignment(QLabel::AlignHCenter); | 728 | //dayLabel->setAlignment(QLabel::AlignHCenter); |
729 | 729 | ||
730 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); | 730 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); |
731 | dayLabel->show(); | 731 | dayLabel->show(); |
732 | DateList::ConstIterator dit; | 732 | DateList::ConstIterator dit; |
733 | bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); | 733 | bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); |
734 | int counter = -1; | 734 | int counter = -1; |
735 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { | 735 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { |
736 | ++counter; | 736 | ++counter; |
737 | QDate date = *dit; | 737 | QDate date = *dit; |
738 | // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); | 738 | // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); |
739 | if ( ! appendLabels ) { | 739 | if ( ! appendLabels ) { |
740 | dayLabel = mDayLabelsList.next(); | 740 | dayLabel = mDayLabelsList.next(); |
741 | if ( !dayLabel ) | 741 | if ( !dayLabel ) |
742 | appendLabels = true; | 742 | appendLabels = true; |
743 | } | 743 | } |
744 | if ( appendLabels ) { | 744 | if ( appendLabels ) { |
745 | dayLabel = getNewDaylabel(); | 745 | dayLabel = getNewDaylabel(); |
746 | } | 746 | } |
747 | dayLabel->setMinimumWidth( 1 ); | 747 | dayLabel->setMinimumWidth( 1 ); |
748 | dayLabel->setMaximumWidth( 10240 ); | 748 | dayLabel->setMaximumWidth( 10240 ); |
749 | dayLabel->setFont( dlf ); | 749 | dayLabel->setFont( dlf ); |
750 | dayLabel->show(); | 750 | dayLabel->show(); |
751 | dayLabel->setAutoRepeat( false ); | 751 | dayLabel->setAutoRepeat( false ); |
752 | dayLabel->setNum( counter ); | 752 | dayLabel->setNum( counter ); |
753 | QString str; | 753 | QString str; |
754 | int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); | 754 | int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); |
755 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); | 755 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); |
756 | switch ( maxLen ) { | 756 | switch ( maxLen ) { |
757 | case 2: | 757 | case 2: |
758 | str = QString::number( date.day() ); | 758 | str = QString::number( date.day() ); |
759 | break; | 759 | break; |
760 | 760 | ||
761 | case 3: | 761 | case 3: |
762 | str = dayName.left( 1 ) +QString::number( date.day()); | 762 | str = dayName.left( 1 ) +QString::number( date.day()); |
763 | 763 | ||
764 | break; | 764 | break; |
765 | case 4: | 765 | case 4: |
766 | str = dayName.left( 1 ) + " " +QString::number( date.day()); | 766 | str = dayName.left( 1 ) + " " +QString::number( date.day()); |
767 | 767 | ||
768 | break; | 768 | break; |
769 | case 5: | 769 | case 5: |
770 | str = dayName.left( 2 ) + " " +QString::number( date.day()); | 770 | str = dayName.left( 2 ) + " " +QString::number( date.day()); |
771 | 771 | ||
772 | break; | 772 | break; |
773 | case 6: | 773 | case 6: |
774 | str = dayName.left( 3 ) + " " +QString::number( date.day()); | 774 | str = dayName.left( 3 ) + " " +QString::number( date.day()); |
775 | break; | 775 | break; |
776 | 776 | ||
@@ -778,456 +778,456 @@ void KOAgendaView::createDayLabels() | |||
778 | break; | 778 | break; |
779 | } | 779 | } |
780 | if ( oneday ) { | 780 | if ( oneday ) { |
781 | QString addString; | 781 | QString addString; |
782 | if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) | 782 | if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) |
783 | addString = i18n("Today"); | 783 | addString = i18n("Today"); |
784 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) | 784 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) |
785 | addString = i18n("Tomorrow"); | 785 | addString = i18n("Tomorrow"); |
786 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) | 786 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) |
787 | addString = i18n("Yesterday"); | 787 | addString = i18n("Yesterday"); |
788 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) | 788 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) |
789 | addString = i18n("Day before yesterday"); | 789 | addString = i18n("Day before yesterday"); |
790 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) | 790 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) |
791 | addString = i18n("Day after tomorrow"); | 791 | addString = i18n("Day after tomorrow"); |
792 | if ( !addString.isEmpty() ) { | 792 | if ( !addString.isEmpty() ) { |
793 | str = addString+", " + str; | 793 | str = addString+", " + str; |
794 | } else { | 794 | } else { |
795 | str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer); | 795 | str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer); |
796 | } | 796 | } |
797 | } | 797 | } |
798 | dayLabel->setText(str); | 798 | dayLabel->setText(str); |
799 | //dayLabel->setAlignment(QLabel::AlignHCenter); | 799 | //dayLabel->setAlignment(QLabel::AlignHCenter); |
800 | if (date == QDate::currentDate()) { | 800 | if (date == QDate::currentDate()) { |
801 | QFont bFont = dlf; | 801 | QFont bFont = dlf; |
802 | bFont.setBold( true ); | 802 | bFont.setBold( true ); |
803 | dayLabel->setFont(bFont); | 803 | dayLabel->setFont(bFont); |
804 | } | 804 | } |
805 | //dayLayout->addWidget(dayLabel); | 805 | //dayLayout->addWidget(dayLabel); |
806 | 806 | ||
807 | #ifndef KORG_NOPLUGINS | 807 | #ifndef KORG_NOPLUGINS |
808 | CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); | 808 | CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); |
809 | CalendarDecoration *it; | 809 | CalendarDecoration *it; |
810 | for(it = cds.first(); it; it = cds.next()) { | 810 | for(it = cds.first(); it; it = cds.next()) { |
811 | QString text = it->shortText( date ); | 811 | QString text = it->shortText( date ); |
812 | if ( !text.isEmpty() ) { | 812 | if ( !text.isEmpty() ) { |
813 | QLabel *label = new QLabel(text,mDayLabels); | 813 | QLabel *label = new QLabel(text,mDayLabels); |
814 | label->setAlignment(AlignCenter); | 814 | label->setAlignment(AlignCenter); |
815 | dayLayout->addWidget(label); | 815 | dayLayout->addWidget(label); |
816 | } | 816 | } |
817 | } | 817 | } |
818 | 818 | ||
819 | for(it = cds.first(); it; it = cds.next()) { | 819 | for(it = cds.first(); it; it = cds.next()) { |
820 | QWidget *wid = it->smallWidget(mDayLabels,date); | 820 | QWidget *wid = it->smallWidget(mDayLabels,date); |
821 | if ( wid ) { | 821 | if ( wid ) { |
822 | // wid->setHeight(20); | 822 | // wid->setHeight(20); |
823 | dayLayout->addWidget(wid); | 823 | dayLayout->addWidget(wid); |
824 | } | 824 | } |
825 | } | 825 | } |
826 | #endif | 826 | #endif |
827 | } | 827 | } |
828 | if ( ! appendLabels ) { | 828 | if ( ! appendLabels ) { |
829 | dayLabel = mDayLabelsList.next(); | 829 | dayLabel = mDayLabelsList.next(); |
830 | if ( !dayLabel ) | 830 | if ( !dayLabel ) |
831 | appendLabels = true; | 831 | appendLabels = true; |
832 | } | 832 | } |
833 | if ( appendLabels ) { | 833 | if ( appendLabels ) { |
834 | dayLabel = getNewDaylabel(); | 834 | dayLabel = getNewDaylabel(); |
835 | } | 835 | } |
836 | //dayLabel->hide();//test only | 836 | //dayLabel->hide();//test only |
837 | 837 | ||
838 | dayLabel->setText(">"); | 838 | dayLabel->setText(">"); |
839 | dayLabel->setFont( dlf ); | 839 | dayLabel->setFont( dlf ); |
840 | dayLabel->setAutoRepeat( true ); | 840 | dayLabel->setAutoRepeat( true ); |
841 | dayLabel->show(); | 841 | dayLabel->show(); |
842 | dayLabel->setNum( -2 ); | 842 | dayLabel->setNum( -2 ); |
843 | dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ widModulo ); | 843 | dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ widModulo ); |
844 | 844 | ||
845 | //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); | 845 | //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); |
846 | if ( !appendLabels ) { | 846 | if ( !appendLabels ) { |
847 | dayLabel = mDayLabelsList.next(); | 847 | dayLabel = mDayLabelsList.next(); |
848 | while ( dayLabel ) { | 848 | while ( dayLabel ) { |
849 | //qDebug("!dayLabel %d",dayLabel ); | 849 | //qDebug("!dayLabel %d",dayLabel ); |
850 | dayLabel->hide(); | 850 | dayLabel->hide(); |
851 | dayLabel = mDayLabelsList.next(); | 851 | dayLabel = mDayLabelsList.next(); |
852 | } | 852 | } |
853 | } | 853 | } |
854 | 854 | ||
855 | mDayLabelsFrame->setFixedHeight( newHight + 4 ); | 855 | mDayLabelsFrame->setFixedHeight( newHight + 4 ); |
856 | } | 856 | } |
857 | 857 | ||
858 | int KOAgendaView::maxDatesHint() | 858 | int KOAgendaView::maxDatesHint() |
859 | { | 859 | { |
860 | // Not sure about the max number of events, so return 0 for now. | 860 | // Not sure about the max number of events, so return 0 for now. |
861 | return 0; | 861 | return 0; |
862 | } | 862 | } |
863 | 863 | ||
864 | int KOAgendaView::currentDateCount() | 864 | int KOAgendaView::currentDateCount() |
865 | { | 865 | { |
866 | return mSelectedDates.count(); | 866 | return mSelectedDates.count(); |
867 | } | 867 | } |
868 | 868 | ||
869 | QPtrList<Incidence> KOAgendaView::selectedIncidences() | 869 | QPtrList<Incidence> KOAgendaView::selectedIncidences() |
870 | { | 870 | { |
871 | QPtrList<Incidence> selected; | 871 | QPtrList<Incidence> selected; |
872 | Incidence *incidence; | 872 | Incidence *incidence; |
873 | 873 | ||
874 | incidence = mAgenda->selectedIncidence(); | 874 | incidence = mAgenda->selectedIncidence(); |
875 | if (incidence) selected.append(incidence); | 875 | if (incidence) selected.append(incidence); |
876 | 876 | ||
877 | incidence = mAllDayAgenda->selectedIncidence(); | 877 | incidence = mAllDayAgenda->selectedIncidence(); |
878 | if (incidence) selected.append(incidence); | 878 | if (incidence) selected.append(incidence); |
879 | 879 | ||
880 | return selected; | 880 | return selected; |
881 | } | 881 | } |
882 | 882 | ||
883 | DateList KOAgendaView::selectedDates() | 883 | DateList KOAgendaView::selectedDates() |
884 | { | 884 | { |
885 | DateList selected; | 885 | DateList selected; |
886 | QDate qd; | 886 | QDate qd; |
887 | 887 | ||
888 | qd = mAgenda->selectedIncidenceDate(); | 888 | qd = mAgenda->selectedIncidenceDate(); |
889 | if (qd.isValid()) selected.append(qd); | 889 | if (qd.isValid()) selected.append(qd); |
890 | 890 | ||
891 | qd = mAllDayAgenda->selectedIncidenceDate(); | 891 | qd = mAllDayAgenda->selectedIncidenceDate(); |
892 | if (qd.isValid()) selected.append(qd); | 892 | if (qd.isValid()) selected.append(qd); |
893 | 893 | ||
894 | return selected; | 894 | return selected; |
895 | } | 895 | } |
896 | 896 | ||
897 | 897 | ||
898 | void KOAgendaView::updateView() | 898 | void KOAgendaView::updateView() |
899 | { | 899 | { |
900 | if ( mBlockUpdating ) | 900 | if ( mBlockUpdating ) |
901 | return; | 901 | return; |
902 | // kdDebug() << "KOAgendaView::updateView()" << endl; | 902 | // kdDebug() << "KOAgendaView::updateView()" << endl; |
903 | fillAgenda(); | 903 | fillAgenda(); |
904 | 904 | ||
905 | } | 905 | } |
906 | 906 | ||
907 | 907 | ||
908 | /* | 908 | /* |
909 | Update configuration settings for the agenda view. This method is not | 909 | Update configuration settings for the agenda view. This method is not |
910 | complete. | 910 | complete. |
911 | */ | 911 | */ |
912 | void KOAgendaView::updateConfig() | 912 | void KOAgendaView::updateConfig() |
913 | { | 913 | { |
914 | if ( mBlockUpdating ) | 914 | if ( mBlockUpdating ) |
915 | return; | 915 | return; |
916 | if ( mAgenda->height() > 96 * KOPrefs::instance()->mHourSize ) { | 916 | if ( mAgenda->height() > 96 * KOPrefs::instance()->mHourSize ) { |
917 | int old = KOPrefs::instance()->mHourSize; | 917 | int old = KOPrefs::instance()->mHourSize; |
918 | KOPrefs::instance()->mHourSize = mAgenda->height()/96 +1; | 918 | KOPrefs::instance()->mHourSize = mAgenda->height()/96 +1; |
919 | //qDebug("KOPrefs::instance()->mHourSize adjusted %d to %d ", old,KOPrefs::instance()->mHourSize ); | 919 | //qDebug("KOPrefs::instance()->mHourSize adjusted %d to %d ", old,KOPrefs::instance()->mHourSize ); |
920 | } | 920 | } |
921 | 921 | ||
922 | 922 | ||
923 | // update config for children | 923 | // update config for children |
924 | mTimeLabels->updateConfig(); | 924 | mTimeLabels->updateConfig(); |
925 | mAgenda->storePosition(); | 925 | mAgenda->storePosition(); |
926 | mAgenda->updateConfig(); | 926 | mAgenda->updateConfig(); |
927 | mAllDayAgenda->updateConfig(); | 927 | mAllDayAgenda->updateConfig(); |
928 | // widget synchronization | 928 | // widget synchronization |
929 | //TODO: find a better way, maybe signal/slot | 929 | //TODO: find a better way, maybe signal/slot |
930 | mTimeLabels->positionChanged(); | 930 | mTimeLabels->positionChanged(); |
931 | 931 | ||
932 | // for some reason, this needs to be called explicitly | 932 | // for some reason, this needs to be called explicitly |
933 | mTimeLabels->repaint(); | 933 | mTimeLabels->repaint(); |
934 | 934 | ||
935 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); | 935 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); |
936 | 936 | ||
937 | // ToolTips displaying summary of events | 937 | // ToolTips displaying summary of events |
938 | KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() | 938 | KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() |
939 | ->mEnableToolTips); | 939 | ->mEnableToolTips); |
940 | 940 | ||
941 | //setHolidayMasks(); | 941 | //setHolidayMasks(); |
942 | 942 | ||
943 | //createDayLabels(); called by via updateView(); | 943 | //createDayLabels(); called by via updateView(); |
944 | mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); | 944 | mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); |
945 | updateView(); | 945 | updateView(); |
946 | mAgenda->restorePosition(); | 946 | mAgenda->restorePosition(); |
947 | } | 947 | } |
948 | 948 | ||
949 | 949 | ||
950 | void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) | 950 | void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) |
951 | { | 951 | { |
952 | 952 | ||
953 | 953 | ||
954 | int xxx = item->cellX(); | 954 | int xxx = item->cellX(); |
955 | //qDebug("KOAgendaView::updateEventDates %d %d %d %d %d", xxx, mMinY.at(xxx),mMaxY.at(xxx),item->cellYTop(),item->cellYBottom() ); | 955 | //qDebug("KOAgendaView::updateEventDates %d %d %d %d %d", xxx, mMinY.at(xxx),mMaxY.at(xxx),item->cellYTop(),item->cellYBottom() ); |
956 | if ( mMinY.at(xxx) > item->cellYTop() ) | 956 | if ( mMinY.at(xxx) > item->cellYTop() ) |
957 | mMinY.at(xxx) = item->cellYTop(); | 957 | mMinY.at(xxx) = item->cellYTop(); |
958 | if ( mMaxY.at(xxx) < item->cellYBottom() ) | 958 | if ( mMaxY.at(xxx) < item->cellYBottom() ) |
959 | mMaxY.at(xxx) = item->cellYBottom(); | 959 | mMaxY.at(xxx) = item->cellYBottom(); |
960 | 960 | ||
961 | QDateTime startDt,endDt; | 961 | QDateTime startDt,endDt; |
962 | QDate startDate; | 962 | QDate startDate; |
963 | int lenInSecs; | 963 | int lenInSecs; |
964 | // if ( type == KOAgenda::RESIZETOP ) | 964 | // if ( type == KOAgenda::RESIZETOP ) |
965 | // qDebug("RESIZETOP "); | 965 | // qDebug("RESIZETOP "); |
966 | // if ( type == KOAgenda::RESIZEBOTTOM ) | 966 | // if ( type == KOAgenda::RESIZEBOTTOM ) |
967 | // qDebug("RESIZEBOTTOM "); | 967 | // qDebug("RESIZEBOTTOM "); |
968 | // if ( type == KOAgenda::MOVE ) | 968 | // if ( type == KOAgenda::MOVE ) |
969 | // qDebug("MOVE "); | 969 | // qDebug("MOVE "); |
970 | if ( item->incidence()->type() == "Event" ) { | 970 | if ( item->incidence()->typeID() == eventID ) { |
971 | startDt =item->incidence()->dtStart(); | 971 | startDt =item->incidence()->dtStart(); |
972 | endDt = item->incidence()->dtEnd(); | 972 | endDt = item->incidence()->dtEnd(); |
973 | lenInSecs = startDt.secsTo( endDt ); | 973 | lenInSecs = startDt.secsTo( endDt ); |
974 | } | 974 | } |
975 | 975 | ||
976 | // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); | 976 | // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); |
977 | 977 | ||
978 | if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { | 978 | if ( item->incidence()->typeID()== todoID && item->mLastMoveXPos > 0 ) { |
979 | startDate = mSelectedDates[item->mLastMoveXPos]; | 979 | startDate = mSelectedDates[item->mLastMoveXPos]; |
980 | } else { | 980 | } else { |
981 | if (item->cellX() < 0) { | 981 | if (item->cellX() < 0) { |
982 | startDate = (mSelectedDates.first()).addDays(item->cellX()); | 982 | startDate = (mSelectedDates.first()).addDays(item->cellX()); |
983 | } else { | 983 | } else { |
984 | startDate = mSelectedDates[item->cellX()]; | 984 | startDate = mSelectedDates[item->cellX()]; |
985 | } | 985 | } |
986 | } | 986 | } |
987 | startDt.setDate(startDate); | 987 | startDt.setDate(startDate); |
988 | 988 | ||
989 | if (item->incidence()->doesFloat()) { | 989 | if (item->incidence()->doesFloat()) { |
990 | endDt.setDate(startDate.addDays(item->cellWidth() - 1)); | 990 | endDt.setDate(startDate.addDays(item->cellWidth() - 1)); |
991 | } else { | 991 | } else { |
992 | if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) | 992 | if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) |
993 | startDt.setTime(mAgenda->gyToTime(item->cellYTop())); | 993 | startDt.setTime(mAgenda->gyToTime(item->cellYTop())); |
994 | if ( item->incidence()->type() == "Event" ) { | 994 | if ( item->incidence()->typeID() == eventID ) { |
995 | if ( type == KOAgenda::MOVE ) { | 995 | if ( type == KOAgenda::MOVE ) { |
996 | endDt = startDt.addSecs(lenInSecs); | 996 | endDt = startDt.addSecs(lenInSecs); |
997 | 997 | ||
998 | } else if ( type == KOAgenda::RESIZEBOTTOM ) { | 998 | } else if ( type == KOAgenda::RESIZEBOTTOM ) { |
999 | if (item->lastMultiItem()) { | 999 | if (item->lastMultiItem()) { |
1000 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); | 1000 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); |
1001 | endDt.setDate(startDate. | 1001 | endDt.setDate(startDate. |
1002 | addDays(item->lastMultiItem()->cellX() - item->cellX())); | 1002 | addDays(item->lastMultiItem()->cellX() - item->cellX())); |
1003 | } else { | 1003 | } else { |
1004 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); | 1004 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); |
1005 | endDt.setDate(startDate); | 1005 | endDt.setDate(startDate); |
1006 | } | 1006 | } |
1007 | } | 1007 | } |
1008 | } else { | 1008 | } else { |
1009 | // todo | 1009 | // todo |
1010 | if (item->lastMultiItem()) { | 1010 | if (item->lastMultiItem()) { |
1011 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); | 1011 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); |
1012 | endDt.setDate(startDate. | 1012 | endDt.setDate(startDate. |
1013 | addDays(item->lastMultiItem()->cellX() - item->cellX())); | 1013 | addDays(item->lastMultiItem()->cellX() - item->cellX())); |
1014 | } else { | 1014 | } else { |
1015 | //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); | 1015 | //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); |
1016 | if ( item->cellYBottom() > 0 ) | 1016 | if ( item->cellYBottom() > 0 ) |
1017 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); | 1017 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); |
1018 | else | 1018 | else |
1019 | endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); | 1019 | endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); |
1020 | endDt.setDate(startDate); | 1020 | endDt.setDate(startDate); |
1021 | } | 1021 | } |
1022 | } | 1022 | } |
1023 | } | 1023 | } |
1024 | if ( item->incidence()->type() == "Event" ) { | 1024 | if ( item->incidence()->typeID() == eventID ) { |
1025 | item->incidence()->setDtStart(startDt); | 1025 | item->incidence()->setDtStart(startDt); |
1026 | (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); | 1026 | (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); |
1027 | } else if ( item->incidence()->type() == "Todo" ) { | 1027 | } else if ( item->incidence()->typeID() == todoID ) { |
1028 | Todo* to = static_cast<Todo*>(item->incidence()); | 1028 | Todo* to = static_cast<Todo*>(item->incidence()); |
1029 | 1029 | ||
1030 | to->setDtDue(endDt); | 1030 | to->setDtDue(endDt); |
1031 | if ( to->hasStartDate() ) { | 1031 | if ( to->hasStartDate() ) { |
1032 | if (to->dtStart() >= to->dtDue() ) | 1032 | if (to->dtStart() >= to->dtDue() ) |
1033 | to->setDtStart(to->dtDue().addDays( -2 )); | 1033 | to->setDtStart(to->dtDue().addDays( -2 )); |
1034 | } | 1034 | } |
1035 | 1035 | ||
1036 | } | 1036 | } |
1037 | //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); | 1037 | //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); |
1038 | item->incidence()->setRevision(item->incidence()->revision()+1); | 1038 | item->incidence()->setRevision(item->incidence()->revision()+1); |
1039 | item->setItemDate(startDt.date()); | 1039 | item->setItemDate(startDt.date()); |
1040 | //item->updateItem(); | 1040 | //item->updateItem(); |
1041 | if ( item->incidence()->type() == "Todo" ) { | 1041 | if ( item->incidence()->typeID() == todoID ) { |
1042 | emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); | 1042 | emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); |
1043 | 1043 | ||
1044 | } | 1044 | } |
1045 | else | 1045 | else |
1046 | emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); | 1046 | emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); |
1047 | item->updateItem(); | 1047 | item->updateItem(); |
1048 | } | 1048 | } |
1049 | 1049 | ||
1050 | void KOAgendaView::showDates( const QDate &start, const QDate &end ) | 1050 | void KOAgendaView::showDates( const QDate &start, const QDate &end ) |
1051 | { | 1051 | { |
1052 | // kdDebug() << "KOAgendaView::selectDates" << endl; | 1052 | // kdDebug() << "KOAgendaView::selectDates" << endl; |
1053 | 1053 | ||
1054 | mSelectedDates.clear(); | 1054 | mSelectedDates.clear(); |
1055 | // qDebug("KOAgendaView::showDates "); | 1055 | // qDebug("KOAgendaView::showDates "); |
1056 | QDate d = start; | 1056 | QDate d = start; |
1057 | while (d <= end) { | 1057 | while (d <= end) { |
1058 | mSelectedDates.append(d); | 1058 | mSelectedDates.append(d); |
1059 | d = d.addDays( 1 ); | 1059 | d = d.addDays( 1 ); |
1060 | } | 1060 | } |
1061 | 1061 | ||
1062 | // and update the view | 1062 | // and update the view |
1063 | fillAgenda(); | 1063 | fillAgenda(); |
1064 | } | 1064 | } |
1065 | 1065 | ||
1066 | 1066 | ||
1067 | void KOAgendaView::showEvents(QPtrList<Event>) | 1067 | void KOAgendaView::showEvents(QPtrList<Event>) |
1068 | { | 1068 | { |
1069 | kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; | 1069 | kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; |
1070 | } | 1070 | } |
1071 | 1071 | ||
1072 | void KOAgendaView::changeEventDisplay(Event *, int) | 1072 | void KOAgendaView::changeEventDisplay(Event *, int) |
1073 | { | 1073 | { |
1074 | // qDebug("KOAgendaView::changeEventDisplay "); | 1074 | // qDebug("KOAgendaView::changeEventDisplay "); |
1075 | // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; | 1075 | // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; |
1076 | // this should be re-written to be MUCH smarter. Right now we | 1076 | // this should be re-written to be MUCH smarter. Right now we |
1077 | // are just playing dumb. | 1077 | // are just playing dumb. |
1078 | fillAgenda(); | 1078 | fillAgenda(); |
1079 | } | 1079 | } |
1080 | 1080 | ||
1081 | void KOAgendaView::fillAgenda(const QDate &) | 1081 | void KOAgendaView::fillAgenda(const QDate &) |
1082 | { | 1082 | { |
1083 | // qDebug("KOAgendaView::fillAgenda "); | 1083 | // qDebug("KOAgendaView::fillAgenda "); |
1084 | fillAgenda(); | 1084 | fillAgenda(); |
1085 | } | 1085 | } |
1086 | 1086 | ||
1087 | void KOAgendaView::fillAgenda() | 1087 | void KOAgendaView::fillAgenda() |
1088 | { | 1088 | { |
1089 | if ( globalFlagBlockStartup ) | 1089 | if ( globalFlagBlockStartup ) |
1090 | return; | 1090 | return; |
1091 | if ( globalFlagBlockAgenda == 1 ) | 1091 | if ( globalFlagBlockAgenda == 1 ) |
1092 | return; | 1092 | return; |
1093 | static bool onlyOne = false; | 1093 | static bool onlyOne = false; |
1094 | if ( onlyOne ) | 1094 | if ( onlyOne ) |
1095 | return; | 1095 | return; |
1096 | onlyOne = true; | 1096 | onlyOne = true; |
1097 | //if ( globalFlagBlockAgenda == 2 ) | 1097 | //if ( globalFlagBlockAgenda == 2 ) |
1098 | //globalFlagBlockAgenda = 0; | 1098 | //globalFlagBlockAgenda = 0; |
1099 | // globalFlagBlockPainting = false; | 1099 | // globalFlagBlockPainting = false; |
1100 | if ( globalFlagBlockAgenda == 0 ) | 1100 | if ( globalFlagBlockAgenda == 0 ) |
1101 | globalFlagBlockAgenda = 1; | 1101 | globalFlagBlockAgenda = 1; |
1102 | // clearView(); | 1102 | // clearView(); |
1103 | //qDebug("fillAgenda()++++ "); | 1103 | //qDebug("fillAgenda()++++ "); |
1104 | globalFlagBlockAgendaItemPaint = 1; | 1104 | globalFlagBlockAgendaItemPaint = 1; |
1105 | 1105 | ||
1106 | mAllDayAgenda->changeColumns(mSelectedDates.count()); | 1106 | mAllDayAgenda->changeColumns(mSelectedDates.count()); |
1107 | mAgenda->changeColumns(mSelectedDates.count()); | 1107 | mAgenda->changeColumns(mSelectedDates.count()); |
1108 | qApp->processEvents(); | 1108 | qApp->processEvents(); |
1109 | mEventIndicatorTop->changeColumns(mSelectedDates.count()); | 1109 | mEventIndicatorTop->changeColumns(mSelectedDates.count()); |
1110 | mEventIndicatorBottom->changeColumns(mSelectedDates.count()); | 1110 | mEventIndicatorBottom->changeColumns(mSelectedDates.count()); |
1111 | setHolidayMasks(); | 1111 | setHolidayMasks(); |
1112 | 1112 | ||
1113 | //mAgenda->hideUnused(); | 1113 | //mAgenda->hideUnused(); |
1114 | //mAllDayAgenda->hideUnused(); | 1114 | //mAllDayAgenda->hideUnused(); |
1115 | 1115 | ||
1116 | // mAgenda->blockNextRepaint( false ); | 1116 | // mAgenda->blockNextRepaint( false ); |
1117 | // mAgenda->viewport()->repaint(); | 1117 | // mAgenda->viewport()->repaint(); |
1118 | // mAgenda->blockNextRepaint( true ); | 1118 | // mAgenda->blockNextRepaint( true ); |
1119 | mMinY.resize(mSelectedDates.count()); | 1119 | mMinY.resize(mSelectedDates.count()); |
1120 | mMaxY.resize(mSelectedDates.count()); | 1120 | mMaxY.resize(mSelectedDates.count()); |
1121 | 1121 | ||
1122 | QPtrList<Event> dayEvents; | 1122 | QPtrList<Event> dayEvents; |
1123 | 1123 | ||
1124 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. | 1124 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. |
1125 | // Therefore, gtodoset all of them. | 1125 | // Therefore, gtodoset all of them. |
1126 | QPtrList<Todo> todos = calendar()->todos(); | 1126 | QPtrList<Todo> todos = calendar()->todos(); |
1127 | 1127 | ||
1128 | mAgenda->setDateList(mSelectedDates); | 1128 | mAgenda->setDateList(mSelectedDates); |
1129 | 1129 | ||
1130 | QDate today = QDate::currentDate(); | 1130 | QDate today = QDate::currentDate(); |
1131 | 1131 | ||
1132 | DateList::ConstIterator dit; | 1132 | DateList::ConstIterator dit; |
1133 | int curCol = 0; | 1133 | int curCol = 0; |
1134 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { | 1134 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { |
1135 | QDate currentDate = *dit; | 1135 | QDate currentDate = *dit; |
1136 | // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() | 1136 | // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() |
1137 | // << endl; | 1137 | // << endl; |
1138 | 1138 | ||
1139 | dayEvents = calendar()->events(currentDate,true); | 1139 | dayEvents = calendar()->events(currentDate,true); |
1140 | 1140 | ||
1141 | // Default values, which can never be reached | 1141 | // Default values, which can never be reached |
1142 | mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; | 1142 | mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; |
1143 | mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; | 1143 | mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; |
1144 | 1144 | ||
1145 | unsigned int numEvent; | 1145 | unsigned int numEvent; |
1146 | for(numEvent=0;numEvent<dayEvents.count();++numEvent) { | 1146 | for(numEvent=0;numEvent<dayEvents.count();++numEvent) { |
1147 | Event *event = dayEvents.at(numEvent); | 1147 | Event *event = dayEvents.at(numEvent); |
1148 | if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) | 1148 | if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) |
1149 | if ( event->uid().left(15) == QString("last-syncEvent-") ) | 1149 | if ( event->uid().left(15) == QString("last-syncEvent-") ) |
1150 | continue; | 1150 | continue; |
1151 | // kdDebug() << " Event: " << event->summary() << endl; | 1151 | // kdDebug() << " Event: " << event->summary() << endl; |
1152 | 1152 | ||
1153 | int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; | 1153 | int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; |
1154 | int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; | 1154 | int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; |
1155 | 1155 | ||
1156 | // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; | 1156 | // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; |
1157 | 1157 | ||
1158 | if (event->doesFloat()) { | 1158 | if (event->doesFloat()) { |
1159 | if (event->recurrence()->doesRecur()) { | 1159 | if (event->recurrence()->doesRecur()) { |
1160 | if (event->isMultiDay() ) { | 1160 | if (event->isMultiDay() ) { |
1161 | endX = endX - beginX;// endX is now number of days | 1161 | endX = endX - beginX;// endX is now number of days |
1162 | if ( event->recursOn( currentDate ) ) { | 1162 | if ( event->recursOn( currentDate ) ) { |
1163 | endX += curCol; | 1163 | endX += curCol; |
1164 | beginX = curCol; | 1164 | beginX = curCol; |
1165 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); | 1165 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); |
1166 | } else { | 1166 | } else { |
1167 | //qDebug("days %d %s",endX , currentDate.toString().latin1()); | 1167 | //qDebug("days %d %s",endX , currentDate.toString().latin1()); |
1168 | QDate dateit = currentDate.addDays( -endX ); | 1168 | QDate dateit = currentDate.addDays( -endX ); |
1169 | if ( event->recursOn( dateit ) ) { | 1169 | if ( event->recursOn( dateit ) ) { |
1170 | //qDebug("found %d %d %d %s", endX,curCol, curCol-endX ,dateit.toString().latin1() ); | 1170 | //qDebug("found %d %d %d %s", endX,curCol, curCol-endX ,dateit.toString().latin1() ); |
1171 | if ( curCol-endX < 0 ) { | 1171 | if ( curCol-endX < 0 ) { |
1172 | mAllDayAgenda->insertAllDayItem(event,currentDate,0,curCol); | 1172 | mAllDayAgenda->insertAllDayItem(event,currentDate,0,curCol); |
1173 | } | 1173 | } |
1174 | } | 1174 | } |
1175 | } | 1175 | } |
1176 | } else { | 1176 | } else { |
1177 | mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); | 1177 | mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); |
1178 | } | 1178 | } |
1179 | 1179 | ||
1180 | } else { | 1180 | } else { |
1181 | if (beginX <= 0 && curCol == 0) { | 1181 | if (beginX <= 0 && curCol == 0) { |
1182 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); | 1182 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); |
1183 | } else if (beginX == curCol) { | 1183 | } else if (beginX == curCol) { |
1184 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); | 1184 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); |
1185 | } | 1185 | } |
1186 | } | 1186 | } |
1187 | } else if (event->isMultiDay()) { | 1187 | } else if (event->isMultiDay()) { |
1188 | if ( event->doesRecur () ) { | 1188 | if ( event->doesRecur () ) { |
1189 | QDate dateit = currentDate; | 1189 | QDate dateit = currentDate; |
1190 | int count = 0; | 1190 | int count = 0; |
1191 | int max = event->dtStart().daysTo( event->dtEnd() ) +2; | 1191 | int max = event->dtStart().daysTo( event->dtEnd() ) +2; |
1192 | while (! event->recursOn( dateit ) && count <= max ) { | 1192 | while (! event->recursOn( dateit ) && count <= max ) { |
1193 | ++count; | 1193 | ++count; |
1194 | dateit = dateit.addDays( -1 ); | 1194 | dateit = dateit.addDays( -1 ); |
1195 | } | 1195 | } |
1196 | bool ok; | 1196 | bool ok; |
1197 | QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); | 1197 | QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); |
1198 | if ( ok ) | 1198 | if ( ok ) |
1199 | { | 1199 | { |
1200 | int secs = event->dtStart().secsTo( event->dtEnd() ); | 1200 | int secs = event->dtStart().secsTo( event->dtEnd() ); |
1201 | QDateTime nextOcend =nextOcstart.addSecs( secs ); ; | 1201 | QDateTime nextOcend =nextOcstart.addSecs( secs ); ; |
1202 | beginX = currentDate.daysTo(nextOcstart.date()) + curCol; | 1202 | beginX = currentDate.daysTo(nextOcstart.date()) + curCol; |
1203 | endX = currentDate.daysTo(nextOcend.date()) + curCol; | 1203 | endX = currentDate.daysTo(nextOcend.date()) + curCol; |
1204 | 1204 | ||
1205 | } | 1205 | } |
1206 | } | 1206 | } |
1207 | int startY = mAgenda->timeToY(event->dtStart().time()); | 1207 | int startY = mAgenda->timeToY(event->dtStart().time()); |
1208 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; | 1208 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; |
1209 | //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); | 1209 | //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); |
1210 | if ((beginX <= 0 && curCol == 0) || beginX == curCol) { | 1210 | if ((beginX <= 0 && curCol == 0) || beginX == curCol) { |
1211 | //qDebug("insert!!! "); | 1211 | //qDebug("insert!!! "); |
1212 | mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); | 1212 | mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); |
1213 | } | 1213 | } |
1214 | if (beginX == curCol) { | 1214 | if (beginX == curCol) { |
1215 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); | 1215 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); |
1216 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1216 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1217 | } else if (endX == curCol) { | 1217 | } else if (endX == curCol) { |
1218 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); | 1218 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); |
1219 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1219 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1220 | } else { | 1220 | } else { |
1221 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); | 1221 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); |
1222 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); | 1222 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); |
1223 | } | 1223 | } |
1224 | } else { | 1224 | } else { |
1225 | int startY = mAgenda->timeToY(event->dtStart().time()); | 1225 | int startY = mAgenda->timeToY(event->dtStart().time()); |
1226 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; | 1226 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; |
1227 | if (endY < startY) endY = startY; | 1227 | if (endY < startY) endY = startY; |
1228 | mAgenda->insertItem(event,currentDate,curCol,startY,endY); | 1228 | mAgenda->insertItem(event,currentDate,curCol,startY,endY); |
1229 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1229 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1230 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1230 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1231 | } | 1231 | } |
1232 | } | 1232 | } |
1233 | // ---------- [display Todos -------------- | 1233 | // ---------- [display Todos -------------- |
diff --git a/korganizer/koeditorrecurrence.cpp b/korganizer/koeditorrecurrence.cpp index e165017..dea8981 100644 --- a/korganizer/koeditorrecurrence.cpp +++ b/korganizer/koeditorrecurrence.cpp | |||
@@ -682,385 +682,385 @@ int RecurrenceChooser::type() | |||
682 | if ( mDailyButton->isChecked() ) return Daily; | 682 | if ( mDailyButton->isChecked() ) return Daily; |
683 | else if ( mWeeklyButton->isChecked() ) return Weekly; | 683 | else if ( mWeeklyButton->isChecked() ) return Weekly; |
684 | else if ( mMonthlyButton->isChecked() ) return Monthly; | 684 | else if ( mMonthlyButton->isChecked() ) return Monthly; |
685 | else return Yearly; | 685 | else return Yearly; |
686 | } | 686 | } |
687 | } | 687 | } |
688 | 688 | ||
689 | void RecurrenceChooser::setType( int type ) | 689 | void RecurrenceChooser::setType( int type ) |
690 | { | 690 | { |
691 | if ( mTypeCombo ) { | 691 | if ( mTypeCombo ) { |
692 | mTypeCombo->setCurrentItem( type ); | 692 | mTypeCombo->setCurrentItem( type ); |
693 | } else { | 693 | } else { |
694 | switch ( type ) { | 694 | switch ( type ) { |
695 | case Daily: | 695 | case Daily: |
696 | mDailyButton->setChecked( true ); | 696 | mDailyButton->setChecked( true ); |
697 | break; | 697 | break; |
698 | case Weekly: | 698 | case Weekly: |
699 | mWeeklyButton->setChecked( true ); | 699 | mWeeklyButton->setChecked( true ); |
700 | break; | 700 | break; |
701 | case Monthly: | 701 | case Monthly: |
702 | mMonthlyButton->setChecked( true ); | 702 | mMonthlyButton->setChecked( true ); |
703 | break; | 703 | break; |
704 | case Yearly: | 704 | case Yearly: |
705 | default: | 705 | default: |
706 | mYearlyButton->setChecked( true ); | 706 | mYearlyButton->setChecked( true ); |
707 | break; | 707 | break; |
708 | } | 708 | } |
709 | } | 709 | } |
710 | } | 710 | } |
711 | 711 | ||
712 | void RecurrenceChooser::emitChoice() | 712 | void RecurrenceChooser::emitChoice() |
713 | { | 713 | { |
714 | emit chosen ( type() ); | 714 | emit chosen ( type() ); |
715 | } | 715 | } |
716 | 716 | ||
717 | /////////////////////////////// Main Widget ///////////////////////////// | 717 | /////////////////////////////// Main Widget ///////////////////////////// |
718 | 718 | ||
719 | KOEditorRecurrence::KOEditorRecurrence( QWidget* parent, const char *name ) : | 719 | KOEditorRecurrence::KOEditorRecurrence( QWidget* parent, const char *name ) : |
720 | QWidget( parent, name ) | 720 | QWidget( parent, name ) |
721 | { | 721 | { |
722 | QGridLayout *topLayout = new QGridLayout( this, 2,2 ); | 722 | QGridLayout *topLayout = new QGridLayout( this, 2,2 ); |
723 | topLayout->setSpacing( KDialog::spacingHint() ); | 723 | topLayout->setSpacing( KDialog::spacingHint() ); |
724 | topLayout->setMargin( KDialog::marginHintSmall() ); | 724 | topLayout->setMargin( KDialog::marginHintSmall() ); |
725 | 725 | ||
726 | mEnabledCheck = new QCheckBox( i18n("Enable Recurrence"), this ); | 726 | mEnabledCheck = new QCheckBox( i18n("Enable Recurrence"), this ); |
727 | connect( mEnabledCheck, SIGNAL( toggled( bool ) ), | 727 | connect( mEnabledCheck, SIGNAL( toggled( bool ) ), |
728 | SLOT( setEnabled( bool ) ) ); | 728 | SLOT( setEnabled( bool ) ) ); |
729 | topLayout->addMultiCellWidget( mEnabledCheck, 0, 0, 0, 1 ); | 729 | topLayout->addMultiCellWidget( mEnabledCheck, 0, 0, 0, 1 ); |
730 | 730 | ||
731 | 731 | ||
732 | mTimeGroupBox = new QGroupBox( 1, Horizontal, i18n("Time"), | 732 | mTimeGroupBox = new QGroupBox( 1, Horizontal, i18n("Time"), |
733 | this ); | 733 | this ); |
734 | topLayout->addMultiCellWidget( mTimeGroupBox, 1, 1 , 0 , 1 ); | 734 | topLayout->addMultiCellWidget( mTimeGroupBox, 1, 1 , 0 , 1 ); |
735 | 735 | ||
736 | if ( QApplication::desktop()->width() <= 640 ) { | 736 | if ( QApplication::desktop()->width() <= 640 ) { |
737 | mTimeGroupBox->hide(); | 737 | mTimeGroupBox->hide(); |
738 | } | 738 | } |
739 | 739 | ||
740 | // QFrame *timeFrame = new QFrame( mTimeGroupBox ); | 740 | // QFrame *timeFrame = new QFrame( mTimeGroupBox ); |
741 | // QBoxLayout *layoutTimeFrame = new QHBoxLayout( timeFrame ); | 741 | // QBoxLayout *layoutTimeFrame = new QHBoxLayout( timeFrame ); |
742 | // layoutTimeFrame->setSpacing( KDialog::spacingHint() ); | 742 | // layoutTimeFrame->setSpacing( KDialog::spacingHint() ); |
743 | 743 | ||
744 | mDateTimeLabel = new QLabel( mTimeGroupBox ); | 744 | mDateTimeLabel = new QLabel( mTimeGroupBox ); |
745 | // mDateTimeLabel = new QLabel( timeFrame ); | 745 | // mDateTimeLabel = new QLabel( timeFrame ); |
746 | // layoutTimeFrame->addWidget( mDateTimeLabel ); | 746 | // layoutTimeFrame->addWidget( mDateTimeLabel ); |
747 | //mTimeGroupBox->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum ) ); | 747 | //mTimeGroupBox->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum ) ); |
748 | //mDateTimeLabel->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum) ); | 748 | //mDateTimeLabel->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum) ); |
749 | mRuleBox = new QGroupBox( 1, Horizontal, i18n("Recurrence Rule"), this ); | 749 | mRuleBox = new QGroupBox( 1, Horizontal, i18n("Recurrence Rule"), this ); |
750 | topLayout->addMultiCellWidget( mRuleBox, 2, 2, 0, 1 ); | 750 | topLayout->addMultiCellWidget( mRuleBox, 2, 2, 0, 1 ); |
751 | mRecurrenceChooser = new RecurrenceChooser( mRuleBox ); | 751 | mRecurrenceChooser = new RecurrenceChooser( mRuleBox ); |
752 | connect( mRecurrenceChooser, SIGNAL( chosen( int ) ), | 752 | connect( mRecurrenceChooser, SIGNAL( chosen( int ) ), |
753 | SLOT( showCurrentRule( int ) ) ); | 753 | SLOT( showCurrentRule( int ) ) ); |
754 | 754 | ||
755 | 755 | ||
756 | mRuleStack = new QWidgetStack( mRuleBox ); | 756 | mRuleStack = new QWidgetStack( mRuleBox ); |
757 | 757 | ||
758 | mDaily = new RecurDaily( mRuleStack ); | 758 | mDaily = new RecurDaily( mRuleStack ); |
759 | mRuleStack->addWidget( mDaily, 0 ); | 759 | mRuleStack->addWidget( mDaily, 0 ); |
760 | 760 | ||
761 | mWeekly = new RecurWeekly( mRuleStack ); | 761 | mWeekly = new RecurWeekly( mRuleStack ); |
762 | mRuleStack->addWidget( mWeekly, 0 ); | 762 | mRuleStack->addWidget( mWeekly, 0 ); |
763 | 763 | ||
764 | mMonthly = new RecurMonthly( mRuleStack ); | 764 | mMonthly = new RecurMonthly( mRuleStack ); |
765 | mRuleStack->addWidget( mMonthly, 0 ); | 765 | mRuleStack->addWidget( mMonthly, 0 ); |
766 | 766 | ||
767 | mYearly = new RecurYearly( mRuleStack ); | 767 | mYearly = new RecurYearly( mRuleStack ); |
768 | mRuleStack->addWidget( mYearly, 0 ); | 768 | mRuleStack->addWidget( mYearly, 0 ); |
769 | 769 | ||
770 | showCurrentRule( mRecurrenceChooser->type() ); | 770 | showCurrentRule( mRecurrenceChooser->type() ); |
771 | mRecurrenceRangeWidget = 0; | 771 | mRecurrenceRangeWidget = 0; |
772 | mRecurrenceRangeDialog = new RecurrenceRangeDialog( this ); | 772 | mRecurrenceRangeDialog = new RecurrenceRangeDialog( this ); |
773 | mRecurrenceRange = mRecurrenceRangeDialog; | 773 | mRecurrenceRange = mRecurrenceRangeDialog; |
774 | mRecurrenceRangeButton = new QPushButton( i18n("Recurrence Range..."), | 774 | mRecurrenceRangeButton = new QPushButton( i18n("Recurrence Range..."), |
775 | this ); | 775 | this ); |
776 | 776 | ||
777 | connect( mRecurrenceRangeButton, SIGNAL( clicked() ), | 777 | connect( mRecurrenceRangeButton, SIGNAL( clicked() ), |
778 | SLOT( showRecurrenceRangeDialog() ) ); | 778 | SLOT( showRecurrenceRangeDialog() ) ); |
779 | 779 | ||
780 | mExceptionsWidget = 0; | 780 | mExceptionsWidget = 0; |
781 | mExceptionsDialog = new ExceptionsDialog( this ); | 781 | mExceptionsDialog = new ExceptionsDialog( this ); |
782 | mExceptions = mExceptionsDialog; | 782 | mExceptions = mExceptionsDialog; |
783 | mExceptionsButton = new QPushButton( i18n("Exceptions..."), this ); | 783 | mExceptionsButton = new QPushButton( i18n("Exceptions..."), this ); |
784 | if ( QApplication::desktop()->width() < 320 ) { | 784 | if ( QApplication::desktop()->width() < 320 ) { |
785 | topLayout->addMultiCellWidget( mRecurrenceRangeButton, 3, 3, 0, 1 ); | 785 | topLayout->addMultiCellWidget( mRecurrenceRangeButton, 3, 3, 0, 1 ); |
786 | topLayout->addMultiCellWidget( mExceptionsButton, 4, 4, 0, 1 ); | 786 | topLayout->addMultiCellWidget( mExceptionsButton, 4, 4, 0, 1 ); |
787 | } else { | 787 | } else { |
788 | topLayout->addWidget( mRecurrenceRangeButton, 3, 0 ); | 788 | topLayout->addWidget( mRecurrenceRangeButton, 3, 0 ); |
789 | topLayout->addWidget( mExceptionsButton, 3, 1 ); | 789 | topLayout->addWidget( mExceptionsButton, 3, 1 ); |
790 | } | 790 | } |
791 | connect( mExceptionsButton, SIGNAL( clicked() ), | 791 | connect( mExceptionsButton, SIGNAL( clicked() ), |
792 | SLOT( showExceptionsDialog() ) ); | 792 | SLOT( showExceptionsDialog() ) ); |
793 | } | 793 | } |
794 | 794 | ||
795 | KOEditorRecurrence::~KOEditorRecurrence() | 795 | KOEditorRecurrence::~KOEditorRecurrence() |
796 | { | 796 | { |
797 | } | 797 | } |
798 | 798 | ||
799 | void KOEditorRecurrence::setEnabled( bool enabled ) | 799 | void KOEditorRecurrence::setEnabled( bool enabled ) |
800 | { | 800 | { |
801 | // kdDebug() << "KOEditorRecurrence::setEnabled(): " << (enabled ? "on" : "off") << endl; | 801 | // kdDebug() << "KOEditorRecurrence::setEnabled(): " << (enabled ? "on" : "off") << endl; |
802 | 802 | ||
803 | mTimeGroupBox->setEnabled( enabled ); | 803 | mTimeGroupBox->setEnabled( enabled ); |
804 | if ( mRecurrenceRangeWidget ) mRecurrenceRangeWidget->setEnabled( enabled ); | 804 | if ( mRecurrenceRangeWidget ) mRecurrenceRangeWidget->setEnabled( enabled ); |
805 | if ( mRecurrenceRangeButton ) mRecurrenceRangeButton->setEnabled( enabled ); | 805 | if ( mRecurrenceRangeButton ) mRecurrenceRangeButton->setEnabled( enabled ); |
806 | if ( mExceptionsWidget ) mExceptionsWidget->setEnabled( enabled ); | 806 | if ( mExceptionsWidget ) mExceptionsWidget->setEnabled( enabled ); |
807 | if ( mExceptionsButton ) mExceptionsButton->setEnabled( enabled ); | 807 | if ( mExceptionsButton ) mExceptionsButton->setEnabled( enabled ); |
808 | mRuleBox->setEnabled( enabled ); | 808 | mRuleBox->setEnabled( enabled ); |
809 | } | 809 | } |
810 | 810 | ||
811 | void KOEditorRecurrence::showCurrentRule( int current ) | 811 | void KOEditorRecurrence::showCurrentRule( int current ) |
812 | { | 812 | { |
813 | switch ( current ) { | 813 | switch ( current ) { |
814 | case Daily: | 814 | case Daily: |
815 | mRuleStack->raiseWidget( mDaily ); | 815 | mRuleStack->raiseWidget( mDaily ); |
816 | break; | 816 | break; |
817 | case Weekly: | 817 | case Weekly: |
818 | mRuleStack->raiseWidget( mWeekly ); | 818 | mRuleStack->raiseWidget( mWeekly ); |
819 | break; | 819 | break; |
820 | case Monthly: | 820 | case Monthly: |
821 | mRuleStack->raiseWidget( mMonthly ); | 821 | mRuleStack->raiseWidget( mMonthly ); |
822 | break; | 822 | break; |
823 | default: | 823 | default: |
824 | case Yearly: | 824 | case Yearly: |
825 | mRuleStack->raiseWidget( mYearly ); | 825 | mRuleStack->raiseWidget( mYearly ); |
826 | break; | 826 | break; |
827 | } | 827 | } |
828 | } | 828 | } |
829 | 829 | ||
830 | void KOEditorRecurrence::setDateTimes( QDateTime start, QDateTime end ) | 830 | void KOEditorRecurrence::setDateTimes( QDateTime start, QDateTime end ) |
831 | { | 831 | { |
832 | // kdDebug() << "KOEditorRecurrence::setDateTimes" << endl; | 832 | // kdDebug() << "KOEditorRecurrence::setDateTimes" << endl; |
833 | 833 | ||
834 | mRecurrenceRange->setDateTimes( start, end ); | 834 | mRecurrenceRange->setDateTimes( start, end ); |
835 | mExceptions->setDefaults( end ); | 835 | mExceptions->setDefaults( end ); |
836 | 836 | ||
837 | } | 837 | } |
838 | 838 | ||
839 | void KOEditorRecurrence::setDefaults( QDateTime from, QDateTime to, bool ) | 839 | void KOEditorRecurrence::setDefaults( QDateTime from, QDateTime to, bool ) |
840 | { | 840 | { |
841 | 841 | ||
842 | // qDebug("KOEditorRecurrence::setDefaults %s %s ",from.toString().latin1(),to.toString().latin1() ); | 842 | // qDebug("KOEditorRecurrence::setDefaults %s %s ",from.toString().latin1(),to.toString().latin1() ); |
843 | setDateTimes( from, to ); | 843 | setDateTimes( from, to ); |
844 | 844 | ||
845 | bool enabled = false; | 845 | bool enabled = false; |
846 | mEnabledCheck->setChecked( enabled ); | 846 | mEnabledCheck->setChecked( enabled ); |
847 | setEnabled( enabled ); | 847 | setEnabled( enabled ); |
848 | 848 | ||
849 | mExceptions->setDefaults( to ); | 849 | mExceptions->setDefaults( to ); |
850 | mRecurrenceRange->setDefaults( to ); | 850 | mRecurrenceRange->setDefaults( to ); |
851 | 851 | ||
852 | mRecurrenceChooser->setType( RecurrenceChooser::Weekly ); | 852 | mRecurrenceChooser->setType( RecurrenceChooser::Weekly ); |
853 | showCurrentRule( mRecurrenceChooser->type() ); | 853 | showCurrentRule( mRecurrenceChooser->type() ); |
854 | 854 | ||
855 | mDaily->setFrequency( 1 ); | 855 | mDaily->setFrequency( 1 ); |
856 | 856 | ||
857 | mWeekly->setFrequency( 1 ); | 857 | mWeekly->setFrequency( 1 ); |
858 | QBitArray days( 7 ); | 858 | QBitArray days( 7 ); |
859 | days.fill( 0 ); | 859 | days.fill( 0 ); |
860 | days.setBit( from.date().dayOfWeek()- 1); | 860 | days.setBit( from.date().dayOfWeek()- 1); |
861 | mWeekly->setDays( days ); | 861 | mWeekly->setDays( days ); |
862 | mMonthly->setFrequency( 1 ); | 862 | mMonthly->setFrequency( 1 ); |
863 | mMonthly->setByPos((from.date().day()/7), from.date().dayOfWeek()-1 ); | 863 | mMonthly->setByPos((from.date().day()/7), from.date().dayOfWeek()-1 ); |
864 | mMonthly->setByDay( from.date().day()-1 ); | 864 | mMonthly->setByDay( from.date().day()-1 ); |
865 | mYearly->setFrequency( 1 ); | 865 | mYearly->setFrequency( 1 ); |
866 | mYearly->setByDay( from.date().dayOfYear() ); | 866 | mYearly->setByDay( from.date().dayOfYear() ); |
867 | mYearly->setByMonth( from.date().month(), from.date().day() ); | 867 | mYearly->setByMonth( from.date().month(), from.date().day() ); |
868 | } | 868 | } |
869 | 869 | ||
870 | void KOEditorRecurrence::readEvent(Incidence *event) | 870 | void KOEditorRecurrence::readEvent(Incidence *event) |
871 | { | 871 | { |
872 | 872 | ||
873 | QDateTime dtEnd; | 873 | QDateTime dtEnd; |
874 | if ( event->type() == "Event" ) | 874 | if ( event->typeID() == eventID ) |
875 | dtEnd = ((Event*)event)->dtEnd(); | 875 | dtEnd = ((Event*)event)->dtEnd(); |
876 | else | 876 | else |
877 | dtEnd = ((Todo*)event)->dtDue(); | 877 | dtEnd = ((Todo*)event)->dtDue(); |
878 | 878 | ||
879 | setDefaults( event->dtStart(), dtEnd, true ); | 879 | setDefaults( event->dtStart(), dtEnd, true ); |
880 | QBitArray rDays( 7 ); | 880 | QBitArray rDays( 7 ); |
881 | QPtrList<Recurrence::rMonthPos> rmp; | 881 | QPtrList<Recurrence::rMonthPos> rmp; |
882 | QPtrList<int> rmd; | 882 | QPtrList<int> rmd; |
883 | int day = 0; | 883 | int day = 0; |
884 | int count = 0; | 884 | int count = 0; |
885 | int month = 0; | 885 | int month = 0; |
886 | setDateTimes( event->dtStart(), dtEnd ); | 886 | setDateTimes( event->dtStart(), dtEnd ); |
887 | 887 | ||
888 | Recurrence *r = event->recurrence(); | 888 | Recurrence *r = event->recurrence(); |
889 | int f = r->frequency(); | 889 | int f = r->frequency(); |
890 | 890 | ||
891 | int recurs = r->doesRecur(); | 891 | int recurs = r->doesRecur(); |
892 | 892 | ||
893 | mEnabledCheck->setChecked( recurs ); | 893 | mEnabledCheck->setChecked( recurs ); |
894 | setEnabled( recurs ); | 894 | setEnabled( recurs ); |
895 | 895 | ||
896 | int recurrenceType = RecurrenceChooser::Weekly; | 896 | int recurrenceType = RecurrenceChooser::Weekly; |
897 | 897 | ||
898 | switch ( recurs ) { | 898 | switch ( recurs ) { |
899 | case Recurrence::rNone: | 899 | case Recurrence::rNone: |
900 | setDefaults( event->dtStart(), dtEnd, true ); | 900 | setDefaults( event->dtStart(), dtEnd, true ); |
901 | break; | 901 | break; |
902 | case Recurrence::rDaily: | 902 | case Recurrence::rDaily: |
903 | recurrenceType = RecurrenceChooser::Daily; | 903 | recurrenceType = RecurrenceChooser::Daily; |
904 | mDaily->setFrequency( f ); | 904 | mDaily->setFrequency( f ); |
905 | break; | 905 | break; |
906 | case Recurrence::rWeekly: | 906 | case Recurrence::rWeekly: |
907 | recurrenceType = RecurrenceChooser::Weekly; | 907 | recurrenceType = RecurrenceChooser::Weekly; |
908 | mWeekly->setFrequency( f ); | 908 | mWeekly->setFrequency( f ); |
909 | mWeekly->setDays( r->days() ); | 909 | mWeekly->setDays( r->days() ); |
910 | break; | 910 | break; |
911 | case Recurrence::rMonthlyPos: | 911 | case Recurrence::rMonthlyPos: |
912 | // we only handle one possibility in the list right now, | 912 | // we only handle one possibility in the list right now, |
913 | // so I have hardcoded calls with first(). If we make the GUI | 913 | // so I have hardcoded calls with first(). If we make the GUI |
914 | // more extended, this can be changed. | 914 | // more extended, this can be changed. |
915 | recurrenceType = RecurrenceChooser::Monthly; | 915 | recurrenceType = RecurrenceChooser::Monthly; |
916 | 916 | ||
917 | rmp = r->monthPositions(); | 917 | rmp = r->monthPositions(); |
918 | if ( rmp.first()->negative ) | 918 | if ( rmp.first()->negative ) |
919 | count = 5 - rmp.first()->rPos - 1; | 919 | count = 5 - rmp.first()->rPos - 1; |
920 | else | 920 | else |
921 | count = rmp.first()->rPos - 1; | 921 | count = rmp.first()->rPos - 1; |
922 | day = 0; | 922 | day = 0; |
923 | while ( !rmp.first()->rDays.testBit( day ) ) ++day; | 923 | while ( !rmp.first()->rDays.testBit( day ) ) ++day; |
924 | mMonthly->setByPos( count, day ); | 924 | mMonthly->setByPos( count, day ); |
925 | 925 | ||
926 | mMonthly->setFrequency( f ); | 926 | mMonthly->setFrequency( f ); |
927 | 927 | ||
928 | break; | 928 | break; |
929 | case Recurrence::rMonthlyDay: | 929 | case Recurrence::rMonthlyDay: |
930 | recurrenceType = RecurrenceChooser::Monthly; | 930 | recurrenceType = RecurrenceChooser::Monthly; |
931 | 931 | ||
932 | rmd = r->monthDays(); | 932 | rmd = r->monthDays(); |
933 | day = *rmd.first() - 1; | 933 | day = *rmd.first() - 1; |
934 | mMonthly->setByDay( day ); | 934 | mMonthly->setByDay( day ); |
935 | 935 | ||
936 | mMonthly->setFrequency( f ); | 936 | mMonthly->setFrequency( f ); |
937 | 937 | ||
938 | break; | 938 | break; |
939 | case Recurrence::rYearlyMonth: | 939 | case Recurrence::rYearlyMonth: |
940 | { | 940 | { |
941 | recurrenceType = RecurrenceChooser::Yearly; | 941 | recurrenceType = RecurrenceChooser::Yearly; |
942 | //qDebug("Recurrence::rYearlyMonth: "); | 942 | //qDebug("Recurrence::rYearlyMonth: "); |
943 | day = event->dtStart().date().day(); | 943 | day = event->dtStart().date().day(); |
944 | rmd = r->yearNums(); | 944 | rmd = r->yearNums(); |
945 | if ( rmd.count() > 0 ) | 945 | if ( rmd.count() > 0 ) |
946 | month = *rmd.first(); | 946 | month = *rmd.first(); |
947 | else | 947 | else |
948 | month = event->dtStart().date().month() ; | 948 | month = event->dtStart().date().month() ; |
949 | mYearly->setByMonth( month, day ); | 949 | mYearly->setByMonth( month, day ); |
950 | #if 0 | 950 | #if 0 |
951 | //qDebug("2day = %d ",day ); | 951 | //qDebug("2day = %d ",day ); |
952 | QPtrList<Recurrence::rMonthPos> monthlist = r->yearMonthPositions(); | 952 | QPtrList<Recurrence::rMonthPos> monthlist = r->yearMonthPositions(); |
953 | int month; | 953 | int month; |
954 | if ( !monthlist.isEmpty() ) { | 954 | if ( !monthlist.isEmpty() ) { |
955 | month = monthlist.first()->rPos ; | 955 | month = monthlist.first()->rPos ; |
956 | } else { | 956 | } else { |
957 | month = event->dtStart().date().month() ; | 957 | month = event->dtStart().date().month() ; |
958 | } | 958 | } |
959 | mYearly->setByMonth( day, month ); | 959 | mYearly->setByMonth( day, month ); |
960 | #endif | 960 | #endif |
961 | mYearly->setFrequency( f ); | 961 | mYearly->setFrequency( f ); |
962 | } | 962 | } |
963 | 963 | ||
964 | break; | 964 | break; |
965 | case Recurrence::rYearlyDay: | 965 | case Recurrence::rYearlyDay: |
966 | //qDebug("Recurrence::rYearlyDay: "); | 966 | //qDebug("Recurrence::rYearlyDay: "); |
967 | recurrenceType = RecurrenceChooser::Yearly; | 967 | recurrenceType = RecurrenceChooser::Yearly; |
968 | mYearly->setByDay( event->dtStart().date().dayOfYear() ); | 968 | mYearly->setByDay( event->dtStart().date().dayOfYear() ); |
969 | mYearly->setFrequency( f ); | 969 | mYearly->setFrequency( f ); |
970 | break; | 970 | break; |
971 | default: | 971 | default: |
972 | setDefaults( event->dtStart(), dtEnd, true ); | 972 | setDefaults( event->dtStart(), dtEnd, true ); |
973 | break; | 973 | break; |
974 | } | 974 | } |
975 | 975 | ||
976 | mRecurrenceChooser->setType( recurrenceType ); | 976 | mRecurrenceChooser->setType( recurrenceType ); |
977 | showCurrentRule( recurrenceType ); | 977 | showCurrentRule( recurrenceType ); |
978 | 978 | ||
979 | mRecurrenceRange->setDateTimes( event->dtStart() ); | 979 | mRecurrenceRange->setDateTimes( event->dtStart() ); |
980 | 980 | ||
981 | if ( r->doesRecur() ) { | 981 | if ( r->doesRecur() ) { |
982 | mRecurrenceRange->setDuration( r->duration() ); | 982 | mRecurrenceRange->setDuration( r->duration() ); |
983 | if ( r->duration() == 0 ) | 983 | if ( r->duration() == 0 ) |
984 | { | 984 | { |
985 | if ( r->endDate() < event->dtStart().date() ) | 985 | if ( r->endDate() < event->dtStart().date() ) |
986 | mRecurrenceRange->setEndDate( event->dtStart().date() ); | 986 | mRecurrenceRange->setEndDate( event->dtStart().date() ); |
987 | else | 987 | else |
988 | mRecurrenceRange->setEndDate( r->endDate() ); | 988 | mRecurrenceRange->setEndDate( r->endDate() ); |
989 | } else | 989 | } else |
990 | mRecurrenceRange->setEndDate( event->dtStart().date() ); | 990 | mRecurrenceRange->setEndDate( event->dtStart().date() ); |
991 | } | 991 | } |
992 | 992 | ||
993 | mExceptions->setDates( event->exDates() ); | 993 | mExceptions->setDates( event->exDates() ); |
994 | } | 994 | } |
995 | 995 | ||
996 | void KOEditorRecurrence::writeEvent( Incidence *event ) | 996 | void KOEditorRecurrence::writeEvent( Incidence *event ) |
997 | { | 997 | { |
998 | Recurrence *r = event->recurrence(); | 998 | Recurrence *r = event->recurrence(); |
999 | 999 | ||
1000 | // clear out any old settings; | 1000 | // clear out any old settings; |
1001 | r->unsetRecurs(); | 1001 | r->unsetRecurs(); |
1002 | 1002 | ||
1003 | if ( mEnabledCheck->isChecked() ) { | 1003 | if ( mEnabledCheck->isChecked() ) { |
1004 | int duration = mRecurrenceRange->duration(); | 1004 | int duration = mRecurrenceRange->duration(); |
1005 | QDate endDate; | 1005 | QDate endDate; |
1006 | if ( duration == 0 ) endDate = mRecurrenceRange->endDate(); | 1006 | if ( duration == 0 ) endDate = mRecurrenceRange->endDate(); |
1007 | 1007 | ||
1008 | int recurrenceType = mRecurrenceChooser->type(); | 1008 | int recurrenceType = mRecurrenceChooser->type(); |
1009 | 1009 | ||
1010 | if ( recurrenceType == RecurrenceChooser::Daily ) { | 1010 | if ( recurrenceType == RecurrenceChooser::Daily ) { |
1011 | int freq = mDaily->frequency(); | 1011 | int freq = mDaily->frequency(); |
1012 | if ( duration != 0 ) r->setDaily( freq, duration ); | 1012 | if ( duration != 0 ) r->setDaily( freq, duration ); |
1013 | else r->setDaily( freq, endDate ); | 1013 | else r->setDaily( freq, endDate ); |
1014 | } else if ( recurrenceType == RecurrenceChooser::Weekly ) { | 1014 | } else if ( recurrenceType == RecurrenceChooser::Weekly ) { |
1015 | int freq = mWeekly->frequency(); | 1015 | int freq = mWeekly->frequency(); |
1016 | QBitArray days = mWeekly->days(); | 1016 | QBitArray days = mWeekly->days(); |
1017 | int j; | 1017 | int j; |
1018 | bool found = false; | 1018 | bool found = false; |
1019 | for (j = 0; j < 7 ; ++j ) { | 1019 | for (j = 0; j < 7 ; ++j ) { |
1020 | found |=days.at(j); | 1020 | found |=days.at(j); |
1021 | } | 1021 | } |
1022 | if ( !found ) { | 1022 | if ( !found ) { |
1023 | days.setBit( event->dtStart().date().dayOfWeek()-1); | 1023 | days.setBit( event->dtStart().date().dayOfWeek()-1); |
1024 | //qDebug("bit set %d ", event->dtStart().date().dayOfWeek()-1); | 1024 | //qDebug("bit set %d ", event->dtStart().date().dayOfWeek()-1); |
1025 | } | 1025 | } |
1026 | if ( duration != 0 ) r->setWeekly( freq, days, duration ); | 1026 | if ( duration != 0 ) r->setWeekly( freq, days, duration ); |
1027 | else r->setWeekly( freq, days, endDate ); | 1027 | else r->setWeekly( freq, days, endDate ); |
1028 | } else if ( recurrenceType == RecurrenceChooser::Monthly ) { | 1028 | } else if ( recurrenceType == RecurrenceChooser::Monthly ) { |
1029 | int freq = mMonthly->frequency(); | 1029 | int freq = mMonthly->frequency(); |
1030 | if ( mMonthly->byPos() ) { | 1030 | if ( mMonthly->byPos() ) { |
1031 | int pos = mMonthly->count(); | 1031 | int pos = mMonthly->count(); |
1032 | 1032 | ||
1033 | QBitArray days( 7 ); | 1033 | QBitArray days( 7 ); |
1034 | days.fill( false ); | 1034 | days.fill( false ); |
1035 | 1035 | ||
1036 | days.setBit( mMonthly->weekday() ); | 1036 | days.setBit( mMonthly->weekday() ); |
1037 | if ( duration != 0 ) | 1037 | if ( duration != 0 ) |
1038 | r->setMonthly( Recurrence::rMonthlyPos, freq, duration ); | 1038 | r->setMonthly( Recurrence::rMonthlyPos, freq, duration ); |
1039 | else | 1039 | else |
1040 | r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); | 1040 | r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); |
1041 | r->addMonthlyPos( pos, days ); | 1041 | r->addMonthlyPos( pos, days ); |
1042 | } else { | 1042 | } else { |
1043 | // it's by day | 1043 | // it's by day |
1044 | int day = mMonthly->day(); | 1044 | int day = mMonthly->day(); |
1045 | 1045 | ||
1046 | if ( duration != 0 ) { | 1046 | if ( duration != 0 ) { |
1047 | r->setMonthly( Recurrence::rMonthlyDay, freq, duration ); | 1047 | r->setMonthly( Recurrence::rMonthlyDay, freq, duration ); |
1048 | } else { | 1048 | } else { |
1049 | r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); | 1049 | r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); |
1050 | } | 1050 | } |
1051 | r->addMonthlyDay( day ); | 1051 | r->addMonthlyDay( day ); |
1052 | } | 1052 | } |
1053 | } else if ( recurrenceType == RecurrenceChooser::Yearly ) { | 1053 | } else if ( recurrenceType == RecurrenceChooser::Yearly ) { |
1054 | //qDebug("RecurrenceChooser::Yearly "); | 1054 | //qDebug("RecurrenceChooser::Yearly "); |
1055 | int freq = mYearly->frequency(); | 1055 | int freq = mYearly->frequency(); |
1056 | if ( mYearly->byDay() ) { | 1056 | if ( mYearly->byDay() ) { |
1057 | if ( duration != 0 ) { | 1057 | if ( duration != 0 ) { |
1058 | r->setYearly( Recurrence::rYearlyDay, freq, duration ); | 1058 | r->setYearly( Recurrence::rYearlyDay, freq, duration ); |
1059 | } else { | 1059 | } else { |
1060 | r->setYearly( Recurrence::rYearlyDay, freq, endDate ); | 1060 | r->setYearly( Recurrence::rYearlyDay, freq, endDate ); |
1061 | } | 1061 | } |
1062 | r->addYearlyNum( event->dtStart().date().dayOfYear() ); | 1062 | r->addYearlyNum( event->dtStart().date().dayOfYear() ); |
1063 | } else { | 1063 | } else { |
1064 | if ( duration != 0 ) { | 1064 | if ( duration != 0 ) { |
1065 | r->setYearly( Recurrence::rYearlyMonth, freq, duration ); | 1065 | r->setYearly( Recurrence::rYearlyMonth, freq, duration ); |
1066 | } else { | 1066 | } else { |
diff --git a/korganizer/koeventviewerdialog.cpp b/korganizer/koeventviewerdialog.cpp index e5ff8af..02f13c7 100644 --- a/korganizer/koeventviewerdialog.cpp +++ b/korganizer/koeventviewerdialog.cpp | |||
@@ -1,307 +1,307 @@ | |||
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 | 19 | ||
20 | #include <klocale.h> | 20 | #include <klocale.h> |
21 | 21 | ||
22 | #include <libkcal/event.h> | 22 | #include <libkcal/event.h> |
23 | #include <qtimer.h> | 23 | #include <qtimer.h> |
24 | #include <qpushbutton.h> | 24 | #include <qpushbutton.h> |
25 | 25 | ||
26 | #include "koeventviewer.h" | 26 | #include "koeventviewer.h" |
27 | #include <kmessagebox.h> | 27 | #include <kmessagebox.h> |
28 | #include "koprefs.h" | 28 | #include "koprefs.h" |
29 | #include <libkcal/todo.h> | 29 | #include <libkcal/todo.h> |
30 | #include "qapp.h" | 30 | #include "qapp.h" |
31 | 31 | ||
32 | #include "koeventviewerdialog.h" | 32 | #include "koeventviewerdialog.h" |
33 | extern int globalFlagBlockAgenda; | 33 | extern int globalFlagBlockAgenda; |
34 | 34 | ||
35 | KOEventViewerDialog::KOEventViewerDialog(QWidget *parent,const char *name) | 35 | KOEventViewerDialog::KOEventViewerDialog(QWidget *parent,const char *name) |
36 | : KDialogBase(parent,name, | 36 | : KDialogBase(parent,name, |
37 | #ifndef DESKTOP_VERSION | 37 | #ifndef DESKTOP_VERSION |
38 | true , | 38 | true , |
39 | #else | 39 | #else |
40 | false, | 40 | false, |
41 | #endif | 41 | #endif |
42 | i18n("Event Viewer"),Ok|User1|Close,Close, false, i18n("Agenda")) | 42 | i18n("Event Viewer"),Ok|User1|Close,Close, false, i18n("Agenda")) |
43 | { | 43 | { |
44 | sendSignalViewerClosed = true; | 44 | sendSignalViewerClosed = true; |
45 | mEventViewer = new KOEventViewer(this); | 45 | mEventViewer = new KOEventViewer(this); |
46 | mEventViewer->setFont( KOPrefs::instance()->mEventViewFont ); | 46 | mEventViewer->setFont( KOPrefs::instance()->mEventViewFont ); |
47 | setMainWidget(mEventViewer); | 47 | setMainWidget(mEventViewer); |
48 | setButtonText(Ok, i18n("Edit") ); | 48 | setButtonText(Ok, i18n("Edit") ); |
49 | 49 | ||
50 | QObject::connect(findButton( Ok ),SIGNAL(clicked()), | 50 | QObject::connect(findButton( Ok ),SIGNAL(clicked()), |
51 | SLOT(editIncidence())); | 51 | SLOT(editIncidence())); |
52 | QObject::connect(this,SIGNAL(user1Clicked()), | 52 | QObject::connect(this,SIGNAL(user1Clicked()), |
53 | SLOT(showIncidence())); | 53 | SLOT(showIncidence())); |
54 | mIncidence = 0; | 54 | mIncidence = 0; |
55 | // TODO: Set a sensible size (based on the content?). | 55 | // TODO: Set a sensible size (based on the content?). |
56 | //showMaximized(); | 56 | //showMaximized(); |
57 | //qDebug("++++++++++++KOEventViewerDialog() "); | 57 | //qDebug("++++++++++++KOEventViewerDialog() "); |
58 | // if ( KOPrefs::instance()->mCompactDialogs ) { | 58 | // if ( KOPrefs::instance()->mCompactDialogs ) { |
59 | // setFixedSize( 240,284 ); | 59 | // setFixedSize( 240,284 ); |
60 | // move( 0, 15 ); | 60 | // move( 0, 15 ); |
61 | // } else { | 61 | // } else { |
62 | // setMinimumSize(300,200); | 62 | // setMinimumSize(300,200); |
63 | // resize(320,300); | 63 | // resize(320,300); |
64 | // } | 64 | // } |
65 | mSyncMode = false; | 65 | mSyncMode = false; |
66 | mSyncResult = 0; | 66 | mSyncResult = 0; |
67 | 67 | ||
68 | } | 68 | } |
69 | 69 | ||
70 | KOEventViewerDialog::~KOEventViewerDialog() | 70 | KOEventViewerDialog::~KOEventViewerDialog() |
71 | { | 71 | { |
72 | //qDebug("-------~KOEventViewerDialog() "); | 72 | //qDebug("-------~KOEventViewerDialog() "); |
73 | } | 73 | } |
74 | void KOEventViewerDialog::showMe() | 74 | void KOEventViewerDialog::showMe() |
75 | { | 75 | { |
76 | 76 | ||
77 | #ifdef DESKTOP_VERSION | 77 | #ifdef DESKTOP_VERSION |
78 | int x,y,w,h; | 78 | int x,y,w,h; |
79 | x = geometry().x(); | 79 | x = geometry().x(); |
80 | y = geometry().y(); | 80 | y = geometry().y(); |
81 | w = width(); | 81 | w = width(); |
82 | h = height(); | 82 | h = height(); |
83 | show(); | 83 | show(); |
84 | setGeometry(x,y,w,h); | 84 | setGeometry(x,y,w,h); |
85 | raise(); | 85 | raise(); |
86 | #else | 86 | #else |
87 | showMaximized(); | 87 | showMaximized(); |
88 | #endif | 88 | #endif |
89 | QTimer::singleShot( 1, this, SLOT ( setMyFocus() ) ); | 89 | QTimer::singleShot( 1, this, SLOT ( setMyFocus() ) ); |
90 | 90 | ||
91 | } | 91 | } |
92 | void KOEventViewerDialog::setMyFocus() | 92 | void KOEventViewerDialog::setMyFocus() |
93 | { | 93 | { |
94 | 94 | ||
95 | setActiveWindow(); | 95 | setActiveWindow(); |
96 | mEventViewer->setFocus(); | 96 | mEventViewer->setFocus(); |
97 | 97 | ||
98 | } | 98 | } |
99 | void KOEventViewerDialog::print() | 99 | void KOEventViewerDialog::print() |
100 | { | 100 | { |
101 | mEventViewer->printMe(); | 101 | mEventViewer->printMe(); |
102 | 102 | ||
103 | } | 103 | } |
104 | void KOEventViewerDialog::setSyncMode( bool b ) | 104 | void KOEventViewerDialog::setSyncMode( bool b ) |
105 | { | 105 | { |
106 | mSyncMode = b; | 106 | mSyncMode = b; |
107 | //qDebug("KOEventViewerDialog::setSyncMode %d ",mSyncMode ); | 107 | //qDebug("KOEventViewerDialog::setSyncMode %d ",mSyncMode ); |
108 | if ( mSyncMode ) { | 108 | if ( mSyncMode ) { |
109 | findButton( Close )->setText( i18n("Cancel Sync")); | 109 | findButton( Close )->setText( i18n("Cancel Sync")); |
110 | findButton( Ok )->setText( i18n("Remote")); | 110 | findButton( Ok )->setText( i18n("Remote")); |
111 | findButton( User1 )->setText( i18n("Local")); | 111 | findButton( User1 )->setText( i18n("Local")); |
112 | } else { | 112 | } else { |
113 | findButton( Close )->setText( i18n("Close")); | 113 | findButton( Close )->setText( i18n("Close")); |
114 | findButton( Ok )->setText( i18n("Edit")); | 114 | findButton( Ok )->setText( i18n("Edit")); |
115 | findButton( User1 )->setText( i18n("Agenda")); | 115 | findButton( User1 )->setText( i18n("Agenda")); |
116 | } | 116 | } |
117 | mEventViewer->setSyncMode( b ); | 117 | mEventViewer->setSyncMode( b ); |
118 | } | 118 | } |
119 | void KOEventViewerDialog::setColorMode( int m ) | 119 | void KOEventViewerDialog::setColorMode( int m ) |
120 | { | 120 | { |
121 | mEventViewer->setColorMode( m ); | 121 | mEventViewer->setColorMode( m ); |
122 | } | 122 | } |
123 | int KOEventViewerDialog::executeS( bool local ) | 123 | int KOEventViewerDialog::executeS( bool local ) |
124 | { | 124 | { |
125 | mSyncResult = 3; | 125 | mSyncResult = 3; |
126 | if ( local ) | 126 | if ( local ) |
127 | findButton( User1 )->setFocus(); | 127 | findButton( User1 )->setFocus(); |
128 | else | 128 | else |
129 | findButton( Ok )->setFocus(); | 129 | findButton( Ok )->setFocus(); |
130 | exec(); | 130 | exec(); |
131 | return mSyncResult; | 131 | return mSyncResult; |
132 | } | 132 | } |
133 | 133 | ||
134 | void KOEventViewerDialog::updateConfig() | 134 | void KOEventViewerDialog::updateConfig() |
135 | { | 135 | { |
136 | mEventViewer->setFont( KOPrefs::instance()->mEventViewFont ); | 136 | mEventViewer->setFont( KOPrefs::instance()->mEventViewFont ); |
137 | 137 | ||
138 | } | 138 | } |
139 | void KOEventViewerDialog::setEvent(Event *event) | 139 | void KOEventViewerDialog::setEvent(Event *event) |
140 | { | 140 | { |
141 | mEventViewer->setEvent(event); | 141 | mEventViewer->setEvent(event); |
142 | mIncidence = event; | 142 | mIncidence = event; |
143 | mEventViewer->setFocus(); | 143 | mEventViewer->setFocus(); |
144 | //findButton( Close )->setFocus(); | 144 | //findButton( Close )->setFocus(); |
145 | if ( !mSyncMode ) { | 145 | if ( !mSyncMode ) { |
146 | findButton( User1 )->setText( i18n("Agenda")); | 146 | findButton( User1 )->setText( i18n("Agenda")); |
147 | } | 147 | } |
148 | } | 148 | } |
149 | void KOEventViewerDialog::setIncidence(Incidence *in ) | 149 | void KOEventViewerDialog::setIncidence(Incidence *in ) |
150 | { | 150 | { |
151 | if ( in->type() == "Event" ) | 151 | if ( in->typeID() == eventID ) |
152 | setEvent( (Event*) in ); | 152 | setEvent( (Event*) in ); |
153 | else if ( in->type() =="Todo" ) | 153 | else if ( in->typeID() == todoID ) |
154 | setTodo( (Todo*) in ); | 154 | setTodo( (Todo*) in ); |
155 | else if ( in->type() =="Journal" ) | 155 | else if ( in->typeID() == journalID ) |
156 | setJournal( (Journal*) in ); | 156 | setJournal( (Journal*) in ); |
157 | } | 157 | } |
158 | void KOEventViewerDialog::addIncidence(Incidence *in) | 158 | void KOEventViewerDialog::addIncidence(Incidence *in) |
159 | { | 159 | { |
160 | if ( in->type() == "Event" ) | 160 | if ( in->typeID() == eventID ) |
161 | addEvent( (Event*) in ); | 161 | addEvent( (Event*) in ); |
162 | else if ( in->type() =="Todo" ) | 162 | else if ( in->typeID() == todoID ) |
163 | mEventViewer->setTodo( (Todo*) in, false ); | 163 | mEventViewer->setTodo( (Todo*) in, false ); |
164 | else if ( in->type() =="Journal" ) | 164 | else if ( in->typeID() == journalID ) |
165 | mEventViewer->setJournal( (Journal*) in, false ); | 165 | mEventViewer->setJournal( (Journal*) in, false ); |
166 | if ( mSyncMode ) { | 166 | if ( mSyncMode ) { |
167 | findButton( User1 )->setFocus(); | 167 | findButton( User1 )->setFocus(); |
168 | setCaption(i18n("Conflict! Please choose entry")); | 168 | setCaption(i18n("Conflict! Please choose entry")); |
169 | } | 169 | } |
170 | } | 170 | } |
171 | 171 | ||
172 | void KOEventViewerDialog::addEvent(Event *event) | 172 | void KOEventViewerDialog::addEvent(Event *event) |
173 | { | 173 | { |
174 | mEventViewer->addEvent(event); | 174 | mEventViewer->addEvent(event); |
175 | mIncidence = event; | 175 | mIncidence = event; |
176 | mEventViewer->setFocus(); | 176 | mEventViewer->setFocus(); |
177 | //findButton( Close )->setFocus(); | 177 | //findButton( Close )->setFocus(); |
178 | if ( !mSyncMode ) { | 178 | if ( !mSyncMode ) { |
179 | findButton( User1 )->setText( i18n("Agenda")); | 179 | findButton( User1 )->setText( i18n("Agenda")); |
180 | } | 180 | } |
181 | } | 181 | } |
182 | 182 | ||
183 | void KOEventViewerDialog::setTodo(Todo *event) | 183 | void KOEventViewerDialog::setTodo(Todo *event) |
184 | { | 184 | { |
185 | mEventViewer->setTodo(event); | 185 | mEventViewer->setTodo(event); |
186 | mIncidence = (Incidence*)event; | 186 | mIncidence = (Incidence*)event; |
187 | mEventViewer->setFocus(); | 187 | mEventViewer->setFocus(); |
188 | //findButton( Close )->setFocus(); | 188 | //findButton( Close )->setFocus(); |
189 | if ( !mSyncMode ) { | 189 | if ( !mSyncMode ) { |
190 | findButton( User1 )->setText( i18n("Set complete")); | 190 | findButton( User1 )->setText( i18n("Set complete")); |
191 | } | 191 | } |
192 | } | 192 | } |
193 | void KOEventViewerDialog::setJournal(Journal *j) | 193 | void KOEventViewerDialog::setJournal(Journal *j) |
194 | { | 194 | { |
195 | mEventViewer->setJournal(j); | 195 | mEventViewer->setJournal(j); |
196 | mIncidence = (Incidence*)j; | 196 | mIncidence = (Incidence*)j; |
197 | mEventViewer->setFocus(); | 197 | mEventViewer->setFocus(); |
198 | //findButton( Close )->setFocus(); | 198 | //findButton( Close )->setFocus(); |
199 | if ( !mSyncMode ) { | 199 | if ( !mSyncMode ) { |
200 | findButton( User1 )->setText( i18n("Agenda")); | 200 | findButton( User1 )->setText( i18n("Agenda")); |
201 | } | 201 | } |
202 | } | 202 | } |
203 | 203 | ||
204 | void KOEventViewerDialog::addText(QString text) | 204 | void KOEventViewerDialog::addText(QString text) |
205 | { | 205 | { |
206 | mEventViewer->addText(text); | 206 | mEventViewer->addText(text); |
207 | mEventViewer->setFocus(); | 207 | mEventViewer->setFocus(); |
208 | //findButton( Close )->setFocus(); | 208 | //findButton( Close )->setFocus(); |
209 | } | 209 | } |
210 | void KOEventViewerDialog::editIncidence() | 210 | void KOEventViewerDialog::editIncidence() |
211 | { | 211 | { |
212 | sendSignalViewerClosed = false; | 212 | sendSignalViewerClosed = false; |
213 | if ( mSyncMode ) { | 213 | if ( mSyncMode ) { |
214 | mSyncResult = 2; | 214 | mSyncResult = 2; |
215 | accept(); | 215 | accept(); |
216 | return; | 216 | return; |
217 | } | 217 | } |
218 | if ( mIncidence ){ | 218 | if ( mIncidence ){ |
219 | close(); | 219 | close(); |
220 | emit editIncidence( mIncidence ); | 220 | emit editIncidence( mIncidence ); |
221 | } | 221 | } |
222 | } | 222 | } |
223 | void KOEventViewerDialog::showIncidence() | 223 | void KOEventViewerDialog::showIncidence() |
224 | { | 224 | { |
225 | sendSignalViewerClosed = false; | 225 | sendSignalViewerClosed = false; |
226 | if ( mSyncMode ) { | 226 | if ( mSyncMode ) { |
227 | mSyncResult = 1; | 227 | mSyncResult = 1; |
228 | accept(); | 228 | accept(); |
229 | return; | 229 | return; |
230 | } | 230 | } |
231 | 231 | ||
232 | if ( mIncidence ){ | 232 | if ( mIncidence ){ |
233 | QDate date; | 233 | QDate date; |
234 | if ( mIncidence->type() == "Todo" ) { | 234 | if ( mIncidence->type() == "Todo" ) { |
235 | /* | 235 | /* |
236 | if ( ((Todo*)mIncidence)->hasDueDate() ) | 236 | if ( ((Todo*)mIncidence)->hasDueDate() ) |
237 | date = ((Todo*)mIncidence)->dtDue().date(); | 237 | date = ((Todo*)mIncidence)->dtDue().date(); |
238 | else { | 238 | else { |
239 | globalFlagBlockAgenda = 2; | 239 | globalFlagBlockAgenda = 2; |
240 | emit showAgendaView( false ); | 240 | emit showAgendaView( false ); |
241 | return; | 241 | return; |
242 | } | 242 | } |
243 | */ | 243 | */ |
244 | ((Todo*)mIncidence)->setCompleted( true ); | 244 | ((Todo*)mIncidence)->setCompleted( true ); |
245 | ((Todo*)mIncidence)->setCompleted(QDateTime::currentDateTime() ); | 245 | ((Todo*)mIncidence)->setCompleted(QDateTime::currentDateTime() ); |
246 | emit todoCompleted(((Todo*)mIncidence)); | 246 | emit todoCompleted(((Todo*)mIncidence)); |
247 | } else { | 247 | } else { |
248 | date = mIncidence->dtStart().date(); | 248 | date = mIncidence->dtStart().date(); |
249 | globalFlagBlockAgenda = 1; | 249 | globalFlagBlockAgenda = 1; |
250 | emit showAgendaView( false ); | 250 | emit showAgendaView( false ); |
251 | globalFlagBlockAgenda = 2; | 251 | globalFlagBlockAgenda = 2; |
252 | emit jumpToTime( date ); | 252 | emit jumpToTime( date ); |
253 | } | 253 | } |
254 | close(); | 254 | close(); |
255 | } | 255 | } |
256 | } | 256 | } |
257 | void KOEventViewerDialog::keyPressEvent ( QKeyEvent * e ) | 257 | void KOEventViewerDialog::keyPressEvent ( QKeyEvent * e ) |
258 | { | 258 | { |
259 | switch ( e->key() ) { | 259 | switch ( e->key() ) { |
260 | 260 | ||
261 | case Qt::Key_A : | 261 | case Qt::Key_A : |
262 | case Qt::Key_L : | 262 | case Qt::Key_L : |
263 | showIncidence(); | 263 | showIncidence(); |
264 | break; | 264 | break; |
265 | case Qt::Key_E : | 265 | case Qt::Key_E : |
266 | case Qt::Key_R : | 266 | case Qt::Key_R : |
267 | editIncidence(); | 267 | editIncidence(); |
268 | break; | 268 | break; |
269 | case Qt::Key_C: | 269 | case Qt::Key_C: |
270 | case Qt::Key_Escape: | 270 | case Qt::Key_Escape: |
271 | sendSignalViewerClosed = true; | 271 | sendSignalViewerClosed = true; |
272 | close(); | 272 | close(); |
273 | break; | 273 | break; |
274 | case Qt::Key_I: | 274 | case Qt::Key_I: |
275 | #ifndef DESKTOP_VERSION | 275 | #ifndef DESKTOP_VERSION |
276 | sendSignalViewerClosed = true; | 276 | sendSignalViewerClosed = true; |
277 | close(); | 277 | close(); |
278 | #else | 278 | #else |
279 | sendSignalViewerClosed = true; | 279 | sendSignalViewerClosed = true; |
280 | slotViewerClosed(); | 280 | slotViewerClosed(); |
281 | //accept(); | 281 | //accept(); |
282 | #endif | 282 | #endif |
283 | break; | 283 | break; |
284 | default: | 284 | default: |
285 | KDialogBase::keyPressEvent ( e ); | 285 | KDialogBase::keyPressEvent ( e ); |
286 | break; | 286 | break; |
287 | } | 287 | } |
288 | 288 | ||
289 | } | 289 | } |
290 | void KOEventViewerDialog::hideEvent ( QHideEvent * e ) | 290 | void KOEventViewerDialog::hideEvent ( QHideEvent * e ) |
291 | { | 291 | { |
292 | KDialogBase::hideEvent ( e ); | 292 | KDialogBase::hideEvent ( e ); |
293 | QTimer::singleShot( 1, this, SLOT (slotViewerClosed() ) ); | 293 | QTimer::singleShot( 1, this, SLOT (slotViewerClosed() ) ); |
294 | } | 294 | } |
295 | 295 | ||
296 | void KOEventViewerDialog::slotViewerClosed() | 296 | void KOEventViewerDialog::slotViewerClosed() |
297 | { | 297 | { |
298 | if ( mSyncMode ) | 298 | if ( mSyncMode ) |
299 | return; | 299 | return; |
300 | 300 | ||
301 | if ( sendSignalViewerClosed ) { | 301 | if ( sendSignalViewerClosed ) { |
302 | //qDebug("KOEventViewerDialog::hideEvent "); | 302 | //qDebug("KOEventViewerDialog::hideEvent "); |
303 | emit signalViewerClosed(); | 303 | emit signalViewerClosed(); |
304 | } | 304 | } |
305 | sendSignalViewerClosed = true; | 305 | sendSignalViewerClosed = true; |
306 | } | 306 | } |
307 | 307 | ||
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 678cab6..c868270 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp | |||
@@ -193,385 +193,385 @@ void KNoScrollListBox::keyPressEvent(QKeyEvent *e) | |||
193 | } | 193 | } |
194 | } | 194 | } |
195 | } | 195 | } |
196 | } | 196 | } |
197 | break; | 197 | break; |
198 | case Key_Down: | 198 | case Key_Down: |
199 | if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { | 199 | if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { |
200 | e->ignore(); | 200 | e->ignore(); |
201 | break; | 201 | break; |
202 | } | 202 | } |
203 | if ( count () ) { | 203 | if ( count () ) { |
204 | if ( currentItem()+1 == count () ) { | 204 | if ( currentItem()+1 == count () ) { |
205 | emit nextCell(); | 205 | emit nextCell(); |
206 | } else { | 206 | } else { |
207 | setCurrentItem((currentItem()+1)%count()); | 207 | setCurrentItem((currentItem()+1)%count()); |
208 | if(!itemVisible(currentItem())) { | 208 | if(!itemVisible(currentItem())) { |
209 | if(currentItem() == 0) { | 209 | if(currentItem() == 0) { |
210 | setTopItem(0); | 210 | setTopItem(0); |
211 | } else { | 211 | } else { |
212 | setTopItem(topItem()+1); | 212 | setTopItem(topItem()+1); |
213 | } | 213 | } |
214 | } | 214 | } |
215 | } | 215 | } |
216 | } | 216 | } |
217 | break; | 217 | break; |
218 | case Key_I: | 218 | case Key_I: |
219 | QTimer::singleShot( 1, this, SLOT ( oneDown() ) ); | 219 | QTimer::singleShot( 1, this, SLOT ( oneDown() ) ); |
220 | e->ignore(); | 220 | e->ignore(); |
221 | break; | 221 | break; |
222 | case Key_Return: | 222 | case Key_Return: |
223 | case Key_Enter: | 223 | case Key_Enter: |
224 | { | 224 | { |
225 | if ( currentItem() >= 0 ) { | 225 | if ( currentItem() >= 0 ) { |
226 | emit doubleClicked( item( currentItem() ) ); | 226 | emit doubleClicked( item( currentItem() ) ); |
227 | e->accept(); | 227 | e->accept(); |
228 | } else { | 228 | } else { |
229 | e->ignore(); | 229 | e->ignore(); |
230 | } | 230 | } |
231 | } | 231 | } |
232 | break; | 232 | break; |
233 | case Key_Shift: | 233 | case Key_Shift: |
234 | emit shiftDown(); | 234 | emit shiftDown(); |
235 | break; | 235 | break; |
236 | default: | 236 | default: |
237 | e->ignore(); | 237 | e->ignore(); |
238 | break; | 238 | break; |
239 | } | 239 | } |
240 | } | 240 | } |
241 | 241 | ||
242 | void KNoScrollListBox::oneDown() | 242 | void KNoScrollListBox::oneDown() |
243 | { | 243 | { |
244 | if ( count () ) { | 244 | if ( count () ) { |
245 | if ( currentItem()+1 == count () ) { | 245 | if ( currentItem()+1 == count () ) { |
246 | emit nextCell(); | 246 | emit nextCell(); |
247 | } else { | 247 | } else { |
248 | resetOnFocusIn = false; | 248 | resetOnFocusIn = false; |
249 | setCurrentItem((currentItem()+1)%count()); | 249 | setCurrentItem((currentItem()+1)%count()); |
250 | if(!itemVisible(currentItem())) { | 250 | if(!itemVisible(currentItem())) { |
251 | if(currentItem() == 0) { | 251 | if(currentItem() == 0) { |
252 | setTopItem(0); | 252 | setTopItem(0); |
253 | } else { | 253 | } else { |
254 | setTopItem(topItem()+1); | 254 | setTopItem(topItem()+1); |
255 | } | 255 | } |
256 | } | 256 | } |
257 | } | 257 | } |
258 | } | 258 | } |
259 | } | 259 | } |
260 | void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) | 260 | void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) |
261 | { | 261 | { |
262 | switch(e->key()) { | 262 | switch(e->key()) { |
263 | case Key_Shift: | 263 | case Key_Shift: |
264 | emit shiftUp(); | 264 | emit shiftUp(); |
265 | break; | 265 | break; |
266 | default: | 266 | default: |
267 | break; | 267 | break; |
268 | } | 268 | } |
269 | } | 269 | } |
270 | 270 | ||
271 | void KNoScrollListBox::mousePressEvent(QMouseEvent *e) | 271 | void KNoScrollListBox::mousePressEvent(QMouseEvent *e) |
272 | { | 272 | { |
273 | QListBox::mousePressEvent(e); | 273 | QListBox::mousePressEvent(e); |
274 | 274 | ||
275 | if(e->button() == RightButton) { | 275 | if(e->button() == RightButton) { |
276 | emit rightClick(); | 276 | emit rightClick(); |
277 | } | 277 | } |
278 | } | 278 | } |
279 | 279 | ||
280 | MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) | 280 | MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) |
281 | : QListBoxItem() | 281 | : QListBoxItem() |
282 | { | 282 | { |
283 | mblockRepaint = true; | 283 | mblockRepaint = true; |
284 | setText( s ); | 284 | setText( s ); |
285 | mMultiday = 0; | 285 | mMultiday = 0; |
286 | mIncidence = incidence; | 286 | mIncidence = incidence; |
287 | mDate = qd; | 287 | mDate = qd; |
288 | mRecur = false; | 288 | mRecur = false; |
289 | mAlarm = false; | 289 | mAlarm = false; |
290 | mReply = false; | 290 | mReply = false; |
291 | mInfo = false; | 291 | mInfo = false; |
292 | mdayPos = 0; | 292 | mdayPos = 0; |
293 | isWeekItem = KOPrefs::instance()->mMonthViewWeek; | 293 | isWeekItem = KOPrefs::instance()->mMonthViewWeek; |
294 | } | 294 | } |
295 | void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s) | 295 | void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s) |
296 | { | 296 | { |
297 | setText( s ); | 297 | setText( s ); |
298 | mMultiday = 0; | 298 | mMultiday = 0; |
299 | mIncidence = incidence; | 299 | mIncidence = incidence; |
300 | mDate = qd; | 300 | mDate = qd; |
301 | mRecur = false; | 301 | mRecur = false; |
302 | mAlarm = false; | 302 | mAlarm = false; |
303 | mReply = false; | 303 | mReply = false; |
304 | mInfo = false; | 304 | mInfo = false; |
305 | mdayPos = 0; | 305 | mdayPos = 0; |
306 | } | 306 | } |
307 | 307 | ||
308 | void MonthViewItem::paint(QPainter *p) | 308 | void MonthViewItem::paint(QPainter *p) |
309 | { | 309 | { |
310 | if ( mblockRepaint ) { | 310 | if ( mblockRepaint ) { |
311 | return; | 311 | return; |
312 | } | 312 | } |
313 | #if QT_VERSION >= 0x030000 | 313 | #if QT_VERSION >= 0x030000 |
314 | bool sel = isSelected(); | 314 | bool sel = isSelected(); |
315 | #else | 315 | #else |
316 | bool sel = selected(); | 316 | bool sel = selected(); |
317 | #endif | 317 | #endif |
318 | 318 | ||
319 | 319 | ||
320 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) | 320 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) |
321 | { | 321 | { |
322 | p->setBackgroundColor( palette().color( QPalette::Normal, \ | 322 | p->setBackgroundColor( palette().color( QPalette::Normal, \ |
323 | sel ? QColorGroup::Highlight : QColorGroup::Background ) ); | 323 | sel ? QColorGroup::Highlight : QColorGroup::Background ) ); |
324 | p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); | 324 | p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); |
325 | } | 325 | } |
326 | int x = 1; | 326 | int x = 1; |
327 | //int y = 3;//(height() - mRecurPixmap.height()) /2; | 327 | //int y = 3;//(height() - mRecurPixmap.height()) /2; |
328 | int size = PIXMAP_SIZE; | 328 | int size = PIXMAP_SIZE; |
329 | if ( QApplication::desktop()->width() < 300 ) | 329 | if ( QApplication::desktop()->width() < 300 ) |
330 | size = 3; | 330 | size = 3; |
331 | int heihei = height( listBox () ); | 331 | int heihei = height( listBox () ); |
332 | int y = (heihei - size -1 ) /2; | 332 | int y = (heihei - size -1 ) /2; |
333 | 333 | ||
334 | if ( KOPrefs::instance()->mMonthShowIcons ) { | 334 | if ( KOPrefs::instance()->mMonthShowIcons ) { |
335 | if ( mInfo ) { | 335 | if ( mInfo ) { |
336 | p->fillRect ( x, y,size,size, Qt::darkGreen ); | 336 | p->fillRect ( x, y,size,size, Qt::darkGreen ); |
337 | x += size + 1; | 337 | x += size + 1; |
338 | } | 338 | } |
339 | if ( mRecur ) { | 339 | if ( mRecur ) { |
340 | p->fillRect ( x, y,size,size, Qt::blue ); | 340 | p->fillRect ( x, y,size,size, Qt::blue ); |
341 | x += size + 1; | 341 | x += size + 1; |
342 | } | 342 | } |
343 | if ( mAlarm ) { | 343 | if ( mAlarm ) { |
344 | p->fillRect ( x, y,size,size, Qt::red ); | 344 | p->fillRect ( x, y,size,size, Qt::red ); |
345 | x += size + 1; | 345 | x += size + 1; |
346 | } | 346 | } |
347 | if ( mReply ) { | 347 | if ( mReply ) { |
348 | p->fillRect ( x, y,size,size, Qt::yellow ); | 348 | p->fillRect ( x, y,size,size, Qt::yellow ); |
349 | x += size + 1; | 349 | x += size + 1; |
350 | } | 350 | } |
351 | } | 351 | } |
352 | if ( mMultiday ) { | 352 | if ( mMultiday ) { |
353 | int yyy = y+(size/2); | 353 | int yyy = y+(size/2); |
354 | int sizeM = size+2; | 354 | int sizeM = size+2; |
355 | p->setBrush( QBrush::SolidPattern ); | 355 | p->setBrush( QBrush::SolidPattern ); |
356 | p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ; | 356 | p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ; |
357 | if ( mMultiday == 2 || mMultiday == 3 ) { | 357 | if ( mMultiday == 2 || mMultiday == 3 ) { |
358 | QPointArray pa ( 3 ); | 358 | QPointArray pa ( 3 ); |
359 | pa.setPoint (0, x, yyy ); | 359 | pa.setPoint (0, x, yyy ); |
360 | pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 ); | 360 | pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 ); |
361 | pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 ); | 361 | pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 ); |
362 | p->drawPolygon( pa ); | 362 | p->drawPolygon( pa ); |
363 | } | 363 | } |
364 | if ( mMultiday == 2 || mMultiday == 1 ) { | 364 | if ( mMultiday == 2 || mMultiday == 1 ) { |
365 | QPointArray pa ( 3 ); | 365 | QPointArray pa ( 3 ); |
366 | pa.setPoint (0, x+sizeM +sizeM/2, yyy ); | 366 | pa.setPoint (0, x+sizeM +sizeM/2, yyy ); |
367 | pa.setPoint (1, x+sizeM, yyy+sizeM/2 ); | 367 | pa.setPoint (1, x+sizeM, yyy+sizeM/2 ); |
368 | pa.setPoint (2, x+sizeM, yyy-sizeM/2 ); | 368 | pa.setPoint (2, x+sizeM, yyy-sizeM/2 ); |
369 | p->drawPolygon( pa ); | 369 | p->drawPolygon( pa ); |
370 | } | 370 | } |
371 | if ( mMultiday == 1 ) { | 371 | if ( mMultiday == 1 ) { |
372 | // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); | 372 | // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); |
373 | 373 | ||
374 | p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 ); | 374 | p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 ); |
375 | } | 375 | } |
376 | if ( mMultiday == 3 ) { | 376 | if ( mMultiday == 3 ) { |
377 | // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); | 377 | // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); |
378 | p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 ); | 378 | p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 ); |
379 | 379 | ||
380 | } | 380 | } |
381 | x += sizeM/2 + 1; | 381 | x += sizeM/2 + 1; |
382 | x += sizeM + 1; | 382 | x += sizeM + 1; |
383 | } | 383 | } |
384 | 384 | ||
385 | if ( mIncidence->type() == "Todo" ){ | 385 | if ( mIncidence->typeID() == todoID ){ |
386 | Todo* td = ( Todo* ) mIncidence; | 386 | Todo* td = ( Todo* ) mIncidence; |
387 | if ( td->isCompleted() ) { | 387 | if ( td->isCompleted() ) { |
388 | int half = size/2; | 388 | int half = size/2; |
389 | p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ; | 389 | p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ; |
390 | p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ; | 390 | p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ; |
391 | x += half+half + 4; | 391 | x += half+half + 4; |
392 | 392 | ||
393 | } else { | 393 | } else { |
394 | int val = td->percentComplete()/20; | 394 | int val = td->percentComplete()/20; |
395 | p->fillRect ( x+1, y-2, val ,size+4,Qt::black ); | 395 | p->fillRect ( x+1, y-2, val ,size+4,Qt::black ); |
396 | p->drawRect ( x, y-2,7,size+4); | 396 | p->drawRect ( x, y-2,7,size+4); |
397 | x += size + 3; | 397 | x += size + 3; |
398 | } | 398 | } |
399 | } | 399 | } |
400 | QFontMetrics fm = p->fontMetrics(); | 400 | QFontMetrics fm = p->fontMetrics(); |
401 | int yPos; | 401 | int yPos; |
402 | int pmheight = size; | 402 | int pmheight = size; |
403 | if( pmheight < fm.height() ) | 403 | if( pmheight < fm.height() ) |
404 | yPos = fm.ascent() + fm.leading()/2; | 404 | yPos = fm.ascent() + fm.leading()/2; |
405 | else | 405 | else |
406 | yPos = pmheight/2 - fm.height()/2 + fm.ascent(); | 406 | yPos = pmheight/2 - fm.height()/2 + fm.ascent(); |
407 | p->setPen( palette().color( QPalette::Normal, sel ? \ | 407 | p->setPen( palette().color( QPalette::Normal, sel ? \ |
408 | QColorGroup::HighlightedText : QColorGroup::Foreground ) ); | 408 | QColorGroup::HighlightedText : QColorGroup::Foreground ) ); |
409 | if ( KOPrefs::instance()->mMonthShowTimes || isWeekItem) { | 409 | if ( KOPrefs::instance()->mMonthShowTimes || isWeekItem) { |
410 | p->drawText( x, yPos, text() ); | 410 | p->drawText( x, yPos, text() ); |
411 | if ( mIncidence->cancelled() ) { | 411 | if ( mIncidence->cancelled() ) { |
412 | int wid = fm.width( text() ); | 412 | int wid = fm.width( text() ); |
413 | p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); | 413 | p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); |
414 | } | 414 | } |
415 | } else { | 415 | } else { |
416 | QString pText = text(); | 416 | QString pText = text(); |
417 | if( pText.mid(2,1) == ":" ) | 417 | if( pText.mid(2,1) == ":" ) |
418 | pText = pText.mid( 6 ); | 418 | pText = pText.mid( 6 ); |
419 | p->drawText( x, yPos, pText ); | 419 | p->drawText( x, yPos, pText ); |
420 | if ( mIncidence->cancelled() ) { | 420 | if ( mIncidence->cancelled() ) { |
421 | int wid = fm.width( pText ); | 421 | int wid = fm.width( pText ); |
422 | p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); | 422 | p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); |
423 | } | 423 | } |
424 | } | 424 | } |
425 | } | 425 | } |
426 | 426 | ||
427 | int MonthViewItem::height(const QListBox *lb) const | 427 | int MonthViewItem::height(const QListBox *lb) const |
428 | { | 428 | { |
429 | int ret = 10; | 429 | int ret = 10; |
430 | if ( lb ) | 430 | if ( lb ) |
431 | ret = lb->fontMetrics().lineSpacing()+1; | 431 | ret = lb->fontMetrics().lineSpacing()+1; |
432 | return ret; | 432 | return ret; |
433 | } | 433 | } |
434 | 434 | ||
435 | int MonthViewItem::width(const QListBox *lb) const | 435 | int MonthViewItem::width(const QListBox *lb) const |
436 | { | 436 | { |
437 | if( KOPrefs::instance()->mEnableMonthScroll || isWeekItem ) { | 437 | if( KOPrefs::instance()->mEnableMonthScroll || isWeekItem ) { |
438 | int size = PIXMAP_SIZE; | 438 | int size = PIXMAP_SIZE; |
439 | if ( QApplication::desktop()->width() < 300 ) | 439 | if ( QApplication::desktop()->width() < 300 ) |
440 | size = 3; | 440 | size = 3; |
441 | int x = 1; | 441 | int x = 1; |
442 | if ( KOPrefs::instance()->mMonthShowIcons ) { | 442 | if ( KOPrefs::instance()->mMonthShowIcons ) { |
443 | if ( mInfo ) { | 443 | if ( mInfo ) { |
444 | x += size + 1; | 444 | x += size + 1; |
445 | } | 445 | } |
446 | if( mRecur ) { | 446 | if( mRecur ) { |
447 | x += size+1; | 447 | x += size+1; |
448 | } | 448 | } |
449 | if( mAlarm ) { | 449 | if( mAlarm ) { |
450 | x += size+1; | 450 | x += size+1; |
451 | } | 451 | } |
452 | if( mReply ) { | 452 | if( mReply ) { |
453 | x += size+1; | 453 | x += size+1; |
454 | } | 454 | } |
455 | } | 455 | } |
456 | if( mMultiday ) { | 456 | if( mMultiday ) { |
457 | x += size+1+2+size/2; | 457 | x += size+1+2+size/2; |
458 | } | 458 | } |
459 | return( x + lb->fontMetrics().width( text() ) + 1 ); | 459 | return( x + lb->fontMetrics().width( text() ) + 1 ); |
460 | } | 460 | } |
461 | if ( ! lb ) | 461 | if ( ! lb ) |
462 | return 10; | 462 | return 10; |
463 | return lb->width(); | 463 | return lb->width(); |
464 | } | 464 | } |
465 | 465 | ||
466 | 466 | ||
467 | MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) | 467 | MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) |
468 | : KNoScrollListBox( par ), | 468 | : KNoScrollListBox( par ), |
469 | mMonthView( parent ) | 469 | mMonthView( parent ) |
470 | { | 470 | { |
471 | //QVBoxLayout *topLayout = new QVBoxLayout( this ); | 471 | //QVBoxLayout *topLayout = new QVBoxLayout( this ); |
472 | currentPalette = 0; | 472 | currentPalette = 0; |
473 | // mLabel = new QLabel( this );QPushButton | 473 | // mLabel = new QLabel( this );QPushButton |
474 | mLabel = new QPushButton( this ); | 474 | mLabel = new QPushButton( this ); |
475 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); | 475 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); |
476 | //mLabel->setLineWidth( 1 ); | 476 | //mLabel->setLineWidth( 1 ); |
477 | //mLabel->setAlignment( AlignCenter ); | 477 | //mLabel->setAlignment( AlignCenter ); |
478 | mLabel->setFlat( true ); | 478 | mLabel->setFlat( true ); |
479 | mLabel->setFocusPolicy(NoFocus); | 479 | mLabel->setFocusPolicy(NoFocus); |
480 | //mItemList = new KNoScrollListBox( this ); | 480 | //mItemList = new KNoScrollListBox( this ); |
481 | setMinimumSize( 10, 10 ); | 481 | setMinimumSize( 10, 10 ); |
482 | setFrameStyle( QFrame::Panel | QFrame::Plain ); | 482 | setFrameStyle( QFrame::Panel | QFrame::Plain ); |
483 | setLineWidth( 1 ); | 483 | setLineWidth( 1 ); |
484 | //topLayout->addWidget( mItemList ); | 484 | //topLayout->addWidget( mItemList ); |
485 | mLabel->raise(); | 485 | mLabel->raise(); |
486 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) | 486 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) |
487 | mStandardPalette = palette(); | 487 | mStandardPalette = palette(); |
488 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); | 488 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); |
489 | 489 | ||
490 | enableScrollBars( false ); | 490 | enableScrollBars( false ); |
491 | updateConfig(); | 491 | updateConfig(); |
492 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); | 492 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); |
493 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); | 493 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); |
494 | connect( this , SIGNAL( doubleClicked( QListBoxItem *) ), | 494 | connect( this , SIGNAL( doubleClicked( QListBoxItem *) ), |
495 | SLOT( defaultAction( QListBoxItem * ) ) ); | 495 | SLOT( defaultAction( QListBoxItem * ) ) ); |
496 | connect( this, SIGNAL( rightButtonPressed( QListBoxItem *, | 496 | connect( this, SIGNAL( rightButtonPressed( QListBoxItem *, |
497 | const QPoint &) ), | 497 | const QPoint &) ), |
498 | SLOT( contextMenu( QListBoxItem * ) ) ); | 498 | SLOT( contextMenu( QListBoxItem * ) ) ); |
499 | connect( this, SIGNAL( highlighted( QListBoxItem *) ), | 499 | connect( this, SIGNAL( highlighted( QListBoxItem *) ), |
500 | SLOT( selection( QListBoxItem * ) ) ); | 500 | SLOT( selection( QListBoxItem * ) ) ); |
501 | 501 | ||
502 | /* | 502 | /* |
503 | connect( this, SIGNAL( clicked( QListBoxItem * ) ), | 503 | connect( this, SIGNAL( clicked( QListBoxItem * ) ), |
504 | SLOT( selection( QListBoxItem * ) ) ); | 504 | SLOT( selection( QListBoxItem * ) ) ); |
505 | */ | 505 | */ |
506 | } | 506 | } |
507 | #ifdef DESKTOP_VERSION | 507 | #ifdef DESKTOP_VERSION |
508 | QToolTipGroup *MonthViewCell::toolTipGroup() | 508 | QToolTipGroup *MonthViewCell::toolTipGroup() |
509 | { | 509 | { |
510 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); | 510 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); |
511 | return mToolTipGroup; | 511 | return mToolTipGroup; |
512 | } | 512 | } |
513 | #endif | 513 | #endif |
514 | 514 | ||
515 | void MonthViewCell::setDate( const QDate &date ) | 515 | void MonthViewCell::setDate( const QDate &date ) |
516 | { | 516 | { |
517 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; | 517 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; |
518 | mDate = date; | 518 | mDate = date; |
519 | 519 | ||
520 | 520 | ||
521 | 521 | ||
522 | //resizeEvent( 0 ); | 522 | //resizeEvent( 0 ); |
523 | } | 523 | } |
524 | 524 | ||
525 | QDate MonthViewCell::date() const | 525 | QDate MonthViewCell::date() const |
526 | { | 526 | { |
527 | return mDate; | 527 | return mDate; |
528 | } | 528 | } |
529 | 529 | ||
530 | void MonthViewCell::setPrimary( bool primary ) | 530 | void MonthViewCell::setPrimary( bool primary ) |
531 | { | 531 | { |
532 | mPrimary = primary; | 532 | mPrimary = primary; |
533 | //setMyPalette(); | 533 | //setMyPalette(); |
534 | } | 534 | } |
535 | void MonthViewCell::setMyPalette() | 535 | void MonthViewCell::setMyPalette() |
536 | { | 536 | { |
537 | 537 | ||
538 | if ( mHoliday) { | 538 | if ( mHoliday) { |
539 | if ( currentPalette == 1 ) return; | 539 | if ( currentPalette == 1 ) return; |
540 | mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) )); | 540 | mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) )); |
541 | setPalette( mHolidayPalette ); | 541 | setPalette( mHolidayPalette ); |
542 | //mLabel->setPalette( mHolidayPalette ); | 542 | //mLabel->setPalette( mHolidayPalette ); |
543 | currentPalette = 1; | 543 | currentPalette = 1; |
544 | 544 | ||
545 | } else { | 545 | } else { |
546 | if ( mPrimary ) { | 546 | if ( mPrimary ) { |
547 | if ( currentPalette == 2 ) return; | 547 | if ( currentPalette == 2 ) return; |
548 | mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); | 548 | mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); |
549 | //mLabel->setPalette( mPrimaryPalette ); | 549 | //mLabel->setPalette( mPrimaryPalette ); |
550 | setPalette( mPrimaryPalette ); | 550 | setPalette( mPrimaryPalette ); |
551 | currentPalette = 2; | 551 | currentPalette = 2; |
552 | 552 | ||
553 | } else { | 553 | } else { |
554 | if ( currentPalette == 3 ) return; | 554 | if ( currentPalette == 3 ) return; |
555 | setPalette( mNonPrimaryPalette ); | 555 | setPalette( mNonPrimaryPalette ); |
556 | mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); | 556 | mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); |
557 | //mLabel->setPalette( mNonPrimaryPalette );; | 557 | //mLabel->setPalette( mNonPrimaryPalette );; |
558 | currentPalette = 3; | 558 | currentPalette = 3; |
559 | } | 559 | } |
560 | } | 560 | } |
561 | //QPalette pal = palette(); | 561 | //QPalette pal = palette(); |
562 | 562 | ||
563 | //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); | 563 | //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); |
564 | } | 564 | } |
565 | QPalette MonthViewCell::getPalette () | 565 | QPalette MonthViewCell::getPalette () |
566 | { | 566 | { |
567 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) | 567 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) |
568 | return mStandardPalette; | 568 | return mStandardPalette; |
569 | if ( mHoliday) { | 569 | if ( mHoliday) { |
570 | return mHolidayPalette ; | 570 | return mHolidayPalette ; |
571 | } else { | 571 | } else { |
572 | if ( mPrimary ) { | 572 | if ( mPrimary ) { |
573 | return mPrimaryPalette ; | 573 | return mPrimaryPalette ; |
574 | } | 574 | } |
575 | } | 575 | } |
576 | return mNonPrimaryPalette; | 576 | return mNonPrimaryPalette; |
577 | } | 577 | } |
@@ -1754,343 +1754,343 @@ void KOMonthView::computeLayoutWeek() | |||
1754 | for ( i = 0; i < mCellsW.count(); ++i) { | 1754 | for ( i = 0; i < mCellsW.count(); ++i) { |
1755 | if ( i > 6 ) { | 1755 | if ( i > 6 ) { |
1756 | mCellsW[i]->hide(); | 1756 | mCellsW[i]->hide(); |
1757 | continue; | 1757 | continue; |
1758 | } | 1758 | } |
1759 | 1759 | ||
1760 | w = colWid; | 1760 | w = colWid; |
1761 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { | 1761 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { |
1762 | ++w; | 1762 | ++w; |
1763 | } | 1763 | } |
1764 | if ( i == (daysToShow-1-rowModulo)*7) | 1764 | if ( i == (daysToShow-1-rowModulo)*7) |
1765 | ++h; | 1765 | ++h; |
1766 | 1766 | ||
1767 | if ( i >= 5 ) { | 1767 | if ( i >= 5 ) { |
1768 | if ( i ==5 ) { | 1768 | if ( i ==5 ) { |
1769 | max = h/2; | 1769 | max = h/2; |
1770 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,max ); | 1770 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,max ); |
1771 | x -= w ;y += h/2; | 1771 | x -= w ;y += h/2; |
1772 | } else { | 1772 | } else { |
1773 | if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { | 1773 | if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { |
1774 | ++w; | 1774 | ++w; |
1775 | } | 1775 | } |
1776 | max = h-h/2; | 1776 | max = h-h/2; |
1777 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,max ); | 1777 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,max ); |
1778 | y -= h/2; | 1778 | y -= h/2; |
1779 | } | 1779 | } |
1780 | } else { | 1780 | } else { |
1781 | max = h; | 1781 | max = h; |
1782 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1782 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
1783 | } | 1783 | } |
1784 | 1784 | ||
1785 | 1785 | ||
1786 | x += w; | 1786 | x += w; |
1787 | if ( x + w/2 > wid ) { | 1787 | if ( x + w/2 > wid ) { |
1788 | x = 0; | 1788 | x = 0; |
1789 | y += h+dayLabelHei ; | 1789 | y += h+dayLabelHei ; |
1790 | } | 1790 | } |
1791 | //mCellsW[i]->dateLabel()->setMaximumHeight( max - mCellsW[i]->lineWidth()*2 ); | 1791 | //mCellsW[i]->dateLabel()->setMaximumHeight( max - mCellsW[i]->lineWidth()*2 ); |
1792 | } | 1792 | } |
1793 | y= dayLabelHei; | 1793 | y= dayLabelHei; |
1794 | h = cellHei ; | 1794 | h = cellHei ; |
1795 | mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); | 1795 | mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); |
1796 | mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei); | 1796 | mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei); |
1797 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); | 1797 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); |
1798 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); | 1798 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); |
1799 | mShortDayLabelsW = mDayLabelsW[0]->width()-2 < mWidthLongDayLabel ; | 1799 | mShortDayLabelsW = mDayLabelsW[0]->width()-2 < mWidthLongDayLabel ; |
1800 | updateDayLabels(); | 1800 | updateDayLabels(); |
1801 | //bool forceUpdate = !updatePossible; | 1801 | //bool forceUpdate = !updatePossible; |
1802 | updatePossible = true; | 1802 | updatePossible = true; |
1803 | //mWeekLabels[mNumWeeks]->setText( i18n("M")); | 1803 | //mWeekLabels[mNumWeeks]->setText( i18n("M")); |
1804 | //if ( forceUpdate ) | 1804 | //if ( forceUpdate ) |
1805 | // updateView(); | 1805 | // updateView(); |
1806 | } | 1806 | } |
1807 | void KOMonthView::computeLayout() | 1807 | void KOMonthView::computeLayout() |
1808 | { | 1808 | { |
1809 | 1809 | ||
1810 | 1810 | ||
1811 | static int lastWid = 0; | 1811 | static int lastWid = 0; |
1812 | static int lastHei = 0; | 1812 | static int lastHei = 0; |
1813 | 1813 | ||
1814 | if ( mShowWeekView ){ | 1814 | if ( mShowWeekView ){ |
1815 | computeLayoutWeek(); | 1815 | computeLayoutWeek(); |
1816 | return; | 1816 | return; |
1817 | } | 1817 | } |
1818 | int daysToShow = 7; | 1818 | int daysToShow = 7; |
1819 | bool combinedSatSun = false; | 1819 | bool combinedSatSun = false; |
1820 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { | 1820 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { |
1821 | daysToShow = 6; | 1821 | daysToShow = 6; |
1822 | combinedSatSun = true; | 1822 | combinedSatSun = true; |
1823 | } | 1823 | } |
1824 | int tWid = topLevelWidget()->size().width(); | 1824 | int tWid = topLevelWidget()->size().width(); |
1825 | int tHei = topLevelWidget()->size().height(); | 1825 | int tHei = topLevelWidget()->size().height(); |
1826 | 1826 | ||
1827 | int wid = width();//e | 1827 | int wid = width();//e |
1828 | int hei = height()-1-mNavigatorBar->height(); | 1828 | int hei = height()-1-mNavigatorBar->height(); |
1829 | 1829 | ||
1830 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) { | 1830 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) { |
1831 | return; | 1831 | return; |
1832 | } | 1832 | } |
1833 | if ( lastWid == width() && lastHei == height() ){ | 1833 | if ( lastWid == width() && lastHei == height() ){ |
1834 | //qDebug("KOMonthview::No compute layout needed "); | 1834 | //qDebug("KOMonthview::No compute layout needed "); |
1835 | return; | 1835 | return; |
1836 | } | 1836 | } |
1837 | 1837 | ||
1838 | lastWid = width(); | 1838 | lastWid = width(); |
1839 | lastHei = height(); | 1839 | lastHei = height(); |
1840 | //qDebug("KOMonthView::computeLayout() MMM ------------------- "); | 1840 | //qDebug("KOMonthView::computeLayout() MMM ------------------- "); |
1841 | QFontMetrics fm ( mWeekLabels[0]->font() ); | 1841 | QFontMetrics fm ( mWeekLabels[0]->font() ); |
1842 | int weeklabelwid = fm.width( "888" ); | 1842 | int weeklabelwid = fm.width( "888" ); |
1843 | wid -= weeklabelwid; | 1843 | wid -= weeklabelwid; |
1844 | 1844 | ||
1845 | int colWid = wid / daysToShow; | 1845 | int colWid = wid / daysToShow; |
1846 | int lastCol = wid - ( colWid*6 ); | 1846 | int lastCol = wid - ( colWid*6 ); |
1847 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); | 1847 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); |
1848 | int cellHei = (hei - dayLabelHei) /6; | 1848 | int cellHei = (hei - dayLabelHei) /6; |
1849 | int colModulo = wid % daysToShow; | 1849 | int colModulo = wid % daysToShow; |
1850 | int rowModulo = (hei- dayLabelHei) % 6; | 1850 | int rowModulo = (hei- dayLabelHei) % 6; |
1851 | //qDebug("rowmod %d ", rowModulo); | 1851 | //qDebug("rowmod %d ", rowModulo); |
1852 | int i; | 1852 | int i; |
1853 | int x,y,w,h; | 1853 | int x,y,w,h; |
1854 | x= 0; | 1854 | x= 0; |
1855 | y= 0; | 1855 | y= 0; |
1856 | w = colWid; | 1856 | w = colWid; |
1857 | h = dayLabelHei ; | 1857 | h = dayLabelHei ; |
1858 | for ( i = 0; i < 7; i++) { | 1858 | for ( i = 0; i < 7; i++) { |
1859 | if ( i == daysToShow-colModulo ) | 1859 | if ( i == daysToShow-colModulo ) |
1860 | ++w; | 1860 | ++w; |
1861 | if ( combinedSatSun ) { | 1861 | if ( combinedSatSun ) { |
1862 | if ( i >= daysToShow-1 ) { | 1862 | if ( i >= daysToShow-1 ) { |
1863 | 1863 | ||
1864 | if ( i == 6 ) | 1864 | if ( i == 6 ) |
1865 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,width()-x-weeklabelwid,h); | 1865 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,width()-x-weeklabelwid,h); |
1866 | else | 1866 | else |
1867 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); | 1867 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); |
1868 | x -= w/2 ; | 1868 | x -= w/2 ; |
1869 | } | 1869 | } |
1870 | else | 1870 | else |
1871 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); | 1871 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); |
1872 | } else | 1872 | } else |
1873 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); | 1873 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); |
1874 | x += w; | 1874 | x += w; |
1875 | } | 1875 | } |
1876 | x= 0; | 1876 | x= 0; |
1877 | y= dayLabelHei; | 1877 | y= dayLabelHei; |
1878 | w = colWid; | 1878 | w = colWid; |
1879 | h = cellHei ; | 1879 | h = cellHei ; |
1880 | int max = 0; | 1880 | int max = 0; |
1881 | for ( i = 0; i < mCells.count(); ++i) { | 1881 | for ( i = 0; i < mCells.count(); ++i) { |
1882 | //qDebug("iii %d ", i); | 1882 | //qDebug("iii %d ", i); |
1883 | w = colWid; | 1883 | w = colWid; |
1884 | if ( ((i) % 7) >= 7-colModulo ) { | 1884 | if ( ((i) % 7) >= 7-colModulo ) { |
1885 | ++w; | 1885 | ++w; |
1886 | } | 1886 | } |
1887 | if ( i == (6-rowModulo)*7) | 1887 | if ( i == (6-rowModulo)*7) |
1888 | ++h; | 1888 | ++h; |
1889 | if ( combinedSatSun ) { | 1889 | if ( combinedSatSun ) { |
1890 | if ( (i)%7 >= daysToShow-1 ) { | 1890 | if ( (i)%7 >= daysToShow-1 ) { |
1891 | if ( (i)%7 == daysToShow-1 ) { | 1891 | if ( (i)%7 == daysToShow-1 ) { |
1892 | w = width()-x-weeklabelwid; | 1892 | w = width()-x-weeklabelwid; |
1893 | max = h/2; | 1893 | max = h/2; |
1894 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,max ); | 1894 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,max ); |
1895 | x -= w ;y += h/2; | 1895 | x -= w ;y += h/2; |
1896 | } else { | 1896 | } else { |
1897 | w = width()-x-weeklabelwid; | 1897 | w = width()-x-weeklabelwid; |
1898 | max = h-h/2; | 1898 | max = h-h/2; |
1899 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,max ); | 1899 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,max ); |
1900 | y -= h/2; | 1900 | y -= h/2; |
1901 | } | 1901 | } |
1902 | } else { | 1902 | } else { |
1903 | max = h; | 1903 | max = h; |
1904 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1904 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
1905 | } | 1905 | } |
1906 | 1906 | ||
1907 | } | 1907 | } |
1908 | else { | 1908 | else { |
1909 | max = h; | 1909 | max = h; |
1910 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1910 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
1911 | } | 1911 | } |
1912 | x += w; | 1912 | x += w; |
1913 | if ( x + w/2 > wid ) { | 1913 | if ( x + w/2 > wid ) { |
1914 | x = 0; | 1914 | x = 0; |
1915 | y += h; | 1915 | y += h; |
1916 | } | 1916 | } |
1917 | //mCells[i]->dateLabel()->setMaximumHeight( max- mCells[i]->lineWidth()*2 ); | 1917 | //mCells[i]->dateLabel()->setMaximumHeight( max- mCells[i]->lineWidth()*2 ); |
1918 | } | 1918 | } |
1919 | y= dayLabelHei; | 1919 | y= dayLabelHei; |
1920 | h = cellHei ; | 1920 | h = cellHei ; |
1921 | for ( i = 0; i < 6; i++) { | 1921 | for ( i = 0; i < 6; i++) { |
1922 | if ( i == (6-rowModulo)) | 1922 | if ( i == (6-rowModulo)) |
1923 | ++h; | 1923 | ++h; |
1924 | mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); | 1924 | mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); |
1925 | y += h; | 1925 | y += h; |
1926 | } | 1926 | } |
1927 | mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); | 1927 | mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); |
1928 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); | 1928 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); |
1929 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); | 1929 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); |
1930 | mShortDayLabelsM = mDayLabels[0]->width()-2 < mWidthLongDayLabel ; | 1930 | mShortDayLabelsM = mDayLabels[0]->width()-2 < mWidthLongDayLabel ; |
1931 | updateDayLabels(); | 1931 | updateDayLabels(); |
1932 | //bool forceUpdate = !updatePossible; | 1932 | //bool forceUpdate = !updatePossible; |
1933 | updatePossible = true; | 1933 | updatePossible = true; |
1934 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); | 1934 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); |
1935 | } | 1935 | } |
1936 | 1936 | ||
1937 | void KOMonthView::showContextMenu( Incidence *incidence ) | 1937 | void KOMonthView::showContextMenu( Incidence *incidence ) |
1938 | { | 1938 | { |
1939 | if( incidence ) | 1939 | if( incidence ) |
1940 | mContextMenu->showIncidencePopup(incidence); | 1940 | mContextMenu->showIncidencePopup(incidence); |
1941 | else { | 1941 | else { |
1942 | //qDebug("KOMonthView::showContextMenu "); | 1942 | //qDebug("KOMonthView::showContextMenu "); |
1943 | mNewItemMenu->popup(QCursor::pos()); | 1943 | mNewItemMenu->popup(QCursor::pos()); |
1944 | } | 1944 | } |
1945 | /* | 1945 | /* |
1946 | if( incidence && incidence->type() == "Event" ) { | 1946 | if( incidence && incidence->typeID() == eventID ) { |
1947 | Event *event = static_cast<Event *>(incidence); | 1947 | Event *event = static_cast<Event *>(incidence); |
1948 | mContextMenu->showEventPopup(event); | 1948 | mContextMenu->showEventPopup(event); |
1949 | } else { | 1949 | } else { |
1950 | kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; | 1950 | kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; |
1951 | } | 1951 | } |
1952 | */ | 1952 | */ |
1953 | } | 1953 | } |
1954 | MonthViewCell * KOMonthView::selectedCell( ) | 1954 | MonthViewCell * KOMonthView::selectedCell( ) |
1955 | { | 1955 | { |
1956 | return mSelectedCell; | 1956 | return mSelectedCell; |
1957 | } | 1957 | } |
1958 | void KOMonthView::setSelectedCell( MonthViewCell *cell ) | 1958 | void KOMonthView::setSelectedCell( MonthViewCell *cell ) |
1959 | { | 1959 | { |
1960 | //qDebug("KOMonthView::setSelectedCell %d", cell); | 1960 | //qDebug("KOMonthView::setSelectedCell %d", cell); |
1961 | if ( mSelectedCell && mSelectedCell != cell ) { | 1961 | if ( mSelectedCell && mSelectedCell != cell ) { |
1962 | MonthViewCell * mvc = mSelectedCell; | 1962 | MonthViewCell * mvc = mSelectedCell; |
1963 | mSelectedCell = cell; | 1963 | mSelectedCell = cell; |
1964 | mvc->deselect(); | 1964 | mvc->deselect(); |
1965 | } else | 1965 | } else |
1966 | mSelectedCell = cell; | 1966 | mSelectedCell = cell; |
1967 | // if ( mSelectedCell ) | 1967 | // if ( mSelectedCell ) |
1968 | // mSelectedCell->select(); | 1968 | // mSelectedCell->select(); |
1969 | if ( !mSelectedCell ) | 1969 | if ( !mSelectedCell ) |
1970 | emit incidenceSelected( 0 ); | 1970 | emit incidenceSelected( 0 ); |
1971 | else | 1971 | else |
1972 | emit incidenceSelected( mSelectedCell->selectedIncidence() ); | 1972 | emit incidenceSelected( mSelectedCell->selectedIncidence() ); |
1973 | } | 1973 | } |
1974 | 1974 | ||
1975 | void KOMonthView::processSelectionChange() | 1975 | void KOMonthView::processSelectionChange() |
1976 | { | 1976 | { |
1977 | QPtrList<Incidence> incidences = selectedIncidences(); | 1977 | QPtrList<Incidence> incidences = selectedIncidences(); |
1978 | if (incidences.count() > 0) { | 1978 | if (incidences.count() > 0) { |
1979 | emit incidenceSelected( incidences.first() ); | 1979 | emit incidenceSelected( incidences.first() ); |
1980 | } else { | 1980 | } else { |
1981 | emit incidenceSelected( 0 ); | 1981 | emit incidenceSelected( 0 ); |
1982 | clearSelection(); | 1982 | clearSelection(); |
1983 | } | 1983 | } |
1984 | } | 1984 | } |
1985 | 1985 | ||
1986 | void KOMonthView::clearSelection() | 1986 | void KOMonthView::clearSelection() |
1987 | { | 1987 | { |
1988 | if ( mSelectedCell ) { | 1988 | if ( mSelectedCell ) { |
1989 | mSelectedCell->deselect(); | 1989 | mSelectedCell->deselect(); |
1990 | mSelectedCell = 0; | 1990 | mSelectedCell = 0; |
1991 | } | 1991 | } |
1992 | } | 1992 | } |
1993 | 1993 | ||
1994 | void KOMonthView::keyReleaseEvent ( QKeyEvent * e) | 1994 | void KOMonthView::keyReleaseEvent ( QKeyEvent * e) |
1995 | { | 1995 | { |
1996 | if ( !e->isAutoRepeat() ) { | 1996 | if ( !e->isAutoRepeat() ) { |
1997 | mFlagKeyPressed = false; | 1997 | mFlagKeyPressed = false; |
1998 | } | 1998 | } |
1999 | } | 1999 | } |
2000 | 2000 | ||
2001 | void KOMonthView::keyPressEvent ( QKeyEvent * e ) | 2001 | void KOMonthView::keyPressEvent ( QKeyEvent * e ) |
2002 | { | 2002 | { |
2003 | 2003 | ||
2004 | qApp->processEvents(); | 2004 | qApp->processEvents(); |
2005 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { | 2005 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { |
2006 | //e->ignore(); | 2006 | //e->ignore(); |
2007 | e->accept(); | 2007 | e->accept(); |
2008 | return; | 2008 | return; |
2009 | } | 2009 | } |
2010 | if (! e->isAutoRepeat() ) | 2010 | if (! e->isAutoRepeat() ) |
2011 | mFlagKeyPressed = true; | 2011 | mFlagKeyPressed = true; |
2012 | switch(e->key()) { | 2012 | switch(e->key()) { |
2013 | case Key_Up: | 2013 | case Key_Up: |
2014 | { | 2014 | { |
2015 | if ( mShowWeekView ) { | 2015 | if ( mShowWeekView ) { |
2016 | emit selectWeekNum ( currentWeek() - 1 ); | 2016 | emit selectWeekNum ( currentWeek() - 1 ); |
2017 | } | 2017 | } |
2018 | else { | 2018 | else { |
2019 | emit prevMonth(); | 2019 | emit prevMonth(); |
2020 | } | 2020 | } |
2021 | } | 2021 | } |
2022 | e->accept(); | 2022 | e->accept(); |
2023 | break; | 2023 | break; |
2024 | case Key_Down: | 2024 | case Key_Down: |
2025 | { | 2025 | { |
2026 | if ( mShowWeekView ) { | 2026 | if ( mShowWeekView ) { |
2027 | emit selectWeekNum ( currentWeek() +1); | 2027 | emit selectWeekNum ( currentWeek() +1); |
2028 | } | 2028 | } |
2029 | else { | 2029 | else { |
2030 | emit nextMonth(); | 2030 | emit nextMonth(); |
2031 | } | 2031 | } |
2032 | 2032 | ||
2033 | } | 2033 | } |
2034 | e->accept(); | 2034 | e->accept(); |
2035 | break; | 2035 | break; |
2036 | case Key_Return: | 2036 | case Key_Return: |
2037 | case Key_Enter: | 2037 | case Key_Enter: |
2038 | { | 2038 | { |
2039 | selectInternalWeekNum ( currentWeek() ); | 2039 | selectInternalWeekNum ( currentWeek() ); |
2040 | } | 2040 | } |
2041 | e->accept(); | 2041 | e->accept(); |
2042 | break; | 2042 | break; |
2043 | case Key_D: | 2043 | case Key_D: |
2044 | if ( mSelectedCell ) { | 2044 | if ( mSelectedCell ) { |
2045 | mSelectedCell->showDay(); | 2045 | mSelectedCell->showDay(); |
2046 | e->accept(); | 2046 | e->accept(); |
2047 | } else { | 2047 | } else { |
2048 | e->ignore(); | 2048 | e->ignore(); |
2049 | } | 2049 | } |
2050 | break; | 2050 | break; |
2051 | default: | 2051 | default: |
2052 | e->ignore(); | 2052 | e->ignore(); |
2053 | break; | 2053 | break; |
2054 | } | 2054 | } |
2055 | } | 2055 | } |
2056 | 2056 | ||
2057 | void KOMonthView::nextCell() | 2057 | void KOMonthView::nextCell() |
2058 | { | 2058 | { |
2059 | bool res = focusNextPrevChild ( true ); | 2059 | bool res = focusNextPrevChild ( true ); |
2060 | } | 2060 | } |
2061 | void KOMonthView::prevCell() | 2061 | void KOMonthView::prevCell() |
2062 | { | 2062 | { |
2063 | focusNextPrevChild ( false ); | 2063 | focusNextPrevChild ( false ); |
2064 | } | 2064 | } |
2065 | 2065 | ||
2066 | void KOMonthView::slotNewTodo() | 2066 | void KOMonthView::slotNewTodo() |
2067 | { | 2067 | { |
2068 | //qDebug("KOMonthView::slotNewTodo() "); | 2068 | //qDebug("KOMonthView::slotNewTodo() "); |
2069 | if ( mPopupCell ){ | 2069 | if ( mPopupCell ){ |
2070 | QDateTime dt( mPopupCell->date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 2070 | QDateTime dt( mPopupCell->date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
2071 | emit newTodoSignal(dt,true); | 2071 | emit newTodoSignal(dt,true); |
2072 | } | 2072 | } |
2073 | mPopupCell = 0; | 2073 | mPopupCell = 0; |
2074 | } | 2074 | } |
2075 | void KOMonthView::slotNewEvent() | 2075 | void KOMonthView::slotNewEvent() |
2076 | { | 2076 | { |
2077 | if ( mPopupCell ) { | 2077 | if ( mPopupCell ) { |
2078 | QDateTime dt( mPopupCell->date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 2078 | QDateTime dt( mPopupCell->date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
2079 | emit newEventSignal( dt ); | 2079 | emit newEventSignal( dt ); |
2080 | } | 2080 | } |
2081 | //qDebug("KOMonthView::slotNewEvent() "); | 2081 | //qDebug("KOMonthView::slotNewEvent() "); |
2082 | mPopupCell = 0; | 2082 | mPopupCell = 0; |
2083 | } | 2083 | } |
2084 | 2084 | ||
2085 | void KOMonthView::slotEditJournal() | 2085 | void KOMonthView::slotEditJournal() |
2086 | { | 2086 | { |
2087 | if ( mPopupCell ) | 2087 | if ( mPopupCell ) |
2088 | emit showJournalSignal( 7, mPopupCell->date() ); | 2088 | emit showJournalSignal( 7, mPopupCell->date() ); |
2089 | //qDebug("KOMonthView::slotEditJournal() "); | 2089 | //qDebug("KOMonthView::slotEditJournal() "); |
2090 | mPopupCell = 0; | 2090 | mPopupCell = 0; |
2091 | } | 2091 | } |
2092 | 2092 | ||
2093 | void KOMonthView::setPopupCell( MonthViewCell * c) | 2093 | void KOMonthView::setPopupCell( MonthViewCell * c) |
2094 | { | 2094 | { |
2095 | mPopupCell = c; | 2095 | mPopupCell = c; |
2096 | } | 2096 | } |
diff --git a/korganizer/outgoingdialog.cpp b/korganizer/outgoingdialog.cpp index 0fc90c4..7253c8e 100644 --- a/korganizer/outgoingdialog.cpp +++ b/korganizer/outgoingdialog.cpp | |||
@@ -1,393 +1,393 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 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 | 19 | ||
20 | #include <kdebug.h> | 20 | #include <kdebug.h> |
21 | 21 | ||
22 | #include <qfile.h> | 22 | #include <qfile.h> |
23 | #include <qdir.h> | 23 | #include <qdir.h> |
24 | #include <qtextstream.h> | 24 | #include <qtextstream.h> |
25 | 25 | ||
26 | #include <kglobal.h> | 26 | #include <kglobal.h> |
27 | #include <klocale.h> | 27 | #include <klocale.h> |
28 | #include <ktempfile.h> | 28 | #include <ktempfile.h> |
29 | #include <kstandarddirs.h> | 29 | #include <kstandarddirs.h> |
30 | 30 | ||
31 | #include <libkcal/event.h> | 31 | #include <libkcal/event.h> |
32 | #include <libkcal/freebusy.h> | 32 | #include <libkcal/freebusy.h> |
33 | //#include <libkcal/imipscheduler.h> | 33 | //#include <libkcal/imipscheduler.h> |
34 | #include <libkcal/dummyscheduler.h> | 34 | #include <libkcal/dummyscheduler.h> |
35 | #include <libkcal/icalformat.h> | 35 | #include <libkcal/icalformat.h> |
36 | #include <libkcal/calendar.h> | 36 | #include <libkcal/calendar.h> |
37 | 37 | ||
38 | #ifndef KORG_NOMAIL | 38 | #ifndef KORG_NOMAIL |
39 | #include "mailscheduler.h" | 39 | #include "mailscheduler.h" |
40 | #endif | 40 | #endif |
41 | 41 | ||
42 | #include "koprefs.h" | 42 | #include "koprefs.h" |
43 | #include "outgoingdialog.h" | 43 | #include "outgoingdialog.h" |
44 | #include "koeventviewerdialog.h" | 44 | #include "koeventviewerdialog.h" |
45 | #include "docprefs.h" | 45 | #include "docprefs.h" |
46 | 46 | ||
47 | ScheduleItemOut::ScheduleItemOut(QListView *parent,IncidenceBase *ev, | 47 | ScheduleItemOut::ScheduleItemOut(QListView *parent,IncidenceBase *ev, |
48 | Scheduler::Method method, | 48 | Scheduler::Method method, |
49 | const QString &recipients) | 49 | const QString &recipients) |
50 | : QListViewItem(parent) | 50 | : QListViewItem(parent) |
51 | { | 51 | { |
52 | mIncidence = ev; | 52 | mIncidence = ev; |
53 | mMethod = method; | 53 | mMethod = method; |
54 | mRecipients = recipients; | 54 | mRecipients = recipients; |
55 | 55 | ||
56 | // kdDebug() << "ScheduleItemOut: setting the summary" << endl; | 56 | // kdDebug() << "ScheduleItemOut: setting the summary" << endl; |
57 | //Set the summary | 57 | //Set the summary |
58 | if(ev->type() != "FreeBusy") { | 58 | if(ev->typeID() != freebusyID ) { |
59 | Incidence *incidence = static_cast<Incidence *>(ev); | 59 | Incidence *incidence = static_cast<Incidence *>(ev); |
60 | setText(0,incidence->summary()); | 60 | setText(0,incidence->summary()); |
61 | } else { | 61 | } else { |
62 | setText(0,i18n("Free Busy Object")); | 62 | setText(0,i18n("Free Busy Object")); |
63 | } | 63 | } |
64 | 64 | ||
65 | // kdDebug() << "ScheduleItemOut: checking if the object is an event" << endl; | 65 | // kdDebug() << "ScheduleItemOut: checking if the object is an event" << endl; |
66 | //If the object is an event | 66 | //If the object is an event |
67 | if(ev->type()=="Event") { | 67 | if(ev->typeID()== eventID ) { |
68 | Event *event = static_cast<Event *>(ev); | 68 | Event *event = static_cast<Event *>(ev); |
69 | 69 | ||
70 | setText(1,event->dtStartDateStr()); | 70 | setText(1,event->dtStartDateStr()); |
71 | if (event->doesFloat()) { //If the event floats set the start and end times to no time | 71 | if (event->doesFloat()) { //If the event floats set the start and end times to no time |
72 | setText(2,i18n("no time")); | 72 | setText(2,i18n("no time")); |
73 | setText(4,i18n("no time")); | 73 | setText(4,i18n("no time")); |
74 | } else { //If it does not float | 74 | } else { //If it does not float |
75 | setText(2,event->dtStartTimeStr()); | 75 | setText(2,event->dtStartTimeStr()); |
76 | if (event->hasDuration()) { | 76 | if (event->hasDuration()) { |
77 | setText(4,event->dtEndTimeStr()); | 77 | setText(4,event->dtEndTimeStr()); |
78 | } else { | 78 | } else { |
79 | setText(4,i18n("no time")); | 79 | setText(4,i18n("no time")); |
80 | } | 80 | } |
81 | } | 81 | } |
82 | if (event->hasEndDate()) { | 82 | if (event->hasEndDate()) { |
83 | setText(3,event->dtEndDateStr()); | 83 | setText(3,event->dtEndDateStr()); |
84 | } | 84 | } |
85 | else { | 85 | else { |
86 | setText(3,i18n("no time")); | 86 | setText(3,i18n("no time")); |
87 | } | 87 | } |
88 | } | 88 | } |
89 | 89 | ||
90 | //If the object is an Todo | 90 | //If the object is an Todo |
91 | if(ev->type()=="Todo") { | 91 | if(ev->typeID() == todoID ) { |
92 | Todo *event = static_cast<Todo *>(ev); | 92 | Todo *event = static_cast<Todo *>(ev); |
93 | if (event->hasStartDate()) { | 93 | if (event->hasStartDate()) { |
94 | setText(1,event->dtStartDateStr()); | 94 | setText(1,event->dtStartDateStr()); |
95 | if (!event->doesFloat()) { | 95 | if (!event->doesFloat()) { |
96 | setText(2,event->dtStartTimeStr()); | 96 | setText(2,event->dtStartTimeStr()); |
97 | } | 97 | } |
98 | } | 98 | } |
99 | if (event->hasDueDate()) { | 99 | if (event->hasDueDate()) { |
100 | setText(3,event->dtDueDateStr()); | 100 | setText(3,event->dtDueDateStr()); |
101 | if (!event->doesFloat()) { | 101 | if (!event->doesFloat()) { |
102 | setText(4,event->dtDueTimeStr()); | 102 | setText(4,event->dtDueTimeStr()); |
103 | } | 103 | } |
104 | } | 104 | } |
105 | } | 105 | } |
106 | 106 | ||
107 | // kdDebug() << "ScheduleItemOut: checking if the object is a FreeBusy object" << endl; | 107 | // kdDebug() << "ScheduleItemOut: checking if the object is a FreeBusy object" << endl; |
108 | //If the object is a freebusy object | 108 | //If the object is a freebusy object |
109 | if(ev->type() == "FreeBusy") { | 109 | if(ev->typeID() == freebusyID ) { |
110 | FreeBusy *freebusy = static_cast<FreeBusy *>(ev); | 110 | FreeBusy *freebusy = static_cast<FreeBusy *>(ev); |
111 | 111 | ||
112 | setText(1,freebusy->dtStartDateStr()); | 112 | setText(1,freebusy->dtStartDateStr()); |
113 | setText(2,freebusy->dtStartTimeStr()); | 113 | setText(2,freebusy->dtStartTimeStr()); |
114 | //Must try and get this to the users local settings | 114 | //Must try and get this to the users local settings |
115 | setText(3,KGlobal::locale()->formatDate( freebusy->dtEnd().date() ) ); | 115 | setText(3,KGlobal::locale()->formatDate( freebusy->dtEnd().date() ) ); |
116 | setText(4,KGlobal::locale()->formatTime( freebusy->dtEnd().time() ) ); | 116 | setText(4,KGlobal::locale()->formatTime( freebusy->dtEnd().time() ) ); |
117 | } | 117 | } |
118 | 118 | ||
119 | // kdDebug() << "ScheduleItemOut: Setting the method" << endl; | 119 | // kdDebug() << "ScheduleItemOut: Setting the method" << endl; |
120 | //Set the Method | 120 | //Set the Method |
121 | setText(5,Scheduler::translatedMethodName(mMethod)); | 121 | setText(5,Scheduler::translatedMethodName(mMethod)); |
122 | } | 122 | } |
123 | 123 | ||
124 | OutgoingDialog::OutgoingDialog(Calendar *calendar,QWidget* parent, | 124 | OutgoingDialog::OutgoingDialog(Calendar *calendar,QWidget* parent, |
125 | const char* name,bool modal, | 125 | const char* name,bool modal, |
126 | WFlags fl) | 126 | WFlags fl) |
127 | : OutgoingDialog_base(parent,name,modal,fl) | 127 | : OutgoingDialog_base(parent,name,modal,fl) |
128 | { | 128 | { |
129 | mCalendar = calendar; | 129 | mCalendar = calendar; |
130 | 130 | ||
131 | mFormat = new ICalFormat; | 131 | mFormat = new ICalFormat; |
132 | 132 | ||
133 | if (KOPrefs::instance()->mIMIPScheduler == KOPrefs::IMIPDummy ) { | 133 | if (KOPrefs::instance()->mIMIPScheduler == KOPrefs::IMIPDummy ) { |
134 | mScheduler = new DummyScheduler(mCalendar); | 134 | mScheduler = new DummyScheduler(mCalendar); |
135 | } else { | 135 | } else { |
136 | #ifndef KORG_NOMAIL | 136 | #ifndef KORG_NOMAIL |
137 | mScheduler = new MailScheduler(mCalendar); | 137 | mScheduler = new MailScheduler(mCalendar); |
138 | #else | 138 | #else |
139 | mScheduler = new DummyScheduler(mCalendar); | 139 | mScheduler = new DummyScheduler(mCalendar); |
140 | #endif | 140 | #endif |
141 | } | 141 | } |
142 | mMessageListView->setColumnAlignment(1,AlignHCenter); | 142 | mMessageListView->setColumnAlignment(1,AlignHCenter); |
143 | mMessageListView->setColumnAlignment(2,AlignHCenter); | 143 | mMessageListView->setColumnAlignment(2,AlignHCenter); |
144 | mMessageListView->setColumnAlignment(3,AlignHCenter); | 144 | mMessageListView->setColumnAlignment(3,AlignHCenter); |
145 | mMessageListView->setColumnAlignment(4,AlignHCenter); | 145 | mMessageListView->setColumnAlignment(4,AlignHCenter); |
146 | QObject::connect(mMessageListView,SIGNAL(doubleClicked(QListViewItem *)), | 146 | QObject::connect(mMessageListView,SIGNAL(doubleClicked(QListViewItem *)), |
147 | this,SLOT(showEvent(QListViewItem *))); | 147 | this,SLOT(showEvent(QListViewItem *))); |
148 | mDocPrefs = new DocPrefs("groupschedule"); | 148 | mDocPrefs = new DocPrefs("groupschedule"); |
149 | loadMessages(); | 149 | loadMessages(); |
150 | } | 150 | } |
151 | 151 | ||
152 | OutgoingDialog::~OutgoingDialog() | 152 | OutgoingDialog::~OutgoingDialog() |
153 | { | 153 | { |
154 | delete mDocPrefs; | 154 | delete mDocPrefs; |
155 | delete mFormat; | 155 | delete mFormat; |
156 | } | 156 | } |
157 | 157 | ||
158 | bool OutgoingDialog::addMessage(IncidenceBase *incidence,Scheduler::Method method) | 158 | bool OutgoingDialog::addMessage(IncidenceBase *incidence,Scheduler::Method method) |
159 | { | 159 | { |
160 | kdDebug() << "Outgoing::addMessage" << "Method:" << method << endl; | 160 | kdDebug() << "Outgoing::addMessage" << "Method:" << method << endl; |
161 | if (method == Scheduler::Publish) return false; | 161 | if (method == Scheduler::Publish) return false; |
162 | if( mDocPrefs ) { | 162 | if( mDocPrefs ) { |
163 | if (method != Scheduler::Cancel) { | 163 | if (method != Scheduler::Cancel) { |
164 | mDocPrefs->writeEntry( incidence->uid()+"-scheduled", true ); | 164 | mDocPrefs->writeEntry( incidence->uid()+"-scheduled", true ); |
165 | } else { | 165 | } else { |
166 | if (!mDocPrefs->readBoolEntry(incidence->uid()+"-scheduled") ) | 166 | if (!mDocPrefs->readBoolEntry(incidence->uid()+"-scheduled") ) |
167 | return true; | 167 | return true; |
168 | } | 168 | } |
169 | } | 169 | } |
170 | 170 | ||
171 | if (KOPrefs::instance()->mIMIPSend == KOPrefs::IMIPOutbox) { | 171 | if (KOPrefs::instance()->mIMIPSend == KOPrefs::IMIPOutbox) { |
172 | new ScheduleItemOut(mMessageListView,incidence,method); | 172 | new ScheduleItemOut(mMessageListView,incidence,method); |
173 | saveMessage(incidence,method); | 173 | saveMessage(incidence,method); |
174 | emit numMessagesChanged(mMessageListView->childCount()); | 174 | emit numMessagesChanged(mMessageListView->childCount()); |
175 | } | 175 | } |
176 | else { | 176 | else { |
177 | mScheduler->performTransaction(incidence,method); | 177 | mScheduler->performTransaction(incidence,method); |
178 | } | 178 | } |
179 | return true; | 179 | return true; |
180 | } | 180 | } |
181 | 181 | ||
182 | bool OutgoingDialog::addMessage(IncidenceBase *incidence,Scheduler::Method method, | 182 | bool OutgoingDialog::addMessage(IncidenceBase *incidence,Scheduler::Method method, |
183 | const QString &recipients) | 183 | const QString &recipients) |
184 | { | 184 | { |
185 | //if (method != Scheduler::Publish) return false; | 185 | //if (method != Scheduler::Publish) return false; |
186 | if( mDocPrefs ) { | 186 | if( mDocPrefs ) { |
187 | if (method != Scheduler::Cancel) { | 187 | if (method != Scheduler::Cancel) { |
188 | mDocPrefs->writeEntry( incidence->uid()+"-scheduled", true ); | 188 | mDocPrefs->writeEntry( incidence->uid()+"-scheduled", true ); |
189 | } else { | 189 | } else { |
190 | if (!mDocPrefs->readBoolEntry(incidence->uid()+"-scheduled") ) | 190 | if (!mDocPrefs->readBoolEntry(incidence->uid()+"-scheduled") ) |
191 | return true; | 191 | return true; |
192 | } | 192 | } |
193 | } | 193 | } |
194 | if (KOPrefs::instance()->mIMIPSend == KOPrefs::IMIPOutbox) { | 194 | if (KOPrefs::instance()->mIMIPSend == KOPrefs::IMIPOutbox) { |
195 | new ScheduleItemOut(mMessageListView,incidence,method,recipients); | 195 | new ScheduleItemOut(mMessageListView,incidence,method,recipients); |
196 | saveMessage(incidence,method,recipients); | 196 | saveMessage(incidence,method,recipients); |
197 | emit numMessagesChanged(mMessageListView->childCount()); | 197 | emit numMessagesChanged(mMessageListView->childCount()); |
198 | } | 198 | } |
199 | else { | 199 | else { |
200 | mScheduler->performTransaction(incidence,method,recipients); | 200 | mScheduler->performTransaction(incidence,method,recipients); |
201 | } | 201 | } |
202 | return true; | 202 | return true; |
203 | } | 203 | } |
204 | 204 | ||
205 | void OutgoingDialog::send() | 205 | void OutgoingDialog::send() |
206 | { | 206 | { |
207 | kdDebug() << "OutgoingDialog::send" << endl; | 207 | kdDebug() << "OutgoingDialog::send" << endl; |
208 | ScheduleItemOut *item = (ScheduleItemOut *)(mMessageListView->firstChild()); | 208 | ScheduleItemOut *item = (ScheduleItemOut *)(mMessageListView->firstChild()); |
209 | while(item) { | 209 | while(item) { |
210 | bool success; | 210 | bool success; |
211 | if (item->method() == Scheduler::Publish) { | 211 | if (item->method() == Scheduler::Publish) { |
212 | success = mScheduler->publish(item->event(),item->recipients()); | 212 | success = mScheduler->publish(item->event(),item->recipients()); |
213 | } else { | 213 | } else { |
214 | success = mScheduler->performTransaction(item->event(),item->method()); | 214 | success = mScheduler->performTransaction(item->event(),item->method()); |
215 | } | 215 | } |
216 | ScheduleItemOut *oldItem = item; | 216 | ScheduleItemOut *oldItem = item; |
217 | item = (ScheduleItemOut *)(item->nextSibling()); | 217 | item = (ScheduleItemOut *)(item->nextSibling()); |
218 | if (success) { | 218 | if (success) { |
219 | deleteMessage(oldItem->event()); | 219 | deleteMessage(oldItem->event()); |
220 | delete (oldItem->event()); | 220 | delete (oldItem->event()); |
221 | delete oldItem; | 221 | delete oldItem; |
222 | } | 222 | } |
223 | } | 223 | } |
224 | 224 | ||
225 | emit numMessagesChanged(mMessageListView->childCount()); | 225 | emit numMessagesChanged(mMessageListView->childCount()); |
226 | } | 226 | } |
227 | 227 | ||
228 | void OutgoingDialog::deleteItem() | 228 | void OutgoingDialog::deleteItem() |
229 | { | 229 | { |
230 | ScheduleItemOut *item = (ScheduleItemOut *)(mMessageListView->selectedItem()); | 230 | ScheduleItemOut *item = (ScheduleItemOut *)(mMessageListView->selectedItem()); |
231 | if(!item) | 231 | if(!item) |
232 | return; | 232 | return; |
233 | deleteMessage(item->event()); | 233 | deleteMessage(item->event()); |
234 | delete(item->event()); | 234 | delete(item->event()); |
235 | mMessageListView->takeItem(item); | 235 | mMessageListView->takeItem(item); |
236 | emit numMessagesChanged(mMessageListView->childCount()); | 236 | emit numMessagesChanged(mMessageListView->childCount()); |
237 | } | 237 | } |
238 | 238 | ||
239 | void OutgoingDialog::showEvent(QListViewItem *qitem) | 239 | void OutgoingDialog::showEvent(QListViewItem *qitem) |
240 | { | 240 | { |
241 | ScheduleItemOut *item = (ScheduleItemOut *)qitem; | 241 | ScheduleItemOut *item = (ScheduleItemOut *)qitem; |
242 | Event *event = 0; | 242 | Event *event = 0; |
243 | Todo *todo = 0; | 243 | Todo *todo = 0; |
244 | if ( item->event()->type()=="Event" ) { | 244 | if ( item->event()->typeID() == eventID ) { |
245 | event = static_cast<Event *>(item->event()); | 245 | event = static_cast<Event *>(item->event()); |
246 | } | 246 | } |
247 | if ( item->event()->type()=="Todo" ) { | 247 | if ( item->event()->typeID() == todoID ) { |
248 | todo = static_cast<Todo *>(item->event()); | 248 | todo = static_cast<Todo *>(item->event()); |
249 | } | 249 | } |
250 | QString sendText; | 250 | QString sendText; |
251 | if (event || todo) { | 251 | if (event || todo) { |
252 | KOEventViewerDialog *eventViewer = new KOEventViewerDialog(this); | 252 | KOEventViewerDialog *eventViewer = new KOEventViewerDialog(this); |
253 | if (event) eventViewer->setEvent(event); | 253 | if (event) eventViewer->setEvent(event); |
254 | if (todo) eventViewer->setTodo(todo); | 254 | if (todo) eventViewer->setTodo(todo); |
255 | sendText = "<hr><h4>"+i18n("Event will be sent to:")+"</h4>"; | 255 | sendText = "<hr><h4>"+i18n("Event will be sent to:")+"</h4>"; |
256 | switch (item->method()) { | 256 | switch (item->method()) { |
257 | case Scheduler::Publish: { | 257 | case Scheduler::Publish: { |
258 | sendText += item->recipients(); | 258 | sendText += item->recipients(); |
259 | break; } | 259 | break; } |
260 | case Scheduler::Request: { | 260 | case Scheduler::Request: { |
261 | sendText += i18n("All attendees"); | 261 | sendText += i18n("All attendees"); |
262 | break; } | 262 | break; } |
263 | case Scheduler::Refresh: { | 263 | case Scheduler::Refresh: { |
264 | sendText += i18n("All attendees"); | 264 | sendText += i18n("All attendees"); |
265 | break; } | 265 | break; } |
266 | case Scheduler::Cancel: { | 266 | case Scheduler::Cancel: { |
267 | sendText += i18n("All attendees"); | 267 | sendText += i18n("All attendees"); |
268 | break; } | 268 | break; } |
269 | case Scheduler::Add: { | 269 | case Scheduler::Add: { |
270 | sendText += i18n("All attendees"); | 270 | sendText += i18n("All attendees"); |
271 | break; } | 271 | break; } |
272 | case Scheduler::Reply: { | 272 | case Scheduler::Reply: { |
273 | sendText += i18n("The organizer %1").arg(item->event()->organizer()); | 273 | sendText += i18n("The organizer %1").arg(item->event()->organizer()); |
274 | break; } | 274 | break; } |
275 | case Scheduler::Counter: { | 275 | case Scheduler::Counter: { |
276 | sendText += i18n("The organizer %1").arg(item->event()->organizer()); | 276 | sendText += i18n("The organizer %1").arg(item->event()->organizer()); |
277 | break; } | 277 | break; } |
278 | case Scheduler::Declinecounter: { | 278 | case Scheduler::Declinecounter: { |
279 | sendText += i18n("All attendees"); | 279 | sendText += i18n("All attendees"); |
280 | break; } | 280 | break; } |
281 | case Scheduler::NoMethod: { | 281 | case Scheduler::NoMethod: { |
282 | sendText += ""; | 282 | sendText += ""; |
283 | break; } | 283 | break; } |
284 | default: | 284 | default: |
285 | sendText = ""; | 285 | sendText = ""; |
286 | } | 286 | } |
287 | eventViewer->addText(sendText); | 287 | eventViewer->addText(sendText); |
288 | eventViewer->show(); | 288 | eventViewer->show(); |
289 | } | 289 | } |
290 | } | 290 | } |
291 | 291 | ||
292 | bool OutgoingDialog::saveMessage(IncidenceBase *incidence,Scheduler::Method method, | 292 | bool OutgoingDialog::saveMessage(IncidenceBase *incidence,Scheduler::Method method, |
293 | const QString &recipients) | 293 | const QString &recipients) |
294 | { | 294 | { |
295 | KTempFile ktfile(locateLocal("data","korganizer/outgoing/"),"ics"); | 295 | KTempFile ktfile(locateLocal("data","korganizer/outgoing/"),"ics"); |
296 | QString messageText = mFormat->createScheduleMessage(incidence,method); | 296 | QString messageText = mFormat->createScheduleMessage(incidence,method); |
297 | QTextStream *qts = ktfile.textStream(); | 297 | QTextStream *qts = ktfile.textStream(); |
298 | *qts << messageText; | 298 | *qts << messageText; |
299 | *qts << "METHOD-BEGIN:" << endl << method << endl << ":METHOD-END" << endl; | 299 | *qts << "METHOD-BEGIN:" << endl << method << endl << ":METHOD-END" << endl; |
300 | *qts << "RECIPIENTS-BEGIN:" << endl << recipients << endl << ":RECIPIENTS-END" << endl; | 300 | *qts << "RECIPIENTS-BEGIN:" << endl << recipients << endl << ":RECIPIENTS-END" << endl; |
301 | mMessageMap[incidence]=ktfile.name(); | 301 | mMessageMap[incidence]=ktfile.name(); |
302 | 302 | ||
303 | return true; | 303 | return true; |
304 | } | 304 | } |
305 | 305 | ||
306 | bool OutgoingDialog::deleteMessage(IncidenceBase *incidence) | 306 | bool OutgoingDialog::deleteMessage(IncidenceBase *incidence) |
307 | { | 307 | { |
308 | QFile f( mMessageMap[incidence] ); | 308 | QFile f( mMessageMap[incidence] ); |
309 | mMessageMap.remove(incidence); | 309 | mMessageMap.remove(incidence); |
310 | if ( !f.exists() ) return false; | 310 | if ( !f.exists() ) return false; |
311 | else | 311 | else |
312 | return f.remove(); | 312 | return f.remove(); |
313 | } | 313 | } |
314 | 314 | ||
315 | void OutgoingDialog::loadMessages() | 315 | void OutgoingDialog::loadMessages() |
316 | { | 316 | { |
317 | Scheduler::Method method; | 317 | Scheduler::Method method; |
318 | QString recipients; | 318 | QString recipients; |
319 | 319 | ||
320 | QString outgoingDirName = locateLocal("data","korganizer/outgoing"); | 320 | QString outgoingDirName = locateLocal("data","korganizer/outgoing"); |
321 | QDir outgoingDir(outgoingDirName); | 321 | QDir outgoingDir(outgoingDirName); |
322 | QStringList outgoing = outgoingDir.entryList(QDir::Files); | 322 | QStringList outgoing = outgoingDir.entryList(QDir::Files); |
323 | QStringList::ConstIterator it; | 323 | QStringList::ConstIterator it; |
324 | for(it = outgoing.begin(); it != outgoing.end(); ++it) { | 324 | for(it = outgoing.begin(); it != outgoing.end(); ++it) { |
325 | kdDebug() << "-- File: " << (*it) << endl; | 325 | kdDebug() << "-- File: " << (*it) << endl; |
326 | QFile f(outgoingDirName + "/" + (*it)); | 326 | QFile f(outgoingDirName + "/" + (*it)); |
327 | bool inserted = false; | 327 | bool inserted = false; |
328 | QMap<IncidenceBase*, QString>::Iterator iter; | 328 | QMap<IncidenceBase*, QString>::Iterator iter; |
329 | for ( iter = mMessageMap.begin(); iter != mMessageMap.end(); ++iter ) { | 329 | for ( iter = mMessageMap.begin(); iter != mMessageMap.end(); ++iter ) { |
330 | if (iter.data() == outgoingDirName + "/" + (*it)) inserted = true; | 330 | if (iter.data() == outgoingDirName + "/" + (*it)) inserted = true; |
331 | } | 331 | } |
332 | if (!inserted) { | 332 | if (!inserted) { |
333 | if (!f.open(IO_ReadOnly)) { | 333 | if (!f.open(IO_ReadOnly)) { |
334 | kdDebug() << "OutgoingDialog::loadMessage(): Can't open file'" | 334 | kdDebug() << "OutgoingDialog::loadMessage(): Can't open file'" |
335 | << (*it) << "'" << endl; | 335 | << (*it) << "'" << endl; |
336 | } else { | 336 | } else { |
337 | QTextStream t(&f); | 337 | QTextStream t(&f); |
338 | QString messageString = t.read(); | 338 | QString messageString = t.read(); |
339 | ScheduleMessage *message = mFormat->parseScheduleMessage(mCalendar, | 339 | ScheduleMessage *message = mFormat->parseScheduleMessage(mCalendar, |
340 | messageString); | 340 | messageString); |
341 | int begin_pos = messageString.find("METHOD-BEGIN:"); | 341 | int begin_pos = messageString.find("METHOD-BEGIN:"); |
342 | begin_pos = messageString.find('\n',begin_pos)+1; | 342 | begin_pos = messageString.find('\n',begin_pos)+1; |
343 | QString meth = messageString.mid(begin_pos,1); | 343 | QString meth = messageString.mid(begin_pos,1); |
344 | switch (meth.toInt()) { | 344 | switch (meth.toInt()) { |
345 | case 0:method=Scheduler::Publish; break; | 345 | case 0:method=Scheduler::Publish; break; |
346 | case 1:method=Scheduler::Request; break; | 346 | case 1:method=Scheduler::Request; break; |
347 | case 2:method=Scheduler::Refresh; break; | 347 | case 2:method=Scheduler::Refresh; break; |
348 | case 3:method=Scheduler::Cancel; break; | 348 | case 3:method=Scheduler::Cancel; break; |
349 | case 4:method=Scheduler::Add; break; | 349 | case 4:method=Scheduler::Add; break; |
350 | case 5:method=Scheduler::Reply; break; | 350 | case 5:method=Scheduler::Reply; break; |
351 | case 6:method=Scheduler::Counter; break; | 351 | case 6:method=Scheduler::Counter; break; |
352 | case 7:method=Scheduler::Declinecounter; break; | 352 | case 7:method=Scheduler::Declinecounter; break; |
353 | default :method=Scheduler::NoMethod; break; | 353 | default :method=Scheduler::NoMethod; break; |
354 | } | 354 | } |
355 | begin_pos = messageString.find("RECIPIENTS-BEGIN:"); | 355 | begin_pos = messageString.find("RECIPIENTS-BEGIN:"); |
356 | begin_pos = messageString.find('\n',begin_pos)+1; | 356 | begin_pos = messageString.find('\n',begin_pos)+1; |
357 | int end_pos = messageString.find(":RECIPIENTS-END",begin_pos)-1; | 357 | int end_pos = messageString.find(":RECIPIENTS-END",begin_pos)-1; |
358 | recipients = messageString.mid(begin_pos, end_pos-begin_pos); | 358 | recipients = messageString.mid(begin_pos, end_pos-begin_pos); |
359 | kdDebug() << "Outgoing::loadMessage(): Recipients: " << recipients << endl; | 359 | kdDebug() << "Outgoing::loadMessage(): Recipients: " << recipients << endl; |
360 | 360 | ||
361 | if (message) { | 361 | if (message) { |
362 | bool inserted = false; | 362 | bool inserted = false; |
363 | QMap<IncidenceBase*, QString>::Iterator iter; | 363 | QMap<IncidenceBase*, QString>::Iterator iter; |
364 | for ( iter = mMessageMap.begin(); iter != mMessageMap.end(); ++iter ) { | 364 | for ( iter = mMessageMap.begin(); iter != mMessageMap.end(); ++iter ) { |
365 | if (iter.data() == outgoingDirName + "/" + (*it)) inserted = true; | 365 | if (iter.data() == outgoingDirName + "/" + (*it)) inserted = true; |
366 | } | 366 | } |
367 | if (!inserted) { | 367 | if (!inserted) { |
368 | kdDebug() << "OutgoingDialog::loadMessage(): got message '" | 368 | kdDebug() << "OutgoingDialog::loadMessage(): got message '" |
369 | << (*it) << "'" << endl; | 369 | << (*it) << "'" << endl; |
370 | IncidenceBase *inc = message->event(); | 370 | IncidenceBase *inc = message->event(); |
371 | new ScheduleItemOut(mMessageListView,inc,method,recipients); | 371 | new ScheduleItemOut(mMessageListView,inc,method,recipients); |
372 | mMessageMap[message->event()]=outgoingDirName + "/" + (*it); | 372 | mMessageMap[message->event()]=outgoingDirName + "/" + (*it); |
373 | } | 373 | } |
374 | } else { | 374 | } else { |
375 | QString errorMessage; | 375 | QString errorMessage; |
376 | if (mFormat->exception()) { | 376 | if (mFormat->exception()) { |
377 | errorMessage = mFormat->exception()->message(); | 377 | errorMessage = mFormat->exception()->message(); |
378 | } | 378 | } |
379 | kdDebug() << "OutgoingDialog::loadMessage(): Error parsing " | 379 | kdDebug() << "OutgoingDialog::loadMessage(): Error parsing " |
380 | "message: " << errorMessage << endl; | 380 | "message: " << errorMessage << endl; |
381 | } | 381 | } |
382 | f.close(); | 382 | f.close(); |
383 | } | 383 | } |
384 | } | 384 | } |
385 | } | 385 | } |
386 | emit numMessagesChanged(mMessageListView->childCount()); | 386 | emit numMessagesChanged(mMessageListView->childCount()); |
387 | } | 387 | } |
388 | 388 | ||
389 | void OutgoingDialog::setDocumentId( const QString &id ) | 389 | void OutgoingDialog::setDocumentId( const QString &id ) |
390 | { | 390 | { |
391 | mDocPrefs->setDoc( id ); | 391 | mDocPrefs->setDoc( id ); |
392 | } | 392 | } |
393 | 393 | ||
diff --git a/libkcal/alarm.cpp b/libkcal/alarm.cpp index 6de1566..0afa0a7 100644 --- a/libkcal/alarm.cpp +++ b/libkcal/alarm.cpp | |||
@@ -149,333 +149,333 @@ void Alarm::setType(Alarm::Type type) | |||
149 | return; | 149 | return; |
150 | } | 150 | } |
151 | mType = type; | 151 | mType = type; |
152 | mParent->updated(); | 152 | mParent->updated(); |
153 | } | 153 | } |
154 | 154 | ||
155 | Alarm::Type Alarm::type() const | 155 | Alarm::Type Alarm::type() const |
156 | { | 156 | { |
157 | return mType; | 157 | return mType; |
158 | } | 158 | } |
159 | 159 | ||
160 | void Alarm::setAudioAlarm(const QString &audioFile) | 160 | void Alarm::setAudioAlarm(const QString &audioFile) |
161 | { | 161 | { |
162 | mType = Audio; | 162 | mType = Audio; |
163 | mFile = audioFile; | 163 | mFile = audioFile; |
164 | mParent->updated(); | 164 | mParent->updated(); |
165 | } | 165 | } |
166 | 166 | ||
167 | void Alarm::setAudioFile(const QString &audioFile) | 167 | void Alarm::setAudioFile(const QString &audioFile) |
168 | { | 168 | { |
169 | if (mType == Audio) { | 169 | if (mType == Audio) { |
170 | mFile = audioFile; | 170 | mFile = audioFile; |
171 | mParent->updated(); | 171 | mParent->updated(); |
172 | } | 172 | } |
173 | } | 173 | } |
174 | 174 | ||
175 | QString Alarm::audioFile() const | 175 | QString Alarm::audioFile() const |
176 | { | 176 | { |
177 | return (mType == Audio) ? mFile : QString::null; | 177 | return (mType == Audio) ? mFile : QString::null; |
178 | } | 178 | } |
179 | 179 | ||
180 | void Alarm::setProcedureAlarm(const QString &programFile, const QString &arguments) | 180 | void Alarm::setProcedureAlarm(const QString &programFile, const QString &arguments) |
181 | { | 181 | { |
182 | mType = Procedure; | 182 | mType = Procedure; |
183 | mFile = programFile; | 183 | mFile = programFile; |
184 | mDescription = arguments; | 184 | mDescription = arguments; |
185 | mParent->updated(); | 185 | mParent->updated(); |
186 | } | 186 | } |
187 | 187 | ||
188 | void Alarm::setProgramFile(const QString &programFile) | 188 | void Alarm::setProgramFile(const QString &programFile) |
189 | { | 189 | { |
190 | if (mType == Procedure) { | 190 | if (mType == Procedure) { |
191 | mFile = programFile; | 191 | mFile = programFile; |
192 | mParent->updated(); | 192 | mParent->updated(); |
193 | } | 193 | } |
194 | } | 194 | } |
195 | 195 | ||
196 | QString Alarm::programFile() const | 196 | QString Alarm::programFile() const |
197 | { | 197 | { |
198 | return (mType == Procedure) ? mFile : QString::null; | 198 | return (mType == Procedure) ? mFile : QString::null; |
199 | } | 199 | } |
200 | 200 | ||
201 | void Alarm::setProgramArguments(const QString &arguments) | 201 | void Alarm::setProgramArguments(const QString &arguments) |
202 | { | 202 | { |
203 | if (mType == Procedure) { | 203 | if (mType == Procedure) { |
204 | mDescription = arguments; | 204 | mDescription = arguments; |
205 | mParent->updated(); | 205 | mParent->updated(); |
206 | } | 206 | } |
207 | } | 207 | } |
208 | 208 | ||
209 | QString Alarm::programArguments() const | 209 | QString Alarm::programArguments() const |
210 | { | 210 | { |
211 | return (mType == Procedure) ? mDescription : QString::null; | 211 | return (mType == Procedure) ? mDescription : QString::null; |
212 | } | 212 | } |
213 | 213 | ||
214 | void Alarm::setEmailAlarm(const QString &subject, const QString &text, | 214 | void Alarm::setEmailAlarm(const QString &subject, const QString &text, |
215 | const QValueList<Person> &addressees, const QStringList &attachments) | 215 | const QValueList<Person> &addressees, const QStringList &attachments) |
216 | { | 216 | { |
217 | mType = Email; | 217 | mType = Email; |
218 | mMailSubject = subject; | 218 | mMailSubject = subject; |
219 | mDescription = text; | 219 | mDescription = text; |
220 | mMailAddresses = addressees; | 220 | mMailAddresses = addressees; |
221 | mMailAttachFiles = attachments; | 221 | mMailAttachFiles = attachments; |
222 | mParent->updated(); | 222 | mParent->updated(); |
223 | } | 223 | } |
224 | 224 | ||
225 | void Alarm::setMailAddress(const Person &mailAddress) | 225 | void Alarm::setMailAddress(const Person &mailAddress) |
226 | { | 226 | { |
227 | if (mType == Email) { | 227 | if (mType == Email) { |
228 | mMailAddresses.clear(); | 228 | mMailAddresses.clear(); |
229 | mMailAddresses += mailAddress; | 229 | mMailAddresses += mailAddress; |
230 | mParent->updated(); | 230 | mParent->updated(); |
231 | } | 231 | } |
232 | } | 232 | } |
233 | 233 | ||
234 | void Alarm::setMailAddresses(const QValueList<Person> &mailAddresses) | 234 | void Alarm::setMailAddresses(const QValueList<Person> &mailAddresses) |
235 | { | 235 | { |
236 | if (mType == Email) { | 236 | if (mType == Email) { |
237 | mMailAddresses = mailAddresses; | 237 | mMailAddresses = mailAddresses; |
238 | mParent->updated(); | 238 | mParent->updated(); |
239 | } | 239 | } |
240 | } | 240 | } |
241 | 241 | ||
242 | void Alarm::addMailAddress(const Person &mailAddress) | 242 | void Alarm::addMailAddress(const Person &mailAddress) |
243 | { | 243 | { |
244 | if (mType == Email) { | 244 | if (mType == Email) { |
245 | mMailAddresses += mailAddress; | 245 | mMailAddresses += mailAddress; |
246 | mParent->updated(); | 246 | mParent->updated(); |
247 | } | 247 | } |
248 | } | 248 | } |
249 | 249 | ||
250 | QValueList<Person> Alarm::mailAddresses() const | 250 | QValueList<Person> Alarm::mailAddresses() const |
251 | { | 251 | { |
252 | return (mType == Email) ? mMailAddresses : QValueList<Person>(); | 252 | return (mType == Email) ? mMailAddresses : QValueList<Person>(); |
253 | } | 253 | } |
254 | 254 | ||
255 | void Alarm::setMailSubject(const QString &mailAlarmSubject) | 255 | void Alarm::setMailSubject(const QString &mailAlarmSubject) |
256 | { | 256 | { |
257 | if (mType == Email) { | 257 | if (mType == Email) { |
258 | mMailSubject = mailAlarmSubject; | 258 | mMailSubject = mailAlarmSubject; |
259 | mParent->updated(); | 259 | mParent->updated(); |
260 | } | 260 | } |
261 | } | 261 | } |
262 | 262 | ||
263 | QString Alarm::mailSubject() const | 263 | QString Alarm::mailSubject() const |
264 | { | 264 | { |
265 | return (mType == Email) ? mMailSubject : QString::null; | 265 | return (mType == Email) ? mMailSubject : QString::null; |
266 | } | 266 | } |
267 | 267 | ||
268 | void Alarm::setMailAttachment(const QString &mailAttachFile) | 268 | void Alarm::setMailAttachment(const QString &mailAttachFile) |
269 | { | 269 | { |
270 | if (mType == Email) { | 270 | if (mType == Email) { |
271 | mMailAttachFiles.clear(); | 271 | mMailAttachFiles.clear(); |
272 | mMailAttachFiles += mailAttachFile; | 272 | mMailAttachFiles += mailAttachFile; |
273 | mParent->updated(); | 273 | mParent->updated(); |
274 | } | 274 | } |
275 | } | 275 | } |
276 | 276 | ||
277 | void Alarm::setMailAttachments(const QStringList &mailAttachFiles) | 277 | void Alarm::setMailAttachments(const QStringList &mailAttachFiles) |
278 | { | 278 | { |
279 | if (mType == Email) { | 279 | if (mType == Email) { |
280 | mMailAttachFiles = mailAttachFiles; | 280 | mMailAttachFiles = mailAttachFiles; |
281 | mParent->updated(); | 281 | mParent->updated(); |
282 | } | 282 | } |
283 | } | 283 | } |
284 | 284 | ||
285 | void Alarm::addMailAttachment(const QString &mailAttachFile) | 285 | void Alarm::addMailAttachment(const QString &mailAttachFile) |
286 | { | 286 | { |
287 | if (mType == Email) { | 287 | if (mType == Email) { |
288 | mMailAttachFiles += mailAttachFile; | 288 | mMailAttachFiles += mailAttachFile; |
289 | mParent->updated(); | 289 | mParent->updated(); |
290 | } | 290 | } |
291 | } | 291 | } |
292 | 292 | ||
293 | QStringList Alarm::mailAttachments() const | 293 | QStringList Alarm::mailAttachments() const |
294 | { | 294 | { |
295 | return (mType == Email) ? mMailAttachFiles : QStringList(); | 295 | return (mType == Email) ? mMailAttachFiles : QStringList(); |
296 | } | 296 | } |
297 | 297 | ||
298 | void Alarm::setMailText(const QString &text) | 298 | void Alarm::setMailText(const QString &text) |
299 | { | 299 | { |
300 | if (mType == Email) { | 300 | if (mType == Email) { |
301 | mDescription = text; | 301 | mDescription = text; |
302 | mParent->updated(); | 302 | mParent->updated(); |
303 | } | 303 | } |
304 | } | 304 | } |
305 | 305 | ||
306 | QString Alarm::mailText() const | 306 | QString Alarm::mailText() const |
307 | { | 307 | { |
308 | return (mType == Email) ? mDescription : QString::null; | 308 | return (mType == Email) ? mDescription : QString::null; |
309 | } | 309 | } |
310 | 310 | ||
311 | void Alarm::setDisplayAlarm(const QString &text) | 311 | void Alarm::setDisplayAlarm(const QString &text) |
312 | { | 312 | { |
313 | mType = Display; | 313 | mType = Display; |
314 | mDescription = text; | 314 | mDescription = text; |
315 | mParent->updated(); | 315 | mParent->updated(); |
316 | } | 316 | } |
317 | 317 | ||
318 | void Alarm::setText(const QString &text) | 318 | void Alarm::setText(const QString &text) |
319 | { | 319 | { |
320 | if (mType == Display) { | 320 | if (mType == Display) { |
321 | mDescription = text; | 321 | mDescription = text; |
322 | mParent->updated(); | 322 | mParent->updated(); |
323 | } | 323 | } |
324 | } | 324 | } |
325 | 325 | ||
326 | QString Alarm::text() const | 326 | QString Alarm::text() const |
327 | { | 327 | { |
328 | return (mType == Display) ? mDescription : QString::null; | 328 | return (mType == Display) ? mDescription : QString::null; |
329 | } | 329 | } |
330 | 330 | ||
331 | void Alarm::setTime(const QDateTime &alarmTime) | 331 | void Alarm::setTime(const QDateTime &alarmTime) |
332 | { | 332 | { |
333 | mAlarmTime = alarmTime; | 333 | mAlarmTime = alarmTime; |
334 | mHasTime = true; | 334 | mHasTime = true; |
335 | 335 | ||
336 | mParent->updated(); | 336 | mParent->updated(); |
337 | } | 337 | } |
338 | int Alarm::offset() | 338 | int Alarm::offset() |
339 | { | 339 | { |
340 | if ( hasTime() ) { | 340 | if ( hasTime() ) { |
341 | if (mParent->type()=="Todo") { | 341 | if (mParent->typeID() == todoID ) { |
342 | Todo *t = static_cast<Todo*>(mParent); | 342 | Todo *t = static_cast<Todo*>(mParent); |
343 | return t->dtDue().secsTo( mAlarmTime ) ; | 343 | return t->dtDue().secsTo( mAlarmTime ) ; |
344 | } else | 344 | } else |
345 | return mParent->dtStart().secsTo( mAlarmTime ) ; | 345 | return mParent->dtStart().secsTo( mAlarmTime ) ; |
346 | } | 346 | } |
347 | else | 347 | else |
348 | { | 348 | { |
349 | return mOffset.asSeconds(); | 349 | return mOffset.asSeconds(); |
350 | } | 350 | } |
351 | 351 | ||
352 | } | 352 | } |
353 | QString Alarm::offsetText() | 353 | QString Alarm::offsetText() |
354 | { | 354 | { |
355 | int min = -offset()/60; | 355 | int min = -offset()/60; |
356 | int hours = min /60; | 356 | int hours = min /60; |
357 | min = min % 60; | 357 | min = min % 60; |
358 | int days = hours /24; | 358 | int days = hours /24; |
359 | hours = hours % 24; | 359 | hours = hours % 24; |
360 | QString message; | 360 | QString message; |
361 | //qDebug("%d %d %d ", days, hours, min ); | 361 | //qDebug("%d %d %d ", days, hours, min ); |
362 | if ( days > 0 ) | 362 | if ( days > 0 ) |
363 | message += i18n("%1d").arg( days ); | 363 | message += i18n("%1d").arg( days ); |
364 | if ( hours > 0 ) { | 364 | if ( hours > 0 ) { |
365 | if ( !message.isEmpty() ) message += "/"; | 365 | if ( !message.isEmpty() ) message += "/"; |
366 | message += i18n("%1h").arg( hours ); | 366 | message += i18n("%1h").arg( hours ); |
367 | } | 367 | } |
368 | if ( min > 0 ) { | 368 | if ( min > 0 ) { |
369 | if ( !message.isEmpty() ) message += "/"; | 369 | if ( !message.isEmpty() ) message += "/"; |
370 | message += i18n("%1min").arg( min ); | 370 | message += i18n("%1min").arg( min ); |
371 | } | 371 | } |
372 | if ( message.isEmpty() ) | 372 | if ( message.isEmpty() ) |
373 | message = i18n("%1min").arg( 0 ); | 373 | message = i18n("%1min").arg( 0 ); |
374 | return message; | 374 | return message; |
375 | } | 375 | } |
376 | 376 | ||
377 | 377 | ||
378 | QDateTime Alarm::time() const | 378 | QDateTime Alarm::time() const |
379 | { | 379 | { |
380 | if ( hasTime() ) | 380 | if ( hasTime() ) |
381 | return mAlarmTime; | 381 | return mAlarmTime; |
382 | else | 382 | else |
383 | { | 383 | { |
384 | if (mParent->type()=="Todo") { | 384 | if (mParent->typeID() == todoID ) { |
385 | Todo *t = static_cast<Todo*>(mParent); | 385 | Todo *t = static_cast<Todo*>(mParent); |
386 | return mOffset.end( t->dtDue() ); | 386 | return mOffset.end( t->dtDue() ); |
387 | } else if (mEndOffset) { | 387 | } else if (mEndOffset) { |
388 | return mOffset.end( mParent->dtEnd() ); | 388 | return mOffset.end( mParent->dtEnd() ); |
389 | } else { | 389 | } else { |
390 | return mOffset.end( mParent->dtStart() ); | 390 | return mOffset.end( mParent->dtStart() ); |
391 | } | 391 | } |
392 | } | 392 | } |
393 | } | 393 | } |
394 | 394 | ||
395 | bool Alarm::hasTime() const | 395 | bool Alarm::hasTime() const |
396 | { | 396 | { |
397 | return mHasTime; | 397 | return mHasTime; |
398 | } | 398 | } |
399 | 399 | ||
400 | void Alarm::setSnoozeTime(int alarmSnoozeTime) | 400 | void Alarm::setSnoozeTime(int alarmSnoozeTime) |
401 | { | 401 | { |
402 | mAlarmSnoozeTime = alarmSnoozeTime; | 402 | mAlarmSnoozeTime = alarmSnoozeTime; |
403 | mParent->updated(); | 403 | mParent->updated(); |
404 | } | 404 | } |
405 | 405 | ||
406 | int Alarm::snoozeTime() const | 406 | int Alarm::snoozeTime() const |
407 | { | 407 | { |
408 | return mAlarmSnoozeTime; | 408 | return mAlarmSnoozeTime; |
409 | } | 409 | } |
410 | 410 | ||
411 | void Alarm::setRepeatCount(int alarmRepeatCount) | 411 | void Alarm::setRepeatCount(int alarmRepeatCount) |
412 | { | 412 | { |
413 | kdDebug(5800) << "Alarm::setRepeatCount(): " << alarmRepeatCount << endl; | 413 | kdDebug(5800) << "Alarm::setRepeatCount(): " << alarmRepeatCount << endl; |
414 | 414 | ||
415 | mAlarmRepeatCount = alarmRepeatCount; | 415 | mAlarmRepeatCount = alarmRepeatCount; |
416 | mParent->updated(); | 416 | mParent->updated(); |
417 | } | 417 | } |
418 | 418 | ||
419 | int Alarm::repeatCount() const | 419 | int Alarm::repeatCount() const |
420 | { | 420 | { |
421 | kdDebug(5800) << "Alarm::repeatCount(): " << mAlarmRepeatCount << endl; | 421 | kdDebug(5800) << "Alarm::repeatCount(): " << mAlarmRepeatCount << endl; |
422 | return mAlarmRepeatCount; | 422 | return mAlarmRepeatCount; |
423 | } | 423 | } |
424 | 424 | ||
425 | void Alarm::toggleAlarm() | 425 | void Alarm::toggleAlarm() |
426 | { | 426 | { |
427 | mAlarmEnabled = !mAlarmEnabled; | 427 | mAlarmEnabled = !mAlarmEnabled; |
428 | mParent->updated(); | 428 | mParent->updated(); |
429 | } | 429 | } |
430 | 430 | ||
431 | void Alarm::setEnabled(bool enable) | 431 | void Alarm::setEnabled(bool enable) |
432 | { | 432 | { |
433 | mAlarmEnabled = enable; | 433 | mAlarmEnabled = enable; |
434 | mParent->updated(); | 434 | mParent->updated(); |
435 | } | 435 | } |
436 | 436 | ||
437 | bool Alarm::enabled() const | 437 | bool Alarm::enabled() const |
438 | { | 438 | { |
439 | return mAlarmEnabled; | 439 | return mAlarmEnabled; |
440 | } | 440 | } |
441 | 441 | ||
442 | void Alarm::setStartOffset( const Duration &offset ) | 442 | void Alarm::setStartOffset( const Duration &offset ) |
443 | { | 443 | { |
444 | mOffset = offset; | 444 | mOffset = offset; |
445 | mEndOffset = false; | 445 | mEndOffset = false; |
446 | mHasTime = false; | 446 | mHasTime = false; |
447 | mParent->updated(); | 447 | mParent->updated(); |
448 | } | 448 | } |
449 | 449 | ||
450 | Duration Alarm::startOffset() const | 450 | Duration Alarm::startOffset() const |
451 | { | 451 | { |
452 | return (mHasTime || mEndOffset) ? 0 : mOffset; | 452 | return (mHasTime || mEndOffset) ? 0 : mOffset; |
453 | } | 453 | } |
454 | 454 | ||
455 | bool Alarm::hasStartOffset() const | 455 | bool Alarm::hasStartOffset() const |
456 | { | 456 | { |
457 | return !mHasTime && !mEndOffset; | 457 | return !mHasTime && !mEndOffset; |
458 | } | 458 | } |
459 | 459 | ||
460 | bool Alarm::hasEndOffset() const | 460 | bool Alarm::hasEndOffset() const |
461 | { | 461 | { |
462 | return !mHasTime && mEndOffset; | 462 | return !mHasTime && mEndOffset; |
463 | } | 463 | } |
464 | 464 | ||
465 | void Alarm::setEndOffset( const Duration &offset ) | 465 | void Alarm::setEndOffset( const Duration &offset ) |
466 | { | 466 | { |
467 | mOffset = offset; | 467 | mOffset = offset; |
468 | mEndOffset = true; | 468 | mEndOffset = true; |
469 | mHasTime = false; | 469 | mHasTime = false; |
470 | mParent->updated(); | 470 | mParent->updated(); |
471 | } | 471 | } |
472 | 472 | ||
473 | Duration Alarm::endOffset() const | 473 | Duration Alarm::endOffset() const |
474 | { | 474 | { |
475 | return (mHasTime || !mEndOffset) ? 0 : mOffset; | 475 | return (mHasTime || !mEndOffset) ? 0 : mOffset; |
476 | } | 476 | } |
477 | 477 | ||
478 | void Alarm::setParent( Incidence *parent ) | 478 | void Alarm::setParent( Incidence *parent ) |
479 | { | 479 | { |
480 | mParent = parent; | 480 | mParent = parent; |
481 | } | 481 | } |