Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[nemo-qml-plugin-calendar] Add deleteEvent() method to CalendarEvent.…
… Contributes to JB#46945

Allows a CalendarEvent to be deleted directly. Calling the deleteEvent()
method immediately invalidates the CalendarEvent and the results from
any further method calls to it should not be relied upon.

Also adds a readOnly property to CalendarImportEvent.
  • Loading branch information
llewelld authored and rainemak committed Feb 19, 2021
1 parent 216eb01 commit 484fb36
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
10 changes: 8 additions & 2 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 - 2021 Open Mobile Platform LLC.
*
* You may use this file under the terms of the BSD license as follows:
*
Expand Down Expand Up @@ -201,6 +201,12 @@ bool CalendarEvent::sendResponse(int response)
return mManager->sendResponse(mManager->getEvent(mUniqueId, mRecurrenceId), (Response)response);
}

void CalendarEvent::deleteEvent()
{
mManager->deleteEvent(mUniqueId, mRecurrenceId, QDateTime());
mManager->save();
}

KDateTime CalendarEvent::recurrenceId() const
{
return mRecurrenceId;
Expand Down
5 changes: 3 additions & 2 deletions src/calendarevent.h
@@ -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 - 2021 Open Mobile Platform LLC.
*
* You may use this file under the terms of the BSD license as follows:
*
Expand Down Expand Up @@ -162,6 +162,7 @@ class CalendarEvent : public QObject

Q_INVOKABLE bool sendResponse(int response);
Q_INVOKABLE QString iCalendar(const QString &prodId = QString()) const;
Q_INVOKABLE void deleteEvent();

private slots:
void notebookColorChanged(QString notebookUid);
Expand Down
9 changes: 7 additions & 2 deletions src/calendarimportevent.cpp
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2015 Jolla Ltd.
* Contact: Petri M. Gerdt <petri.gerdt@jollamobile.com>
* Copyright (c) 2015 - 2019 Jolla Ltd.
* Copyright (c) 2020 - 2021 Open Mobile Platform LLC.
*
* You may use this file under the terms of the BSD license as follows:
*
Expand Down Expand Up @@ -122,6 +122,11 @@ QString CalendarImportEvent::color() const
return mColor;
}

bool CalendarImportEvent::readOnly() const
{
return true;
}

QString CalendarImportEvent::location() const
{
if (!mEvent)
Expand Down
6 changes: 4 additions & 2 deletions src/calendarimportevent.h
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2015 Jolla Ltd.
* Contact: Petri M. Gerdt <petri.gerdt@jollamobile.com>
* Copyright (c) 2015 - 2019 Jolla Ltd.
* Copyright (c) 2020 - 2021 Open Mobile Platform LLC.
*
* You may use this file under the terms of the BSD license as follows:
*
Expand Down Expand Up @@ -60,6 +60,7 @@ class CalendarImportEvent : public QObject
Q_PROPERTY(CalendarEvent::Secrecy secrecy READ secrecy CONSTANT)
Q_PROPERTY(CalendarEvent::Response ownerStatus READ ownerStatus CONSTANT)
Q_PROPERTY(bool rsvp READ rsvp CONSTANT)
Q_PROPERTY(bool readOnly READ readOnly CONSTANT)

public:
CalendarImportEvent(KCalCore::Event::Ptr event);
Expand All @@ -74,6 +75,7 @@ class CalendarImportEvent : public QObject
int reminder() const;
QString uniqueId() const;
QString color() const;
bool readOnly() const;
QString location() const;
QList<QObject*> attendees() const;
CalendarEvent::Secrecy secrecy() const;
Expand Down

0 comments on commit 484fb36

Please sign in to comment.