• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.14.10 API Reference
  • KDE Home
  • Contact Us
 

KCalUtils Library

  • KCalUtils
  • IncidenceFormatter
Functions
KCalUtils::IncidenceFormatter Namespace Reference

Functions

KCALUTILS_EXPORT QString dateTimeToString (const KDateTime &date, bool dateOnly=false, bool shortfmt=true, const KDateTime::Spec &spec=KDateTime::Spec())
 
KCALUTILS_EXPORT QString dateToString (const KDateTime &date, bool shortfmt=true, const KDateTime::Spec &spec=KDateTime::Spec())
 
KCALUTILS_EXPORT QString durationString (const KCalCore::Incidence::Ptr &incidence)
 
KCALUTILS_EXPORT QString extensiveDisplayStr (const KCalCore::Calendar::Ptr &calendar, const KCalCore::IncidenceBase::Ptr &incidence, const QDate &date=QDate(), KDateTime::Spec spec=KDateTime::Spec())
 
KCALUTILS_EXPORT QString extensiveDisplayStr (const QString &sourceName, const KCalCore::IncidenceBase::Ptr &incidence, const QDate &date=QDate(), KDateTime::Spec spec=KDateTime::Spec())
 
KCALUTILS_EXPORT QString formatICalInvitation (QString invitation, const KCalCore::MemoryCalendar::Ptr &calendar, InvitationFormatterHelper *helper, bool outlookCompareStyle)
 
KCALUTILS_EXPORT QString formatICalInvitationNoHtml (const QString &invitation, const KCalCore::MemoryCalendar::Ptr &calendar, InvitationFormatterHelper *helper, const QString &sender, bool outlookCompareStyle)
 
KCALUTILS_EXPORT QString incidenceStatusName (KCalCore::Incidence::Status status)
 
KCALUTILS_EXPORT QString incidenceStatusStr (const KCalCore::Incidence::Ptr &incidence)
 
KCALUTILS_EXPORT QString mailBodyStr (const KCalCore::IncidenceBase::Ptr &incidence, KDateTime::Spec spec=KDateTime::Spec())
 
KCALUTILS_EXPORT QString recurrenceString (const KCalCore::Incidence::Ptr &incidence)
 
KCALUTILS_EXPORT QStringList reminderStringList (const KCalCore::Incidence::Ptr &incidence, bool shortfmt=true)
 
KCALUTILS_EXPORT QString resourceString (const KCalCore::Calendar::Ptr &calendar, const KCalCore::Incidence::Ptr &incidence)
 
KCALUTILS_EXPORT QString timeToString (const KDateTime &date, bool shortfmt=true, const KDateTime::Spec &spec=KDateTime::Spec())
 
KCALUTILS_EXPORT QString toolTipStr (const QString &sourceName, const KCalCore::IncidenceBase::Ptr &incidence, const QDate &date=QDate(), bool richText=true, KDateTime::Spec spec=KDateTime::Spec())
 

Detailed Description

Provides methods to format Incidences in various ways for display purposes.

Helpers that provides several static methods to format an Incidence in different ways: like an HTML representation for KMail, a representation for tool tips, or a representation for a viewer widget.

Function Documentation

◆ dateTimeToString()

QString KCalUtils::IncidenceFormatter::dateTimeToString ( const KDateTime &  date,
bool  dateOnly = false,
bool  shortfmt = true,
const KDateTime::Spec &  spec = KDateTime::Spec() 
)

Build a QString date/time representation of a KDateTime object.

Parameters
dateThe date to be formatted.
dateOnlyIf true, don't print the time fields; print the date fields only.
shortfmtIf true, display info in short format.
specTime spec to use.
See also
dateToString(), timeToString().

Definition at line 4455 of file incidenceformatter.cpp.

◆ dateToString()

QString KCalUtils::IncidenceFormatter::dateToString ( const KDateTime &  date,
bool  shortfmt = true,
const KDateTime::Spec &  spec = KDateTime::Spec() 
)

Build a QString date representation of a KDateTime object.

