Commit 00423b37 authored by Bea Lam's avatar Bea Lam

[nemo-qml-plugin-calendar] Port to KF5CalendarCore. JB#47814

parent ae4f872a
......@@ -6,7 +6,7 @@ QT += qml dbus
QT -= gui
CONFIG += link_pkgconfig
PKGCONFIG += libkcalcoren-qt5 libmkcal-qt5 libical accounts-qt5
PKGCONFIG += KF5CalendarCore libmkcal-qt5 libical accounts-qt5
HEADERS += \
calendardataservice.h \
......
......@@ -12,7 +12,7 @@ BuildRequires: pkgconfig(Qt5Gui)
BuildRequires: pkgconfig(Qt5Qml)
BuildRequires: pkgconfig(Qt5Concurrent)
BuildRequires: pkgconfig(libmkcal-qt5)
BuildRequires: pkgconfig(libkcalcoren-qt5)
BuildRequires: pkgconfig(KF5CalendarCore)
BuildRequires: pkgconfig(libical)
BuildRequires: pkgconfig(accounts-qt5)
......@@ -41,7 +41,7 @@ Summary: Calendar import/export tool
License: BSD
Group: Applications/System
BuildRequires: pkgconfig(libmkcal-qt5)
BuildRequires: pkgconfig(libkcalcoren-qt5)
BuildRequires: pkgconfig(KF5CalendarCore)
%description tools
%{summary}.
......
/*
* Copyright (C) 2013 Jolla Ltd.
* Contact: Aaron Kennedy <aaron.kennedy@jollamobile.com>
* Copyright (C) 2013 - 2019 Jolla Ltd.
* Copyright (c) 2020 Open Mobile Platform LLC.
*
* You may use this file under the terms of the BSD license as follows:
*
......@@ -65,7 +65,7 @@ CalendarEventModification * CalendarApi::createModification(CalendarEvent *sourc
void CalendarApi::remove(const QString &uid, const QString &recurrenceId, const QDateTime &time)
{
KDateTime recurrenceTime = KDateTime::fromString(recurrenceId);
QDateTime recurrenceTime = QDateTime::fromString(recurrenceId, Qt::ISODate);
CalendarManager::instance()->deleteEvent(uid, recurrenceTime, time);
// TODO: this sucks
......
/*
* Copyright (c) 2015 - 2019 Jolla Ltd.
* Copyright (c) 2019 - 2020 Open Mobile Platform LLC.
*
* You may use this file under the terms of the BSD license as follows:
*
* "Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Nemo Mobile nor the names of its contributors
* may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
*/
#include "calendarchangeinformation.h"
#include "calendarutils.h"
#include <QDebug>
CalendarChangeInformation::CalendarChangeInformation(QObject *parent) :
......@@ -10,7 +44,7 @@ CalendarChangeInformation::~CalendarChangeInformation()
{
}
void CalendarChangeInformation::setInformation(const QString &uniqueId, const KDateTime &recurrenceId)
void CalendarChangeInformation::setInformation(const QString &uniqueId, const QDateTime &recurrenceId)
{
m_uniqueId = uniqueId;
m_recurrenceId = recurrenceId;
......@@ -33,5 +67,5 @@ QString CalendarChangeInformation::uniqueId()
QString CalendarChangeInformation::recurrenceId()
{
return m_recurrenceId.toString();
return CalendarUtils::recurrenceIdToString(m_recurrenceId);
}
/*
* Copyright (c) 2014 - 2019 Jolla Ltd.
* Copyright (c) 2020 Open Mobile Platform LLC.
*
* You may use this file under the terms of the BSD license as follows:
*
* "Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Nemo Mobile nor the names of its contributors
* may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
*/
#ifndef CALENDARCHANGEINFORMATION_H
#define CALENDARCHANGEINFORMATION_H
#include <QObject>
#include <QString>
#include <KDateTime>
#include <QDateTime>
class CalendarChangeInformation : public QObject
{
......@@ -17,7 +48,7 @@ public:
explicit CalendarChangeInformation(QObject *parent = 0);
virtual ~CalendarChangeInformation();
void setInformation(const QString &uniqueId, const KDateTime &recurrenceId);
void setInformation(const QString &uniqueId, const QDateTime &recurrenceId);
bool pending();
QString uniqueId();
QString recurrenceId();
......@@ -30,7 +61,7 @@ signals:
private:
bool m_pending;
QString m_uniqueId;
KDateTime m_recurrenceId;
QDateTime m_recurrenceId;
};
#endif
/*
* Copyright (c) 2014 - 2019 Jolla Ltd.
* Copyright (c) 2020 Open Mobile Platform LLC.
*
* You may use this file under the terms of the BSD license as follows:
*
* "Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Nemo Mobile nor the names of its contributors
* may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
*/
#ifndef NEMOCALENDARDATA_H
#define NEMOCALENDARDATA_H
#include <QString>
#include <QUrl>
#include <QDateTime>
// KCalCore
#include <attendee.h>
#include <KDateTime>
// KCalendarCore
#include <KCalendarCore/Attendee>
#include "calendarevent.h"
......@@ -14,7 +46,7 @@ namespace CalendarData {
struct EventOccurrence {
QString eventUid;
KDateTime recurrenceId;
QDateTime recurrenceId;
QDateTime startTime;
QDateTime endTime;
......@@ -27,8 +59,8 @@ struct EventOccurrence {
struct Event {
QString displayLabel;
QString description;
KDateTime startTime;
KDateTime endTime;
QDateTime startTime;
QDateTime endTime;
bool allDay = false;
bool readOnly = false;
bool rsvp = false;
......@@ -38,7 +70,7 @@ struct Event {
CalendarEvent::Days recurWeeklyDays;
int reminder; // seconds; 15 minutes before event = +900, at time of event = 0, no reminder = negative value.
QString uniqueId;
KDateTime recurrenceId;
QDateTime recurrenceId;
QString location;
CalendarEvent::Secrecy secrecy;
QString calendarUid;
......@@ -92,8 +124,8 @@ struct Attendee {
bool isOrganizer = false;
QString name;
QString email;
KCalCore::Attendee::Role participationRole = KCalCore::Attendee::OptParticipant;
KCalCore::Attendee::PartStat status = KCalCore::Attendee::None;
KCalendarCore::Attendee::Role participationRole = KCalendarCore::Attendee::OptParticipant;
KCalendarCore::Attendee::PartStat status = KCalendarCore::Attendee::None;
bool operator==(const Attendee &other) const {
return isOrganizer == other.isOrganizer
......
/*
* Copyright (C) 2013 Jolla Ltd.
* Contact: Robin Burchell <robin.burchell@jollamobile.com>
* Copyright (c) 2013 - 2019 Jolla Ltd.
* Copyright (c) 2020 Open Mobile Platform LLC.
*
* You may use this file under the terms of the BSD license as follows:
*
......@@ -33,13 +33,13 @@
#include "calendarevent.h"
#include <QQmlInfo>
#include <QDateTime>
#include <QTimeZone>
// kcalcore
#include <KDateTime>
#include "calendarutils.h"
#include "calendarmanager.h"
CalendarEvent::CalendarEvent(CalendarManager *manager, const QString &uid, const KDateTime &recurrenceId)
CalendarEvent::CalendarEvent(CalendarManager *manager, const QString &uid, const QDateTime &recurrenceId)
: QObject(manager), mManager(manager), mUniqueId(uid), mRecurrenceId(recurrenceId)
{
connect(mManager, SIGNAL(notebookColorChanged(QString)),
......@@ -64,56 +64,47 @@ QString CalendarEvent::description() const
QDateTime CalendarEvent::startTime() const
{
// Cannot use KDateTime::dateTime() here because it is handling UTC
// spec in a different manner than other specs. If UTC, the QDateTime
// Cannot return the date time directly here. If UTC, the QDateTime
// will be in UTC also and the UI will convert it to local when displaying
// the time, while in every other case, it set the QDateTime in
// local zone.
const KDateTime kdt = mManager->getEvent(mUniqueId, mRecurrenceId).startTime;
return QDateTime(kdt.date(), kdt.time());
const QDateTime dt = mManager->getEvent(mUniqueId, mRecurrenceId).startTime;
return QDateTime(dt.date(), dt.time());
}
QDateTime CalendarEvent::endTime() const
{
const KDateTime kdt = mManager->getEvent(mUniqueId, mRecurrenceId).endTime;
return QDateTime(kdt.date(), kdt.time());
const QDateTime dt = mManager->getEvent(mUniqueId, mRecurrenceId).endTime;
return QDateTime(dt.date(), dt.time());
}
static CalendarEvent::TimeSpec toTimeSpec(const KDateTime &dt)
static Qt::TimeSpec toTimeSpec(const QDateTime &dt)
{
switch (dt.timeType()) {
case (KDateTime::ClockTime):
return CalendarEvent::SpecClockTime;
case (KDateTime::LocalZone):
return CalendarEvent::SpecLocalZone;
case (KDateTime::TimeZone):
return CalendarEvent::SpecTimeZone;
case (KDateTime::UTC):
return CalendarEvent::SpecUtc;
default:
// Ignore other time types.
return CalendarEvent::SpecLocalZone;
if (dt.timeZone() == QTimeZone::utc()) {
return Qt::UTC;
}
return dt.timeSpec();
}
CalendarEvent::TimeSpec CalendarEvent::startTimeSpec() const
Qt::TimeSpec CalendarEvent::startTimeSpec() const
{
return toTimeSpec(mManager->getEvent(mUniqueId, mRecurrenceId).startTime);
}
CalendarEvent::TimeSpec CalendarEvent::endTimeSpec() const
Qt::TimeSpec CalendarEvent::endTimeSpec() const
{
return toTimeSpec(mManager->getEvent(mUniqueId, mRecurrenceId).endTime);
}
QString CalendarEvent::startTimeZone() const
{
return mManager->getEvent(mUniqueId, mRecurrenceId).startTime.timeZone().name();
return QString::fromLatin1(mManager->getEvent(mUniqueId, mRecurrenceId).startTime.timeZone().id());
}
QString CalendarEvent::endTimeZone() const
{
return mManager->getEvent(mUniqueId, mRecurrenceId).endTime.timeZone().name();
return QString::fromLatin1(mManager->getEvent(mUniqueId, mRecurrenceId).endTime.timeZone().id());
}
bool CalendarEvent::allDay() const
......@@ -201,7 +192,7 @@ bool CalendarEvent::sendResponse(int response)
return mManager->sendResponse(mManager->getEvent(mUniqueId, mRecurrenceId), (Response)response);
}
KDateTime CalendarEvent::recurrenceId() const
QDateTime CalendarEvent::recurrenceId() const
{
return mRecurrenceId;
}
......@@ -209,7 +200,7 @@ KDateTime CalendarEvent::recurrenceId() const
QString CalendarEvent::recurrenceIdString() const
{
if (mRecurrenceId.isValid()) {
return mRecurrenceId.toString();
return CalendarUtils::recurrenceIdToString(mRecurrenceId);
} else {
return QString();
}
......
......@@ -36,8 +36,6 @@
#include <QObject>
#include <QDateTime>
#include <KDateTime>
class CalendarManager;
class CalendarEvent : public QObject
......@@ -51,8 +49,8 @@ class CalendarEvent : public QObject
Q_PROPERTY(QString description READ description NOTIFY descriptionChanged)
Q_PROPERTY(QDateTime startTime READ startTime NOTIFY startTimeChanged)
Q_PROPERTY(QDateTime endTime READ endTime NOTIFY endTimeChanged)
Q_PROPERTY(CalendarEvent::TimeSpec startTimeSpec READ startTimeSpec NOTIFY startTimeChanged)
Q_PROPERTY(CalendarEvent::TimeSpec endTimeSpec READ endTimeSpec NOTIFY endTimeChanged)
Q_PROPERTY(Qt::TimeSpec startTimeSpec READ startTimeSpec NOTIFY startTimeChanged)
Q_PROPERTY(Qt::TimeSpec endTimeSpec READ endTimeSpec NOTIFY endTimeChanged)
Q_PROPERTY(QString startTimeZone READ startTimeZone NOTIFY startTimeChanged)
Q_PROPERTY(QString endTimeZone READ endTimeZone NOTIFY endTimeChanged)
Q_PROPERTY(bool allDay READ allDay NOTIFY allDayChanged)
......@@ -101,14 +99,6 @@ public:
Q_DECLARE_FLAGS(Days, Day)
Q_FLAG(Days)
enum TimeSpec {
SpecLocalZone,
SpecClockTime,
SpecTimeZone,
SpecUtc
};
Q_ENUM(TimeSpec)
enum Secrecy {
SecrecyPublic,
SecrecyPrivate,
......@@ -130,15 +120,15 @@ public:
};
Q_ENUM(SyncFailure)
CalendarEvent(CalendarManager *manager, const QString &uid, const KDateTime &recurrenceId);
CalendarEvent(CalendarManager *manager, const QString &uid, const QDateTime &recurrenceId);
~CalendarEvent();
QString displayLabel() const;
QString description() const;
QDateTime startTime() const;
QDateTime endTime() const;
TimeSpec startTimeSpec() const;
TimeSpec endTimeSpec() const;
Qt::TimeSpec startTimeSpec() const;
Qt::TimeSpec endTimeSpec() const;
QString startTimeZone() const;
QString endTimeZone() const;
bool allDay() const;
......@@ -152,7 +142,7 @@ public:
bool readOnly() const;
QString calendarUid() const;
QString location() const;
KDateTime recurrenceId() const;
QDateTime recurrenceId() const;
QString recurrenceIdString() const;
Secrecy secrecy() const;
SyncFailure syncFailure() const;
......@@ -191,7 +181,7 @@ signals:
private:
CalendarManager *mManager;
QString mUniqueId;
KDateTime mRecurrenceId;
QDateTime mRecurrenceId;
};
#endif // CALENDAREVENT_H
/*
* Copyright (c) 2014 - 2019 Jolla Ltd.
* Copyright (c) 2020 Open Mobile Platform LLC.
*
* You may use this file under the terms of the BSD license as follows:
*
* "Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Nemo Mobile nor the names of its contributors
* may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
*/
#include "calendareventmodification.h"
#include "calendarmanager.h"
#include <ksystemtimezone.h>
#include "calendarutils.h"
#include <QTimeZone>
#include <QDebug>
namespace {
void updateTime(QDateTime *dt, Qt::TimeSpec spec, const QString &timeZone)
{
if (spec == Qt::TimeZone) {
QTimeZone tz(timeZone.toUtf8());
if (tz.isValid()) {
dt->setTimeZone(tz);
} else {
qWarning() << "Cannot find time zone:" << timeZone;
}
} else {
dt->setTimeSpec(spec);
}
}
}
CalendarEventModification::CalendarEventModification(CalendarData::Event data, QObject *parent)
: QObject(parent), m_event(data), m_attendeesSet(false)
{
......@@ -16,8 +67,6 @@ CalendarEventModification::CalendarEventModification(QObject *parent)
m_event.reminder = -1; // ReminderNone
m_event.allDay = false;
m_event.readOnly = false;
m_event.startTime = KDateTime(QDateTime(), KDateTime::LocalZone);
m_event.endTime = KDateTime(QDateTime(), KDateTime::LocalZone);
}
CalendarEventModification::~CalendarEventModification()
......@@ -52,46 +101,28 @@ void CalendarEventModification::setDescription(const QString &description)
QDateTime CalendarEventModification::startTime() const
{
return m_event.startTime.dateTime();
}
static KDateTime toKDateTime(const QDateTime &dt, int spec, const QString &timezone)
{
if (spec == CalendarEvent::SpecTimeZone) {
KTimeZone tz = KSystemTimeZones::zone(timezone);
if (tz.isValid()) {
return KDateTime(dt, tz);
} else {
qWarning() << "Invalid zone name, falling back to local zone:" << timezone;
return KDateTime(dt, KDateTime::LocalZone);
}
} else if (spec == CalendarEvent::SpecClockTime) {
return KDateTime(dt, KDateTime::ClockTime);
} else if (spec == CalendarEvent::SpecUtc) {
return KDateTime(QDateTime(dt.date(), dt.time(), Qt::UTC));
}
return KDateTime(dt, KDateTime::LocalZone);
return m_event.startTime;
}
void CalendarEventModification::setStartTime(const QDateTime &startTime, int spec, const QString &timezone)
void CalendarEventModification::setStartTime(const QDateTime &startTime, Qt::TimeSpec spec, const QString &timezone)
{
const KDateTime time = toKDateTime(startTime, spec, timezone);
if (m_event.startTime != time) {
m_event.startTime = time;
if (m_event.startTime != startTime) {
m_event.startTime = startTime;
updateTime(&m_event.startTime, spec, timezone);
emit startTimeChanged();
}
}
QDateTime CalendarEventModification::endTime() const
{
return m_event.endTime.dateTime();
return m_event.endTime;
}
void CalendarEventModification::setEndTime(const QDateTime &endTime, int spec, const QString &timezone)
void CalendarEventModification::setEndTime(const QDateTime &endTime, Qt::TimeSpec spec, const QString &timezone)
{
const KDateTime time = toKDateTime(endTime, spec, timezone);
if (m_event.endTime != time) {
m_event.endTime = time;
if (m_event.endTime != endTime) {
m_event.endTime = endTime;
updateTime(&m_event.endTime, spec, timezone);
emit endTimeChanged();
}
}
......@@ -168,7 +199,7 @@ void CalendarEventModification::setRecurWeeklyDays(CalendarEvent::Days days)
QString CalendarEventModification::recurrenceIdString() const
{
if (m_event.recurrenceId.isValid()) {
return m_event.recurrenceId.toString();
return CalendarUtils::recurrenceIdToString(m_event.recurrenceId);
} else {
return QString();
}
......
/*
* Copyright (c) 2014 - 2019 Jolla Ltd.
* Copyright (c) 2020 Open Mobile Platform LLC.
*
* You may use this file under the terms of the BSD license as follows:
*
* "Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Nemo Mobile nor the names of its contributors
* may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
*/
#ifndef CALENDAREVENTMODIFICATION_H
#define CALENDAREVENTMODIFICATION_H
......@@ -38,10 +70,10 @@ public:
void setDescription(const QString &description);
QDateTime startTime() const;
Q_INVOKABLE void setStartTime(const QDateTime &startTime, int spec, const QString &timezone = QString());
Q_INVOKABLE void setStartTime(const QDateTime &startTime, Qt::TimeSpec spec, const QString &timezone = QString());
QDateTime endTime() const;
Q_INVOKABLE void setEndTime(const QDateTime &endTime, int spec, const QString &timezone = QString());
Q_INVOKABLE void setEndTime(const QDateTime &endTime, Qt::TimeSpec spec, const QString &timezone = QString());
bool allDay() const;
void setAllDay(bool);
......
/*
* Copyright (C) 2013 Jolla Ltd.
* Contact: Robin Burchell <robin.burchell@jollamobile.com>
* Copyright (C) 2013 - 2019 Jolla Ltd.
* Copyright (C) 2020 Open Mobile Platform LLC.
*
* You may use this file under the terms of the BSD license as follows:
*
......@@ -38,7 +38,7 @@
#include "calendarmanager.h"
CalendarEventOccurrence::CalendarEventOccurrence(const QString &eventUid,
const KDateTime &recurrenceId,
const QDateTime &recurrenceId,
const QDateTime &startTime,
const QDateTime &endTime,
QObject *parent)
......@@ -74,15 +74,15 @@ void CalendarEventOccurrence::eventUidChanged(QString oldUid, QString newUid)
}
static QDateTime toEventDateTime(const QDateTime &dateTime,
CalendarEvent::TimeSpec eventSpec,
Qt::TimeSpec eventSpec,
const QString &eventTimezone)
{
switch (eventSpec) {
case (CalendarEvent::SpecTimeZone): {
case (Qt::TimeZone): {
const QDateTime dt = dateTime.toTimeZone(QTimeZone(eventTimezone.toUtf8()));
return QDateTime(dt.date(), dt.time());
}
case (CalendarEvent::SpecUtc): {
case (Qt::UTC): {
const QDateTime dt = dateTime.toUTC();
return QDateTime(dt.date(), dt.time());
}
......
/*
* Copyright (C) 2013 Jolla Ltd.
* Contact: Robin Burchell <robin.burchell@jollamobile.com>
* Copyright (C) 2013 - 2019 Jolla Ltd.
* Copyright (C) 2020 Open Mobile Platform LLC.
*
* You may use this file under the terms of the BSD license as follows:
*
......@@ -36,8 +36,6 @@
#include <QObject>
#include <QDateTime>
#include <KDateTime>
class CalendarEvent;
class CalendarEventOccurrence : public QObject
......@@ -53,7 +51,7 @@ class CalendarEventOccurrence : public QObject
public:
CalendarEventOccurrence(const QString &eventUid,
const KDateTime &recurrenceId,
const QDateTime &recurrenceId,
const QDateTime &startTime,
const QDateTime &endTime,
QObject *parent = 0);
......@@ -70,7 +68,7 @@ private slots:
private:
QString mEventUid;
KDateTime mRecurrenceId;
QDateTime mRecurrenceId;
QDateTime mStartTime;
QDateTime mEndTime;
};
......
/*
* Copyright (C) 2013 Jolla Ltd.
* Contact: Aaron Kennedy <aaron.kennedy@jollamobile.com>
* Copyright (c) 2013 - 2019 Jolla Ltd.
* Copyright (c) 2020 Open Mobile Platform LLC.
*
* You may use this file under the terms of the BSD license as follows:
*
......@@ -36,6 +36,8 @@
#include "calendareventoccurrence.h"
#include "calendarutils.h"
#include <QDebug>
CalendarEventQuery::CalendarEventQuery()
: mIsComplete(true), mOccurrence(0), mAttendeesCached(false), mEventError(false)
{
......@@ -82,7 +84,7 @@ void CalendarEventQuery::setUniqueId(const QString &uid)
QString CalendarEventQuery::recurrenceIdString()
{
if (mRecurrenceId.isValid()) {
return mRecurrenceId.toString();
return CalendarUtils::recurrenceIdToString(mRecurrenceId);
} else {
return QString();
}
......@@ -90,7 +92,7 @@ QString CalendarEventQuery::recurrenceIdString()
void CalendarEventQuery::setRecurrenceIdString(const QString &recurrenceId)
{
KDateTime recurrenceIdTime = KDateTime::fromString(recurrenceId);
QDateTime recurrenceIdTime = QDateTime::fromString(recurrenceId, Qt::ISODate);
if (mRecurrenceId == recurrenceIdTime) {
return;
}
......@@ -224,7 +226,7 @@ bool CalendarEventQuery::eventError() const
return mEventError;
}
KDateTime CalendarEventQuery::recurrenceId()
QDateTime CalendarEventQuery::recurrenceId()
{
return mRecurrenceId;
}