summaryrefslogtreecommitdiffabout
path: root/korganizer/koeventviewer.cpp
Unidiff
Diffstat (limited to 'korganizer/koeventviewer.cpp') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/koeventviewer.cpp68
1 files changed, 40 insertions, 28 deletions
diff --git a/korganizer/koeventviewer.cpp b/korganizer/koeventviewer.cpp
index f39b5e1..c8c2f28 100644
--- a/korganizer/koeventviewer.cpp
+++ b/korganizer/koeventviewer.cpp
@@ -269,24 +269,25 @@ void KOEventViewer::addTag(const QString & tag,const QString & text)
269 } 269 }
270} 270}
271 271
272void KOEventViewer::setColorMode( int m ) 272void KOEventViewer::setColorMode( int m )
273{ 273{
274 mColorMode = m; 274 mColorMode = m;
275} 275}
276void KOEventViewer::appendEvent(Event *event, int mode ) 276void KOEventViewer::appendEvent(Event *event, int mode )
277{ 277{
278 mMailSubject = ""; 278 mMailSubject = "";
279 mCurrentIncidence = event; 279 mCurrentIncidence = event;
280 bool shortDate = KOPrefs::instance()->mShortDateInViewer; 280 bool shortDate = KOPrefs::instance()->mShortDateInViewer;
281 bool wideScreen = ( QApplication::desktop()->width() >= 640 );
281 topLevelWidget()->setCaption(i18n("Event Viewer")); 282 topLevelWidget()->setCaption(i18n("Event Viewer"));
282 if ( mode == 0 ) { 283 if ( mode == 0 ) {
283 addTag("h2",deTag(event->summary())); 284 addTag("h2",deTag(event->summary()));
284 } 285 }
285 else { 286 else {
286 if ( mColorMode == 1 ) { 287 if ( mColorMode == 1 ) {
287 mText +="<font color=\"#00A000\">"; 288 mText +="<font color=\"#00A000\">";
288 } 289 }
289 if ( mColorMode == 2 ) { 290 if ( mColorMode == 2 ) {
290 mText +="<font color=\"#C00000\">"; 291 mText +="<font color=\"#C00000\">";
291 } 292 }
292 // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; 293 // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>";
@@ -322,110 +323,120 @@ void KOEventViewer::appendEvent(Event *event, int mode )
322 .arg(event->dtStartStr( shortDate))); 323 .arg(event->dtStartStr( shortDate)));
323 mText.append(i18n("<p><b>To:</b> %1</p>") 324 mText.append(i18n("<p><b>To:</b> %1</p>")
324 .arg(event->dtEndStr(shortDate))); 325 .arg(event->dtEndStr(shortDate)));
325 } else { 326 } else {
326 mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>") 327 mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>")
327 .arg(event->dtStartTimeStr()) 328 .arg(event->dtStartTimeStr())
328 .arg(event->dtEndTimeStr())); 329 .arg(event->dtEndTimeStr()));
329 mText.append(i18n("<p><b>On:</b> %1</p> ") 330 mText.append(i18n("<p><b>On:</b> %1</p> ")
330 .arg(event->dtStartDateStr( shortDate ))); 331 .arg(event->dtStartDateStr( shortDate )));
331 } 332 }
332 } 333 }
333 if (!event->location().isEmpty()) { 334 if (!event->location().isEmpty()) {
334 addTag("b",i18n("Location: ")); 335 addTag("p","<b>"+i18n("Location: ")+"</b>"+ deTag(event->location() ) );
335 mText.append(deTag(event->location())+"<br>");
336 mMailSubject += i18n(" at ") + event->location(); 336 mMailSubject += i18n(" at ") + event->location();
337 } 337 }
338 if (event->recurrence()->doesRecur()) { 338 if (event->recurrence()->doesRecur()) {
339 339
340 QString recurText = event->recurrence()->recurrenceText(); 340 QString recurText = event->recurrence()->recurrenceText();
341 addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>"); 341 addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>");
342 bool ok; 342 bool ok;
343 QDate start = QDate::currentDate(); 343 QDate start = QDate::currentDate();
344 QDateTime next; 344 QDateTime next;
345 next = event->getNextOccurence( QDateTime::currentDateTime() , &ok ); 345 next = event->getNextOccurence( QDateTime::currentDateTime() , &ok );
346 if ( ok ) { 346 if ( ok ) {
347 if ( wideScreen ){
348 addTag("p",i18n("<b>Next recurrence is on:</b>") +" " + KGlobal::locale()->formatDate( next.date(), shortDate ) );
349 } else {
347 addTag("p",i18n("<b>Next recurrence is on:</b>") ); 350 addTag("p",i18n("<b>Next recurrence is on:</b>") );
348 addTag("p", KGlobal::locale()->formatDate( next.date(), shortDate )); 351 addTag("p", KGlobal::locale()->formatDate( next.date(), shortDate ));
352 }
349 mMailSubject += i18n(" - " )+ KGlobal::locale()->formatDateTime( next, true ); 353 mMailSubject += i18n(" - " )+ KGlobal::locale()->formatDateTime( next, true );
350 354
351 } else { 355 } else {
352 bool last; 356 bool last;
353 QDate nextd; 357 QDate nextd;
354 nextd = event->recurrence()->getPreviousDate( QDate::currentDate() , &last ); 358 nextd = event->recurrence()->getPreviousDate( QDate::currentDate() , &last );
355 if ( last ) { 359 if ( last ) {
360 if ( wideScreen ){
361 addTag("p",i18n("<b>Last recurrence was on:</b>") +" " + KGlobal::locale()->formatDate( nextd, shortDate ));
362 } else{
356 addTag("p",i18n("<b>Last recurrence was on:</b>") ); 363 addTag("p",i18n("<b>Last recurrence was on:</b>") );
357 addTag("p", KGlobal::locale()->formatDate( nextd, shortDate )); 364 addTag("p", KGlobal::locale()->formatDate( nextd, shortDate ));
358 } 365 }
359 } 366 }
367 }
360 } else { 368 } else {
361 mMailSubject += i18n(" - " )+event->dtStartStr( true ); 369 mMailSubject += i18n(" - " )+event->dtStartStr( true );
362 370
363 } 371 }
364 372
365 373
366 if (event->isAlarmEnabled()) { 374 if (event->isAlarmEnabled()) {
367 Alarm *alarm =event->alarms().first() ; 375 Alarm *alarm =event->alarms().first() ;
368 QDateTime t = alarm->time(); 376 QDateTime t = alarm->time();
369 QString s =i18n("( %1 before )").arg( alarm->offsetText() ); 377 QString s =i18n("( %1 before )").arg( alarm->offsetText() );
378 if(wideScreen ){
379 addTag("p",i18n("<b>Alarm on: ") + s +" </b>"+ KGlobal::locale()->formatDateTime( t, shortDate ));
380 }else{
370 addTag("p",i18n("<b>Alarm on: ") + s +" </b>"); 381 addTag("p",i18n("<b>Alarm on: ") + s +" </b>");
371 addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); 382 addTag("p", KGlobal::locale()->formatDateTime( t, shortDate ));
383 }
372 //addTag("p",s); 384 //addTag("p",s);
373 } 385 }
374 386
375 addTag("b",i18n("Access: ")); 387 addTag("p","<b>"+i18n("Access: ") + "</b>" + event->secrecyStr());
376 mText.append(event->secrecyStr()+"<br>");
377
378
379 388
380 formatCategories(event); 389 formatCategories(event);
381 390
382 formatReadOnly(event); 391 formatReadOnly(event);
383 formatAttendees(event); 392 formatAttendees(event);
384 393
385 if ( KOPrefs::instance()->mEVshowCreated ) { 394 if ( KOPrefs::instance()->mEVshowCreated ) {
386#ifdef DESKTOP_VERSION 395 if(wideScreen ){
387 addTag("p",i18n("<b>Created: ") +" </b>"+KGlobal::locale()->formatDateTime( event->created(), shortDate )); 396 addTag("p",i18n("<b>Created: ") +" </b>"+KGlobal::locale()->formatDateTime( event->created(), shortDate ));
388#else 397 }else{
389 addTag("p",i18n("<b>Created: ") +" </b>"); 398 addTag("p",i18n("<b>Created: ") +" </b>");
390 addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); 399 addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate ));
391#endif 400 }
401
392 402
393 } 403 }
394 if ( KOPrefs::instance()->mEVshowChanged ) { 404 if ( KOPrefs::instance()->mEVshowChanged ) {
395#ifdef DESKTOP_VERSION 405 if(wideScreen ){
396 addTag("p",i18n("<b>Last modified: ") +" </b>" + KGlobal::locale()->formatDateTime( event->lastModified(), shortDate ) ); 406 addTag("p",i18n("<b>Last modified: ") +" </b>" + KGlobal::locale()->formatDateTime( event->lastModified(), shortDate ) );
397#else 407 }else{
398 addTag("p",i18n("<b>Last modified: ") +" </b>"); 408 addTag("p",i18n("<b>Last modified: ") +" </b>");
399 addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); 409 addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate ));
400#endif 410 }
401 411
402 } 412 }
403 if ( KOPrefs::instance()->mEVshowDetails ) { 413 if ( KOPrefs::instance()->mEVshowDetails ) {
404 if (!event->description().isEmpty()) { 414 if (!event->description().isEmpty()) {
405 addTag("p",i18n("<b>Details: </b>")); 415 addTag("p",i18n("<b>Details: </b>"));
406 addTag("p",deTag(event->description())); 416 addTag("p",deTag(event->description()));
407 } 417 }
408 } 418 }
409 setText(mText); 419 setText(mText);
410 //QWhatsThis::add(this,mText); 420 //QWhatsThis::add(this,mText);
411 421
412} 422}
413 423
414void KOEventViewer::appendTodo(Todo *event, int mode ) 424void KOEventViewer::appendTodo(Todo *event, int mode )
415{ 425{
416 mMailSubject = ""; 426 mMailSubject = "";
417 mCurrentIncidence = event; 427 mCurrentIncidence = event;
418 topLevelWidget()->setCaption(i18n("Todo Viewer")); 428 topLevelWidget()->setCaption(i18n("Todo Viewer"));
419 bool shortDate = KOPrefs::instance()->mShortDateInViewer; 429 bool shortDate = KOPrefs::instance()->mShortDateInViewer;
430 bool wideScreen = ( QApplication::desktop()->width() >= 640 );
420 if (mode == 0 ) 431 if (mode == 0 )
421 addTag("h2",deTag(event->summary())); 432 addTag("h2",deTag(event->summary()));
422 else { 433 else {
423 if ( mColorMode == 1 ) { 434 if ( mColorMode == 1 ) {
424 mText +="<font color=\"#00A000\">"; 435 mText +="<font color=\"#00A000\">";
425 } 436 }
426 if ( mColorMode == 2 ) { 437 if ( mColorMode == 2 ) {
427 mText +="<font color=\"#B00000\">"; 438 mText +="<font color=\"#B00000\">";
428 } 439 }
429 if ( mode == 1 ) { 440 if ( mode == 1 ) {
430 addTag("h2",i18n( "Local: " ) +deTag(event->summary())); 441 addTag("h2",i18n( "Local: " ) +deTag(event->summary()));
431 } else { 442 } else {
@@ -461,65 +472,67 @@ void KOEventViewer::appendTodo(Todo *event, int mode )
461 QString recurText = event->recurrence()->recurrenceText(); 472 QString recurText = event->recurrence()->recurrenceText();
462 addTag("p","<em>" + i18n("This is a %1 recurring todo.").arg(recurText ) + "</em>"); 473 addTag("p","<em>" + i18n("This is a %1 recurring todo.").arg(recurText ) + "</em>");
463 474
464 } 475 }
465 if (event->hasStartDate()) { 476 if (event->hasStartDate()) {
466 mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(KOPrefs::instance()->mShortDateInViewer))); 477 mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(KOPrefs::instance()->mShortDateInViewer)));
467 } 478 }
468 if (event->hasDueDate()) { 479 if (event->hasDueDate()) {
469 mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(KOPrefs::instance()->mShortDateInViewer))); 480 mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(KOPrefs::instance()->mShortDateInViewer)));
470 mMailSubject += i18n(" - " )+event->dtDueStr( true ); 481 mMailSubject += i18n(" - " )+event->dtDueStr( true );
471 } 482 }
472 if (!event->location().isEmpty()) { 483 if (!event->location().isEmpty()) {
473 addTag("b",i18n("Location: ")); 484 addTag("p","<b>"+i18n("Location: ")+"</b>"+ deTag(event->location() ) );
474 mText.append(deTag(event->location())+"<br>");
475 mMailSubject += i18n(" at ") + event->location(); 485 mMailSubject += i18n(" at ") + event->location();
476 } 486 }
477 mText.append(i18n("<p><b>Priority:</b> %2</p>") 487 mText.append(i18n("<p><b>Priority:</b> %2</p>")
478 .arg(QString::number(event->priority()))); 488 .arg(QString::number(event->priority())));
479 489
480 if (event->isAlarmEnabled()) { 490 if (event->isAlarmEnabled()) {
481 Alarm *alarm =event->alarms().first() ; 491 Alarm *alarm =event->alarms().first() ;
482 QDateTime t = alarm->time(); 492 QDateTime t = alarm->time();
483 QString s =i18n("( %1 before )").arg( alarm->offsetText() ); 493 QString s =i18n("( %1 before )").arg( alarm->offsetText() );
494 if ( wideScreen ) {
495 addTag("p",i18n("<b>Alarm on: ") + s +" </b>"+ KGlobal::locale()->formatDateTime( t, shortDate ));
496 } else {
484 addTag("p",i18n("<b>Alarm on: ") + s +" </b>"); 497 addTag("p",i18n("<b>Alarm on: ") + s +" </b>");
485 addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); 498 addTag("p", KGlobal::locale()->formatDateTime( t, shortDate ));
486 //addTag("p",s); 499 }
487 } 500 }
488 501
489 addTag("b",i18n("Access: ")); 502 addTag("p","<b>"+i18n("Access: ") + "</b>" + event->secrecyStr());
490 mText.append(event->secrecyStr()+"<br>");
491 503
492 formatCategories(event); 504 formatCategories(event);
493 505
494 formatReadOnly(event); 506 formatReadOnly(event);
495 formatAttendees(event); 507 formatAttendees(event);
496 508
497 if ( KOPrefs::instance()->mEVshowCreated ) { 509 if ( KOPrefs::instance()->mEVshowCreated ) {
498#ifdef DESKTOP_VERSION 510 if(wideScreen ){
511
499 addTag("p",i18n("<b>Created: ") +" </b>"+KGlobal::locale()->formatDateTime( event->created(), shortDate )); 512 addTag("p",i18n("<b>Created: ") +" </b>"+KGlobal::locale()->formatDateTime( event->created(), shortDate ));
500#else 513
514 } else {
501 addTag("p",i18n("<b>Created: ") +" </b>"); 515 addTag("p",i18n("<b>Created: ") +" </b>");
502 addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); 516 addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate ));
503#endif 517 }
504
505 } 518 }
506 if ( KOPrefs::instance()->mEVshowChanged ) { 519 if ( KOPrefs::instance()->mEVshowChanged ) {
507#ifdef DESKTOP_VERSION 520 if(wideScreen ){
508 addTag("p",i18n("<b>Last modified: ") +" </b>" +KGlobal::locale()->formatDateTime( event->lastModified(), shortDate ) ); 521 addTag("p",i18n("<b>Last modified: ") +" </b>" +KGlobal::locale()->formatDateTime( event->lastModified(), shortDate ) );
509#else 522
523 } else {
510 addTag("p",i18n("<b>Last modified: ") +" </b>"); 524 addTag("p",i18n("<b>Last modified: ") +" </b>");
511 addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); 525 addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate ));
512#endif 526 }
513
514 } 527 }
515 if ( event->relatedTo() ) { 528 if ( event->relatedTo() ) {
516 addTag("b",i18n("Parent todo:<br>")); 529 addTag("b",i18n("Parent todo:<br>"));
517 mText.append(deTag(event->relatedTo()->summary())+" [" +QString::number(event->relatedTo()->priority()) + "/" + QString::number(((Todo*)event->relatedTo())->percentComplete())+"%] <br>"); 530 mText.append(deTag(event->relatedTo()->summary())+" [" +QString::number(event->relatedTo()->priority()) + "/" + QString::number(((Todo*)event->relatedTo())->percentComplete())+"%] <br>");
518 } 531 }
519 QPtrList<Incidence> Relations = event->relations(); 532 QPtrList<Incidence> Relations = event->relations();
520 Incidence *to; 533 Incidence *to;
521 if ( Relations.first() ) 534 if ( Relations.first() )
522 addTag("b",i18n("Sub todos:<br>")); 535 addTag("b",i18n("Sub todos:<br>"));
523 for (to=Relations.first();to;to=Relations.next()) { 536 for (to=Relations.first();to;to=Relations.next()) {
524 mText.append( deTag(to->summary())+" [" +QString::number(to->priority()) + "/" + QString::number(((Todo*)to)->percentComplete())+"%]<br>"); 537 mText.append( deTag(to->summary())+" [" +QString::number(to->priority()) + "/" + QString::number(((Todo*)to)->percentComplete())+"%]<br>");
525 538
@@ -529,29 +542,28 @@ void KOEventViewer::appendTodo(Todo *event, int mode )
529 if (!event->description().isEmpty()) { 542 if (!event->description().isEmpty()) {
530 addTag("p",i18n("<b>Details: </b>")); 543 addTag("p",i18n("<b>Details: </b>"));
531 addTag("p",deTag(event->description())); 544 addTag("p",deTag(event->description()));
532 } 545 }
533 } 546 }
534 setText(mText); 547 setText(mText);
535} 548}
536 549
537void KOEventViewer::formatCategories(Incidence *event) 550void KOEventViewer::formatCategories(Incidence *event)
538{ 551{
539 if (!event->categoriesStr().isEmpty()) { 552 if (!event->categoriesStr().isEmpty()) {
540 if (event->categories().count() == 1) { 553 if (event->categories().count() == 1) {
541 addTag("h3",i18n("Category")); 554 addTag("p","<b>"+i18n("Category") + ":</b> " + event->categoriesStrWithSpace());
542 } else { 555 } else {
543 addTag("h3",i18n("Categories")); 556 addTag("p","<b>"+i18n("Categories")+":</b> " + event->categoriesStrWithSpace() ) ;
544 } 557 }
545 addTag("p",event->categoriesStr());
546 } 558 }
547} 559}
548void KOEventViewer::formatAttendees(Incidence *event) 560void KOEventViewer::formatAttendees(Incidence *event)
549{ 561{
550 QPtrList<Attendee> attendees = event->attendees(); 562 QPtrList<Attendee> attendees = event->attendees();
551 if (attendees.count()) { 563 if (attendees.count()) {
552 564
553 565
554 QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); 566 QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small);
555 QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small); 567 QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small);
556 addTag("h3",i18n("Organizer")); 568 addTag("h3",i18n("Organizer"));
557 mText.append("<ul><li>"); 569 mText.append("<ul><li>");