~ubuntu-branches/ubuntu/trusty/kdepimlibs/trusty

« back to all changes in this revision

Viewing changes to kcalutils/incidenceformatter.cpp

  • Committer: Package Import Robot
  • Author(s): Rohan Garg, Rohan Garg, Philip Muškovac
  • Date: 2013-11-23 17:36:44 UTC
  • mfrom: (1.1.102)
  • Revision ID: package-import@ubuntu.com-20131123173644-p5ow94192ezsny8g
Tags: 4:4.11.80-0ubuntu1
[ Rohan Garg ]
* New upstream beta release
  - Bump akonadi requirement to 1.10.45
  - Update install files
  - Update symbols

[ Philip Muškovac ]
* kdepimlibs-dev/-dbg breaks/replaces kdepim-runtime/-dbg (<< 4:4.11.80)

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
#include <kcalcore/visitor.h>
46
46
using namespace KCalCore;
47
47
 
 
48
#include <kpimidentities/identitymanager.h>
 
49
 
48
50
#include <kpimutils/email.h>
49
51
#include <kpimutils/linklocator.h>
50
52
 
51
53
#include <KCalendarSystem>
52
54
#include <KDebug>
53
 
#include <KEMailSettings>
54
55
#include <KIconLoader>
55
56
#include <KLocalizedString>
56
57
#include <KGlobal>
77
78
  return KPIMUtils::LinkLocator::convertToHtml( str );
78
79
}
79
80
 
 
81
static bool thatIsMe( const QString &email )
 
82
{
 
83
  return KPIMIdentities::IdentityManager( true ).thatIsMe( email );
 
84
}
 
85
 
 
86
static bool iamAttendee( Attendee::Ptr attendee )
 
87
{
 
88
  // Check if this attendee is the user
 
89
  return thatIsMe( attendee->email() );
 
90
}
 
91
 
 
92
static bool iamPerson( const Person &person )
 
93
{
 
94
  // Check if this person is the user. test email only
 
95
  return thatIsMe( person.email() );
 
96
}
 
97
 
80
98
static QString htmlAddLink( const QString &ref, const QString &text,
81
99
                            bool newline = true )
82
100
{
83
 
  QString tmpStr( "<a href=\"" + ref + "\">" + text + "</a>" );
 
101
  QString tmpStr( QLatin1String("<a href=\"") + ref + QLatin1String("\">") + text + QLatin1String("</a>") );
84
102
  if ( newline ) {
85
 
    tmpStr += '\n';
 
103
    tmpStr += QLatin1Char('\n');
86
104
  }
87
105
  return tmpStr;
88
106
}
93
111
 
94
112
  if ( !email.isEmpty() ) {
95
113
    Person person( name, email );
96
 
    QString path = person.fullName().simplified();
97
 
    if ( path.isEmpty() || path.startsWith( '"' ) ) {
98
 
      path = email;
 
114
    if ( !iamPerson( person ) ) { // do not add a link for the user's email
 
115
      QString path = person.fullName().simplified();
 
116
      if ( path.isEmpty() || path.startsWith( QLatin1Char('"') ) ) {
 
117
        path = email;
 
118
      }
 
119
      KUrl mailto;
 
120
      mailto.setProtocol( QLatin1String("mailto") );
 
121
      mailto.setPath( path );
 
122
      const QString iconPath =
 
123
        KIconLoader::global()->iconPath( QLatin1String("mail-message-new"), KIconLoader::Small );
 
124
      str = htmlAddLink( mailto.url(), QLatin1String("<img valign=\"top\" src=\"") + iconPath + QLatin1String("\">") );
99
125
    }
100
 
    KUrl mailto;
101
 
    mailto.setProtocol( "mailto" );
102
 
    mailto.setPath( path );
103
 
    const QString iconPath =
104
 
      KIconLoader::global()->iconPath( "mail-message-new", KIconLoader::Small );
105
 
    str = htmlAddLink( mailto.url(), "<img valign=\"top\" src=\"" + iconPath + "\">" );
106
126
  }
107
127
  return str;
108
128
}
115
135
    // There is a UID, so make a link to the addressbook
116
136
    if ( name.isEmpty() ) {
117
137
      // Use the email address for text
118
 
      str += htmlAddLink( "uid:" + uid, email );
 
138
      str += htmlAddLink( QLatin1String("uid:") + uid, email );
119
139
    } else {
120
 
      str += htmlAddLink( "uid:" + uid, name );
 
140
      str += htmlAddLink( QLatin1String("uid:") + uid, name );
121
141
    }
122
142
  }
123
143
  return str;
125
145
 
126
146
static QString htmlAddTag( const QString &tag, const QString &text )
127
147
{
128
 
  int numLineBreaks = text.count( "\n" );
129
 
  QString str = '<' + tag + '>';
 
148
  int numLineBreaks = text.count( QLatin1String("\n") );
 
149
  QString str = QLatin1Char('<') + tag + QLatin1Char('>');
130
150
  QString tmpText = text;
131
151
  QString tmpStr = str;
132
152
  if( numLineBreaks >= 0 ) {
134
154
      int pos = 0;
135
155
      QString tmp;
136
156
      for ( int i = 0; i <= numLineBreaks; ++i ) {
137
 
        pos = tmpText.indexOf( "\n" );
 
157
        pos = tmpText.indexOf( QLatin1String("\n") );
138
158
        tmp = tmpText.left( pos );
139
159
        tmpText = tmpText.right( tmpText.length() - pos - 1 );
140
 
        tmpStr += tmp + "<br>";
 
160
        tmpStr += tmp + QLatin1String("<br>");
141
161
      }
142
162
    } else {
143
163
      tmpStr += tmpText;
144
164
    }
145
165
  }
146
 
  tmpStr += "</" + tag + '>';
 
166
  tmpStr += QLatin1String("</") + tag + QLatin1Char('>');
147
167
  return tmpStr;
148
168
}
149
169
 
168
188
  return printName;
169
189
}
170
190
 
171
 
static bool iamAttendee( Attendee::Ptr attendee )
172
 
{
173
 
  // Check if I'm this attendee
174
 
 
175
 
  bool iam = false;
176
 
  KEMailSettings settings;
177
 
  QStringList profiles = settings.profiles();
178
 
  for ( QStringList::Iterator it=profiles.begin(); it != profiles.end(); ++it ) {
179
 
    settings.setProfile( *it );
180
 
    if ( settings.getSetting( KEMailSettings::EmailAddress ) == attendee->email() ) {
181
 
      iam = true;
182
 
      break;
183
 
    }
184
 
  }
185
 
  return iam;
186
 
}
187
 
 
188
191
static bool iamOrganizer( Incidence::Ptr incidence )
189
192
{
190
 
  // Check if I'm the organizer for this incidence
 
193
  // Check if the user is the organizer for this incidence
191
194
 
192
195
  if ( !incidence ) {
193
196
    return false;
194
197
  }
195
198
 
196
 
  bool iam = false;
197
 
  KEMailSettings settings;
198
 
  QStringList profiles = settings.profiles();
199
 
  for ( QStringList::Iterator it=profiles.begin(); it != profiles.end(); ++it ) {
200
 
    settings.setProfile( *it );
201
 
    if ( settings.getSetting( KEMailSettings::EmailAddress ) == incidence->organizer()->email() ) {
202
 
      iam = true;
203
 
      break;
204
 
    }
205
 
  }
206
 
  return iam;
 
199
  return thatIsMe( incidence->organizer()->email() );
207
200
}
208
201
 
209
202
static bool senderIsOrganizer( Incidence::Ptr incidence, const QString &sender )
289
282
  QString iconPath;
290
283
  switch ( status ) {
291
284
  case Attendee::Accepted:
292
 
    iconPath = KIconLoader::global()->iconPath( "dialog-ok-apply", KIconLoader::Small );
 
285
    iconPath = KIconLoader::global()->iconPath( QLatin1String("dialog-ok-apply"), KIconLoader::Small );
293
286
    break;
294
287
  case Attendee::Declined:
295
 
    iconPath = KIconLoader::global()->iconPath( "dialog-cancel", KIconLoader::Small );
 
288
    iconPath = KIconLoader::global()->iconPath( QLatin1String("dialog-cancel"), KIconLoader::Small );
296
289
    break;
297
290
  case Attendee::NeedsAction:
298
 
    iconPath = KIconLoader::global()->iconPath( "help-about", KIconLoader::Small );
 
291
    iconPath = KIconLoader::global()->iconPath( QLatin1String("help-about"), KIconLoader::Small );
299
292
    break;
300
293
  case Attendee::InProcess:
301
 
    iconPath = KIconLoader::global()->iconPath( "help-about", KIconLoader::Small );
 
294
    iconPath = KIconLoader::global()->iconPath( QLatin1String("help-about"), KIconLoader::Small );
302
295
    break;
303
296
  case Attendee::Tentative:
304
 
    iconPath = KIconLoader::global()->iconPath( "dialog-ok", KIconLoader::Small );
 
297
    iconPath = KIconLoader::global()->iconPath( QLatin1String("dialog-ok"), KIconLoader::Small );
305
298
    break;
306
299
  case Attendee::Delegated:
307
 
    iconPath = KIconLoader::global()->iconPath( "mail-forward", KIconLoader::Small );
 
300
    iconPath = KIconLoader::global()->iconPath( QLatin1String("mail-forward"), KIconLoader::Small );
308
301
    break;
309
302
  case Attendee::Completed:
310
 
    iconPath = KIconLoader::global()->iconPath( "mail-mark-read", KIconLoader::Small );
 
303
    iconPath = KIconLoader::global()->iconPath( QLatin1String("mail-mark-read"), KIconLoader::Small );
311
304
  default:
312
305
    break;
313
306
  }
331
324
 
332
325
  QString personString;
333
326
  if ( !iconPath.isEmpty() ) {
334
 
    personString += "<img valign=\"top\" src=\"" + iconPath + "\">" + "&nbsp;";
 
327
    personString += QLatin1String("<img valign=\"top\" src=\"") + iconPath + QLatin1String("\">") + QLatin1String("&nbsp;");
335
328
  }
336
329
 
337
330
  // Make the uid link
345
338
#ifndef KDEPIM_MOBILE_UI
346
339
  // Make the mailto link
347
340
  if ( !email.isEmpty() ) {
348
 
    personString += "&nbsp;" + htmlAddMailtoLink( email, printName );
 
341
    personString += QLatin1String("&nbsp;") + htmlAddMailtoLink( email, printName );
349
342
  }
350
343
#endif
351
344
 
393
386
    if ( !a->delegate().isEmpty() ) {
394
387
      tmpStr += i18n( " (delegated to %1)", a->delegate() );
395
388
    }
396
 
    tmpStr += "<br>";
 
389
    tmpStr += QLatin1String("<br>");
397
390
  }
398
391
  if ( tmpStr.endsWith( QLatin1String( "<br>" ) ) ) {
399
392
    tmpStr.chop( 4 );
414
407
    QPair<QString, QString> s = searchNameAndUid( incidence->organizer()->email(),
415
408
                                                  incidence->organizer()->name(),
416
409
                                                  QString() );
417
 
    tmpStr += "<tr>";
418
 
    tmpStr += "<td><b>" + i18n( "Organizer:" ) + "</b></td>";
 
410
    tmpStr += QLatin1String("<tr>");
 
411
    tmpStr += QLatin1String("<td><b>") + i18n( "Organizer:" ) + QLatin1String("</b></td>");
419
412
    const QString iconPath =
420
 
      KIconLoader::global()->iconPath( "meeting-organizer", KIconLoader::Small );
421
 
    tmpStr += "<td>" + displayViewFormatPerson( incidence->organizer()->email(),
 
413
      KIconLoader::global()->iconPath( QLatin1String("meeting-organizer"), KIconLoader::Small );
 
414
    tmpStr += QLatin1String("<td>") + displayViewFormatPerson( incidence->organizer()->email(),
422
415
                                                s.first, s.second, iconPath ) +
423
 
              "</td>";
424
 
    tmpStr += "</tr>";
 
416
              QLatin1String("</td>");
 
417
    tmpStr += QLatin1String("</tr>");
425
418
  }
426
419
 
427
420
  // Show the attendee status if the incidence's organizer owns the resource calendar,
431
424
  // Add "chair"
432
425
  str = displayViewFormatAttendeeRoleList( incidence, Attendee::Chair, showStatus );
433
426
  if ( !str.isEmpty() ) {
434
 
    tmpStr += "<tr>";
435
 
    tmpStr += "<td><b>" + i18n( "Chair:" ) + "</b></td>";
436
 
    tmpStr += "<td>" + str + "</td>";
437
 
    tmpStr += "</tr>";
 
427
    tmpStr += QLatin1String("<tr>");
 
428
    tmpStr += QLatin1String("<td><b>") + i18n( "Chair:" ) + QLatin1String("</b></td>");
 
429
    tmpStr += QLatin1String("<td>") + str + QLatin1String("</td>");
 
430
    tmpStr += QLatin1String("</tr>");
438
431
  }
439
432
 
440
433
  // Add required participants
441
434
  str = displayViewFormatAttendeeRoleList( incidence, Attendee::ReqParticipant, showStatus );
442
435
  if ( !str.isEmpty() ) {
443
 
    tmpStr += "<tr>";
444
 
    tmpStr += "<td><b>" + i18n( "Required Participants:" ) + "</b></td>";
445
 
    tmpStr += "<td>" + str + "</td>";
446
 
    tmpStr += "</tr>";
 
436
    tmpStr += QLatin1String("<tr>");
 
437
    tmpStr += QLatin1String("<td><b>") + i18n( "Required Participants:" ) + QLatin1String("</b></td>");
 
438
    tmpStr += QLatin1String("<td>") + str + QLatin1String("</td>");
 
439
    tmpStr += QLatin1String("</tr>");
447
440
  }
448
441
 
449
442
  // Add optional participants
450
443
  str = displayViewFormatAttendeeRoleList( incidence, Attendee::OptParticipant, showStatus );
451
444
  if ( !str.isEmpty() ) {
452
 
    tmpStr += "<tr>";
453
 
    tmpStr += "<td><b>" + i18n( "Optional Participants:" ) + "</b></td>";
454
 
    tmpStr += "<td>" + str + "</td>";
455
 
    tmpStr += "</tr>";
 
445
    tmpStr += QLatin1String("<tr>");
 
446
    tmpStr += QLatin1String("<td><b>") + i18n( "Optional Participants:" ) + QLatin1String("</b></td>");
 
447
    tmpStr += QLatin1String("<td>") + str + QLatin1String("</td>");
 
448
    tmpStr += QLatin1String("</tr>");
456
449
  }
457
450
 
458
451
  // Add observers
459
452
  str = displayViewFormatAttendeeRoleList( incidence, Attendee::NonParticipant, showStatus );
460
453
  if ( !str.isEmpty() ) {
461
 
    tmpStr += "<tr>";
462
 
    tmpStr += "<td><b>" + i18n( "Observers:" ) + "</b></td>";
463
 
    tmpStr += "<td>" + str + "</td>";
464
 
    tmpStr += "</tr>";
 
454
    tmpStr += QLatin1String("<tr>");
 
455
    tmpStr += QLatin1String("<td><b>") + i18n( "Observers:" ) + QLatin1String("</b></td>");
 
456
    tmpStr += QLatin1String("<td>") + str + QLatin1String("</td>");
 
457
    tmpStr += QLatin1String("</tr>");
465
458
  }
466
459
 
467
460
  return tmpStr;
493
486
                             (*it)->label() );
