summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/incomingdialog.cpp14
-rw-r--r--korganizer/koagendaview.cpp14
-rw-r--r--korganizer/koeditorrecurrence.cpp2
-rw-r--r--korganizer/koeventviewerdialog.cpp12
-rw-r--r--korganizer/komonthview.cpp4
-rw-r--r--korganizer/outgoingdialog.cpp12
-rw-r--r--libkcal/alarm.cpp4
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
@@ -85,444 +85,444 @@ bool ScheduleItemVisitor::visit(Event *e)
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
104bool ScheduleItemVisitor::visit(Todo *e) 104bool 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
124bool ScheduleItemVisitor::visit(Journal *) 124bool 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 */
137IncomingDialog::IncomingDialog(Calendar *calendar,OutgoingDialog *outgoing, 137IncomingDialog::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 */
160IncomingDialog::~IncomingDialog() 160IncomingDialog::~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
165void IncomingDialog::setOutgoingDialog(OutgoingDialog *outgoing) 165void IncomingDialog::setOutgoingDialog(OutgoingDialog *outgoing)
166{ 166{
167 mOutgoing = outgoing; 167 mOutgoing = outgoing;
168} 168}
169 169
170void IncomingDialog::retrieve() 170void 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
199void IncomingDialog::acceptAllMessages() 199void 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
213void IncomingDialog::acceptMessage() 213void 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
221bool IncomingDialog::acceptMessage(ScheduleItemIn *item) 221bool 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
245void IncomingDialog::rejectMessage() 245void 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
255void IncomingDialog::showEvent(QListViewItem *item) 255void 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
266bool IncomingDialog::incomeRefresh(ScheduleItemIn *item) 266bool 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
289bool IncomingDialog::incomeCounter(ScheduleItemIn *item) 289bool 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
352bool IncomingDialog::incomeDeclineCounter(ScheduleItemIn *item) 352bool 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
368bool IncomingDialog::incomeAdd(ScheduleItemIn *item) 368bool 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
388bool IncomingDialog::incomeDefault(ScheduleItemIn *item) 388bool 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
403bool IncomingDialog::incomeRequest(ScheduleItemIn *item) 403bool 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
434bool IncomingDialog::automaticAction(ScheduleItemIn *item) 434bool 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
499bool IncomingDialog::checkOrganizerInAddressbook(QString organizer) 499bool 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
511bool IncomingDialog::checkAttendeesInAddressbook(IncidenceBase *inc) 511bool 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
@@ -488,193 +488,193 @@ KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) :
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
574void KOAgendaView::toggleAllDay() 574void KOAgendaView::toggleAllDay()
575{ 575{
576 if ( mSplitterAgenda->firstHandle() ) 576 if ( mSplitterAgenda->firstHandle() )
577 mSplitterAgenda->firstHandle()->toggle(); 577 mSplitterAgenda->firstHandle()->toggle();
578} 578}
579void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) 579void 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
592KOAgendaView::~KOAgendaView() 592KOAgendaView::~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}
599void KOAgendaView::resizeEvent( QResizeEvent* e ) 599void 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}
624void KOAgendaView::slotDaylabelClicked( int num ) 624void 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
640KOAgendaButton* KOAgendaView::getNewDaylabel() 640KOAgendaButton* 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
650void KOAgendaView::createDayLabels() 650void 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
@@ -874,264 +874,264 @@ QPtrList<Incidence> KOAgendaView::selectedIncidences()
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
883DateList KOAgendaView::selectedDates() 883DateList 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
898void KOAgendaView::updateView() 898void 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*/
912void KOAgendaView::updateConfig() 912void 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
950void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) 950void 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
1050void KOAgendaView::showDates( const QDate &start, const QDate &end ) 1050void 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
1067void KOAgendaView::showEvents(QPtrList<Event>) 1067void 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
1072void KOAgendaView::changeEventDisplay(Event *, int) 1072void 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
1081void KOAgendaView::fillAgenda(const QDate &) 1081void KOAgendaView::fillAgenda(const QDate &)
1082{ 1082{
1083 // qDebug("KOAgendaView::fillAgenda "); 1083 // qDebug("KOAgendaView::fillAgenda ");
1084 fillAgenda(); 1084 fillAgenda();
1085} 1085}
1086 1086
1087void KOAgendaView::fillAgenda() 1087void 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;
diff --git a/korganizer/koeditorrecurrence.cpp b/korganizer/koeditorrecurrence.cpp
index e165017..dea8981 100644
--- a/korganizer/koeditorrecurrence.cpp
+++ b/korganizer/koeditorrecurrence.cpp
@@ -778,193 +778,193 @@ KOEditorRecurrence::KOEditorRecurrence( QWidget* parent, const char *name ) :
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
795KOEditorRecurrence::~KOEditorRecurrence() 795KOEditorRecurrence::~KOEditorRecurrence()
796{ 796{
797} 797}
798 798
799void KOEditorRecurrence::setEnabled( bool enabled ) 799void 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
811void KOEditorRecurrence::showCurrentRule( int current ) 811void 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
830void KOEditorRecurrence::setDateTimes( QDateTime start, QDateTime end ) 830void 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
839void KOEditorRecurrence::setDefaults( QDateTime from, QDateTime to, bool ) 839void 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
870void KOEditorRecurrence::readEvent(Incidence *event) 870void 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;
diff --git a/korganizer/koeventviewerdialog.cpp b/korganizer/koeventviewerdialog.cpp
index e5ff8af..02f13c7 100644
--- a/korganizer/koeventviewerdialog.cpp
+++ b/korganizer/koeventviewerdialog.cpp
@@ -55,206 +55,206 @@ KOEventViewerDialog::KOEventViewerDialog(QWidget *parent,const char *name)
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
70KOEventViewerDialog::~KOEventViewerDialog() 70KOEventViewerDialog::~KOEventViewerDialog()
71{ 71{
72 //qDebug("-------~KOEventViewerDialog() "); 72 //qDebug("-------~KOEventViewerDialog() ");
73} 73}
74void KOEventViewerDialog::showMe() 74void 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}
92void KOEventViewerDialog::setMyFocus() 92void KOEventViewerDialog::setMyFocus()
93{ 93{
94 94
95 setActiveWindow(); 95 setActiveWindow();
96 mEventViewer->setFocus(); 96 mEventViewer->setFocus();
97 97
98} 98}
99void KOEventViewerDialog::print() 99void KOEventViewerDialog::print()
100{ 100{
101 mEventViewer->printMe(); 101 mEventViewer->printMe();
102 102
103} 103}
104void KOEventViewerDialog::setSyncMode( bool b ) 104void 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}
119void KOEventViewerDialog::setColorMode( int m ) 119void KOEventViewerDialog::setColorMode( int m )
120{ 120{
121 mEventViewer->setColorMode( m ); 121 mEventViewer->setColorMode( m );
122} 122}
123int KOEventViewerDialog::executeS( bool local ) 123int 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
134void KOEventViewerDialog::updateConfig() 134void KOEventViewerDialog::updateConfig()
135{ 135{
136 mEventViewer->setFont( KOPrefs::instance()->mEventViewFont ); 136 mEventViewer->setFont( KOPrefs::instance()->mEventViewFont );
137 137
138} 138}
139void KOEventViewerDialog::setEvent(Event *event) 139void 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}
149void KOEventViewerDialog::setIncidence(Incidence *in ) 149void 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}
158void KOEventViewerDialog::addIncidence(Incidence *in) 158void 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
172void KOEventViewerDialog::addEvent(Event *event) 172void 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
183void KOEventViewerDialog::setTodo(Todo *event) 183void 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}
193void KOEventViewerDialog::setJournal(Journal *j) 193void 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
204void KOEventViewerDialog::addText(QString text) 204void 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}
210void KOEventViewerDialog::editIncidence() 210void 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}
223void KOEventViewerDialog::showIncidence() 223void 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}
257void KOEventViewerDialog::keyPressEvent ( QKeyEvent * e ) 257void KOEventViewerDialog::keyPressEvent ( QKeyEvent * e )
258{ 258{
259 switch ( e->key() ) { 259 switch ( e->key() ) {
260 260
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 678cab6..c868270 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -289,193 +289,193 @@ MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s)
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}
295void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s) 295void 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
308void MonthViewItem::paint(QPainter *p) 308void 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
427int MonthViewItem::height(const QListBox *lb) const 427int 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
435int MonthViewItem::width(const QListBox *lb) const 435int 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
467MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) 467MonthViewCell::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 );
@@ -1850,193 +1850,193 @@ void KOMonthView::computeLayout()
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
1937void KOMonthView::showContextMenu( Incidence *incidence ) 1937void 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}
1954MonthViewCell * KOMonthView::selectedCell( ) 1954MonthViewCell * KOMonthView::selectedCell( )
1955{ 1955{
1956 return mSelectedCell; 1956 return mSelectedCell;
1957} 1957}
1958void KOMonthView::setSelectedCell( MonthViewCell *cell ) 1958void 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
1975void KOMonthView::processSelectionChange() 1975void 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
1986void KOMonthView::clearSelection() 1986void 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
1994void KOMonthView::keyReleaseEvent ( QKeyEvent * e) 1994void 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
2001void KOMonthView::keyPressEvent ( QKeyEvent * e ) 2001void 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;
diff --git a/korganizer/outgoingdialog.cpp b/korganizer/outgoingdialog.cpp
index 0fc90c4..7253c8e 100644
--- a/korganizer/outgoingdialog.cpp
+++ b/korganizer/outgoingdialog.cpp
@@ -1,343 +1,343 @@
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
47ScheduleItemOut::ScheduleItemOut(QListView *parent,IncidenceBase *ev, 47ScheduleItemOut::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
124OutgoingDialog::OutgoingDialog(Calendar *calendar,QWidget* parent, 124OutgoingDialog::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
152OutgoingDialog::~OutgoingDialog() 152OutgoingDialog::~OutgoingDialog()
153{ 153{
154 delete mDocPrefs; 154 delete mDocPrefs;
155 delete mFormat; 155 delete mFormat;
156} 156}
157 157
158bool OutgoingDialog::addMessage(IncidenceBase *incidence,Scheduler::Method method) 158bool 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
182bool OutgoingDialog::addMessage(IncidenceBase *incidence,Scheduler::Method method, 182bool 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
205void OutgoingDialog::send() 205void 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
228void OutgoingDialog::deleteItem() 228void 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
239void OutgoingDialog::showEvent(QListViewItem *qitem) 239void 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
292bool OutgoingDialog::saveMessage(IncidenceBase *incidence,Scheduler::Method method, 292bool 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
306bool OutgoingDialog::deleteMessage(IncidenceBase *incidence) 306bool 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
315void OutgoingDialog::loadMessages() 315void 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);
diff --git a/libkcal/alarm.cpp b/libkcal/alarm.cpp
index 6de1566..0afa0a7 100644
--- a/libkcal/alarm.cpp
+++ b/libkcal/alarm.cpp
@@ -245,236 +245,236 @@ void Alarm::addMailAddress(const Person &mailAddress)
245 mMailAddresses += mailAddress; 245 mMailAddresses += mailAddress;
246 mParent->updated(); 246 mParent->updated();
247 } 247 }
248} 248}
249 249
250QValueList<Person> Alarm::mailAddresses() const 250QValueList<Person> Alarm::mailAddresses() const
251{ 251{
252 return (mType == Email) ? mMailAddresses : QValueList<Person>(); 252 return (mType == Email) ? mMailAddresses : QValueList<Person>();
253} 253}
254 254
255void Alarm::setMailSubject(const QString &mailAlarmSubject) 255void 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
263QString Alarm::mailSubject() const 263QString Alarm::mailSubject() const
264{ 264{
265 return (mType == Email) ? mMailSubject : QString::null; 265 return (mType == Email) ? mMailSubject : QString::null;
266} 266}
267 267
268void Alarm::setMailAttachment(const QString &mailAttachFile) 268void 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
277void Alarm::setMailAttachments(const QStringList &mailAttachFiles) 277void 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
285void Alarm::addMailAttachment(const QString &mailAttachFile) 285void 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
293QStringList Alarm::mailAttachments() const 293QStringList Alarm::mailAttachments() const
294{ 294{
295 return (mType == Email) ? mMailAttachFiles : QStringList(); 295 return (mType == Email) ? mMailAttachFiles : QStringList();
296} 296}
297 297
298void Alarm::setMailText(const QString &text) 298void 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
306QString Alarm::mailText() const 306QString Alarm::mailText() const
307{ 307{
308 return (mType == Email) ? mDescription : QString::null; 308 return (mType == Email) ? mDescription : QString::null;
309} 309}
310 310
311void Alarm::setDisplayAlarm(const QString &text) 311void 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
318void Alarm::setText(const QString &text) 318void 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
326QString Alarm::text() const 326QString Alarm::text() const
327{ 327{
328 return (mType == Display) ? mDescription : QString::null; 328 return (mType == Display) ? mDescription : QString::null;
329} 329}
330 330
331void Alarm::setTime(const QDateTime &alarmTime) 331void 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}
338int Alarm::offset() 338int 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}
353QString Alarm::offsetText() 353QString 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
378QDateTime Alarm::time() const 378QDateTime 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
395bool Alarm::hasTime() const 395bool Alarm::hasTime() const
396{ 396{
397 return mHasTime; 397 return mHasTime;
398} 398}
399 399
400void Alarm::setSnoozeTime(int alarmSnoozeTime) 400void Alarm::setSnoozeTime(int alarmSnoozeTime)
401{ 401{
402 mAlarmSnoozeTime = alarmSnoozeTime; 402 mAlarmSnoozeTime = alarmSnoozeTime;
403 mParent->updated(); 403 mParent->updated();
404} 404}
405 405
406int Alarm::snoozeTime() const 406int Alarm::snoozeTime() const
407{ 407{
408 return mAlarmSnoozeTime; 408 return mAlarmSnoozeTime;
409} 409}
410 410
411void Alarm::setRepeatCount(int alarmRepeatCount) 411void 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
419int Alarm::repeatCount() const 419int 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
425void Alarm::toggleAlarm() 425void Alarm::toggleAlarm()
426{ 426{
427 mAlarmEnabled = !mAlarmEnabled; 427 mAlarmEnabled = !mAlarmEnabled;
428 mParent->updated(); 428 mParent->updated();
429} 429}
430 430
431void Alarm::setEnabled(bool enable) 431void Alarm::setEnabled(bool enable)
432{ 432{
433 mAlarmEnabled = enable; 433 mAlarmEnabled = enable;
434 mParent->updated(); 434 mParent->updated();
435} 435}
436 436
437bool Alarm::enabled() const 437bool Alarm::enabled() const
438{ 438{
439 return mAlarmEnabled; 439 return mAlarmEnabled;
440} 440}
441 441
442void Alarm::setStartOffset( const Duration &offset ) 442void 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
450Duration Alarm::startOffset() const 450Duration Alarm::startOffset() const
451{ 451{
452 return (mHasTime || mEndOffset) ? 0 : mOffset; 452 return (mHasTime || mEndOffset) ? 0 : mOffset;
453} 453}
454 454
455bool Alarm::hasStartOffset() const 455bool Alarm::hasStartOffset() const
456{ 456{
457 return !mHasTime && !mEndOffset; 457 return !mHasTime && !mEndOffset;
458} 458}
459 459
460bool Alarm::hasEndOffset() const 460bool Alarm::hasEndOffset() const
461{ 461{
462 return !mHasTime && mEndOffset; 462 return !mHasTime && mEndOffset;
463} 463}
464 464
465void Alarm::setEndOffset( const Duration &offset ) 465void 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
473Duration Alarm::endOffset() const 473Duration Alarm::endOffset() const
474{ 474{
475 return (mHasTime || !mEndOffset) ? 0 : mOffset; 475 return (mHasTime || !mEndOffset) ? 0 : mOffset;
476} 476}
477 477
478void Alarm::setParent( Incidence *parent ) 478void Alarm::setParent( Incidence *parent )
479{ 479{
480 mParent = parent; 480 mParent = parent;