Parameters
dateThe date to be formatted.
shortfmtIf true, display info in short format.
specTime spec to use.
See also
dateToString(), dateTimeToString().

Definition at line 4433 of file incidenceformatter.cpp.

◆ durationString()

QString KCalUtils::IncidenceFormatter::durationString ( const KCalCore::Incidence::Ptr &  incidence)

Returns a duration string computed for the specified Incidence.

Only makes sense for Events and Todos.

Parameters
incidenceis a pointer to the Incidence.

Definition at line 4510 of file incidenceformatter.cpp.

◆ extensiveDisplayStr() [1/2]

KCALUTILS_EXPORT QString KCalUtils::IncidenceFormatter::extensiveDisplayStr ( const KCalCore::Calendar::Ptr &  calendar,
const KCalCore::IncidenceBase::Ptr &  incidence,
const QDate &  date = QDate(),
KDateTime::Spec  spec = KDateTime::Spec() 
)

Create a RichText QString representation of an Incidence in a nice format suitable for using in a viewer widget.

Parameters
calendaris a pointer to the Calendar that owns the specified Incidence.
incidenceis a pointer to the Incidence to be formatted.
dateis the QDate for which the string representation should be computed; used mainly for recurring incidences.
specis an optional time specification which, when specified, will shift the Incidence times to different timezones.

◆ extensiveDisplayStr() [2/2]

KCALUTILS_EXPORT QString KCalUtils::IncidenceFormatter::extensiveDisplayStr ( const QString &  sourceName,
const KCalCore::IncidenceBase::Ptr &  incidence,
const QDate &  date = QDate(),
KDateTime::Spec  spec = KDateTime::Spec() 
)

Create a RichText QString representation of an Incidence in a nice format suitable for using in a viewer widget.

Parameters
sourceNamewhere the incidence is from (e.g. resource name)
incidenceis a pointer to the Incidence to be formatted.
dateis the QDate for which the string representation should be computed; used mainly for recurring incidences.
specis an optional time specification which, when specified, will shift the Incidence times to different timezones.

◆ formatICalInvitation()

KCALUTILS_EXPORT QString KCalUtils::IncidenceFormatter::formatICalInvitation ( QString  invitation,
const KCalCore::MemoryCalendar::Ptr &  calendar,
InvitationFormatterHelper *  helper,
bool  outlookCompareStyle 
)

Deliver an HTML formatted string displaying an invitation.

Use the time zone from mCalendar.

Parameters
invitationa QString containing a string representation of a calendar Incidence which will be intrepreted as an invitation.
calendaris a pointer to the Calendar that owns the invitation.
helperis a pointer to an InvitationFormatterHelper.
outlookCompareStyleif true, display updated invitation comparisons in the style of Microsoft Outlook (tm); else use our own "classic" style.

◆ formatICalInvitationNoHtml()

KCALUTILS_EXPORT QString KCalUtils::IncidenceFormatter::formatICalInvitationNoHtml ( const QString &  invitation,
const KCalCore::MemoryCalendar::Ptr &  calendar,
InvitationFormatterHelper *  helper,
const QString &  sender,
bool  outlookCompareStyle 
)

Deliver an HTML formatted string displaying an invitation.

Differs from formatICalInvitation() in that invitation details (summary, location, etc) have HTML formatting cleaned. Use the time zone from calendar.

Parameters
invitationa QString containing a string representation of a calendar Incidence which will be intrepreted as an invitation.
calendaris a pointer to the Calendar that owns the invitation.
helperis a pointer to an InvitationFormatterHelper.
senderis a QString containing the email address of the person sending the invitation.
outlookCompareStyleif true, display updated invitation comparisons in the style of Microsoft Outlook (tm); else use our own "classic" style.

◆ incidenceStatusName()

KCALUTILS_EXPORT QString KCalUtils::IncidenceFormatter::incidenceStatusName ( KCalCore::Incidence::Status  status)

Returns the translated string form of a specified #Status.

Parameters
statusis a #Status type.

◆ incidenceStatusStr()

KCALUTILS_EXPORT QString KCalUtils::IncidenceFormatter::incidenceStatusStr ( const KCalCore::Incidence::Ptr &  incidence)