494
487
    }
495
488
    if ( count < as.count() ) {
496
 
      tmpStr += "<br>";
 
489
      tmpStr += QLatin1String("<br>");
497
490
    }
498
491
  }
499
492
  return tmpStr;
502
495
static QString displayViewFormatCategories( Incidence::Ptr incidence )
503
496
{
504
497
  // We do not use Incidence::categoriesStr() since it does not have whitespace
505
 
  return incidence->categories().join( ", " );
 
498
  return incidence->categories().join( QLatin1String(", ") );
506
499
}
507
500
 
508
501
static QString displayViewFormatCreationDate( Incidence::Ptr incidence, KDateTime::Spec spec )
516
509
  if ( !event ) {
517
510
    return QString();
518
511
  }
519
 
  if ( event->customProperty( "KABC", "BIRTHDAY" ) != "YES" &&
520
 
       event->customProperty( "KABC", "ANNIVERSARY" ) != "YES" ) {
 
512
  if ( event->customProperty( "KABC", "BIRTHDAY" ) != QLatin1String("YES") &&
 
513
       event->customProperty( "KABC", "ANNIVERSARY" ) != QLatin1String("YES") ) {
521
514
    return QString();
522
515
  }
523
516
 
531
524
 
532
525
static QString displayViewFormatHeader( Incidence::Ptr incidence )
533
526
{
534
 
  QString tmpStr = "<table><tr>";
 
527
  QString tmpStr = QLatin1String( "<table><tr>" );
535
528
 
536
529
  // show icons
537
530
  KIconLoader *iconLoader = KIconLoader::global();
538
 
  tmpStr += "<td>";
 
531
  tmpStr += QLatin1String("<td>");
539
532
 
540
533
  QString iconPath;
541
 
  if ( incidence->customProperty( "KABC", "BIRTHDAY" ) == "YES" ) {
542
 
    iconPath = iconLoader->iconPath( "view-calendar-birthday", KIconLoader::Small );
543
 
  } else if ( incidence->customProperty( "KABC", "ANNIVERSARY" ) == "YES" ) {
544
 
    iconPath = iconLoader->iconPath( "view-calendar-wedding-anniversary", KIconLoader::Small );
 
534
  if ( incidence->customProperty( "KABC", "BIRTHDAY" ) == QLatin1String("YES") ) {
 
535
    iconPath = iconLoader->iconPath( QLatin1String("view-calendar-birthday"), KIconLoader::Small );
 
536
  } else if ( incidence->customProperty( "KABC", "ANNIVERSARY" ) == QLatin1String("YES") ) {
 
537
    iconPath = iconLoader->iconPath( QLatin1String("view-calendar-wedding-anniversary"), KIconLoader::Small );
545
538
  } else {
546
539
    iconPath = iconLoader->iconPath( incidence->iconName(), KIconLoader::Small );
547
540
  }
548
 
  tmpStr += "<img valign=\"top\" src=\"" + iconPath + "\">";
 
541
  tmpStr += QLatin1String("<img valign=\"top\" src=\"") + iconPath + QLatin1String("\">");
549
542
 
550
543
  if ( incidence->hasEnabledAlarms() ) {
551
 
    tmpStr += "<img valign=\"top\" src=\"" +
552
 
              iconLoader->iconPath( "preferences-desktop-notification-bell", KIconLoader::Small ) +
553
 
              "\">";
 
544
    tmpStr += QLatin1String("<img valign=\"top\" src=\"") +
 
545
              iconLoader->iconPath( QLatin1String("preferences-desktop-notification-bell"), KIconLoader::Small ) +
 
546
              QLatin1String("\">");
554
547
  }
555
548
  if ( incidence->recurs() ) {
556
 
    tmpStr += "<img valign=\"top\" src=\"" +
557
 
              iconLoader->iconPath( "edit-redo", KIconLoader::Small ) +
558
 
              "\">";
 
549
    tmpStr += QLatin1String("<img valign=\"top\" src=\"") +
 
550
              iconLoader->iconPath( QLatin1String("edit-redo"), KIconLoader::Small ) +
 
551
              QLatin1String("\">");
559
552
  }
560
553
  if ( incidence->isReadOnly() ) {
561
 
    tmpStr += "<img valign=\"top\" src=\"" +
562
 
              iconLoader->iconPath( "object-locked", KIconLoader::Small ) +
563
 
              "\">";
 
554
    tmpStr += QLatin1String("<img valign=\"top\" src=\"") +
 
555
              iconLoader->iconPath( QLatin1String("object-locked"), KIconLoader::Small ) +
 
556
              QLatin1String("\">");
564
557
  }
565
 
  tmpStr += "</td>";
566
 
 
567
 
  tmpStr += "<td>";
568
 
  tmpStr += "<b><u>" + incidence->richSummary() + "</u></b>";
569
 
  tmpStr += "</td>";
570
 
 
571
 
  tmpStr += "</tr></table>";
 
558
  tmpStr += QLatin1String("</td>");
 
559
 
 
560
  tmpStr += QLatin1String("<td>");
 
561
  tmpStr += QLatin1String("<b><u>") + incidence->richSummary() + QLatin1String("</u></b>");
 
562
  tmpStr += QLatin1String("</td>");
 
563
 
 
564
  tmpStr += QLatin1String("</tr></table>");
572
565
 
573
566
  return tmpStr;
574
567
}
583
576
 
584
577
  QString tmpStr = displayViewFormatHeader( event );
585
578
 
586
 
  tmpStr += "<table>";
587
 
  tmpStr += "<col width=\"25%\"/>";
588
 
  tmpStr += "<col width=\"75%\"/>";
 
579
  tmpStr += QLatin1String("<table>");
 
580
  tmpStr += QLatin1String("<col width=\"25%\"/>");
 
581
  tmpStr += QLatin1String("<col width=\"75%\"/>");
589
582
 
590
583
  const QString calStr = calendar ? resourceString( calendar, event ) : sourceName;
591
584
  if ( !calStr.isEmpty() ) {
592
 
    tmpStr += "<tr>";
593
 
    tmpStr += "<td><b>" + i18n( "Calendar:" ) + "</b></td>";
594
 
    tmpStr += "<td>" + calStr + "</td>";
595
 
    tmpStr += "</tr>";
 
585
    tmpStr += QLatin1String("<tr>");
 
586
    tmpStr += QLatin1String("<td><b>") + i18n( "Calendar:" ) + QLatin1String("</b></td>");
 
587
    tmpStr += QLatin1String("<td>") + calStr + QLatin1String("</td>");
 
588
    tmpStr += QLatin1String("</tr>");
596
589
  }
597
590
 
598
591
  if ( !event->location().isEmpty() ) {
599
 
    tmpStr += "<tr>";
600
 
    tmpStr += "<td><b>" + i18n( "Location:" ) + "</b></td>";
601
 
    tmpStr += "<td>" + event->richLocation() + "</td>";
602
 
    tmpStr += "</tr>";
 
592
    tmpStr += QLatin1String("<tr>");
 
593
    tmpStr += QLatin1String("<td><b>") + i18n( "Location:" ) + QLatin1String("</b></td>");
 
594
    tmpStr += QLatin1String("<td>") + event->richLocation() + QLatin1String("</td>");
 
595
    tmpStr +=QLatin1String( "</tr>");
603
596
  }
604
597
 
605
598
  KDateTime startDt = event->dtStart();
620
613
    }
621
614
  }
622
615
 
623
 
  tmpStr += "<tr>";
 
616
  tmpStr += QLatin1String("<tr>");
624
617
  if ( event->allDay() ) {
625
618
    if ( event->isMultiDay() ) {
626
 
      tmpStr += "<td><b>" + i18n( "Date:" ) + "</b></td>";
627
 
      tmpStr += "<td>" +
 
619
      tmpStr += QLatin1String("<td><b>") + i18n( "Date:" ) + QLatin1String("</b></td>");
 
620
      tmpStr += QLatin1String("<td>") +
628
621
                i18nc( "<beginTime> - <endTime>","%1 - %2",
629
622
                       dateToString( startDt, false, spec ),
630
623
                       dateToString( endDt, false, spec ) ) +
631
 
                "</td>";
 
624
                QLatin1String("</td>");
632
625
    } else {
633
 
      tmpStr += "<td><b>" + i18n( "Date:" ) + "</b></td>";
634
 
      tmpStr += "<td>" +
 
626
      tmpStr += QLatin1String("<td><b>") + i18n( "Date:" ) + QLatin1String("</b></td>");
 
627
      tmpStr += QLatin1String("<td>") +
635
628
                i18nc( "date as string","%1",
636
629
                       dateToString( startDt, false, spec ) ) +
637
 
                "</td>";
 
630
                QLatin1String("</td>");
638
631
    }
639
632
  } else {
640
633
    if ( event->isMultiDay() ) {
641
 
      tmpStr += "<td><b>" + i18n( "Date:" ) + "</b></td>";
642
 
      tmpStr += "<td>" +
 
634
      tmpStr += QLatin1String("<td><b>") + i18n( "Date:" ) + QLatin1String("</b></td>");
 
635
      tmpStr += QLatin1String("<td>") +
643
636
                i18nc( "<beginTime> - <endTime>","%1 - %2",
644
637
                       dateToString( startDt, false, spec ),
645
638
                       dateToString( endDt, false, spec ) ) +
646
 
                "</td>";
 
639
                QLatin1String("</td>");
647
640
    } else {
648
 
      tmpStr += "<td><b>" + i18n( "Date:" ) + "</b></td>";
649
 
      tmpStr += "<td>" +
 
641
      tmpStr += QLatin1String("<td><b>") + i18n( "Date:" ) + QLatin1String("</b></td>");
 
642
      tmpStr += QLatin1String("<td>") +
650
643
                i18nc( "date as string", "%1",
651
644
                       dateToString( startDt, false, spec ) ) +
652
 
                "</td>";
 
645
                QLatin1String("</td>");
653
646
 
654
 
      tmpStr += "</tr><tr>";
655
 
      tmpStr += "<td><b>" + i18n( "Time:" ) + "</b></td>";
 
647
      tmpStr += QLatin1String("</tr><tr>");
 
648
      tmpStr += QLatin1String("<td><b>") + i18n( "Time:" ) + QLatin1String("</b></td>");
656
649
      if ( event->hasEndDate() && startDt != endDt ) {
657
 
        tmpStr += "<td>" +
 
650
        tmpStr += QLatin1String("<td>") +
658
651
                  i18nc( "<beginTime> - <endTime>","%1 - %2",
659
652
                         timeToString( startDt, true, spec ),
660
653
                         timeToString( endDt, true, spec ) ) +
661
 
                  "</td>";
 
654
                  QLatin1String("</td>");
662
655
      } else {
663
 
        tmpStr += "<td>" +
 
656
        tmpStr += QLatin1String("<td>") +
664
657
                  timeToString( startDt, true, spec ) +
665
 
                  "</td>";
 
658
                  QLatin1String("</td>");
666
659
      }
667
660
    }
668
661
  }
669
 
  tmpStr += "</tr>";
 
662
  tmpStr += QLatin1String("</tr>");
670
663
 
671
664
  QString durStr = durationString( event );
672
665
  if ( !durStr.isEmpty() ) {
673
 
    tmpStr += "<tr>";
674
 
    tmpStr += "<td><b>" + i18n( "Duration:" ) + "</b></td>";
675
 
    tmpStr += "<td>" + durStr + "</td>";
676
 
    tmpStr += "</tr>";
 
666
    tmpStr += QLatin1String("<tr>");
 
667
    tmpStr += QLatin1String("<td><b>") + i18n( "Duration:" ) + QLatin1String("</b></td>");
 
668
    tmpStr += QLatin1String("<td>") + durStr + QLatin1String("</td>");
 
669
    tmpStr += QLatin1String("</tr>");
677
670
  }
678
671
 
679
672
  if ( event->recurs() || event->hasRecurrenceId() ) {
680
 
    tmpStr += "<tr>";
681
 
    tmpStr += "<td><b>" + i18n( "Recurrence:" ) + "</b></td>";
 
673
    tmpStr += QLatin1String("<tr>");
 
674
    tmpStr += QLatin1String("<td><b>") + i18n( "Recurrence:" ) + QLatin1String("</b></td>");
682
675
 
683
676
    QString str;
684
677
    if ( event->hasRecurrenceId() ) {
687
680
      str = recurrenceString( event );
688
681
    }
689
682
 
690
 
    tmpStr += "<td>" + str +
691
 
              "</td>";
692
 
    tmpStr += "</tr>";
 
683
    tmpStr += QLatin1String("<td>") + str +
 
684
              QLatin1String("</td>");
 
685
    tmpStr += QLatin1String("</tr>");
693
686
  }
694
687
 
695
 
  const bool isBirthday = event->customProperty( "KABC", "BIRTHDAY" ) == "YES";
696
 
  const bool isAnniversary = event->customProperty( "KABC", "ANNIVERSARY" ) == "YES";
 
688
  const bool isBirthday = event->customProperty( "KABC", "BIRTHDAY" ) == QLatin1String("YES");
 
689
  const bool isAnniversary = event->customProperty( "KABC", "ANNIVERSARY" ) == QLatin1String("YES");
697
690
 
698
691
  if ( isBirthday || isAnniversary ) {
699
 
    tmpStr += "<tr>";
 
692
    tmpStr += QLatin1String("<tr>");
700
693
    if ( isAnniversary ) {
701
 
      tmpStr += "<td><b>" + i18n( "Anniversary:" ) + "</b></td>";
 
694
      tmpStr += QLatin1String("<td><b>") + i18n( "Anniversary:" ) + QLatin1String("</b></td>");
702
695
    } else {
703
 
      tmpStr += "<td><b>" + i18n( "Birthday:" ) + "</b></td>";
 
696
      tmpStr += QLatin1String("<td><b>") + i18n( "Birthday:" ) + QLatin1String("</b></td>");
704
697
    }
705
 
    tmpStr += "<td>" + displayViewFormatBirthday( event ) + "</td>";
706
 
    tmpStr += "</tr>";
707
 
    tmpStr += "</table>";
 
698
    tmpStr += QLatin1String("<td>") + displayViewFormatBirthday( event ) + QLatin1String("</td>");
 
699
    tmpStr += QLatin1String("</tr>");
 
700
    tmpStr += QLatin1String("</table>");
708
701
    return tmpStr;
709
702
  }
710
703
 
721
714
        descStr = event->description();
722
715
      }
723
716
    }
724
 
    tmpStr += "<tr>";
725
 
    tmpStr += "<td><b>" + i18n( "Description:" ) + "</b></td>";
726
 
    tmpStr += "<td>" + descStr + "</td>";
727
 
    tmpStr += "</tr>";
 
717
    tmpStr += QLatin1String("<tr>");
 
718
    tmpStr += QLatin1String("<td><b>") + i18n( "Description:" ) + QLatin1String("</b></td>");
 
719
    tmpStr += QLatin1String("<td>") + descStr + QLatin1String("</td>");
 
720
    tmpStr += QLatin1String("</tr>");
728
721
  }
729
722
 
730
723
  // TODO: print comments?
731
724
 
732
725
  int reminderCount = event->alarms().count();
733
726
  if ( reminderCount > 0 && event->hasEnabledAlarms() ) {
734
 
    tmpStr += "<tr>";
735
 
    tmpStr += "<td><b>" +
 
727
    tmpStr += QLatin1String("<tr>");
 
728
    tmpStr += QLatin1String("<td><b>") +
736
729
              i18np( "Reminder:", "Reminders:", reminderCount ) +
737
 
              "</b></td>";
738
 
    tmpStr += "<td>" + reminderStringList( event ).join( "<br>" ) + "</td>";
739
 
    tmpStr += "</tr>";
 
730
              QLatin1String("</b></td>");
 
731
    tmpStr += QLatin1String("<td>") + reminderStringList( event ).join( QLatin1String("<br>") ) + QLatin1String("</td>");
 
732
    tmpStr += QLatin1String("</tr>");
740
733
  }
741
734
 
742
735
  tmpStr += displayViewFormatAttendees( calendar, event );
743
736
 
744
737
  int categoryCount = event->categories().count();
745
738
  if ( categoryCount > 0 ) {
746
 
    tmpStr += "<tr>";
747
 
    tmpStr += "<td><b>";
 
739
    tmpStr += QLatin1String("<tr>");
 
740
    tmpStr += QLatin1String("<td><b>");
748
741
    tmpStr += i18np( "Category:", "Categories:", categoryCount ) +
749
 
              "</b></td>";
750
 
    tmpStr += "<td>" + displayViewFormatCategories( event ) + "</td>";
751
 
    tmpStr += "</tr>";
 
742
              QLatin1String("</b></td>");
 
743
    tmpStr += QLatin1String("<td>") + displayViewFormatCategories( event ) + QLatin1String("</td>");
 
744
    tmpStr += QLatin1String("</tr>");
752
745
  }
753
746
 
754
747
  int attachmentCount = event->attachments().count();
755
748
  if ( attachmentCount > 0 ) {
756
 
    tmpStr += "<tr>";
757
 
    tmpStr += "<td><b>" +
 
749
    tmpStr += QLatin1String("<tr>");
 
750
    tmpStr += QLatin1String("<td><b>") +
758
751
              i18np( "Attachment:", "Attachments:", attachmentCount ) +
759
 
              "</b></td>";
760
 
    tmpStr += "<td>" + displayViewFormatAttachments( event ) + "</td>";
761
 
    tmpStr += "</tr>";
 
752
              QLatin1String("</b></td>");
 
753
    tmpStr += QLatin1String("<td>") + displayViewFormatAttachments( event ) + QLatin1String("</td>");
 
754
    tmpStr += QLatin1String("</tr>");
762
755
  }
763
 
  tmpStr += "</table>";
 
756
  tmpStr += QLatin1String("</table>");
764
757
 
765
 
  tmpStr += "<p><em>" + displayViewFormatCreationDate( event, spec ) + "</em>";
 
758
  tmpStr += QLatin1String("<p><em>") + displayViewFormatCreationDate( event, spec ) + QLatin1String("</em>");
766
759
 
767
760
  return tmpStr;
768
761
}
769
762
 
770
763
static QString displayViewFormatTodo( const Calendar::Ptr &calendar, const QString &sourceName,
771
764
                                      const Todo::Ptr &todo,
772
 
                                      const QDate &date, KDateTime::Spec spec )
 
765
                                      const QDate &ocurrenceDueDate, KDateTime::Spec spec )
773
766
{
774
767
  if ( !todo ) {
775
768
    kDebug() << "IncidenceFormatter::displayViewFormatTodo was called without to-do, quitting";
778
771
 
779
772
  QString tmpStr = displayViewFormatHeader( todo );
780
773
 
781
 
  tmpStr += "<table>";
782
 
  tmpStr += "<col width=\"25%\"/>";
783
 
  tmpStr += "<col width=\"75%\"/>";
 
774
  tmpStr += QLatin1String("<table>");
 
775
  tmpStr += QLatin1String("<col width=\"25%\"/>");
 
776
  tmpStr += QLatin1String("<col width=\"75%\"/>");
784
777
 
785
778
  const QString calStr = calendar ? resourceString( calendar, todo ) : sourceName;
786
779
  if ( !calStr.isEmpty() ) {
787
 
    tmpStr += "<tr>";
788
 
    tmpStr += "<td><b>" + i18n( "Calendar:" ) + "</b></td>";
789
 
    tmpStr += "<td>" + calStr + "</td>";
790
 
    tmpStr += "</tr>";
 
780
    tmpStr += QLatin1String("<tr>");
 
781
    tmpStr += QLatin1String("<td><b>") + i18n( "Calendar:" ) + QLatin1String("</b></td>");
 
782
    tmpStr += QLatin1String("<td>") + calStr + QLatin1String("</td>");
 
783
    tmpStr += QLatin1String("</tr>");
791
784
  }
792
785
 
793
786
  if ( !todo->location().isEmpty() ) {
794
 
    tmpStr += "<tr>";
795
 
    tmpStr += "<td><b>" + i18n( "Location:" ) + "</b></td>";
796
 
    tmpStr += "<td>" + todo->richLocation() + "</td>";
797
 
    tmpStr += "</tr>";
 
787
    tmpStr += QLatin1String("<tr>");
 
788
    tmpStr += QLatin1String("<td><b>") + i18n( "Location:" ) + QLatin1String("</b></td>");
 
789
    tmpStr += QLatin1String("<td>") + todo->richLocation() + QLatin1String("</td>");
 
790
    tmpStr += QLatin1String("</tr>");
798
791
  }
799
792
 
800
 
  const bool hastStartDate = todo->hasStartDate() && todo->dtStart().isValid();
801
 
  const bool hasDueDate = todo->hasDueDate() && todo->dtDue().isValid();
 
793
  const bool hastStartDate = todo->hasStartDate();
 
794
  const bool hasDueDate = todo->hasDueDate();
802
795
 
803
796
  if ( hastStartDate ) {
804
797
    KDateTime startDt = todo->dtStart( true /**first*/);
805
 
    if ( todo->recurs() ) {
806
 
      if ( date.isValid() ) {
807
 
        if ( hasDueDate ) {
808
 
          // In kdepim all recuring to-dos have due date.
809
 
          const int length = startDt.daysTo( todo->dtDue( true /**first*/) );
810
 
          if ( length >= 0 ) {
811
 
            startDt.setDate( date.addDays( -length ) );
812
 
          } else {
813
 
            kError() << "DTSTART is bigger than DTDUE, todo->uid() is " << todo->uid();
814
 
            startDt.setDate( date );
815
 
          }
 
798
    if ( todo->recurs() && ocurrenceDueDate.isValid() ) {
 
799
      if ( hasDueDate ) {
 
800
        // In kdepim all recuring to-dos have due date.
 
801
        const int length = startDt.daysTo( todo->dtDue( true /**first*/) );
 
802
        if ( length >= 0 ) {
 
803
          startDt.setDate( ocurrenceDueDate.addDays( -length ) );
816
804
        } else {
817
 
          kError() << "To-do is recurring but has no DTDUE set, todo->uid() is " << todo->uid();
818
 
          startDt.setDate( date );
 
805
          kError() << "DTSTART is bigger than DTDUE, todo->uid() is " << todo->uid();
 
806
          startDt.setDate( ocurrenceDueDate );
819
807
        }
 
808
      } else {
 
809
        kError() << "To-do is recurring but has no DTDUE set, todo->uid() is " << todo->uid();
 
810
        startDt.setDate( ocurrenceDueDate );
820
811
      }
821
812
    }
822
 
    tmpStr += "<tr>";
823
 
    tmpStr += "<td><b>" +
 
813
    tmpStr += QLatin1String("<tr>");
 
814
    tmpStr += QLatin1String("<td><b>") +
824
815
              i18nc( "to-do start date/time", "Start:" ) +
825
 
              "</b></td>";
826
 
    tmpStr += "<td>" +
 
816
              QLatin1String("</b></td>");
 
817
    tmpStr += QLatin1String("<td>") +
827
818
              dateTimeToString( startDt, todo->allDay(), false, spec ) +
828
 
              "</td>";
829
 
    tmpStr += "</tr>";
 
819
              QLatin1String("</td>");
 
820
    tmpStr += QLatin1String("</tr>");
830
821
  }
831
822
 
832
823
  if ( hasDueDate ) {
833
824
    KDateTime dueDt = todo->dtDue();
834
825
    if ( todo->recurs() ) {
835
 
      if ( date.isValid() ) {
836
 
        KDateTime kdt( date, QTime( 0, 0, 0 ), KSystemTimeZones::local() );
 
826
      if ( ocurrenceDueDate.isValid() ) {
 
827
        KDateTime kdt( ocurrenceDueDate, QTime( 0, 0, 0 ), KSystemTimeZones::local() );
837
828
        kdt = kdt.addSecs( -1 );
838
829
        dueDt.setDate( todo->recurrence()->getNextDateTime( kdt ).date() );
839
830
      }
840
831
    }
841
 
    tmpStr += "<tr>";
842
 
    tmpStr += "<td><b>" +
 
832
    tmpStr += QLatin1String("<tr>");
 
833
    tmpStr += QLatin1String("<td><b>") +
843
834
              i18nc( "to-do due date/time", "Due:" ) +
844
 
              "</b></td>";
845
 
    tmpStr += "<td>" +
 
835
              QLatin1String("</b></td>");
 
836
    tmpStr += QLatin1String("<td>") +
846
837
              dateTimeToString( dueDt, todo->allDay(), false, spec ) +
847
 
              "</td>";
848
 
    tmpStr += "</tr>";
 
838
              QLatin1String("</td>");
 
839
    tmpStr += QLatin1String("</tr>");
849
840
  }
850
841
 
851
842
  QString durStr = durationString( todo );
852
843
  if ( !durStr.isEmpty() ) {
853
 
    tmpStr += "<tr>";
854
 
    tmpStr += "<td><b>" + i18n( "Duration:" ) + "</b></td>";
855
 
    tmpStr += "<td>" + durStr + "</td>";
856
 
    tmpStr += "</tr>";
 
844
    tmpStr += QLatin1String("<tr>");
 
845
    tmpStr += QLatin1String("<td><b>") + i18n( "Duration:" ) + QLatin1String("</b></td>");
 
846
    tmpStr += QLatin1String("<td>") + durStr + QLatin1String("</td>");
 
847
    tmpStr += QLatin1String("</tr>");
857
848
  }
858
849
 
859
850
  if ( todo->recurs() || todo->hasRecurrenceId() ) {
860
 
    tmpStr += "<tr>";
861
 
    tmpStr += "<td><b>" + i18n( "Recurrence:" ) + "</b></td>";
 
851
    tmpStr += QLatin1String("<tr>");
 
852
    tmpStr += QLatin1String("<td><b>" )+ i18n( "Recurrence:" ) + QLatin1String("</b></td>");
862
853
    QString str;
863
854
    if ( todo->hasRecurrenceId() ) {
864
855
      str = i18n( "Exception" );
865
856
    } else {
866
857
      str = recurrenceString( todo );
867
858
    }
868
 
    tmpStr += "<td>" +
 
859
    tmpStr += QLatin1String("<td>") +
869
860
              str +
870
 
              "</td>";
871
 
    tmpStr += "</tr>";
 
861
              QLatin1String("</td>");
 
862
    tmpStr += QLatin1String("</tr>");
872
863
  }
873
864
 
874
865
  if ( !todo->description().isEmpty() ) {
875
 
    tmpStr += "<tr>";
876
 
    tmpStr += "<td><b>" + i18n( "Description:" ) + "</b></td>";
877
 
    tmpStr += "<td>" + todo->richDescription() + "</td>";
878
 
    tmpStr += "</tr>";
 
866
    tmpStr += QLatin1String("<tr>");
 
867
    tmpStr += QLatin1String("<td><b>") + i18n( "Description:" ) + QLatin1String("</b></td>");
 
868
    tmpStr += QLatin1String("<td>") + todo->richDescription() + QLatin1String("</td>");
 
869
    tmpStr += QLatin1String("</tr>");
879
870
  }
880
871
 
881
872
  // TODO: print comments?
882
873
 
883
874
  int reminderCount = todo->alarms().count();
884
875
  if ( reminderCount > 0 && todo->hasEnabledAlarms() ) {
885
 
    tmpStr += "<tr>";
886
 
    tmpStr += "<td><b>" +
 
876
    tmpStr += QLatin1String("<tr>");
 
877
    tmpStr += QLatin1String("<td><b>") +
887
878
              i18np( "Reminder:", "Reminders:", reminderCount ) +
888
 
              "</b></td>";
889
 
    tmpStr += "<td>" + reminderStringList( todo ).join( "<br>" ) + "</td>";
890
 
    tmpStr += "</tr>";
 
879
              QLatin1String("</b></td>");
 
880
    tmpStr += QLatin1String("<td>") + reminderStringList( todo ).join( QLatin1String("<br>") ) + QLatin1String("</td>");
 
881
    tmpStr += QLatin1String("</tr>");
891
882
  }
892
883
 
893
884
  tmpStr += displayViewFormatAttendees( calendar, todo );
894
885
 
895
886
  int categoryCount = todo->categories().count();
896
887
  if ( categoryCount > 0 ) {
897
 
    tmpStr += "<tr>";
898
 
    tmpStr += "<td><b>" +
 
888
    tmpStr += QLatin1String("<tr>");
 
889
    tmpStr += QLatin1String("<td><b>") +
899
890
              i18np( "Category:", "Categories:", categoryCount ) +
900
 
              "</b></td>";
901
 
    tmpStr += "<td>" + displayViewFormatCategories( todo ) + "</td>";
902
 
    tmpStr += "</tr>";
 
891
              QLatin1String("</b></td>");
 
892
    tmpStr += QLatin1String("<td>") + displayViewFormatCategories( todo ) + QLatin1String("</td>");
 
893
    tmpStr += QLatin1String("</tr>");
903
894
  }
904
895
 
905
896
  if ( todo->priority() > 0 ) {
906
 
    tmpStr += "<tr>";
907
 
    tmpStr += "<td><b>" + i18n( "Priority:" ) + "</b></td>";
908
 
    tmpStr += "<td>";
 
897
    tmpStr += QLatin1String("<tr>");
 
898
    tmpStr += QLatin1String("<td><b>") + i18n( "Priority:" ) + QLatin1String("</b></td>");
 
899
    tmpStr += QLatin1String("<td>");
909
900
    tmpStr += QString::number( todo->priority() );
910
 
    tmpStr += "</td>";
911
 
    tmpStr += "</tr>";
 
901
    tmpStr += QLatin1String("</td>");
 
902
    tmpStr += QLatin1String("</tr>");
912
903
  }
913
904
 
914
 
  tmpStr += "<tr>";
 
905
  tmpStr += QLatin1String("<tr>");
915
906
  if ( todo->isCompleted() ) {
916
 
    tmpStr += "<td><b>" + i18nc( "Completed: date", "Completed:" ) + "</b></td>";
917
 
    tmpStr += "<td>";
 
907
    tmpStr += QLatin1String("<td><b>") + i18nc( "Completed: date", "Completed:" ) + QLatin1String("</b></td>");
 
908
    tmpStr += QLatin1String("<td>");
918
909
    tmpStr += Stringify::todoCompletedDateTime( todo );
919
910
  } else {
920
 
    tmpStr += "<td><b>" + i18n( "Percent Done:" ) + "</b></td>";
921
 
    tmpStr += "<td>";
 
911
    tmpStr += QLatin1String("<td><b>") + i18n( "Percent Done:" ) + QLatin1String("</b></td>");
 
912
    tmpStr += QLatin1String("<td>");
922
913
    tmpStr += i18n( "%1%", todo->percentComplete() );
923
914
  }
924
 
  tmpStr += "</td>";
925
 
  tmpStr += "</tr>";
 
915
  tmpStr += QLatin1String("</td>");
 
916
  tmpStr += QLatin1String("</tr>");
926
917
 
927
918
  int attachmentCount = todo->attachments().count();
928
919
  if ( attachmentCount > 0 ) {
929
 
    tmpStr += "<tr>";
930
 
    tmpStr += "<td><b>" +
 
920
    tmpStr += QLatin1String("<tr>");
 
921
    tmpStr += QLatin1String("<td><b>") +
931
922
              i18np( "Attachment:", "Attachments:", attachmentCount ) +
932
 
              "</b></td>";
933
 
    tmpStr += "<td>" + displayViewFormatAttachments( todo ) + "</td>";
934
 
    tmpStr += "</tr>";
 
923
              QLatin1String("</b></td>");
 
924
    tmpStr += QLatin1String("<td>") + displayViewFormatAttachments( todo ) + QLatin1String("</td>");
 
925
    tmpStr += QLatin1String("</tr>");
935
926
  }
936
 
  tmpStr += "</table>";
 
927
  tmpStr += QLatin1String("</table>");
937
928
 
938
 
  tmpStr += "<p><em>" + displayViewFormatCreationDate( todo, spec ) + "</em>";
 
929
  tmpStr += QLatin1String("<p><em>")+ displayViewFormatCreationDate( todo, spec ) + QLatin1String("</em>");
939
930
 
940
931
  return tmpStr;
941
932
}
949
940
 
950
941
  QString tmpStr = displayViewFormatHeader( journal );
951
942
 
952
 
  tmpStr += "<table>";
953
 
  tmpStr += "<col width=\"25%\"/>";
954
 
  tmpStr += "<col width=\"75%\"/>";
 
943
  tmpStr += QLatin1String("<table>");
 
944
  tmpStr += QLatin1String("<col width=\"25%\"/>");
 
945
  tmpStr += QLatin1String("<col width=\"75%\"/>");
955
946
 
956
947
  const QString calStr = calendar ? resourceString( calendar, journal ) : sourceName;
957
948
  if ( !calStr.isEmpty() ) {
958
 
    tmpStr += "<tr>";
959
 
    tmpStr += "<td><b>" + i18n( "Calendar:" ) + "</b></td>";
960
 
    tmpStr += "<td>" + calStr + "</td>";
961
 
    tmpStr += "</tr>";
 
949
    tmpStr += QLatin1String("<tr>");
 
950
    tmpStr += QLatin1String("<td><b>") + i18n( "Calendar:" ) + QLatin1String("</b></td>");
 
951
    tmpStr += QLatin1String("<td>") + calStr + QLatin1String("</td>");
 
952
    tmpStr += QLatin1String("</tr>");
962
953
  }
963
954
 
964
 
  tmpStr += "<tr>";
965
 
  tmpStr += "<td><b>" + i18n( "Date:" ) + "</b></td>";
966
 
  tmpStr += "<td>" +
 
955
  tmpStr += QLatin1String("<tr>");
 
956
  tmpStr += QLatin1String("<td><b>") + i18n( "Date:" ) + QLatin1String("</b></td>");
 
957
  tmpStr += QLatin1String("<td>") +
967
958
            dateToString( journal->dtStart(), false, spec ) +
968
 
            "</td>";
969
 
  tmpStr += "</tr>";
 
959
            QLatin1String("</td>");
 
960
  tmpStr += QLatin1String("</tr>");
970
961
 
971
962
  if ( !journal->description().isEmpty() ) {
972
 
    tmpStr += "<tr>";
973
 
    tmpStr += "<td><b>" + i18n( "Description:" ) + "</b></td>";
974
 
    tmpStr += "<td>" + journal->richDescription() + "</td>";
975
 
    tmpStr += "</tr>";
 
963
    tmpStr += QLatin1String("<tr>");
 
964
    tmpStr += QLatin1String("<td><b>") + i18n( "Description:" ) + QLatin1String("</b></td>");
 
965
    tmpStr += QLatin1String("<td>") + journal->richDescription() + QLatin1String("</td>");
 
966
    tmpStr += QLatin1String("</tr>");
976
967
  }
977
968
 
978
969
  int categoryCount = journal->categories().count();
979
970
  if ( categoryCount > 0 ) {
980
 
    tmpStr += "<tr>";
981
 
    tmpStr += "<td><b>" +
 
971
    tmpStr += QLatin1String("<tr>");
 
972
    tmpStr += QLatin1String("<td><b>") +
982
973
              i18np( "Category:", "Categories:", categoryCount ) +
983
 
              "</b></td>";
984
 
    tmpStr += "<td>" + displayViewFormatCategories( journal ) + "</td>";
985
 
    tmpStr += "</tr>";
 
974
              QLatin1String("</b></td>");
 
975
    tmpStr += QLatin1String("<td>") + displayViewFormatCategories( journal ) + QLatin1String("</td>");
 
976
    tmpStr += QLatin1String("</tr>");
986
977
  }
987
978
 
988
 
  tmpStr += "</table>";
 
979
  tmpStr += QLatin1String("</table>");
989
980
 
990
 
  tmpStr += "<p><em>" + displayViewFormatCreationDate( journal, spec ) + "</em>";
 
981
  tmpStr += QLatin1String("<p><em>") + displayViewFormatCreationDate( journal, spec ) + QLatin1String("</em>");
991
982
 
992
983
  return tmpStr;
993
984
}
1003
994
 
1004
995
  QString tmpStr(
1005
996
    htmlAddTag(
1006
 
      "h2", i18n( "Free/Busy information for %1", fb->organizer()->fullName() ) ) );
 
997
      QLatin1String("h2"), i18n( "Free/Busy information for %1", fb->organizer()->fullName() ) ) );
1007
998
 
1008
 
  tmpStr += htmlAddTag( "h4",
 
999
  tmpStr += htmlAddTag( QLatin1String("h4"),
1009
1000
                        i18n( "Busy times in date range %1 - %2:",
1010
1001
                              dateToString( fb->dtStart(), true, spec ),
1011
1002
                              dateToString( fb->dtEnd(), true, spec ) ) );
1012
1003
 
1013
1004
  QString text =
1014
 
    htmlAddTag( "em",
1015
 
                htmlAddTag( "b", i18nc( "tag for busy periods list", "Busy:" ) ) );
 
1005
    htmlAddTag( QLatin1String("em"),
 
1006
                htmlAddTag( QLatin1String("b"), i18nc( "tag for busy periods list", "Busy:" ) ) );
1016
1007
 
1017
1008
  Period::List periods = fb->busyPeriods();
1018
1009
  Period::List::iterator it;
1035
1026
      text += i18nc( "startDate for duration", "%1 for %2",
1036
1027
                     dateTimeToString( per.start(), false, true, spec ),
1037
1028
                     cont );
1038
 
      text += "<br>";
 
1029
      text += QLatin1String("<br>");
1039
1030
    } else {
1040
1031
      if ( per.start().date() == per.end().date() ) {
1041
1032
        text += i18nc( "date, fromTime - toTime ", "%1, %2 - %3",
1047
1038
                       dateTimeToString( per.start(), false, true, spec ),
1048
1039
                       dateTimeToString( per.end(), false, true, spec ) );
1049
1040
      }
1050
 
      text += "<br>";
 
1041
      text += QLatin1String("<br>");
1051
1042
    }
1052
1043
  }
1053
 
  tmpStr += htmlAddTag( "p", text );
 
1044
  tmpStr += htmlAddTag( QLatin1String("p"), text );
1054
1045
  return tmpStr;
1055
1046
}
1056
1047
//@endcond
1060
1051
{
1061
1052
  public:
1062
1053
    EventViewerVisitor()
1063
 
      : mCalendar( 0 ), mSpec( KDateTime::Spec() ), mResult( "" ) {}
 
1054
      : mCalendar( 0 ), mSpec( KDateTime::Spec() ), mResult( QLatin1String("") ) {}
1064
1055
 
1065
1056
    bool act( const Calendar::Ptr &calendar, IncidenceBase::Ptr incidence, const QDate &date,
1066
1057
              KDateTime::Spec spec=KDateTime::Spec() )
1069
1060
      mSourceName.clear();
1070
1061
      mDate = date;
1071
1062
      mSpec = spec;
1072
 
      mResult = "";
 
1063
      mResult = QLatin1String("");
1073
1064
      return incidence->accept( *this, incidence );
1074
1065
    }
1075
1066
 
1079
1070
      mSourceName = sourceName;
1080
1071
      mDate = date;
1081
1072
      mSpec = spec;
1082
 
      mResult = "";
 
1073
      mResult = QLatin1String("");
1083
1074
      return incidence->accept( *this, incidence );
1084
1075
    }
1085
1076
 
1156
1147
//@cond PRIVATE
1157
1148
static QString cleanHtml( const QString &html )
1158
1149
{
1159
 
  QRegExp rx( "<body[^>]*>(.*)</body>", Qt::CaseInsensitive );
 
1150
  QRegExp rx( QLatin1String("<body[^>]*>(.*)</body>"), Qt::CaseInsensitive );
1160
1151
  rx.indexIn( html );
1161
1152
  QString body = rx.cap( 1 );
1162
1153
 
1163
 
  return Qt::escape( body.remove( QRegExp( "<[^>]*>" ) ).trimmed() );
 
1154
  return Qt::escape( body.remove( QRegExp( QLatin1String("<[^>]*>") ) ).trimmed() );
1164
1155
}
1165
1156
 
1166
1157
static QString invitationSummary( const Incidence::Ptr &incidence, bool noHtmlMode )
1227
1218
 
1228
1219
static QString htmlInvitationDetailsBegin()
1229
1220
{
1230
 
  QString dir = ( QApplication::isRightToLeft() ? "rtl" : "ltr" );
1231
 
  return QString( "<div dir=\"%1\">\n" ).arg( dir );
 
1221
  QString dir = ( QApplication::isRightToLeft() ? QLatin1String("rtl") : QLatin1String("ltr" ));
 
1222
  return QString::fromLatin1( "<div dir=\"%1\">\n" ).arg( dir );
1232
1223
}
1233
1224
 
1234
1225
static QString htmlInvitationDetailsEnd()
1235
1226
{
1236
 
  return "</div>\n";
 
1227
  return QLatin1String("</div>\n");
1237
1228
}
1238
1229
 
1239
1230
static QString htmlInvitationDetailsTableBegin()
1240
1231
{
1241
1232
 
1242
 
  return "<table cellspacing=\"4\" style=\"border-width:4px; border-style:groove\">";
 
1233
  return QLatin1String("<table cellspacing=\"4\" style=\"border-width:4px; border-style:groove\">");
1243
1234
 
1244
1235
}
1245
1236
 
1246
1237
static QString htmlInvitationDetailsTableEnd()
1247
1238
{
1248
 
  return "</table>\n";
 
1239
  return QLatin1String("</table>\n");
1249
1240
}
1250
1241
 
1251
1242
static QString diffColor()
1265
1256
static QString htmlRow( const QString &title, const QString &value )
1266
1257
{
1267
1258
  if ( !value.isEmpty() ) {
1268
 
    return "<tr><td>" + title + "</td><td>" + value + "</td></tr>\n";
 
1259
    return QLatin1String("<tr><td>") + title + QLatin1String("</td><td>") + value + QLatin1String("</td></tr>\n");
1269
1260
  } else {
1270
1261
    return QString();
1271
1262
  }
1285
1276
 
1286
1277
  // if 'value' has changed, then make a special print
1287
1278
  QString color = diffColor();
1288
 
  QString newtitle = "<font color=\"" + color + "\">" + title + "</font>";
1289
 
  QString newvalue = "<font color=\"" + color + "\">" + value + "</font>" +
1290
 
                     "&nbsp;" +
1291
 
                     "(<strike>" + oldvalue + "</strike>)";
 
1279
  QString newtitle = QLatin1String("<font color=\"") + color + QLatin1String("\">") + title + QLatin1String("</font>");
 
1280
  QString newvalue = QLatin1String("<font color=\"") + color + QLatin1String("\">") + value + QLatin1String("</font>") +
 
1281
                     QLatin1String("&nbsp;" )+
 
1282
                     QLatin1String("(<strike>") + oldvalue + QLatin1String("</strike>");
1292
1283
  return htmlRow( newtitle, newvalue );
1293
1284
 
1294
1285
}
1295
1286
 
1296
1287
static Attendee::Ptr findDelegatedFromMyAttendee( const Incidence::Ptr &incidence )
1297
1288
{
1298
 
  // Return the first attendee that was delegated-from me
 
1289
  // Return the first attendee that was delegated-from the user
1299
1290
 
1300
1291
  Attendee::Ptr attendee;
1301
1292
  if ( !incidence ) {
1302
1293
    return attendee;
1303
1294
  }
1304
1295
 
1305
 
  KEMailSettings settings;
1306
 
  QStringList profiles = settings.profiles();
1307
 
  for ( QStringList::Iterator it=profiles.begin(); it != profiles.end(); ++it ) {
1308
 
    settings.setProfile( *it );
1309
 
 
1310
 
    QString delegatorName, delegatorEmail;
1311
 
    Attendee::List attendees = incidence->attendees();
1312
 
    Attendee::List::ConstIterator it2;
1313
 
    for ( it2 = attendees.constBegin(); it2 != attendees.constEnd(); ++it2 ) {
1314
 
      Attendee::Ptr a = *it2;
1315
 
      KPIMUtils::extractEmailAddressAndName( a->delegator(), delegatorEmail, delegatorName );
1316
 
      if ( settings.getSetting( KEMailSettings::EmailAddress ) == delegatorEmail ) {
1317
 
        attendee = a;
1318
 
        break;
1319
 
      }
 
1296
  QString delegatorName, delegatorEmail;
 
1297
  Attendee::List attendees = incidence->attendees();
 
1298
  Attendee::List::ConstIterator it;
 
1299
  for ( it = attendees.constBegin(); it != attendees.constEnd(); ++it ) {
 
1300
    Attendee::Ptr a = *it;
 
1301
    KPIMUtils::extractEmailAddressAndName( a->delegator(), delegatorEmail, delegatorName );
 
1302
    if ( thatIsMe( delegatorEmail ) ) {
 
1303
      attendee = a;
 
1304
      break;
1320
1305
    }
1321
1306
  }
 
1307
 
1322
1308
  return attendee;
1323
1309
}
1324
1310
 
1325
1311
static Attendee::Ptr findMyAttendee( const Incidence::Ptr &incidence )
1326
1312
{
1327
 
  // Return the attendee for the incidence that is probably me
 
1313
  // Return the attendee for the incidence that is probably the user
1328
1314
 
1329
1315
  Attendee::Ptr attendee;
1330
1316
  if ( !incidence ) {
1331
1317
    return attendee;
1332
1318
  }
1333
1319
 
1334
 
  KEMailSettings settings;
1335
 
  QStringList profiles = settings.profiles();
1336
 
  for ( QStringList::Iterator it=profiles.begin(); it != profiles.end(); ++it ) {
1337
 
    settings.setProfile( *it );
1338
 
 
1339
 
    Attendee::List attendees = incidence->attendees();
1340
 
    Attendee::List::ConstIterator it2;
1341
 
    for ( it2 = attendees.constBegin(); it2 != attendees.constEnd(); ++it2 ) {
1342
 
      Attendee::Ptr a = *it2;
1343
 
      if ( settings.getSetting( KEMailSettings::EmailAddress ) == a->email() ) {
1344
 
        attendee = a;
1345
 
        break;
1346
 
      }
 
1320
  Attendee::List attendees = incidence->attendees();
 
1321
  Attendee::List::ConstIterator it;
 
1322
  for ( it = attendees.constBegin(); it != attendees.constEnd(); ++it ) {
 
1323
    Attendee::Ptr a = *it;
 
1324
    if ( thatIsMe( a->email() ) ) {
 
1325
      attendee = a;
 
1326
      break;
1347
1327
    }
1348
1328
  }
 
1329
 
1349
1330
  return attendee;
1350
1331
}
1351
1332
 
1429
1410
{
1430
1411
  QString noteStr;
1431
1412
  if ( !note.isEmpty() ) {
1432
 
    noteStr += "<table border=\"0\" style=\"margin-top:4px;\">";
1433
 
    noteStr += "<tr><center><td>";
 
1413
    noteStr += QLatin1String("<table border=\"0\" style=\"margin-top:4px;\">");
 
1414
    noteStr += QLatin1String("<tr><center><td>");
1434
1415
    if ( !color.isEmpty() ) {
1435
 
      noteStr += "<font color=\"" + color + "\">";
 
1416
      noteStr += QLatin1String("<font color=\"") + color + QLatin1String("\">");
1436
1417
    }
1437
1418
    if ( !title.isEmpty() ) {
1438
1419
      if ( !tag.isEmpty() ) {
1441
1422
        noteStr += title;
1442
1423
      }
1443
1424
    }
1444
 
    noteStr += "&nbsp;" + note;
 
1425
    noteStr += QLatin1String("&nbsp;)") + note;
1445
1426
    if ( !color.isEmpty() ) {
1446
 
      noteStr += "</font>";
 
1427
      noteStr += QLatin1String("</font>");
1447
1428
    }
1448
 
    noteStr += "</td></center></tr>";
1449
 
    noteStr += "</table>";
 
1429
    noteStr += QLatin1String("</td></center></tr>");
 
1430
    noteStr += QLatin1String("</table>");
1450
1431
  }
1451
1432
  return noteStr;
1452
1433
}
1469
1450
  if ( !comment.isEmpty() ) {
1470
1451
    personString = i18nc( "name (comment)", "%1 (%2)", personString, comment );
1471
1452
  }
1472
 
  personString += '\n';
 
1453
  personString += QLatin1Char('\n');
1473
1454
 
1474
1455
  // Make the mailto link
1475
1456
  if ( !email.isEmpty() ) {
1476
 
    personString += "&nbsp;" + htmlAddMailtoLink( email, printName );
 
1457
    personString += QLatin1String("&nbsp;") + htmlAddMailtoLink( email, printName );
1477
1458
  }
1478
 
  personString += '\n';
 
1459
  personString += QLatin1Char('\n');
1479
1460
 
1480
1461
  return personString;
1481
1462
}
1505
1486
        if ( noHtmlMode ) {
1506
1487
          comments[0] = cleanHtml( comments[0] );
1507
1488
        }
1508
 
        comments[0] = htmlAddTag( "p", comments[0] );
 
1489
        comments[0] = htmlAddTag( QLatin1String("p"), comments[0] );
1509
1490
      }
1510
1491
    }
1511
1492
    //else desc and comments are empty
1518
1499
          comments << string2HTML( c );
1519
1500
        } else {
1520
1501
          if ( noHtmlMode ) {
1521
 
            comments << cleanHtml( cleanHtml( "<body>" + c + "</body>" ) );
 
1502
            comments << cleanHtml( cleanHtml( QLatin1String("<body>") + c +QLatin1String( "</body>") ) );
1522
1503
          } else {
1523
1504
            comments << c;
1524
1505
          }
1539
1520
        if ( noHtmlMode ) {
1540
1521
          descr = cleanHtml( descr );
1541
1522
        }
1542
 
        descr = htmlAddTag( "p", descr );
 
1523
        descr = htmlAddTag( QLatin1String("p"), descr );
1543
1524
      }
1544
1525
    }
1545
1526
  }
1546
1527
 
1547
1528
  if( !descr.isEmpty() ) {
1548
 
    html += "<p>";
1549
 
    html += "<table border=\"0\" style=\"margin-top:4px;\">";
1550
 
    html += "<tr><td><center>" +
1551
 
            htmlAddTag( "u", i18n( "Description:" ) ) +
1552
 
            "</center></td></tr>";
1553
 
    html += "<tr><td>" + descr + "</td></tr>";
1554
 
    html += "</table>";
 
1529
    html += QLatin1String("<p>");
 
1530
    html += QLatin1String("<table border=\"0\" style=\"margin-top:4px;\">");
 
1531
    html += QLatin1String("<tr><td><center>") +
 
1532
            htmlAddTag( QLatin1String("u"), i18n( "Description:" ) ) +
 
1533
            QLatin1String("</center></td></tr>");
 
1534
    html += QLatin1String("<tr><td>") + descr + QLatin1String("</td></tr>");
 
1535
    html += QLatin1String("</table>");
1555
1536
  }
1556
1537
 
1557
1538
  if ( !comments.isEmpty() ) {
1558
 
    html += "<p>";
1559
 
    html += "<table border=\"0\" style=\"margin-top:4px;\">";
1560
 
    html += "<tr><td><center>" +
1561
 
            htmlAddTag( "u", i18n( "Comments:" ) ) +
1562
 
            "</center></td></tr>";
1563
 
    html += "<tr><td>";
 
1539
    html += QLatin1String("<p>");
 
1540
    html += QLatin1String("<table border=\"0\" style=\"margin-top:4px;\">");
 
1541
    html += QLatin1String("<tr><td><center>") +
 
1542
            htmlAddTag( QLatin1String("u"), i18n( "Comments:" ) ) +
 
1543
            QLatin1String("</center></td></tr>");
 
1544
    html += QLatin1String("<tr><td>");
1564
1545
    if ( comments.count() > 1 ) {
1565
 
      html += "<ul>";
 
1546
      html += QLatin1String("<ul>");
1566
1547
      for ( int i=0; i < comments.count(); ++i ) {
1567
 
        html += "<li>" + comments[i] + "</li>";
 
1548
        html += QLatin1String("<li>") + comments[i] + QLatin1String("</li>");
1568
1549
      }
1569
 
      html += "</ul>";
 
1550
      html += QLatin1String("</ul>");
1570
1551
    } else {
1571
1552
      html += comments[0];
1572
1553
    }
1573
 
    html += "</td></tr>";
1574
 
    html += "</table>";
 
1554
    html += QLatin1String("</td></tr>");
 
1555
    html += QLatin1String("</table>");
1575
1556
  }
1576
1557
  return html;
1577
1558
}
1597
1578
    if ( !event->allDay() ) {
1598
1579
      html += htmlRow( i18n( "Time:" ),
1599
1580
                       timeToString( event->dtStart(), true, spec ) +
1600
 
                       " - " +
 
1581
                       QLatin1String(" - ") +
1601
1582
                       timeToString( event->dtEnd(), true, spec ) );
1602
1583
    }
