Commit c46ae6eb authored by David Jarvie's avatar David Jarvie
Browse files

Fix saving local times to calendar

The PIM libraries convert event start times with spec Qt::LocalTime
to the current time zone when saving them, which made it impossible
to tell whether the time was specified as a time zone or as local
time.
parent 01ea3ff9
......@@ -54,7 +54,7 @@ KAlarm uses the iCalendar format defined in RFC2445.
<tr><td>At-login alarm</td><td><em>any</em></td><td>If the event is configured to trigger each time KAlarm starts up (normally at each login), this alarm has a trigger time in the past, which ensures that it always triggers at startup.</td></tr>
<tr><td>Reminder alarm</td><td><tt>DISPLAY</tt></td><td>If a reminder is configured, and it is due before the next or only recurrence of the main alarm, this alarm triggers the reminder.</td></tr>
<tr><td>Deferral alarm</td><td><tt>DISPLAY</tt></td><td>If the user has deferred an alarm (either the main alarm or a reminder), this alarm triggers at the deferral time.</td></tr>
<tr><td>Audio alarm</td><td><tt>AUDIO</tt></td><td>If it is a display event, and any type of sound is configured (beep, speaking or audio file), this alarm is set to trigger at the same time as the next due alarm (main, at-login, reminder, or deferral).</td></tr>
<tr><td>Audio alarm</td><td><tt>AUDIO</tt></td><td>If it is a display event, and any type of sound is configured (beep, speaking or audio file), this alarm is set to trigger at the same time as the next due alarm (main, at-login, reminder, or deferral).<br>Special values of <tt>REPEAT</tt> may be used to specify that an audio file should be played repeatedly in a loop until the user clicks 'stop': see <a href="#audioloop">Audio file loop</a> below.
<tr><td>Pre-alarm action alarm</td><td><tt>PROCEDURE</tt></td><td>If a pre-alarm action is configured, this alarm is set to trigger at the same time as the next due alarm.</td></tr>
<tr><td>Post&#8209;alarm&nbsp;action&nbsp;alarm</td><td><tt>PROCEDURE</tt></td><td>If a post-alarm action is configured, this alarm is set to trigger at the same time as the next due alarm.</td></tr>
<tr><td>Displaying alarm</td><td><tt>DISPLAY</tt></td><td>If an alarm is currently being displayed, this alarm held in the displaying calendar contains a copy of the main alarm, plus other information necessary to redisplay the alarm window after a logout or crash.</td></tr>
......@@ -75,7 +75,7 @@ Compliant with the iCalendar specification, KAlarm defines a number of custom fi
<tr><th align=left>Property&nbsp;&nbsp;&nbsp;&nbsp;</th><th>Parameter</th><th align=left>Description</th></tr>
<tr><td colspan=2><tt>X-KDE-KALARM-VERSION</tt></td><td>Mandatory. The single parameter contains the KAlarm calendar format version used to write this calendar. Note that this version may be older than the actual KAlarm application version; the calendar format version is only updated when the calendar format changes.</td></tr>
<tr><td></td><td><em>version</em><tt></td><td>KAlarm calendar format version, in the format <em>n</em><tt>.</tt><em>n</em><tt>.</tt><em>n</em> . E.g. <tt class=eg>2.3.10</tt></td></tr>
<tr><td></td><td><tt><em>version</em></td><td>KAlarm calendar format version, in the format <tt><em>n</em>.<em>n</em>.<em>n</em></tt> . E.g. <tt class=eg>2.3.10</tt></td></tr>
<tr><td colspan=3 class=titlerow>Event-level custom properties</td></tr>
<tr><td colspan=3>The following custom properties are used within a <tt>VEVENT</tt> element.</td></tr>
......@@ -90,6 +90,7 @@ Compliant with the iCalendar specification, KAlarm defines a number of custom fi
<tr><td class=cont><tt>EDIT</tt></td><td class=cont>For an event in the displaying calendar, indicates that the Edit button should be shown in the alarm window. Optional.</td></tr>
</table></td></tr>
<tr><td colspan=2><tt>X-KDE-KALARM-FLAGS</tt></td><td>Multiple parameters specify various properties of the event</td></tr>
<tr><td></td><td><tt>LOCAL</tt></td><td>The event time is specified using the local system time zone, and any <tt>TZID</tt> specifier in <tt>DTSTART</tt> is to be ignored. Note that this is used because the PIM libraries set the current local time zone as the <tt>TZID</tt> value when storing local times in the calendar.</td></tr>
<tr><td></td><td><tt>DATE</tt></td><td>The event time is date-only, i.e. its time is ignored and it triggers at the first opportunity on the specified date (after the start-of-day time configured by the user). Note that this is used instead of specifying a start date (<tt>DTSTART</tt>) without a time.</td></tr>
<tr><td class=cont></td><td class=cont><tt>ACKCONF</tt></td><td class=cont>For a display alarm, when the user acknowledges the alarm (i.e. closes the alarm window), a confirmation prompt will be output</td></tr>
<tr><td class=cont></td><td class=cont><tt>KORG</tt></td><td class=cont>The event was copied as an alarm to KOrganizer</td></tr>
......@@ -101,7 +102,7 @@ Compliant with the iCalendar specification, KAlarm defines a number of custom fi
<tr><td class=cont></td><td class=cont><tt>TMPLAFTTIME;<em>interval</em></tt></td><td class=cont>For a template alarm, holds the value (in minutes) of the "After time" option</td></tr>
<tr><td class=cont></td><td class=cont><tt>KMAIL;<em>sernum</em></tt></td><td class=cont>The KMail serial number of the email whose text forms the alarm message. The alarm message must be in the form <tt>From: ...\nTo: ...\n<em>[</em>Cc: ...\n<em>]</em>Date: ...\nSubject: ...</tt></td></tr>
<tr><td class=cont></td><td class=cont><tt>BCC</tt></td><td class=cont>For an email alarm, the email will be blind copied to the user</td></tr>
<tr><td class=cont></td><td class=cont><tt>REMINDER;<em>[</em><tt>ONCE;</tt><em>]interval</em></td><td class=cont>The reminder interval for the alarm: &lt; 0 for a reminder before the main alarm, &gt; 0 for a reminder after the main alarm. A suffix indicates the time units: <tt>M</tt> = minutes, <tt>H</tt> = hours, <tt>D</tt> = days. E.g. <tt class=eg>-12M</tt>. If <tt>ONCE</tt> is specified, this indicates that the reminder should be shown only for the first recurrence.</td></tr>
<tr><td class=cont></td><td class=cont><tt>REMINDER;<em>[</em>ONCE;<em>]interval</em></tt></td><td class=cont>The reminder interval for the alarm: &lt; 0 for a reminder before the main alarm, &gt; 0 for a reminder after the main alarm. A suffix indicates the time units: <tt>M</tt> = minutes, <tt>H</tt> = hours, <tt>D</tt> = days. E.g. <tt class=eg>-12M</tt>. If <tt>ONCE</tt> is specified, this indicates that the reminder should be shown only for the first recurrence.</td></tr>
<tr><td class=cont></td><td class=cont><tt>LOGIN</tt></td><td class=cont>For an active alarm, when its main alarm has expired, records that the original alarm was triggered each time KAlarm started up (normally at each login)</td></tr>
<tr><td class=cont></td><td class=cont><tt>ARCHIVE</tt></td><td class=cont>For an active alarm, indicates that the alarm has triggered at least once and should be archived when it expires or is deleted</td></tr>
......@@ -112,7 +113,7 @@ Compliant with the iCalendar specification, KAlarm defines a number of custom fi
<tr><td colspan=2><tt>X-KDE-KALARM-LOG</tt></td><td>The single parameter specifies where command alarm output should go; default = discard</td></tr>
<tr><td></td><td><tt>xterm:</tt></td><td>Display command output in a terminal window</td></tr>
<tr><td class=cont></td><td class=cont><tt>display:</tt></td><td class=cont>Display command output in an alarm window</td></tr>
<tr><td class=cont></td><td class=cont><em>filename</em></td><td class=cont>Store command output in the specified file</td></tr>
<tr><td class=cont></td><td class=cont><tt><em>filename</em></tt></td><td class=cont>Store command output in the specified file</td></tr>
<tr><td colspan=3 class=titlerow>Alarm-level custom properties</td></tr>
<tr><td colspan=3>The following custom properties are used within a <tt>VALARM</tt> element.</td></tr>
......@@ -126,7 +127,7 @@ Compliant with the iCalendar specification, KAlarm defines a number of custom fi
<tr><td class=cont></td><td class=cont><tt>DATE_DEFERRAL</tt></td><td class=cont>The alarm is a subsidiary date-only deferral alarm</td></tr>
<tr><td class=cont></td><td class=cont><tt>PRE</tt></td><td class=cont>The alarm is a subsidiary pre-alarm action command, which is executed immediately before the main alarm</td></tr>
<tr><td class=cont></td><td class=cont><tt>POST</tt></td><td class=cont>The alarm is a subsidiary post-alarm action command, which is executed immediately after the user acknowledges the main display alarm</td></tr>
<tr><td class=cont></td><td class=cont><tt>SOUNDREPEAT<em>[,pause]</em></tt></td><td class=cont>For an audio alarm, indicates that the sound file should be repeated indefinitely. The argument, which is present only in the "main" alarm, is the pause in seconds between repetitions.</td></tr>
<tr><td class=cont></td><td class=cont><tt>SOUNDREPEAT<em>,pause</em></tt></td><td class=cont>For an audio alarm, indicates that the sound file should be played repeatedly in a loop until the user clicks 'stop', each time it triggers. The argument is the pause in seconds between repetitions. This is used only for "main" alarms: see <a href="#audioloop">Audio file loop</a> below.</td></tr>
<tr><td class=cont></td><td class=cont><tt>DISPLAYING</tt></td><td class=cont>The alarm is currently being displayed, i.e. in the displaying calendar</td></tr>
<tr><td colspan=2><tt>X-KDE-KALARM-FLAGS</tt></td><td>Multiple parameters specify various properties of the alarm</td></tr>
<tr><td></td><td><tt>HIDE</tt></td><td>For an alarm of type REMINDER, indicates that it is suppressed by a deferral alarm whose trigger time is later than this alarm. Allows the reminder alarm to be reinstated if the deferral is subsequently cancelled.</td></tr>
......@@ -134,13 +135,13 @@ Compliant with the iCalendar specification, KAlarm defines a number of custom fi
<tr><td class=cont></td><td class=cont><tt>EXECDEFER</tt></td><td class=cont>For a command alarm containing a pre-alarm action, indicates that the pre-alarm action should be executed when a deferred alarm triggers. Normally, it is executed only when the alarm proper triggers.</td></tr>
<tr><td class=cont></td><td class=cont><tt>ERRCANCEL</tt></td><td class=cont>For a command alarm containing a pre-alarm action, indicates that the alarm should be cancelled if the pre-alarm action fails</td></tr>
<tr><td class=cont></td><td class=cont><tt>ERRNOSHOW</tt></td><td class=cont>For a command alarm containing a pre-alarm action, indicates that there should be no error notification if the pre-alarm action fails</td></tr>
<tr><td class=cont></td><td class=cont><tt>EMAILID;</tt><em>uoid</em></td><td class=cont>For an email alarm, holds the email ID (the KDE email UOID) to use in the 'From' field.</td></tr>
<tr><td class=cont></td><td class=cont><tt>EMAILID;<em>uoid</em></tt></td><td class=cont>For an email alarm, holds the email ID (the KDE email UOID) to use in the 'From' field.</td></tr>
<tr><td colspan=2><tt>X-KDE-KALARM-NEXTREPEAT</tt></td><td>The single parameter holds the repetition count of the next due sub-repetition: 0 = the main recurrence, 1 = the first sub-repetition, etc.</td></tr>
<tr><td></td><td><em>count</em></td><td>Repetition number</td></tr>
<tr><td></td><td><tt><em>count</em></tt></td><td>Repetition number</td></tr>
<tr><td colspan=2><tt>X-KDE-KALARM-FONTCOLOR</tt></td><td>For a display alarm, holds the colours to use in the alarm message window</td></tr>
<tr><td></td><td><em>[background][</em><tt>;</tt><em>foreground]</em></td><td>The optional background colour (default = white) and optional foreground colour (default = black)</td></tr>
<tr><td></td><td><tt><em>[background][</em>;<em>foreground]</em></tt></td><td>The optional background colour (default = white) and optional foreground colour (default = black)</td></tr>
<tr><td colspan=2><tt>X-KDE-KALARM-VOLUME</tt></td><td>Holds volume settings for an audio alarm</td></tr>
<tr><td></td><td><em>[volume][</em><tt>;</tt><em>fadevolume</em><tt>;</tt><em>fadeinterval]</em></td><td>Contains the optional volume (floating point, range 0 - 1), and optionally the fade volume (floating point, range 0 - 1) and fade interval in seconds. E.g. <tt class=eg>0.75</tt> to set volume with no fade, <tt class=eg>;0.3;10</tt> for default volume with fade, <tt class=eg>0.75;0.3;10</tt> to specify volume and fade</td></tr>
<tr><td></td><td><tt><em>[volume][</em>;<em>fadevolume</em>;<em>fadeinterval]</em></tt></td><td>Contains the optional volume (floating point, range 0 - 1), and optionally the fade volume (floating point, range 0 - 1) and fade interval in seconds. E.g. <tt class=eg>0.75</tt> to set volume with no fade, <tt class=eg>;0.3;10</tt> for default volume with fade, <tt class=eg>0.75;0.3;10</tt> to specify volume and fade</td></tr>
</table>
<h3>Custom status field values</h3>
......@@ -154,7 +155,7 @@ The following custom parameter value is used in the <tt>STATUS</tt> property in
An audio alarm (<tt>ACTION:AUDIO</tt>) can specify that each time the alarm triggers, the audio file should be played repeatedly in a loop until the user presses 'stop'. This is independent of the overall event recurrence or sub-repetition, and is indicated as follows.
<ul><li>In the "main" alarm, <tt>X-KDE-KALARM-TYPE:SOUNDREPEAT</tt> is used to specify sound file repetition, because the <tt>REPEAT</tt> and <tt>DURATION</tt> properties apply to the overall event.
<ul>No pause between repetitions: <tt>X-KDE-KALARM-TYPE:SOUNDREPEAT</tt>
<br>Pause between repetitions: <tt>X-KDE-KALARM-TYPE:SOUNDREPEAT,<em>pause</em></tt></ul>
<br>Pause (in seconds) between repetitions: <tt>X-KDE-KALARM-TYPE:SOUNDREPEAT,<em>pause</em></tt></ul>
<li>In subsidiary alarms, the following scheme is used. The reason for this scheme is that KCalCore::Alarm cannot set a snooze time of zero.
<ul>No pause between repetitions: <tt>REPEAT:-1</tt> (<tt>DURATION</tt> is ignored)
<br>Pause between repetitions: <tt>REPEAT:-2</tt> with <tt>DURATION</tt> containing the pause interval.</ul>
......
......@@ -582,18 +582,36 @@ Alarm::Ptr copyKcalAlarm(Event::Ptr& kcalevent, Alarm::Ptr& kcalalarm)
}
void KAEventTest::kcalevent()
void KAEventTest::fromKCalEvent()
{
// Check KCalCore::Event custom properties.
const KADateTime dt(QDate(2010,5,13), QTime(3, 45, 0), QTimeZone("Europe/London"));
const QDateTime createdDt(QDate(2009,4,13), QTime(11,14,0), QTimeZone("UTC"));
// Event category
// Event category, UID, revision, start time, created time
{
const QString uid = QStringLiteral("fa74ec931");
Event::Ptr kcalevent = createKcalEvent(dt.qDateTime(), createdDt);
kcalevent->setCustomProperty("KALARM", "TYPE", QStringLiteral("ACTIVE"));
kcalevent->setUid(uid);
kcalevent->setRevision(273);
KAEvent event(kcalevent);
QCOMPARE(event.category(), CalEvent::ACTIVE);
QCOMPARE(event.startDateTime(), dt);
QCOMPARE(event.createdDateTime().qDateTime(), createdDt);
QCOMPARE(event.id(), uid);
QCOMPARE(event.revision(), 273);
}
{
// Start time using LocalZone
const KADateTime dtLocal(dt.date(), dt.time(), KADateTime::LocalZone);
Event::Ptr kcalevent = createKcalEvent(dt.qDateTime(), createdDt);
kcalevent->setCustomProperty("KALARM", "TYPE", QStringLiteral("ACTIVE"));
kcalevent->setCustomProperty("KALARM", "FLAGS", QStringLiteral("LOCAL"));
KAEvent event(kcalevent);
QCOMPARE(event.category(), CalEvent::ACTIVE);
QCOMPARE(event.startDateTime(), dtLocal);
QCOMPARE(event.createdDateTime().qDateTime(), createdDt);
}
{
Event::Ptr kcalevent = createKcalEvent(dt.qDateTime(), createdDt);
......@@ -1192,6 +1210,67 @@ void KAEventTest::kcalevent()
QVERIFY(event.repeatAtLogin(false));
}
}
void KAEventTest::toKCalEvent()
{
// Check KCalCore::Event custom properties.
const KADateTime dt(QDate(2010,5,13), QTime(3, 45, 0), QTimeZone("Europe/London"));
const KADateTime createdDt(QDate(2009,4,13), QTime(11,14,0), QTimeZone("UTC"));
const QString text = QStringLiteral("message");
const QColor fgColour(0x82, 0x6e, 0xf0);
const QColor bgColour(0x14, 0x46, 0x8c);
const QFont font(QStringLiteral("Helvetica"), 10, QFont::Bold, true);
const QString uid = QStringLiteral("fa74ec931");
{
// Event category, UID, revision, start time using time zone, created time
KAEvent event;
event.set(dt, text, bgColour, fgColour, font, KAEvent::MESSAGE, 3, KAEvent::CONFIRM_ACK);
event.setEventId(uid);
event.incrementRevision();
event.incrementRevision();
event.setCategory(CalEvent::ACTIVE);
event.setCreatedDateTime(createdDt);
Event::Ptr kcalevent(new Event);
QVERIFY(event.updateKCalEvent(kcalevent, KAEvent::UID_SET, true));
QCOMPARE(kcalevent->uid(), uid);
QCOMPARE(kcalevent->revision(), 2);
QCOMPARE(kcalevent->customProperty("KALARM", "TYPE"), QStringLiteral("ACTIVE"));
QStringList flags = kcalevent->customProperty("KALARM", "FLAGS").split(SC);
QCOMPARE(flags.size(), 3); // must contain LATECANCEL;3 and ACKCONF
QCOMPARE(flags.removeAll(QStringLiteral("ACKCONF")), 1);
QCOMPARE(flags.at(0), QStringLiteral("LATECANCEL"));
QCOMPARE(flags.at(1), QStringLiteral("3"));
QCOMPARE(kcalevent->dtStart(), dt.qDateTime());
QCOMPARE(kcalevent->created(), createdDt.qDateTime());
const Alarm::List kcalalarms = kcalevent->alarms();
QCOMPARE(kcalalarms.size(), 1);
Alarm::Ptr kcalalarm(kcalalarms[0]);
QCOMPARE(kcalalarm->type(), Alarm::Display);
QCOMPARE(kcalalarm->text(), text);
QCOMPARE(kcalalarm->customProperty("KALARM", "FONTCOLOR").toUpper(), (QStringLiteral("#14468C;#826EF0;") + font.toString()).toUpper());
}
{
// Start time using LocalZone
const KADateTime dt(QDate(2010,5,13), QTime(3, 45, 0), KADateTime::LocalZone);
KAEvent event;
event.set(dt, text, bgColour, fgColour, font, KAEvent::MESSAGE, 3, KAEvent::CONFIRM_ACK);
event.setEventId(uid);
event.incrementRevision();
event.setCategory(CalEvent::ACTIVE);
event.setCreatedDateTime(createdDt);
Event::Ptr kcalevent(new Event);
QVERIFY(event.updateKCalEvent(kcalevent, KAEvent::UID_SET, true));
QCOMPARE(kcalevent->uid(), uid);
QCOMPARE(kcalevent->revision(), 1);
QCOMPARE(kcalevent->customProperty("KALARM", "TYPE"), QStringLiteral("ACTIVE"));
QStringList flags = kcalevent->customProperty("KALARM", "FLAGS").split(SC);
QCOMPARE(flags.size(), 4); // must contain LOCAL, LATECANCEL;3 and ACKCONF
QVERIFY(flags.contains(QStringLiteral("LOCAL")));
const QDateTime dtCurrentTz(dt.date(), dt.time(), QTimeZone::systemTimeZone());
QCOMPARE(kcalevent->dtStart(), dtCurrentTz);
QCOMPARE(kcalevent->created(), createdDt.qDateTime());
}
}
// vim: et sw=4:
......@@ -31,7 +31,8 @@ class KAEventTest : public QObject
private Q_SLOTS:
void constructors();
void flags();
void kcalevent();
void fromKCalEvent();
void toKCalEvent();
};
#endif
......@@ -139,7 +139,9 @@ public:
/** Returns the time specification of the value. */
KADateTime::Spec timeSpec() const;
/** Changes the time specification of the value. */
/** Changes the time specification of the value.
* This will usually change the absolute time which this instance represents.
*/
void setTimeSpec(const KADateTime::Spec &spec);
/** Returns the time specification type of the date/time, i.e. whether it is
......
......@@ -825,8 +825,8 @@ public:
* Changes the time specification of the instance.
*
* Any previous time zone is forgotten. The stored date/time component of
* the instance is left unchanged (except that its UTC/local time setting
* is set to correspond with @p spec). Usually this method will change the
* the instance is left unchanged (except that its Qt::TimeSpec setting is
* set to correspond with @p spec). Usually this method will change the
* absolute time which this instance represents.
*
* @param spec new time specification
......
......@@ -219,7 +219,7 @@ public:
#endif
static bool convertRepetition(const KCalCore::Event::Ptr &);
static bool convertStartOfDay(const KCalCore::Event::Ptr &);
static DateTime readDateTime(const KCalCore::Event::Ptr &, bool dateOnly, DateTime &start);
static DateTime readDateTime(const KCalCore::Event::Ptr &, bool localZone, bool dateOnly, DateTime &start);
static void readAlarms(const KCalCore::Event::Ptr &, AlarmMap *, bool cmdDisplay = false);
static void readAlarm(const KCalCore::Alarm::Ptr &, AlarmData &, bool audioMain, bool cmdDisplay = false);
private:
......@@ -325,6 +325,7 @@ public:
public:
static const QByteArray FLAGS_PROPERTY;
static const QString DATE_ONLY_FLAG;
static const QString LOCAL_ZONE_FLAG;
static const QString EMAIL_BCC_FLAG;
static const QString CONFIRM_ACK_FLAG;
static const QString KORGANIZER_FLAG;
......@@ -393,6 +394,7 @@ int KAEvent::currentCalendarVersion()
// Event properties
const QByteArray KAEventPrivate::FLAGS_PROPERTY("FLAGS"); // X-KDE-KALARM-FLAGS property
const QString KAEventPrivate::DATE_ONLY_FLAG = QStringLiteral("DATE");
const QString KAEventPrivate::LOCAL_ZONE_FLAG = QStringLiteral("LOCAL");
const QString KAEventPrivate::EMAIL_BCC_FLAG = QStringLiteral("BCC");
const QString KAEventPrivate::CONFIRM_ACK_FLAG = QStringLiteral("ACKCONF");
const QString KAEventPrivate::KORGANIZER_FLAG = QStringLiteral("KORG");
......@@ -746,12 +748,15 @@ void KAEventPrivate::set(const Event::Ptr &event)
}
bool dateOnly = false;
bool localZone = false;
QStringList flags = event->customProperty(KACalendar::APPNAME, FLAGS_PROPERTY).split(SC, QString::SkipEmptyParts);
flags << QString() << QString(); // to avoid having to check for end of list
for (int i = 0, end = flags.count() - 1; i < end; ++i) {
QString flag = flags.at(i);
if (flag == DATE_ONLY_FLAG) {
dateOnly = true;
} else if (flag == LOCAL_ZONE_FLAG) {
localZone = true;
} else if (flag == CONFIRM_ACK_FLAG) {
mConfirmAck = true;
} else if (flag == EMAIL_BCC_FLAG) {
......@@ -853,7 +858,7 @@ void KAEventPrivate::set(const Event::Ptr &event)
}
}
}
mNextMainDateTime = readDateTime(event, dateOnly, mStartDateTime);
mNextMainDateTime = readDateTime(event, localZone, dateOnly, mStartDateTime);
mCreatedDateTime = KADateTime(event->created());
if (dateOnly && !mRepetition.isDaily()) {
mRepetition.set(Duration(mRepetition.intervalDays(), Duration::Days));
......@@ -1258,6 +1263,9 @@ bool KAEventPrivate::updateKCalEvent(const Event::Ptr &ev, KAEvent::UidAction ui
if (mStartDateTime.isDateOnly()) {
flags += DATE_ONLY_FLAG;
}
if (mStartDateTime.timeType() == KADateTime::LocalZone) {
flags += LOCAL_ZONE_FLAG;
}
if (mConfirmAck) {
flags += CONFIRM_ACK_FLAG;
}
......@@ -1828,10 +1836,10 @@ bool KAEvent::setItemPayload(Akonadi::Item &item, const QStringList &collectionM
{
QString mimetype;
switch (d->mCategory) {
case CalEvent::ACTIVE: mimetype = MIME_ACTIVE; break;
case CalEvent::ARCHIVED: mimetype = MIME_ARCHIVED; break;
case CalEvent::TEMPLATE: mimetype = MIME_TEMPLATE; break;
default: Q_ASSERT(0); return false;
case CalEvent::ACTIVE: mimetype = MIME_ACTIVE; break;
case CalEvent::ARCHIVED: mimetype = MIME_ARCHIVED; break;
case CalEvent::TEMPLATE: mimetype = MIME_TEMPLATE; break;
default: Q_ASSERT(0); return false;
}
if (!collectionMimeTypes.contains(mimetype)) {
return false;
......@@ -3863,7 +3871,7 @@ void KAEventPrivate::dumpDebug() const
* Fetch the start and next date/time for a KCal::Event.
* Reply = next main date/time.
*/
DateTime KAEventPrivate::readDateTime(const Event::Ptr &event, bool dateOnly, DateTime &start)
DateTime KAEventPrivate::readDateTime(const Event::Ptr &event, bool localZone, bool dateOnly, DateTime &start)
{
start = DateTime(event->dtStart());
if (dateOnly) {
......@@ -3871,6 +3879,12 @@ DateTime KAEventPrivate::readDateTime(const Event::Ptr &event, bool dateOnly, Da
// by a date-only start date/time (for the reasons given in updateKCalEvent()).
start.setDateOnly(true);
}
if (localZone) {
// The local system time zone is indicated by the X-KDE-KALARM-FLAGS:LOCAL
// property, because QDateTime values with time spec Qt::LocalTime are not
// stored correctly in the calendar file.
start.setTimeSpec(KADateTime::LocalZone);
}
DateTime next = start;
const int SZ_YEAR = 4; // number of digits in year value
const int SZ_MONTH = 2; // number of digits in month value
......@@ -5476,7 +5490,7 @@ bool KAEvent::convertKCalEvents(const Calendar::Ptr &calendar, int calendarVersi
if (!flagsValid) {
flags = event->customProperty(KACalendar::APPNAME, KAEventPrivate::FLAGS_PROPERTY).split(KAEventPrivate::SC, QString::SkipEmptyParts);
}
if (flags.indexOf(KAEventPrivate::REMINDER_TYPE) < 0) {
if (!flags.contains(KAEventPrivate::REMINDER_TYPE)) {
flags += KAEventPrivate::REMINDER_TYPE;
if (reminderOnce) {
flags += KAEventPrivate::REMINDER_ONCE_FLAG;
......@@ -5503,7 +5517,7 @@ bool KAEventPrivate::convertStartOfDay(const Event::Ptr &event)
bool changed = false;
const QTime midnight(0, 0);
const QStringList flags = event->customProperty(KACalendar::APPNAME, KAEventPrivate::FLAGS_PROPERTY).split(KAEventPrivate::SC, QString::SkipEmptyParts);
if (flags.indexOf(KAEventPrivate::DATE_ONLY_FLAG) >= 0) {
if (flags.contains(KAEventPrivate::DATE_ONLY_FLAG)) {
// It's an untimed event, so fix it
const QDateTime oldDt = event->dtStart();
const int adjustment = oldDt.time().secsTo(midnight);
......@@ -5535,7 +5549,7 @@ bool KAEventPrivate::convertStartOfDay(const Event::Ptr &event)
int deferralOffset = 0;
int newDeferralOffset = 0;
DateTime start;
const KADateTime nextMainDateTime = readDateTime(event, false, start).kDateTime();
const KADateTime nextMainDateTime = readDateTime(event, false, false, start).kDateTime();
AlarmMap alarmMap;
readAlarms(event, &alarmMap);
for (AlarmMap::ConstIterator it = alarmMap.constBegin(); it != alarmMap.constEnd(); ++it) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment