39 using namespace KCalCore;
42 #include <KLocalizedString>
44 #include <KSystemTimeZone>
46 using namespace KCalUtils;
47 using namespace Stringify;
49 QString Stringify::incidenceType(Incidence::IncidenceType type)
52 case Incidence::TypeEvent:
53 return i18nc(
"@item incidence type is event",
"event");
54 case Incidence::TypeTodo:
55 return i18nc(
"@item incidence type is to-do/task",
"to-do");
56 case Incidence::TypeJournal:
57 return i18nc(
"@item incidence type is journal",
"journal");
58 case Incidence::TypeFreeBusy:
59 return i18nc(
"@item incidence type is freebusy",
"free/busy");
68 return KGlobal::locale()->formatDateTime(todo->completed().dateTime(),
69 (shortfmt ? KLocale::ShortDate :
76 case Incidence::SecrecyPublic:
77 return i18nc(
"@item incidence access if for everyone",
"Public");
78 case Incidence::SecrecyPrivate:
79 return i18nc(
"@item incidence access is by owner only",
"Private");
80 case Incidence::SecrecyConfidential:
81 return i18nc(
"@item incidence access is by owner and a controlled group",
"Confidential");
97 QString Stringify::incidenceStatus(Incidence::Status status)
100 case Incidence::StatusTentative:
101 return i18nc(
"@item event is tentative",
"Tentative");
102 case Incidence::StatusConfirmed:
103 return i18nc(
"@item event is definite",
"Confirmed");
104 case Incidence::StatusCompleted:
105 return i18nc(
"@item to-do is complete",
"Completed");
106 case Incidence::StatusNeedsAction:
107 return i18nc(
"@item to-do needs action",
"Needs-Action");
108 case Incidence::StatusCanceled:
109 return i18nc(
"@item event orto-do is canceled; journal is removed",
"Canceled");
110 case Incidence::StatusInProcess:
111 return i18nc(
"@item to-do is in process",
"In-Process");
112 case Incidence::StatusDraft:
113 return i18nc(
"@item journal is in draft form",
"Draft");
114 case Incidence::StatusFinal:
115 return i18nc(
"@item journal is in final form",
"Final");
116 case Incidence::StatusX:
117 case Incidence::StatusNone:
123 QString Stringify::incidenceStatus(
const Incidence::Ptr &incidence)
125 if (incidence->status() == Incidence::StatusX) {
126 return incidence->customStatus();
128 return incidenceStatus(incidence->status());
136 return i18nc(
"@item chairperson",
"Chair");
140 return i18nc(
"@item participation is required",
"Participant");
143 return i18nc(
"@item participation is optional",
"Optional Participant");
146 return i18nc(
"@item non-participant copied for information",
"Observer");
167 return i18nc(
"@item event, to-do or journal needs action",
"Needs Action");
170 return i18nc(
"@item event, to-do or journal accepted",
"Accepted");
173 return i18nc(
"@item event, to-do or journal declined",
"Declined");
176 return i18nc(
"@item event or to-do tentatively accepted",
"Tentative");
179 return i18nc(
"@item event or to-do delegated",
"Delegated");
182 return i18nc(
"@item to-do completed",
"Completed");
185 return i18nc(
"@item to-do in process of being completed",
"In Process");
188 return i18nc(
"@item event or to-do status unknown",
"Unknown");
209 if (spec.isValid()) {
212 if (spec.timeZone() != KSystemTimeZones::local()) {
213 timeZone =
QLatin1Char(
' ') + spec.timeZone().name();
216 return KGlobal::locale()->formatTime(dt.toTimeSpec(spec).time(), !shortfmt) + timeZone;
218 return KGlobal::locale()->formatTime(dt.time(), !shortfmt);
224 if (spec.isValid()) {
227 if (spec.timeZone() != KSystemTimeZones::local()) {
228 timeZone =
QLatin1Char(
' ') + spec.timeZone().name();
232 KGlobal::locale()->formatDate(dt.toTimeSpec(spec).date(),
233 (shortfmt ? KLocale::ShortDate : KLocale::LongDate)) +
237 KGlobal::locale()->formatDate(dt.date(),
238 (shortfmt ? KLocale::ShortDate : KLocale::LongDate));
243 bool shortfmt,
const KDateTime::Spec &spec)
249 if (spec.isValid()) {
251 if (spec.timeZone() != KSystemTimeZones::local()) {
252 timeZone =
QLatin1Char(
' ') + spec.timeZone().name();
255 return KGlobal::locale()->formatDateTime(
256 dt.toTimeSpec(spec).dateTime(),
257 (shortfmt ? KLocale::ShortDate : KLocale::LongDate)) + timeZone;
259 return KGlobal::locale()->formatDateTime(
261 (shortfmt ? KLocale::ShortDate : KLocale::LongDate));
269 switch (exception.
code()) {
271 message = i18nc(
"@item",
"Load Error");
274 message = i18nc(
"@item",
"Save Error");
277 message = i18nc(
"@item",
"Parse Error in libical");
280 message = i18nc(
"@item",
"Parse Error in the kcalcore library");
283 message = i18nc(
"@item",
"No calendar component found.");
286 message = i18nc(
"@item",
"Expected iCalendar, got vCalendar format");
289 message = i18nc(
"@item",
"iCalendar Version 2.0 detected.");
292 message = i18nc(
"@item",
"Expected iCalendar, got unknown format");
295 message = i18nc(
"@item",
"Restriction violation");
298 message = i18nc(
"@item",
"No writable resource found");
300 case Exception::SaveErrorOpenFile:
302 message = i18nc(
"@item",
"Error saving to '%1'.", exception.
arguments()[0]);
304 case Exception::SaveErrorSaveFile:
306 message = i18nc(
"@item",
"Could not save '%1'", exception.
arguments()[0]);
308 case Exception::LibICalError:
309 message = i18nc(
"@item",
"libical error");
311 case Exception::VersionPropertyMissing:
312 message = i18nc(
"@item",
"No VERSION property found");
314 case Exception::ExpectedCalVersion2:
315 message = i18nc(
"@item",
"Expected iCalendar, got vCalendar format");
317 case Exception::ExpectedCalVersion2Unknown:
318 message = i18nc(
"@item",
"Expected iCalendar, got unknown format");
320 case Exception::ParseErrorNotIncidence:
321 message = i18nc(
"@item",
"object is not a freebusy, event, todo or journal");
323 case Exception::ParseErrorEmptyMessage:
324 message = i18nc(
"@item",
"messageText is empty, unable to parse into a ScheduleMessage");
326 case Exception::ParseErrorUnableToParse:
327 message = i18nc(
"@item",
"icalparser is unable to parse messageText into a ScheduleMessage");
329 case Exception::ParseErrorMethodProperty:
330 message = i18nc(
"@item",
"message does not contain ICAL_METHOD_PROPERTY");
345 return i18nc(
"@item this is a new scheduling message",
346 "New Scheduling Message");
348 return i18nc(
"@item this is an update to an existing scheduling message",
349 "Updated Scheduling Message");
351 return i18nc(
"@item obsolete status",
"Obsolete");
353 return i18nc(
"@item this is a request for a new scheduling message",
354 "New Scheduling Message Request");
356 return i18nc(
"@item this is a request for an update to an existing scheduling message",
357 "Updated Scheduling Message Request");
359 return i18nc(
"@item unknown status",
"Unknown Status: %1",
int(status));
363 QString Stringify::secrecyName(Incidence::Secrecy secrecy)
366 case Incidence::SecrecyPublic:
367 return i18nc(
"@item incidence access if for everyone",
"Public");
368 case Incidence::SecrecyPrivate:
369 return i18nc(
"@item incidence access is by owner only",
"Private");
370 case Incidence::SecrecyConfidential:
371 return i18nc(
"@item incidence access is by owner and a controlled group",
"Confidential");
380 list << secrecyName(Incidence::SecrecyPublic);
381 list << secrecyName(Incidence::SecrecyPrivate);
382 list << secrecyName(Incidence::SecrecyConfidential);
virtual QStringList arguments() const
KCALUTILS_EXPORT QString formatDate(const KDateTime &dt, bool shortfmt=true, const KDateTime::Spec &spec=KDateTime::Spec())
Build a QString date representation of a KDateTime object.
virtual ErrorCode code() const
KCALUTILS_EXPORT QString formatDateTime(const KDateTime &dt, bool dateOnly=false, bool shortfmt=true, const KDateTime::Spec &spec=KDateTime::Spec())
Build a QString date/time representation of a KDateTime object.
KCALUTILS_EXPORT QStringList incidenceSecrecyList()
Returns a list of all available Secrecy types as a list of translated strings.
int count(const T &value) const
KCALUTILS_EXPORT QString incidenceSecrecy(KCalCore::Incidence::Secrecy secrecy)
Returns the incidence Secrecy as translated string.
This file is part of the API for handling calendar data and provides static functions for formatting ...
KCALUTILS_EXPORT QString errorMessage(const KCalCore::Exception &exception)
Build a translated message representing an exception.
KCALUTILS_EXPORT QString todoCompletedDateTime(const KCalCore::Todo::Ptr &todo, bool shortfmt=false)
Returns string containing the date/time when the to-do was completed, formatted according to the user...
KCALUTILS_EXPORT QString formatTime(const KDateTime &dt, bool shortfmt=true, const KDateTime::Spec &spec=KDateTime::Spec())
Build a QString time representation of a KDateTime object.