Returns a translatedstatus string for this incidence.

◆ mailBodyStr()

QString KCalUtils::IncidenceFormatter::mailBodyStr ( const KCalCore::IncidenceBase::Ptr &  incidence,
KDateTime::Spec  spec = KDateTime::Spec() 
)

Create a QString representation of an Incidence in format suitable for including inside a mail message.

Parameters
incidenceis a pointer to the Incidence to be formatted.
specis an optional time specification which, when specified, will shift the Incidence times to different timezones.

Definition at line 3979 of file incidenceformatter.cpp.

◆ recurrenceString()

QString KCalUtils::IncidenceFormatter::recurrenceString ( const KCalCore::Incidence::Ptr &  incidence)

Build a pretty QString representation of an Incidence's recurrence info.

Parameters
incidenceis a pointer to the Incidence whose recurrence info is to be formatted.

Definition at line 4010 of file incidenceformatter.cpp.

◆ reminderStringList()

QStringList KCalUtils::IncidenceFormatter::reminderStringList ( const KCalCore::Incidence::Ptr &  incidence,
bool  shortfmt = true 
)

Returns a reminder string computed for the specified Incidence.

Each item of the returning QStringList corresponds to a string representation of an reminder belonging to this incidence.

Parameters
incidenceis a pointer to the Incidence.
shortfmtif false, a short version of each reminder is printed; else a longer version of each reminder is printed.

Definition at line 4541 of file incidenceformatter.cpp.

◆ resourceString()

QString KCalUtils::IncidenceFormatter::resourceString ( const KCalCore::Calendar::Ptr &  calendar,
const KCalCore::Incidence::Ptr &  incidence 
)

Returns a Calendar Resource label name for the specified Incidence.

Parameters
calendaris a pointer to the Calendar.
incidenceis a pointer to the Incidence.

Definition at line 4480 of file incidenceformatter.cpp.

◆ timeToString()

QString KCalUtils::IncidenceFormatter::timeToString ( const KDateTime &  date,
bool  shortfmt = true,
const KDateTime::Spec &  spec = KDateTime::Spec() 
)

Build a QString time representation of a KDateTime object.

Parameters
dateThe date to be formatted.
shortfmtIf true, display info in short format.
specTime spec to use.
See also
dateToString(), dateTimeToString().

Definition at line 4416 of file incidenceformatter.cpp.

◆ toolTipStr()

QString KCalUtils::IncidenceFormatter::toolTipStr ( const QString &  sourceName,
const KCalCore::IncidenceBase::Ptr &  incidence,
const QDate &  date = QDate(),
bool  richText = true,
KDateTime::Spec  spec = KDateTime::Spec() 
)

Create a QString representation of an Incidence in a nice format suitable for using in a tooltip.

QString IncidenceFormatter::extensiveDisplayStr(const Calendar::Ptr &calendar, const IncidenceBase::Ptr &incidence, const QDate &date, KDateTime::Spec spec) { if (!incidence) { return QString(); }.

Parameters
sourceNamewhere the incidence is from (e.g. resource name)
incidenceis a pointer to the Incidence to be formatted.
dateis the QDate for which the toolTip should be computed; used mainly for recurring incidences. Note: For to-dos, this is the due date of the occurrence, not the start date.
richTextif yes, the QString will be created as RichText.
specis an optional time specification which, when specified, will shift the Incidence times to different timezones.

EventViewerVisitor v; if (v.act(calendar, incidence, date, spec)) { return v.result(); } else { return QString(); } }