1603
1584
  } else {
1646
1627
 
1647
1628
  // Print extra info typically dependent on the iTIP
1648
1629
  if ( message->method() == iTIPDeclineCounter ) {
1649
 
    html += "<br>";
 
1630
    html += QLatin1String("<br>");
1650
1631
    html += invitationNote( QString(),
1651
1632
                            i18n( "Please respond again to the original proposal." ),
1652
1633
                            QString(), noteColor() );
1671
1652
    QString spanStr, oldspanStr;
1672
1653
    if ( !event->allDay() ) {
1673
1654
      spanStr = timeToString( event->dtStart(), true, spec ) +
1674
 
                " - " +
 
1655
                QLatin1String(" - ") +
1675
1656
                timeToString( event->dtEnd(), true, spec );
1676
1657
    }
1677
1658
    if ( !oldevent->allDay() ) {
1678
1659
      oldspanStr = timeToString( oldevent->dtStart(), true, spec ) +
1679
 
                   " - " +
 
1660
                   QLatin1String(" - ") +
1680
1661
                   timeToString( oldevent->dtEnd(), true, spec );
1681
1662
    }
1682
1663
    html += htmlRow( i18n( "Time:" ), spanStr, oldspanStr );
1747
1728
  html += htmlRow( i18n( "What:" ), invitationSummary( todo, noHtmlMode ) );
1748
1729
  html += htmlRow( i18n( "Where:" ), invitationLocation( todo, noHtmlMode ) );
1749
1730
 
1750
 
  if ( todo->hasStartDate() && todo->dtStart().isValid() ) {
 
1731
  if ( todo->hasStartDate() ) {
1751
1732
    html += htmlRow( i18n( "Start Date:" ), dateToString( todo->dtStart(), false, spec ) );
1752
1733
    if ( !todo->allDay() ) {
1753
1734
      html += htmlRow( i18n( "Start Time:" ), timeToString( todo->dtStart(), false, spec ) );
1754
1735
    }
1755
1736
  }
1756
 
  if ( todo->hasDueDate() && todo->dtDue().isValid() ) {
 
1737
  if ( todo->hasDueDate() ) {
1757
1738
    html += htmlRow( i18n( "Due Date:" ), dateToString( todo->dtDue(), false, spec ) );
1758
1739
    if ( !todo->allDay() ) {
1759
1740
      html += htmlRow( i18n( "Due Time:" ), timeToString( todo->dtDue(), false, spec ) );
1794
1775
 
1795
1776
  // Print extra info typically dependent on the iTIP
1796
1777
  if ( message->method() == iTIPDeclineCounter ) {
1797
 
    html += "<br>";
 
1778
    html += QLatin1String("<br>");
1798
1779
    html += invitationNote( QString(),
1799
1780
                            i18n( "Please respond again to the original proposal." ),
1800
1781
                            QString(), noteColor() );
1811
1792
                   invitationLocation( todo, noHtmlMode ),
1812
1793
                   invitationLocation( oldtodo, noHtmlMode ) );
1813
1794
 
1814
 
  if ( todo->hasStartDate() && todo->dtStart().isValid() ) {
 
1795
  if ( todo->hasStartDate() ) {
1815
1796
    html += htmlRow( i18n( "Start Date:" ),
1816
1797
                     dateToString( todo->dtStart(), false, spec ),
1817
1798
                     dateToString( oldtodo->dtStart(), false, spec ) );
1824
1805
    }
1825
1806
    html += htmlRow( i18n( "Start Time:" ), startTimeStr, oldstartTimeStr );
1826
1807
  }
1827
 
  if ( todo->hasDueDate() && todo->dtDue().isValid() ) {
 
1808
  if ( todo->hasDueDate() ) {
1828
1809
    html += htmlRow( i18n( "Due Date:" ),
1829
1810
                     dateToString( todo->dtDue(), false, spec ),
1830
1811
                     dateToString( oldtodo->dtDue(), false, spec ) );
1839
1820
  } else {
1840
1821
    QString dueStr = i18nc( "Due Date: None", "None" );
1841
1822
    QString olddueStr;
1842
 
    if ( !oldtodo->hasDueDate() || !oldtodo->dtDue().isValid() ) {
 
1823
    if ( !oldtodo->hasDueDate() ) {
1843
1824
      olddueStr = i18nc( "Due Date: None", "None" );
1844
1825
   } else {
1845
1826
      olddueStr = dateTimeToString( oldtodo->dtDue(), oldtodo->allDay(), false );
1932
1913
  html += htmlRow( i18n( "Start date:" ), dateToString( fb->dtStart(), true, spec ) );
1933
1914
  html += htmlRow( i18n( "End date:" ), dateToString( fb->dtEnd(), true, spec ) );
1934
1915
 
1935
 
  html += "<tr><td colspan=2><hr></td></tr>\n";
1936
 
  html += "<tr><td colspan=2>Busy periods given in this free/busy object:</td></tr>\n";
 
1916
  html += QLatin1String("<tr><td colspan=2><hr></td></tr>\n");
 
1917
  html += QLatin1String("<tr><td colspan=2>Busy periods given in this free/busy object:</td></tr>\n");
1937
1918
 
1938
1919
  Period::List periods = fb->busyPeriods();
1939
1920
  Period::List::iterator it;
2419
2400
      if ( !iamAttendee( a ) ) {
2420
2401
        count++;
2421
2402
        if ( count == 1 ) {
2422
 
          tmpStr += "<table border=\"1\" cellpadding=\"1\" cellspacing=\"0\">";
 
2403
          tmpStr += QLatin1String("<table border=\"1\" cellpadding=\"1\" cellspacing=\"0\">");
2423
2404
        }
2424
 
        tmpStr += "<tr>";
2425
 
        tmpStr += "<td>";
 
2405
        tmpStr += QLatin1String("<tr>");
 
2406
        tmpStr += QLatin1String("<td>");
2426
2407
        comments.clear();
2427
2408
        if ( attendeeIsOrganizer( incidence, a ) ) {
2428
2409
          comments << i18n( "organizer" );
2433
2414
        if ( !a->delegate().isEmpty() ) {
2434
2415
          comments << i18n( " (delegated to %1)", a->delegate() );
2435
2416
        }
2436
 
        tmpStr += invitationPerson( a->email(), a->name(), QString(), comments.join( "," ) );
2437
 
        tmpStr += "</td>";
2438
 
        tmpStr += "</tr>";
 
2417
        tmpStr += invitationPerson( a->email(), a->name(), QString(), comments.join( QLatin1String(",") ) );
 
2418
        tmpStr += QLatin1String("</td>");
 
2419
        tmpStr += QLatin1String("</tr>");
2439
2420
      }
2440
2421
    }
2441
2422
  }
2442
2423
  if ( count ) {
2443
 
    tmpStr += "</table>";
 
2424
    tmpStr += QLatin1String("</table>");
2444
2425
  } else {
2445
2426
    tmpStr.clear();
2446
2427
  }
2480
2461
        }
2481
2462
        count++;
2482
2463
        if ( count == 1 ) {
2483
 
          tmpStr += "<table border=\"1\" cellpadding=\"1\" cellspacing=\"0\">";
 
2464
          tmpStr += QLatin1String("<table border=\"1\" cellpadding=\"1\" cellspacing=\"0\">");
2484
2465
        }
2485
 
        tmpStr += "<tr>";
2486
 
        tmpStr += "<td>";
 
2466
        tmpStr += QLatin1String("<tr>");
 
2467
        tmpStr += QLatin1String("<td>");
2487
2468
        comments.clear();
2488
2469
        if ( iamAttendee( a ) ) {
2489
2470
          comments << i18n( "myself" );
2494
2475
        if ( !a->delegate().isEmpty() ) {
2495
2476
          comments << i18n( " (delegated to %1)", a->delegate() );
2496
2477
        }
2497
 
        tmpStr += invitationPerson( a->email(), a->name(), QString(), comments.join( "," ) );
2498
 
        tmpStr += "</td>";
2499
 
        tmpStr += "<td>" + statusStr + "</td>";
2500
 
        tmpStr += "</tr>";
 
2478
        tmpStr += invitationPerson( a->email(), a->name(), QString(), comments.join( QLatin1String(",")) );
 
2479
        tmpStr += QLatin1String("</td>");
 
2480
        tmpStr += QLatin1String("<td>" )+ statusStr + QLatin1String("</td>");
 
2481
        tmpStr += QLatin1String("</tr>");
2501
2482
      }
2502
2483
    }
2503
2484
  }
2504
2485
  if ( count ) {
2505
 
    tmpStr += "</table>";
 
2486
    tmpStr += QLatin1String("</table>");
2506
2487
  } else {
2507
 
    tmpStr += "<i> " + i18nc( "no attendees", "None" ) + "</i>";
 
2488
    tmpStr += QLatin1String("<i> ") + i18nc( "no attendees", "None" ) + QLatin1String("</i>");
2508
2489
  }
2509
2490
 
2510
2491
  return tmpStr;
2525
2506
 
2526
2507
  Attachment::List attachments = incidence->attachments();
2527
2508
  if ( !attachments.isEmpty() ) {
2528
 
    tmpStr += i18n( "Attached Documents:" ) + "<ol>";
 
2509
    tmpStr += i18n( "Attached Documents:" ) + QLatin1String("<ol>");
2529
2510
 
2530
2511
    Attachment::List::ConstIterator it;
2531
2512
    for ( it = attachments.constBegin(); it != attachments.constEnd(); ++it ) {
2532
2513
      Attachment::Ptr a = *it;
2533
 
      tmpStr += "<li>";
 
2514
      tmpStr += QLatin1String("<li>");
2534
2515
      // Attachment icon
2535
2516
      KMimeType::Ptr mimeType = KMimeType::mimeType( a->mimeType() );
2536
2517
      const QString iconStr = ( mimeType ?
2537
2518
                                mimeType->iconName( a->uri() ) :
2538
 
                                QString( "application-octet-stream" ) );
 
2519
                                QLatin1String( "application-octet-stream" ) );
2539
2520
      const QString iconPath = KIconLoader::global()->iconPath( iconStr, KIconLoader::Small );
2540
2521
      if ( !iconPath.isEmpty() ) {
2541
 
        tmpStr += "<img valign=\"top\" src=\"" + iconPath + "\">";
 
2522
        tmpStr += QLatin1String("<img valign=\"top\" src=\"") + iconPath + QLatin1String("\">");
2542
2523
      }
2543
 
      tmpStr += helper->makeLink( "ATTACH:" + a->label().toUtf8().toBase64(), a->label() );
2544
 
      tmpStr += "</li>";
 
2524
      tmpStr += helper->makeLink( QLatin1String("ATTACH:") + QLatin1String(a->label().toUtf8().toBase64()), a->label() );
 
2525
      tmpStr += QLatin1String("</li>");
2545
2526
    }
2546
 
    tmpStr += "</ol>";
 
2527
    tmpStr += QLatin1String("</ol>");
2547
2528
  }
2548
2529
 
2549
2530
  return tmpStr;
2553
2534
class KCalUtils::IncidenceFormatter::ScheduleMessageVisitor : public Visitor
2554
2535
{
2555
2536
  public:
2556
 
    ScheduleMessageVisitor() : mMessage( 0 ) { mResult = ""; }
 
2537
    ScheduleMessageVisitor() : mMessage( 0 ) { mResult = QLatin1String(""); }
2557
2538
    bool act( const IncidenceBase::Ptr &incidence,
2558
2539
              const Incidence::Ptr &existingIncidence,
2559
2540
              ScheduleMessage::Ptr msg, const QString &sender )
2675
2656
      if ( mChanges.isEmpty() ) {
2676
2657
        return QString();
2677
2658
      }
2678
 
      QString html = "<div align=\"left\"><ul><li>";
2679
 
      html += mChanges.join( "</li><li>" );
2680
 
      html += "</li><ul></div>";
 
2659
      QString html = QLatin1String("<div align=\"left\"><ul><li>");
 
2660
      html += mChanges.join( QLatin1String("</li><li>") );
 
2661
      html += QLatin1String("</li><ul></div>");
2681
2662
      return html;
2682
2663
    }
2683
2664
 
2828
2809
QString InvitationFormatterHelper::makeLink( const QString &id, const QString &text )
2829
2810
{
2830
2811
  if ( !id.startsWith( QLatin1String( "ATTACH:" ) ) ) {
2831
 
    QString res = QString( "<a href=\"%1\"><font size=\"-1\"><b>%2</b></font></a>" ).
 
2812
    QString res = QString::fromLatin1( "<a href=\"%1\"><font size=\"-1\"><b>%2</b></font></a>" ).
2832
2813
                  arg( generateLinkURL( id ), text );
2833
2814
    return res;
2834
2815
  } else {
2835
2816
    // draw the attachment links in non-bold face
2836
 
    QString res = QString( "<a href=\"%1\">%2</a>" ).
 
2817
    QString res = QString::fromLatin1( "<a href=\"%1\">%2</a>" ).
2837
2818
                  arg( generateLinkURL( id ), text );
2838
2819
    return res;
2839
2820
  }
2857
2838
    return html;
2858
2839
  }
2859
2840
 
2860
 
  html += "<td style=\"border-width:2px;border-style:outset\">";
 
2841
  html += QLatin1String("<td style=\"border-width:2px;border-style:outset\">");
2861
2842
  if ( !id.isEmpty() ) {
2862
2843
    html += helper->makeLink( id, text );
2863
2844
  } else {
2864
2845
    html += text;
2865
2846
  }
2866
 
  html += "</td>";
 
2847
  html += QLatin1String("</td>");
2867
2848
  return html;
2868
2849
}
2869
2850
 
2891
2872
 
2892
2873
  if ( !rsvpReq && ( incidence && incidence->revision() == 0 ) ) {
2893
2874
    // Record only
2894
 
    html += inviteButton( helper, "record", i18n( "Record" ) );
 
2875
    html += inviteButton( helper, QLatin1String("record"), i18n( "Record" ) );
2895
2876
 
2896
2877
    // Move to trash
2897
 
    html += inviteButton( helper, "delete", i18n( "Move to Trash" ) );
 
2878
    html += inviteButton( helper, QLatin1String("delete"), i18n( "Move to Trash" ) );
2898
2879
 
2899
2880
  } else {
2900
2881
 
2901
2882
    // Accept
2902
 
    html += inviteButton( helper, "accept",
 
2883
    html += inviteButton( helper, QLatin1String("accept"),
2903
2884
                          i18nc( "accept invitation", "Accept" ) );
2904
2885
 
2905
2886
    // Tentative
2906
 
    html += inviteButton( helper, "accept_conditionally",
 
2887
    html += inviteButton( helper, QLatin1String("accept_conditionally"),
2907
2888
                          i18nc( "Accept invitation conditionally", "Accept cond." ) );
2908
2889
 
2909
2890
    // Counter proposal
2910
 
    html += inviteButton( helper, "counter",
 
2891
    html += inviteButton( helper, QLatin1String("counter"),
2911
2892
                          i18nc( "invitation counter proposal", "Counter proposal" ) );
2912
2893
 
2913
2894
    // Decline
2914
 
    html += inviteButton( helper, "decline",
 
2895
    html += inviteButton( helper, QLatin1String("decline"),
2915
2896
                          i18nc( "decline invitation", "Decline" ) );
2916
2897
  }
2917
2898
 
2918
2899
  if ( !rsvpRec || ( incidence && incidence->revision() > 0 ) ) {
2919
2900
    // Delegate
2920
 
    html += inviteButton( helper, "delegate",
 
2901
    html += inviteButton( helper, QLatin1String("delegate"),
2921
2902
                          i18nc( "delegate inviation to another", "Delegate" ) );
2922
2903
 
2923
2904
    // Forward
2924
 
    html += inviteButton( helper, "forward", i18nc( "forward request to another", "Forward" ) );
 
2905
    html += inviteButton( helper, QLatin1String("forward"), i18nc( "forward request to another", "Forward" ) );
2925
2906
 
2926
2907
    // Check calendar
2927
2908
    if ( incidence && incidence->type() == Incidence::TypeEvent ) {
2928
 
      html += inviteButton( helper, "check_calendar",
 
2909
      html += inviteButton( helper, QLatin1String("check_calendar"),
2929
2910
                            i18nc( "look for scheduling conflicts", "Check my calendar" ) );
2930
2911
    }
2931
2912
  }
2941
2922
  }
2942
2923
 
2943
2924
  // Accept proposal
2944
 
  html += inviteButton( helper, "accept_counter", i18n( "Accept" ) );
 
2925
  html += inviteButton( helper, QLatin1String("accept_counter"), i18n( "Accept" ) );
2945
2926
 
2946
2927
  // Decline proposal
2947
 
  html += inviteButton( helper, "decline_counter", i18n( "Decline" ) );
 
2928
  html += inviteButton( helper, QLatin1String("decline_counter"), i18n( "Decline" ) );
2948
2929
 
2949
2930
  // Check calendar
2950
2931
  if ( incidence ) {
2951
2932
    if ( incidence->type() == Incidence::TypeTodo ) {
2952
 
      html += inviteButton( helper, "check_calendar", i18n( "Check my to-do list" ) );
 
2933
      html += inviteButton( helper, QLatin1String("check_calendar"), i18n( "Check my to-do list" ) );
2953
2934
    } else {
2954
 
      html += inviteButton( helper, "check_calendar", i18n( "Check my calendar" ) );
 
2935
      html += inviteButton( helper, QLatin1String("check_calendar"), i18n( "Check my calendar" ) );
2955
2936
    }
2956
2937
  }
2957
2938
  return html;
2967
2948
 
2968
2949
  if ( incidence ) {
2969
2950
    if ( incidence->type() == Incidence::TypeTodo ) {
2970
 
      html += inviteLink( helper, "reply",
 
2951
      html += inviteLink( helper, QLatin1String("reply"),
2971
2952
                          i18n( "Record invitation in my to-do list" ) );
2972
2953
    } else {
2973
 
      html += inviteLink( helper, "reply",
 
2954
      html += inviteLink( helper, QLatin1String("reply"),
2974
2955
                          i18n( "Record invitation in my calendar" ) );
2975
2956
    }
2976
2957
  }
2987
2968
 
2988
2969
  if ( incidence ) {
2989
2970
    if ( incidence->type() == Incidence::TypeTodo ) {
2990
 
      html += inviteLink( helper, "reply",
 
2971
      html += inviteLink( helper, QLatin1String("reply"),
2991
2972
                          i18n( "Record response in my to-do list" ) );
2992
2973
    } else {
2993
 
      html += inviteLink( helper, "reply",
 
2974
      html += inviteLink( helper, QLatin1String("reply"),
2994
2975
                          i18n( "Record response in my calendar" ) );
2995
2976
    }
2996
2977
  }
3008
2989
  // Remove invitation
3009
2990
  if ( incidence ) {
3010
2991
    if ( incidence->type() == Incidence::TypeTodo ) {
3011
 
      html += inviteButton( helper, "cancel",
 
2992
      html += inviteButton( helper, QLatin1String("cancel"),
3012
2993
                            i18n( "Remove invitation from my to-do list" ) );
3013
2994
    } else {
3014
 
      html += inviteButton( helper, "cancel",
 
2995
      html += inviteButton( helper, QLatin1String("cancel"),
3015
2996
                            i18n( "Remove invitation from my calendar" ) );
3016
2997
    }
3017
2998
  }
3081
3062
  }
3082
3063
 
3083
3064
  // First make the text of the message
3084
 
  QString html;
3085
 
  html += "<div align=\"center\" style=\"border:solid 1px;\">";
 
3065
  QString html = QLatin1String("<div align=\"center\" style=\"border:solid 1px;\">");
3086
3066
 
3087
3067
  IncidenceFormatter::InvitationHeaderVisitor headerVisitor;
3088
3068
  // The InvitationHeaderVisitor returns false if the incidence is somehow invalid, or not handled
3089
3069
  if ( !headerVisitor.act( inc, existingIncidence, msg, sender ) ) {
3090
3070
    return QString();
3091
3071
  }
3092
 
  html += htmlAddTag( "h3", headerVisitor.result() );
 
3072
  html += htmlAddTag( QLatin1String("h3"), headerVisitor.result() );
3093
3073
 
3094
3074
  if ( outlookCompareStyle ||
3095
3075
       msg->method() == iTIPDeclineCounter ) { //use Outlook style for decline
3123
3103
    if ( msg->method() == iTIPRequest ) {
3124
3104
      IncidenceFormatter::IncidenceCompareVisitor compareVisitor;
3125
3105
      if ( compareVisitor.act( inc, existingIncidence ) ) {
3126
 
        html += "<p align=\"left\">";
 
3106
        html += QLatin1String("<p align=\"left\">");
3127
3107
        if ( senderIsOrganizer( inc, sender ) ) {
3128
3108
          html += i18n( "The following changes have been made by the organizer:" );
3129
3109
        } else if ( !sender.isEmpty() ) {
3131
3111
        } else {
3132
3112
          html += i18n( "The following changes have been made:" );
3133
3113
        }
3134
 
        html += "</p>";
 
3114
        html += QLatin1String("</p>");
3135
3115
        html += compareVisitor.result();
3136
3116
      }
3137
3117
    }
3138
3118
    if ( msg->method() == iTIPReply ) {
3139
3119
      IncidenceCompareVisitor compareVisitor;
3140
3120
      if ( compareVisitor.act( inc, existingIncidence ) ) {
3141
 
        html += "<p align=\"left\">";
 
3121
        html += QLatin1String("<p align=\"left\">");
3142
3122
        if ( !sender.isEmpty() ) {
3143
3123
          html += i18n( "The following changes have been made by %1:", sender );
3144
3124
        } else {
3145
3125
          html += i18n( "The following changes have been made by an attendee:" );
3146
3126
        }
3147
 
        html += "</p>";
 
3127
        html += QLatin1String("</p>");
3148
3128
        html += compareVisitor.result();
3149
3129
      }
3150
3130
    }
3213
3193
        tStr = i18n( "Awaiting delegation response" );
3214
3194
      }
3215
3195
    }
3216
 
    html += "<br>";
3217
 
    html += "<i><u>" + tStr + "</u></i>";
 
3196
    html += QLatin1String("<br>");
 
3197
    html += QLatin1String("<i><u>") + tStr + QLatin1String("</u></i>");
3218
3198
  }
3219
3199
 
3220
3200
  // Print if the organizer gave you a preset status
3222
3202
    if ( inc && incRevision == 0 ) {
3223
3203
      QString statStr = myStatusStr( inc );
3224
3204
      if ( !statStr.isEmpty() ) {
3225
 
        html += "<br>";
3226
 
        html += "<i>" + statStr + "</i>";
 
3205
        html += QLatin1String("<br>");
 
3206
        html += QLatin1String("<i>") + statStr + QLatin1String("</i>");
3227
3207
      }
3228
3208
    }
3229
3209
  }
3230
3210
 
3231
3211
  // Add groupware links
3232
3212
 
3233
 
  html += "<p>";
3234
 
  html += "<table border=\"0\" align=\"center\" cellspacing=\"4\"><tr>";
 
3213
  html += QLatin1String("<p>");
 
3214
  html += QLatin1String("<table border=\"0\" align=\"center\" cellspacing=\"4\"><tr>");
3235
3215
 
3236
3216
  switch ( msg->method() ) {
3237
3217
    case iTIPPublish:
3265
3245
      if ( inc ) {
3266
3246
        // First, determine if this reply is really a counter in disguise.
3267
3247
        if ( replyMeansCounter( inc ) ) {
3268
 
          html += "<tr>" + counterButtons( inc, helper ) + "</tr>";
 
3248
          html += QLatin1String("<tr>") + counterButtons( inc, helper ) + QLatin1String("</tr>");
3269
3249
          break;
3270
3250
        }
3271
3251
 
3294
3274
      if ( ea && ( ea->status() != Attendee::NeedsAction ) && ( ea->status() == a->status() ) ) {
3295
3275
        const QString tStr = i18n( "The <b>%1</b> response has been recorded",
3296
3276
                                   Stringify::attendeeStatus( ea->status() ) );
3297
 
        html += inviteButton( helper, QString(), htmlAddTag( "i", tStr ) );
 
3277
        html += inviteButton( helper, QString(), htmlAddTag( QLatin1String("i"), tStr ) );
3298
3278
      } else {
3299
3279
        if ( inc ) {
3300
3280
          html += recordResponseButtons( inc, helper );
3317
3297
  }
3318
3298
 
3319
3299
  // close the groupware table
3320
 
  html += "</tr></table>";
 
3300
  html += QLatin1String("</tr></table>");
3321
3301
 
3322
3302
  // Add the attendee list
3323
3303
  if ( myInc ) {
3327
3307
  }
3328
3308
 
3329
3309
  // close the top-level table
3330
 
  html += "</div>";
 
3310
  html += QLatin1String("</div>");
3331
3311
 
3332
3312
  // Add the attachment list
3333
3313
  html += invitationAttachments( helper, inc );
3366
3346
{
3367
3347
  public:
3368
3348
    ToolTipVisitor()
3369
 
      : mRichText( true ), mSpec( KDateTime::Spec() ), mResult( "" ) {}
 
3349
      : mRichText( true ), mSpec( KDateTime::Spec() ), mResult( QLatin1String("") ) {}
3370
3350
 
3371
3351
    bool act( const MemoryCalendar::Ptr &calendar,
3372
3352
              const IncidenceBase::Ptr &incidence,
3378
3358
      mDate = date;
3379
3359
      mRichText = richText;
3380
3360
      mSpec = spec;
3381
 
      mResult = "";
 
3361
      mResult = QLatin1String("");
3382
3362
      return incidence ? incidence->accept( *this, incidence ) : false;
3383
3363
    }
3384
3364
 
3390
3370
      mDate = date;
3391
3371
      mRichText = richText;
3392
3372
      mSpec = spec;
3393
 
      mResult = "";
 
3373
      mResult = QLatin1String("");
3394
3374
      return incidence ? incidence->accept( *this, incidence ) : false;
3395
3375
    }
3396
3376
 
3445
3425
 
3446
3426
  if ( event->isMultiDay() ) {
3447
3427
    tmp = dateToString( startDt, true, mSpec );
3448
 
    ret += "<br>" + i18nc( "Event start", "<i>From:</i> %1", tmp );
 
3428
    ret += QLatin1String("<br>") + i18nc( "Event start", "<i>From:</i> %1", tmp );
3449
3429
 
3450
3430
    tmp = dateToString( endDt, true, mSpec );
3451
 
    ret += "<br>" + i18nc( "Event end","<i>To:</i> %1", tmp );
 
3431
    ret += QLatin1String("<br>") + i18nc( "Event end","<i>To:</i> %1", tmp );
3452
3432
 
3453
3433
  } else {
3454
3434
 
3455
 
    ret += "<br>" +
 
3435
    ret += QLatin1String("<br>") +
3456
3436
           i18n( "<i>Date:</i> %1", dateToString( startDt, false, mSpec ) );
3457
3437
    if ( !event->allDay() ) {
3458
3438
      const QString dtStartTime = timeToString( startDt, true, mSpec );
3459
3439
      const QString dtEndTime = timeToString( endDt, true, mSpec );
3460
3440
      if ( dtStartTime == dtEndTime ) {
3461
3441
        // to prevent 'Time: 17:00 - 17:00'
3462
 
        tmp = "<br>" +
 
3442
        tmp = QLatin1String("<br>") +
3463
3443
              i18nc( "time for event", "<i>Time:</i> %1",
3464
3444
                     dtStartTime );
3465
3445
      } else {
3466
 
        tmp = "<br>" +
 
3446
        tmp = QLatin1String("<br>") +
3467
3447
              i18nc( "time range for event",
3468
3448
                     "<i>Time:</i> %1 - %2",
3469
3449
                     dtStartTime, dtEndTime );
3471
3451
      ret += tmp;
3472
3452
    }
3473
3453
  }
3474
 
  return ret.replace( ' ', "&nbsp;" );
 
3454
  return ret.replace( QLatin1Char(' '), QLatin1String("&nbsp;") );
3475
3455
}
3476
3456
 
3477
3457
QString IncidenceFormatter::ToolTipVisitor::dateRangeText( const Todo::Ptr &todo,
3479
3459
{
3480
3460
  //FIXME: support mRichText==false
3481
3461
  QString ret;
3482
 
  if ( todo->hasStartDate() && todo->dtStart().isValid() ) {
 
3462
  if ( todo->hasStartDate() ) {
3483
3463
    KDateTime startDt = todo->dtStart();
3484
 
    if ( todo->recurs() ) {
3485
 
      if ( date.isValid() ) {
3486
 
        startDt.setDate( date );
3487
 
      }
 
3464
    if ( todo->recurs() && date.isValid() ) {
 
3465
      startDt.setDate( date );
3488
3466
    }
3489
 
    ret += "<br>" +
 
3467
    ret += QLatin1String("<br>") +
3490
3468
           i18n( "<i>Start:</i> %1", dateToString( startDt, false, mSpec ) );
3491
3469
  }
3492
3470
 
3493
 
  if ( todo->hasDueDate() && todo->dtDue().isValid() ) {
 
3471
  if ( todo->hasDueDate() ) {
3494
3472
    KDateTime dueDt = todo->dtDue();
3495
 
    if ( todo->recurs() ) {
3496
 
      if ( date.isValid() ) {
3497
 
        KDateTime kdt( date, QTime( 0, 0, 0 ), KSystemTimeZones::local() );
3498
 
        kdt = kdt.addSecs( -1 );
3499
 
        dueDt.setDate( todo->recurrence()->getNextDateTime( kdt ).date() );
3500
 
      }
 
3473
    if ( todo->recurs() && date.isValid() ) {
 
3474
      KDateTime kdt( date, QTime( 0, 0, 0 ), KSystemTimeZones::local() );
 
3475
      kdt = kdt.addSecs( -1 );
 
3476
      dueDt.setDate( todo->recurrence()->getNextDateTime( kdt ).date() );
3501
3477
    }
3502
 
    ret += "<br>" +
 
3478
    ret += QLatin1String("<br>") +
3503
3479
           i18n( "<i>Due:</i> %1",
3504
3480
                 dateTimeToString( dueDt, todo->allDay(), false, mSpec ) );
3505
3481
  }
3507
3483
  // Print priority and completed info here, for lack of a better place
3508
3484
 
3509
3485
  if ( todo->priority() > 0 ) {
3510
 
    ret += "<br>";
3511
 
    ret += "<i>" + i18n( "Priority:" ) + "</i>" + "&nbsp;";
 
3486
    ret += QLatin1String("<br>");
 
3487
    ret += QLatin1String("<i>") + i18n( "Priority:" ) + QLatin1String("</i>") + QLatin1String("&nbsp;");
3512
3488
    ret += QString::number( todo->priority() );
3513
3489
  }
3514
3490
 
3515
 
  ret += "<br>";
 
3491
  ret += QLatin1String("<br>");
3516
3492
  if ( todo->isCompleted() ) {
3517
 
    ret += "<i>" + i18nc( "Completed: date", "Completed:" ) + "</i>" + "&nbsp;";
3518
 
    ret += Stringify::todoCompletedDateTime( todo ).replace( ' ', "&nbsp;" );
 
3493
    ret += QLatin1String("<i>") + i18nc( "Completed: date", "Completed:" ) + QLatin1String("</i>") + QLatin1String("&nbsp;");
 
3494
    ret += Stringify::todoCompletedDateTime( todo ).replace( QLatin1Char(' '), QLatin1String("&nbsp;") );
3519
3495
  } else {
3520
 
    ret += "<i>" + i18n( "Percent Done:" ) + "</i>" + "&nbsp;";
 
3496
    ret += QLatin1String("<i>" )+ i18n( "Percent Done:" ) + QLatin1String("</i>") + QLatin1String("&nbsp;");
3521
3497
    ret += i18n( "%1%", todo->percentComplete() );
3522
3498
  }
3523
3499
 
3524
 
  return ret.replace( ' ', "&nbsp;" );
 
3500
  return ret.replace( QLatin1Char(' '), QLatin1String("&nbsp;") );
3525
3501
}
3526
3502
 
3527
3503
QString IncidenceFormatter::ToolTipVisitor::dateRangeText( const Journal::Ptr &journal )
3529
3505
  //FIXME: support mRichText==false
3530
3506
  QString ret;
3531
3507
  if ( journal->dtStart().isValid() ) {
3532
 
    ret += "<br>" +
 
3508
    ret += QLatin1String("<br>") +
3533
3509
           i18n( "<i>Date:</i> %1", dateToString( journal->dtStart(), false, mSpec ) );
3534
3510
  }
3535
 
  return ret.replace( ' ', "&nbsp;" );
 
3511
  return ret.replace( QLatin1Char(' '), QLatin1String("&nbsp;") );
3536
3512
}
3537
3513
 
3538
3514
QString IncidenceFormatter::ToolTipVisitor::dateRangeText( const FreeBusy::Ptr &fb )
3539
3515
{
3540
3516
  //FIXME: support mRichText==false
3541
3517
  QString ret;
3542
 
  ret = "<br>" +
 
3518
  ret = QLatin1String("<br>") +
3543
3519
        i18n( "<i>Period start:</i> %1",
3544
3520
              KGlobal::locale()->formatDateTime( fb->dtStart().dateTime() ) );
3545
 
  ret += "<br>" +
 
3521
  ret += QLatin1String("<br>") +
3546
3522
         i18n( "<i>Period start:</i> %1",
3547
3523
               KGlobal::locale()->formatDateTime( fb->dtEnd().dateTime() ) );
3548
 
  return ret.replace( ' ', "&nbsp;" );
 
3524
  return ret.replace( QLatin1Char(' '), QLatin1String("&nbsp;") );
3549
3525
}
3550
3526
 
3551
3527
bool IncidenceFormatter::ToolTipVisitor::visit( Event::Ptr event )
3569
3545
bool IncidenceFormatter::ToolTipVisitor::visit( FreeBusy::Ptr fb )
3570
3546
{
3571
3547
  //FIXME: support mRichText==false
3572
 
  mResult = "<qt><b>" +
 
3548
  mResult = QLatin1String("<qt><b>") +
3573
3549
            i18n( "Free/Busy information for %1", fb->organizer()->fullName() ) +
3574
 
            "</b>";
 
3550
            QLatin1String("</b>");
3575
3551
  mResult += dateRangeText( fb );
3576
 
  mResult += "</qt>";
 
3552
  mResult += QLatin1String("</qt>");
3577
3553
  return !mResult.isEmpty();
3578
3554
}
3579
3555
 
3588
3564
  // Make the return string.
3589
3565
  QString personString;
3590
3566
  if ( !iconPath.isEmpty() ) {
3591
 
    personString += "<img valign=\"top\" src=\"" + iconPath + "\">" + "&nbsp;";
 
3567
    personString += QLatin1String("<img valign=\"top\" src=\"") + iconPath + QLatin1String("\">") + QLatin1String("&nbsp;");
3592
3568
  }
3593
3569
  if ( status != Attendee::None ) {
3594
3570
    personString += i18nc( "attendee name (attendee status)", "%1 (%2)",
3607
3583
 
3608
3584
  // Get the icon for organizer
3609
3585
  const QString iconPath =
3610
 
    KIconLoader::global()->iconPath( "meeting-organizer", KIconLoader::Small );
 
3586
    KIconLoader::global()->iconPath( QLatin1String("meeting-organizer"), KIconLoader::Small );
3611
3587
 
3612
3588
  // Make the return string.
3613
3589
  QString personString;
3614
 
  personString += "<img valign=\"top\" src=\"" + iconPath + "\">" + "&nbsp;";
 
3590
  personString += QLatin1String("<img valign=\"top\" src=\"") + iconPath + QLatin1String("\">") + QLatin1String("&nbsp;");
3615
3591
  personString += ( printName.isEmpty() ? email : printName );
3616
3592
  return personString;
3617
3593
}
3638
3614
      continue;
3639
3615
    }
3640
3616
    if ( i == maxNumAtts ) {
3641
 
      tmpStr += "&nbsp;&nbsp;" + etc;
 
3617
      tmpStr += QLatin1String("&nbsp;&nbsp;") + etc;
3642
3618
      break;
3643
3619
    }
3644
 
    tmpStr += "&nbsp;&nbsp;" + tooltipPerson( a->email(), a->name(),
 
3620
    tmpStr += QLatin1String("&nbsp;&nbsp;") + tooltipPerson( a->email(), a->name(),
3645
3621
                                              showStatus ? a->status() : Attendee::None );
3646
3622
    if ( !a->delegator().isEmpty() ) {
3647
3623
      tmpStr += i18n( " (delegated by %1)", a->delegator() );
3649
3625
    if ( !a->delegate().isEmpty() ) {
3650
3626
      tmpStr += i18n( " (delegated to %1)", a->delegate() );
3651
3627
    }
3652
 
    tmpStr += "<br>";
 
3628
    tmpStr += QLatin1String("<br>");
3653
3629
    i++;
3654
3630
  }
3655
3631
  if ( tmpStr.endsWith( QLatin1String( "<br>" ) ) ) {
3668
3644
  if ( attendeeCount > 1 ||
3669
3645
       ( attendeeCount == 1 &&
3670
3646
         !attendeeIsOrganizer( incidence, incidence->attendees().first() ) ) ) {
3671
 
    tmpStr += "<i>" + i18n( "Organizer:" ) + "</i>" + "<br>";
3672
 
    tmpStr += "&nbsp;&nbsp;" + tooltipFormatOrganizer( incidence->organizer()->email(),
 
3647
    tmpStr += QLatin1String("<i>") + i18n( "Organizer:" ) + QLatin1String("</i>") + QLatin1String("<br>");
 
3648
    tmpStr += QLatin1String("&nbsp;&nbsp;") + tooltipFormatOrganizer( incidence->organizer()->email(),
3673
3649
                                                       incidence->organizer()->name() );
3674
3650
  }
3675
3651
 
3680
3656
  // Add "chair"
3681
3657
  str = tooltipFormatAttendeeRoleList( incidence, Attendee::Chair, showStatus );
3682
3658
  if ( !str.isEmpty() ) {
3683
 
    tmpStr += "<br><i>" + i18n( "Chair:" ) + "</i>" + "<br>";
 
3659
    tmpStr += QLatin1String("<br><i>") + i18n( "Chair:" ) + QLatin1String("</i>") + QLatin1String("<br>");
3684
3660
    tmpStr += str;
3685
3661
  }
3686
3662
 
3687
3663
  // Add required participants
3688
3664
  str = tooltipFormatAttendeeRoleList( incidence, Attendee::ReqParticipant, showStatus );
3689
3665
  if ( !str.isEmpty() ) {
3690
 
    tmpStr += "<br><i>" + i18n( "Required Participants:" ) + "</i>" + "<br>";
 
3666
    tmpStr += QLatin1String("<br><i>") + i18n( "Required Participants:" ) + QLatin1String("</i>") + QLatin1String("<br>");
3691
3667
    tmpStr += str;
3692
3668
  }
3693
3669
 
3694
3670
  // Add optional participants
3695
3671
  str = tooltipFormatAttendeeRoleList( incidence, Attendee::OptParticipant, showStatus );
3696
3672
  if ( !str.isEmpty() ) {
3697
 
    tmpStr += "<br><i>" + i18n( "Optional Participants:" ) + "</i>" + "<br>";
 
3673
    tmpStr += QLatin1String("<br><i>") + i18n( "Optional Participants:" ) + QLatin1String("</i>") + QLatin1String("<br>");
3698
3674
    tmpStr += str;
3699
3675
  }
3700
3676
 
3701
3677
  // Add observers
3702
3678
  str = tooltipFormatAttendeeRoleList( incidence, Attendee::NonParticipant, showStatus );
3703
3679
  if ( !str.isEmpty() ) {
3704
 
    tmpStr += "<br><i>" + i18n( "Observers:" ) + "</i>" + "<br>";
 
3680
    tmpStr += QLatin1String("<br><i>") + i18n( "Observers:" ) + QLatin1String("</i>") + QLatin1String("<br>");
3705
3681
    tmpStr += str;
3706
3682
  }
3707
3683
 
3718
3694
    return QString();
3719
3695
  }
3720
3696
 
3721
 
  QString tmp = "<qt>";
 
3697
  QString tmp = QLatin1String("<qt>");
3722
3698
 
3723
3699
  // header
3724
 
  tmp += "<b>" + incidence->richSummary() + "</b>";
3725
 
  tmp += "<hr>";
 
3700
  tmp += QLatin1String("<b>") + incidence->richSummary() + QLatin1String("</b>");
 
3701
  tmp += QLatin1String("<hr>");
3726
3702
 
3727
3703
  QString calStr = mLocation;
3728
3704
  if ( mCalendar ) {
3729
3705
    calStr = resourceString( mCalendar, incidence );
3730
3706
  }
3731
3707
  if ( !calStr.isEmpty() ) {
3732
 
    tmp += "<i>" + i18n( "Calendar:" ) + "</i>" + "&nbsp;";
 
3708
    tmp += QLatin1String("<i>") + i18n( "Calendar:" ) + QLatin1String("</i>") + QLatin1String("&nbsp;");
3733
3709
    tmp += calStr;
3734
3710
  }
3735
3711
 
3736
3712
  tmp += dtRangeText;
3737
3713
 
3738
3714
  if ( !incidence->location().isEmpty() ) {
3739
 
    tmp += "<br>";
3740
 
    tmp += "<i>" + i18n( "Location:" ) + "</i>" + "&nbsp;";
 
3715
    tmp += QLatin1String("<br>");
 
3716
    tmp += QLatin1String("<i>") + i18n( "Location:" ) + QLatin1String("</i>") + QLatin1String("&nbsp;");
3741
3717
    tmp += incidence->richLocation();
3742
3718
  }
3743
3719
 
3744
3720
  QString durStr = durationString( incidence );
3745
3721
  if ( !durStr.isEmpty() ) {
3746
 
    tmp += "<br>";
3747
 
    tmp += "<i>" + i18n( "Duration:" ) + "</i>" + "&nbsp;";
 
3722
    tmp += QLatin1String("<br>");
 
3723
    tmp += QLatin1String("<i>") + i18n( "Duration:" ) + QLatin1String("</i>") + QLatin1String("&nbsp;");
3748
3724
    tmp += durStr;
3749
3725
  }
3750
3726
 
3751
3727
  if ( incidence->recurs() ) {
3752
 
    tmp += "<br>";
3753
 
    tmp += "<i>" + i18n( "Recurrence:" ) + "</i>" + "&nbsp;";
 
3728
    tmp += QLatin1String("<br>");
 
3729
    tmp += QLatin1String("<i>") + i18n( "Recurrence:" ) + QLatin1String("</i>") + QLatin1String("&nbsp;");
3754
3730
    tmp += recurrenceString( incidence );
3755
3731
  }
3756
3732
 
3757
3733
  if ( incidence->hasRecurrenceId() ) {
3758
 
    tmp += "<br>";
3759
 
    tmp += "<i>" + i18n( "Recurrence:" ) + "</i>" + "&nbsp;";
 
3734
    tmp += QLatin1String("<br>");
 
3735
    tmp += QLatin1String("<i>") + i18n( "Recurrence:" ) + QLatin1String("</i>") + QLatin1String("&nbsp;");
3760
3736
    tmp += i18n( "Exception" );
3761
3737
  }
3762
3738
 
3766
3742
      if ( desc.length() > maxDescLen ) {
3767
3743
        desc = desc.left( maxDescLen ) + i18nc( "elipsis", "..." );
3768
3744
      }
3769
 
      desc = Qt::escape( desc ).replace( '\n', "<br>" );
 
3745
      desc = Qt::escape( desc ).replace( QLatin1Char('\n'), QLatin1String("<br>") );
3770
3746
    } else {
3771
3747
      // TODO: truncate the description when it's rich text
3772
3748
    }
3773
 
    tmp += "<hr>";
3774
 
    tmp += "<i>" + i18n( "Description:" ) + "</i>" + "<br>";
 
3749
    tmp += QLatin1String("<hr>");
 
3750
    tmp += QLatin1String("<i>") + i18n( "Description:" ) + QLatin1String("</i>") + QLatin1String("<br>");
3775
3751
    tmp += desc;
3776
 
    tmp += "<hr>";
 
3752
    tmp += QLatin1String("<hr>");
3777
3753
  }
3778
3754
 
3779
3755
  int reminderCount = incidence->alarms().count();
3780
3756
  if ( reminderCount > 0 && incidence->hasEnabledAlarms() ) {
3781
 
    tmp += "<br>";
3782
 
    tmp += "<i>" + i18np( "Reminder:", "Reminders:", reminderCount ) + "</i>" + "&nbsp;";
3783
 
    tmp += reminderStringList( incidence ).join( ", " );
 
3757
    tmp += QLatin1String("<br>");
 
3758
    tmp += QLatin1String("<i>") + i18np( "Reminder:", "Reminders:", reminderCount ) + QLatin1String("</i>") + QLatin1String("&nbsp;");
 
3759
    tmp += reminderStringList( incidence ).join( QLatin1String(", ") );
3784
3760
  }
3785
3761
 
3786
 
  tmp += "<br>";
 
3762
  tmp += QLatin1String("<br>");
3787
3763
  tmp += tooltipFormatAttendees( mCalendar, incidence );
3788
3764
 
3789
3765
  int categoryCount = incidence->categories().count();
3790
3766
  if ( categoryCount > 0 ) {
3791
 
    tmp += "<br>";
3792
 
    tmp += "<i>" + i18np( "Category:", "Categories:", categoryCount ) + "</i>" + "&nbsp;";
3793
 
    tmp += incidence->categories().join( ", " );
 
3767
    tmp += QLatin1String("<br>");
 
3768
    tmp += QLatin1String("<i>") + i18np( "Category:", "Categories:", categoryCount ) + QLatin1String("</i>") +QLatin1String( "&nbsp;");
 
3769
    tmp += incidence->categories().join( QLatin1String(", ") );
3794
3770
  }
3795
3771
 
3796
 
  tmp += "</qt>";
 
3772
  tmp += QLatin1String("</qt>");
3797
3773
  return tmp;
3798
3774
}
3799
3775
//@endcond
3838
3814
{
3839
3815
  public:
3840
3816
    MailBodyVisitor()
3841
 
      : mSpec( KDateTime::Spec() ), mResult( "" ) {}
 
3817
      : mSpec( KDateTime::Spec() ), mResult( QLatin1String("") ) {}
3842
3818
 
3843
3819
    bool act( IncidenceBase::Ptr incidence, KDateTime::Spec spec=KDateTime::Spec() )
3844
3820
    {
3845
3821
      mSpec = spec;
3846
 
      mResult = "";
 
3822
      mResult = QLatin1String("");
3847
3823
      return incidence ? incidence->accept( *this, incidence ) : false;
3848
3824
    }
3849
3825
    QString result() const
3899
3875
 
3900
3876
    if ( recur->duration() > 0 ) {
3901
3877
      mResult += i18np( "Repeats once", "Repeats %1 times", recur->duration() );
3902
 
      mResult += '\n';
 
3878
      mResult += QLatin1Char('\n');
3903
3879
    } else {
3904
3880
      if ( recur->duration() != -1 ) {
3905
3881
// TODO_Recurrence: What to do with all-day
3993
3969
 
3994
3970
QString IncidenceFormatter::recurrenceString( const Incidence::Ptr &incidence )
3995
3971
{
 
3972
  if ( incidence->hasRecurrenceId() ) {
 
3973
    return QLatin1String( "Recurrence exception" );
 
3974
  }
 
3975
 
3996
3976
  if ( !incidence->recurs() ) {
3997
3977
    return i18n( "No recurrence" );
3998
3978
  }
4387
4367
  }
4388
4368
 
4389
4369
  if ( !exStr.isEmpty() ) {
4390
 
    recurStr = i18n( "%1 (excluding %2)", recurStr, exStr.join( "," ) );
 
4370
    recurStr = i18n( "%1 (excluding %2)", recurStr, exStr.join( QLatin1String(",") ) );
4391
4371
  }
4392
4372
 
4393
4373
  return recurStr;
4401
4381
 
4402
4382
    QString timeZone;
4403
4383
    if ( spec.timeZone() != KSystemTimeZones::local() ) {
4404
 
      timeZone = ' ' + spec.timeZone().name();
 
4384
      timeZone = QLatin1Char(' ') + spec.timeZone().name();
4405
4385
    }
4406
4386
 
4407
4387
    return KGlobal::locale()->formatTime( date.toTimeSpec( spec ).time(), !shortfmt ) + timeZone;
4418
4398
 
4419
4399
    QString timeZone;
4420
4400
    if ( spec.timeZone() != KSystemTimeZones::local() ) {
4421
 
      timeZone = ' ' + spec.timeZone().name();
 
4401
      timeZone = QLatin1Char(' ') + spec.timeZone().name();
4422
4402
    }
4423
4403
 
4424
4404
    return
4444
4424
  if ( spec.isValid() ) {
4445
4425
    QString timeZone;
4446
4426
    if ( spec.timeZone() != KSystemTimeZones::local() ) {
4447
 
      timeZone = ' ' + spec.timeZone().name();
 
4427
      timeZone = QLatin1Char(' ') + spec.timeZone().name();
4448
4428
    }
4449
4429
 
4450
4430
    return KGlobal::locale()->formatDateTime(
4471
4451
  int days = secs / 86400;
4472
4452
  if ( days > 0 ) {
4473
4453
    tmp += i18np( "1 day", "%1 days", days );
4474
 
    tmp += ' ';
 
4454
    tmp += QLatin1Char(' ');
4475
4455
    secs -= ( days * 86400 );
4476
4456
  }
4477
4457
  int hours = secs / 3600;
4478
4458
  if ( hours > 0 ) {
4479
4459
    tmp += i18np( "1 hour", "%1 hours", hours );
4480
 
    tmp += ' ';
 
4460
    tmp += QLatin1Char(' ');
4481
4461
    secs -= ( hours * 3600 );
4482
4462
  }
4483
4463
  int mins = secs / 60;
4600
4580
                                     secs2Duration( alarm->snoozeTime().asSeconds() ) );
4601
4581
        QString repeatStr = i18nc( "(repeat string, interval string)",
4602
4582
                                   "(%1, %2)", countStr, intervalStr );
4603
 
        remStr = remStr + ' ' + repeatStr;
 
4583
        remStr = remStr + QLatin1Char(' ') + repeatStr;
4604
4584
 
4605
4585
      }
4606
4586
      reminderStringList << remStr;