Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'kf5' into 'master'
[nemo-qml-plugin-calendar] Port to KF5CalendarCore. JB#47814

See merge request mer-core/nemo-qml-plugin-calendar!67
  • Loading branch information
blam committed Dec 20, 2020
2 parents ae4f872 + 00423b3 commit a01dbb7
Show file tree
Hide file tree
Showing 32 changed files with 827 additions and 627 deletions.
2 changes: 1 addition & 1 deletion lightweight/calendardataservice/calendardataservice.pro
Expand Up @@ -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 \
Expand Down
4 changes: 2 additions & 2 deletions rpm/nemo-qml-plugin-calendar-qt5.spec
Expand Up @@ -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)

Expand Down Expand Up @@ -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}.
Expand Down
6 changes: 3 additions & 3 deletions src/calendarapi.cpp
@@ -1,6 +1,6 @@
/*
* 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:
*
Expand Down Expand Up @@ -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
Expand Down
38 changes: 36 additions & 2 deletions src/calendarchangeinformation.cpp
@@ -1,4 +1,38 @@
/*
* 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) :
Expand All @@ -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;
Expand All @@ -33,5 +67,5 @@ QString CalendarChangeInformation::uniqueId()

QString CalendarChangeInformation::recurrenceId()
{
return m_recurrenceId.toString();
return CalendarUtils::recurrenceIdToString(m_recurrenceId);
}
39 changes: 35 additions & 4 deletions src/calendarchangeinformation.h
@@ -1,10 +1,41 @@
/*
* 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
{
Expand All @@ -17,7 +48,7 @@ class CalendarChangeInformation : public QObject
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();
Expand All @@ -30,7 +61,7 @@ class CalendarChangeInformation : public QObject
private:
bool m_pending;
QString m_uniqueId;
KDateTime m_recurrenceId;
QDateTime m_recurrenceId;
};

#endif
50 changes: 41 additions & 9 deletions src/calendardata.h
@@ -1,20 +1,52 @@
/*
* 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"

namespace CalendarData {

struct EventOccurrence {
QString eventUid;
KDateTime recurrenceId;
QDateTime recurrenceId;
QDateTime startTime;
QDateTime endTime;

Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand Down
53 changes: 22 additions & 31 deletions src/calendarevent.cpp
@@ -1,6 +1,6 @@
/*
* 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:
*
Expand Down Expand Up @@ -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)),
Expand All @@ -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
Expand Down Expand Up @@ -201,15 +192,15 @@ bool CalendarEvent::sendResponse(int response)
return mManager->sendResponse(mManager->getEvent(mUniqueId, mRecurrenceId), (Response)response);
}

KDateTime CalendarEvent::recurrenceId() const
QDateTime CalendarEvent::recurrenceId() const
{
return mRecurrenceId;
}

QString CalendarEvent::recurrenceIdString() const
{
if (mRecurrenceId.isValid()) {
return mRecurrenceId.toString();
return CalendarUtils::recurrenceIdToString(mRecurrenceId);
} else {
return QString();
}
Expand Down

0 comments on commit a01dbb7

Please sign in to comment.