QString IncidenceFormatter::extensiveDisplayStr(const QString &sourceName, const IncidenceBase::Ptr &incidence, const QDate &date, KDateTime::Spec spec) { if (!incidence) { return QString(); }

EventViewerVisitor v; if (v.act(sourceName, incidence, date, spec)) { return v.result(); } else { return QString(); } } /*********************************************************************** Helper functions for the body part formatter of kmail (Invitations) static QString invitationAttendeeList(const Incidence::Ptr &incidence) { RAIIIdentityManager raiiHelper;

QString tmpStr; if (!incidence) { return tmpStr; } if (incidence->type() == Incidence::TypeTodo) { tmpStr += i18n("Assignees"); } else { tmpStr += i18n("Invitation List"); }

int count=0; Attendee::List attendees = incidence->attendees(); if (!attendees.isEmpty()) { QStringList comments; Attendee::List::ConstIterator it; for (it = attendees.constBegin(); it != attendees.constEnd(); ++it) { Attendee::Ptr a = *it; if (!iamAttendee(a)) { count++; if (count == 1) { tmpStr += QLatin1String("<table border=\"1\" cellpadding=\"1\" cellspacing=\"0\">"); } tmpStr += QLatin1String("<tr>"); tmpStr += QLatin1String("<td>"); comments.clear(); if (attendeeIsOrganizer(incidence, a)) { comments << i18n("organizer"); } if (!a->delegator().isEmpty()) { comments << i18n(" (delegated by %1)", a->delegator()); } if (!a->delegate().isEmpty()) { comments << i18n(" (delegated to %1)", a->delegate()); } tmpStr += invitationPerson(a->email(), a->name(), QString(), comments.join(QLatin1String(","))); tmpStr += QLatin1String("</td>"); tmpStr += QLatin1String("</tr>"); } } } if (count) { tmpStr += QLatin1String("</table>"); } else { tmpStr.clear(); }

return tmpStr; }

static QString invitationRsvpList(const Incidence::Ptr &incidence, const Attendee::Ptr &sender) { QString tmpStr; if (!incidence) { return tmpStr; } if (incidence->type() == Incidence::TypeTodo) { tmpStr += i18n("Assignees"); } else { tmpStr += i18n("Invitation List"); }

int count=0; Attendee::List attendees = incidence->attendees(); if (!attendees.isEmpty()) { QStringList comments; Attendee::List::ConstIterator it; for (it = attendees.constBegin(); it != attendees.constEnd(); ++it) { Attendee::Ptr a = *it; if (!attendeeIsOrganizer(incidence, a)) { QString statusStr = Stringify::attendeeStatus(a->status()); if (sender && (a->email() == sender->email())) { use the attendee taken from the response incidence, rather than the attendee from the calendar incidence. if (a->status() != sender->status()) { statusStr = i18n("%1 (<i>unrecorded</i>)", Stringify::attendeeStatus(sender->status())); } a = sender; } count++; if (count == 1) { tmpStr += QLatin1String("<table border=\"1\" cellpadding=\"1\" cellspacing=\"0\">"); } tmpStr += QLatin1String("<tr>"); tmpStr += QLatin1String("<td>"); comments.clear(); if (iamAttendee(a)) { comments << i18n("myself"); } if (!a->delegator().isEmpty()) { comments << i18n(" (delegated by %1)", a->delegator()); } if (!a->delegate().isEmpty()) { comments << i18n(" (delegated to %1)", a->delegate()); } tmpStr += invitationPerson(a->email(), a->name(), QString(), comments.join(QLatin1String(","))); tmpStr += QLatin1String("</td>"); tmpStr += QLatin1String("<td>")+ statusStr + QLatin1String("</td>"); tmpStr += QLatin1String("</tr>"); } } } if (count) { tmpStr += QLatin1String("</table>"); } else { tmpStr += QLatin1String("<i> ") + i18nc("no attendees", "None") + QLatin1String("</i>"); }

return tmpStr; }

static QString invitationAttachments(InvitationFormatterHelper *helper, const Incidence::Ptr &incidence) { QString tmpStr; if (!incidence) { return tmpStr; }

if (incidence->type() == Incidence::TypeFreeBusy) { A FreeBusy does not have a valid attachment due to the static-cast from IncidenceBase return tmpStr; }

Attachment::List attachments = incidence->attachments(); if (!attachments.isEmpty()) { tmpStr += i18n("Attached Documents:") + QLatin1String("<ol>");

Attachment::List::ConstIterator it; for (it = attachments.constBegin(); it != attachments.constEnd(); ++it) { Attachment::Ptr a = *it; tmpStr += QLatin1String("<li>"); Attachment icon KMimeType::Ptr mimeType = KMimeType::mimeType(a->mimeType()); const QString iconStr = (mimeType ? mimeType->iconName(a->uri()) : QLatin1String("application-octet-stream")); const QString iconPath = KIconLoader::global()->iconPath(iconStr, KIconLoader::Small); if (!iconPath.isEmpty()) { tmpStr += QLatin1String("<img valign=\"top\" src=\"") + iconPath + QLatin1String("\">"); } tmpStr += helper->makeLink(QLatin1String("ATTACH:") + QLatin1String(a->label().toUtf8().toBase64()), a->label()); tmpStr += QLatin1String("</li>"); } tmpStr += QLatin1String("</ol>"); }

return tmpStr; }

InvitationFormatterHelper::InvitationFormatterHelper() : d(0) { }

InvitationFormatterHelper::~InvitationFormatterHelper() { }

QString InvitationFormatterHelper::generateLinkURL(const QString &id) { return id; }

QString InvitationFormatterHelper::makeLink(const QString &id, const QString &text) { if (!id.startsWith(QLatin1String("ATTACH:"))) { QString res = QString::fromLatin1("<a href=\"%1\"><font size=\"-1\"><b>%2</b></font></a>"). arg(generateLinkURL(id), text); return res; } else { draw the attachment links in non-bold face QString res = QString::fromLatin1("<a href=\"%1\">%2</a>"). arg(generateLinkURL(id), text); return res; } }

Check if the given incidence is likely one that we own instead one from a shared calendar (Kolab-specific) static bool incidenceOwnedByMe(const Calendar::Ptr &calendar, const Incidence::Ptr &incidence) { Q_UNUSED(calendar); Q_UNUSED(incidence); return true; }

static QString inviteButton(InvitationFormatterHelper *helper, const QString &id, const QString &text) { QString html; if (!helper) { return html; }

html += QLatin1String("<td style=\"border-width:2px;border-style:outset\">"); if (!id.isEmpty()) { html += helper->makeLink(id, text); } else { html += text; } html += QLatin1String("</td>"); return html; }

static QString inviteLink(InvitationFormatterHelper *helper, const QString &id, const QString &text) { QString html;

if (helper && !id.isEmpty()) { html += helper->makeLink(id, text); } else { html += text; } return html; }

static QString responseButtons(const Incidence::Ptr &incidence, bool rsvpReq, bool rsvpRec, InvitationFormatterHelper *helper) { QString html; if (!helper) { return html; }

if (!rsvpReq && (incidence && incidence->revision() == 0)) { Record only html += inviteButton(helper, QLatin1String("record"), i18n("Record"));

Move to trash html += inviteButton(helper, QLatin1String("delete"), i18n("Move to Trash"));

} else {

Accept html += inviteButton(helper, QLatin1String("accept"), i18nc("accept invitation", "Accept"));

Tentative html += inviteButton(helper, QLatin1String("accept_conditionally"), i18nc("Accept invitation conditionally", "Accept cond."));

Counter proposal html += inviteButton(helper, QLatin1String("counter"), i18nc("invitation counter proposal", "Counter proposal"));

Decline html += inviteButton(helper, QLatin1String("decline"), i18nc("decline invitation", "Decline")); }

if (!rsvpRec || (incidence && incidence->revision() > 0)) { Delegate html += inviteButton(helper, QLatin1String("delegate"), i18nc("delegate inviation to another", "Delegate"));

Forward html += inviteButton(helper, QLatin1String("forward"), i18nc("forward request to another", "Forward"));

Check calendar if (incidence && incidence->type() == Incidence::TypeEvent) { html += inviteButton(helper, QLatin1String("check_calendar"), i18nc("look for scheduling conflicts", "Check my calendar")); } } return html; }

static QString counterButtons(const Incidence::Ptr &incidence, InvitationFormatterHelper *helper) { QString html; if (!helper) { return html; }

Accept proposal html += inviteButton(helper, QLatin1String("accept_counter"), i18n("Accept"));

Decline proposal html += inviteButton(helper, QLatin1String("decline_counter"), i18n("Decline"));

Check calendar if (incidence) { if (incidence->type() == Incidence::TypeTodo) { html += inviteButton(helper, QLatin1String("check_calendar"), i18n("Check my to-do list")); } else { html += inviteButton(helper, QLatin1String("check_calendar"), i18n("Check my calendar")); } } return html; }

static QString recordButtons(const Incidence::Ptr &incidence, InvitationFormatterHelper *helper) { QString html; if (!helper) { return html; }

if (incidence) { if (incidence->type() == Incidence::TypeTodo) { html += inviteLink(helper, QLatin1String("reply"), i18n("Record invitation in my to-do list")); } else { html += inviteLink(helper, QLatin1String("reply"), i18n("Record invitation in my calendar")); } } return html; }

static QString recordResponseButtons(const Incidence::Ptr &incidence, InvitationFormatterHelper *helper) { QString html; if (!helper) { return html; }

if (incidence) { if (incidence->type() == Incidence::TypeTodo) { html += inviteLink(helper, QLatin1String("reply"), i18n("Record response in my to-do list")); } else { html += inviteLink(helper, QLatin1String("reply"), i18n("Record response in my calendar")); } } return html; }

static QString cancelButtons(const Incidence::Ptr &incidence, InvitationFormatterHelper *helper) { QString html; if (!helper) { return html; }

Remove invitation if (incidence) { if (incidence->type() == Incidence::TypeTodo) { html += inviteButton(helper, QLatin1String("cancel"), i18n("Remove invitation from my to-do list")); } else { html += inviteButton(helper, QLatin1String("cancel"), i18n("Remove invitation from my calendar")); } } return html; }

Calendar::Ptr InvitationFormatterHelper::calendar() const { return Calendar::Ptr(); }

static QString formatICalInvitationHelper(QString invitation, const MemoryCalendar::Ptr &mCalendar, InvitationFormatterHelper *helper, bool noHtmlMode, KDateTime::Spec spec, const QString &sender, bool outlookCompareStyle) { if (invitation.isEmpty()) { return QString(); }

ICalFormat format; parseScheduleMessage takes the tz from the calendar, no need to set it manually here for the format! ScheduleMessage::Ptr msg = format.parseScheduleMessage(mCalendar, invitation);

if (!msg) { kDebug() << "Failed to parse the scheduling message"; Q_ASSERT(format.exception()); kDebug() << Stringify::errorMessage(*format.exception()); //krazy:exclude=kdebug return QString(); }

IncidenceBase::Ptr incBase = msg->event();

incBase->shiftTimes(mCalendar->timeSpec(), KDateTime::Spec::LocalZone());

Determine if this incidence is in my calendar (and owned by me) Incidence::Ptr existingIncidence; if (incBase && helper->calendar()) { existingIncidence = helper->calendar()->incidence(incBase->uid());

if (!incidenceOwnedByMe(helper->calendar(), existingIncidence)) { existingIncidence.clear(); } if (!existingIncidence) { const Incidence::List list = helper->calendar()->incidences(); for (Incidence::List::ConstIterator it = list.begin(), end = list.end(); it != end; ++it) { if ((*it)->schedulingID() == incBase->uid() && incidenceOwnedByMe(helper->calendar(), *it)) { existingIncidence = *it; break; } } } }

Incidence::Ptr inc = incBase.staticCast<Incidence>(); // the incidence in the invitation email

If the IncidenceBase is a FreeBusy, then we cannot access the revision number in the static-casted Incidence; so for sake of nothing better use 0 as the revision. int incRevision = 0; if (inc && inc->type() != Incidence::TypeFreeBusy) { incRevision = inc->revision(); }

First make the text of the message QString html = QLatin1String("<div align=\"center\" style=\"border:solid 1px;\">");

IncidenceFormatter::InvitationHeaderVisitor headerVisitor; The InvitationHeaderVisitor returns false if the incidence is somehow invalid, or not handled if (!headerVisitor.act(inc, existingIncidence, msg, sender)) { return QString(); } html += htmlAddTag(QLatin1String("h3"), headerVisitor.result());

if (outlookCompareStyle || msg->method() == iTIPDeclineCounter) { //use Outlook style for decline use the Outlook 2007 Comparison Style IncidenceFormatter::InvitationBodyVisitor bodyVisitor(noHtmlMode, spec); bool bodyOk; if (msg->method() == iTIPRequest || msg->method() == iTIPReply || msg->method() == iTIPDeclineCounter) { if (inc && existingIncidence && incRevision < existingIncidence->revision()) { bodyOk = bodyVisitor.act(existingIncidence, inc, msg, sender); } else { bodyOk = bodyVisitor.act(inc, existingIncidence, msg, sender); } } else { bodyOk = bodyVisitor.act(inc, Incidence::Ptr(), msg, sender); } if (bodyOk) { html += bodyVisitor.result(); } else { return QString(); } } else { use our "Classic" Comparison Style InvitationBodyVisitor bodyVisitor(noHtmlMode, spec); if (!bodyVisitor.act(inc, Incidence::Ptr(), msg, sender)) { return QString(); } html += bodyVisitor.result();

if (msg->method() == iTIPRequest) { IncidenceFormatter::IncidenceCompareVisitor compareVisitor; if (compareVisitor.act(inc, existingIncidence)) { html += QLatin1String("<p align=\"left\">"); if (senderIsOrganizer(inc, sender)) { html += i18n("The following changes have been made by the organizer:"); } else if (!sender.isEmpty()) { html += i18n("The following changes have been made by %1:", sender); } else { html += i18n("The following changes have been made:"); } html += QLatin1String("</p>"); html += compareVisitor.result(); } } if (msg->method() == iTIPReply) { IncidenceCompareVisitor compareVisitor; if (compareVisitor.act(inc, existingIncidence)) { html += QLatin1String("<p align=\"left\">"); if (!sender.isEmpty()) { html += i18n("The following changes have been made by %1:", sender); } else { html += i18n("The following changes have been made by an attendee:"); } html += QLatin1String("</p>"); html += compareVisitor.result(); } } }

determine if I am the organizer for this invitation bool myInc = iamOrganizer(inc);

determine if the invitation response has already been recorded bool rsvpRec = false; Attendee::Ptr ea; if (!myInc) { Incidence::Ptr rsvpIncidence = existingIncidence; if (!rsvpIncidence && inc && incRevision > 0) { rsvpIncidence = inc; } if (rsvpIncidence) { ea = findMyAttendee(rsvpIncidence); } if (ea && (ea->status() == Attendee::Accepted || ea->status() == Attendee::Declined || ea->status() == Attendee::Tentative)) { rsvpRec = true; } }

determine invitation role QString role; bool isDelegated = false; Attendee::Ptr a = findMyAttendee(inc); if (!a && inc) { if (!inc->attendees().isEmpty()) { a = inc->attendees().first(); } } if (a) { isDelegated = (a->status() == Attendee::Delegated); role = Stringify::attendeeRole(a->role()); }

determine if RSVP needed, not-needed, or response already recorded bool rsvpReq = rsvpRequested(inc); if (!myInc && a) { QString tStr; if (rsvpRec && inc) { if (incRevision == 0) { tStr = i18n("Your <b>%1</b> response has been recorded", Stringify::attendeeStatus(ea->status())); } else { tStr = i18n("Your status for this invitation is <b>%1</b>", Stringify::attendeeStatus(ea->status())); } rsvpReq = false; } else if (msg->method() == iTIPCancel) { tStr = i18n("This invitation was canceled"); } else if (msg->method() == iTIPAdd) { tStr = i18n("This invitation was accepted"); } else if (msg->method() == iTIPDeclineCounter) { rsvpReq = true; tStr = rsvpRequestedStr(rsvpReq, role); } else { if (!isDelegated) { tStr = rsvpRequestedStr(rsvpReq, role); } else { tStr = i18n("Awaiting delegation response"); } } html += QLatin1String("<br>"); html += QLatin1String("<i><u>") + tStr + QLatin1String("</u></i>"); }

Print if the organizer gave you a preset status if (!myInc) { if (inc && incRevision == 0) { QString statStr = myStatusStr(inc); if (!statStr.isEmpty()) { html += QLatin1String("<br>"); html += QLatin1String("<i>") + statStr + QLatin1String("</i>"); } } }

Add groupware links

html += QLatin1String("<p>");
html += QLatin1String("<table border=\"0\" align=\"center\" cellspacing=\"4\"><tr>");

switch (msg->method()) {
case iTIPPublish:
case iTIPRequest:
case iTIPRefresh:
case iTIPAdd:
{
    if (inc && incRevision > 0 && (existingIncidence || !helper->calendar())) {
        html += recordButtons(inc, helper);
    }

    if (!myInc) {
        if (a) {
            html += responseButtons(inc, rsvpReq, rsvpRec, helper);
        } else {
            html += responseButtons(inc, false, false, helper);
        }
    }
    break;
}

case iTIPCancel:
    html += cancelButtons(inc, helper);
    break;

case iTIPReply:
{

Record invitation response Attendee::Ptr a; Attendee::Ptr ea; if (inc) { First, determine if this reply is really a counter in disguise. if (replyMeansCounter(inc)) { html += QLatin1String("<tr>") + counterButtons(inc, helper) + QLatin1String("</tr>"); break; }

Next, maybe this is a declined reply that was delegated from me? find first attendee who is delegated-from me look a their PARTSTAT response, if the response is declined, then we need to start over which means putting all the action buttons and NOT putting on the [Record response..] button a = findDelegatedFromMyAttendee(inc); if (a) { if (a->status() != Attendee::Accepted || a->status() != Attendee::Tentative) { html += responseButtons(inc, rsvpReq, rsvpRec, helper); break; } }

Finally, simply allow a Record of the reply if (!inc->attendees().isEmpty()) { a = inc->attendees().first(); } if (a && helper->calendar()) { ea = findAttendee(existingIncidence, a->email()); } } if (ea && (ea->status() != Attendee::NeedsAction) && (ea->status() == a->status())) { const QString tStr = i18n("The <b>%1</b> response has been recorded", Stringify::attendeeStatus(ea->status())); html += inviteButton(helper, QString(), htmlAddTag(QLatin1String("i"), tStr)); } else { if (inc) { html += recordResponseButtons(inc, helper); } } break; }

case iTIPCounter: Counter proposal html += counterButtons(inc, helper); break;

case iTIPDeclineCounter: html += responseButtons(inc, rsvpReq, rsvpRec, helper); break;

case iTIPNoMethod: break; }

close the groupware table html += QLatin1String("</tr></table>");

Add the attendee list if (myInc) { html += invitationRsvpList(existingIncidence, a); } else { html += invitationAttendeeList(inc); }

close the top-level table html += QLatin1String("</div>");

Add the attachment list html += invitationAttachments(helper, inc);

return html; }

QString IncidenceFormatter::formatICalInvitation(QString invitation, const MemoryCalendar::Ptr &calendar, InvitationFormatterHelper *helper, bool outlookCompareStyle) { return formatICalInvitationHelper(invitation, calendar, helper, false, KSystemTimeZones::local(), QString(), outlookCompareStyle); }

QString IncidenceFormatter::formatICalInvitationNoHtml(const QString &invitation, const MemoryCalendar::Ptr &calendar, InvitationFormatterHelper *helper, const QString &sender, bool outlookCompareStyle) { return formatICalInvitationHelper(invitation, calendar, helper, true, KSystemTimeZones::local(), sender, outlookCompareStyle); }

/******************************************************************* Helper functions for the Incidence tooltips

Definition at line 3808 of file incidenceformatter.cpp.

This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu Jul 21 2022 00:00:00 by doxygen 1.9.5 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KCalUtils Library

Skip menu "KCalUtils Library"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Members
  • File List
  • Related Pages

kdepimlibs-4.14.10 API Reference

Skip menu "kdepimlibs-4.14.10 API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal