From dd67c8753f87264ba626e72b240559ad2452b071 Mon Sep 17 00:00:00 2001 From: David Llewellyn-Jones Date: Fri, 15 Jan 2021 17:20:19 +0000 Subject: [PATCH] [nemo-qml-plugin-calendar] Allow import to notebook from ics string. Contributes to JB#52660 The CalendarImportModel::importToNotebook() method allowed files to be imported to a notebook, but didn't allow ics data to be imported directly as a string, even though ImportModel supports it more generally. This change allows import to a notebook by string of ics data directly. --- src/calendarimportmodel.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/calendarimportmodel.cpp b/src/calendarimportmodel.cpp index 30400af..77ab124 100644 --- a/src/calendarimportmodel.cpp +++ b/src/calendarimportmodel.cpp @@ -143,6 +143,8 @@ bool CalendarImportModel::importToNotebook(const QString ¬ebookUid) { mKCal::ExtendedCalendar::Ptr calendar(new mKCal::ExtendedCalendar(QTimeZone::systemTimeZone())); mKCal::ExtendedStorage::Ptr storage = calendar->defaultStorage(calendar); + bool success = false; + if (!storage->open()) { qWarning() << "Unable to open calendar DB"; return false; @@ -161,12 +163,19 @@ bool CalendarImportModel::importToNotebook(const QString ¬ebookUid) } } - if (CalendarUtils::importFromFile(mFileName, calendar)) + if (!mFileName.isEmpty()) { + success = CalendarUtils::importFromFile(mFileName, calendar); + } else { + success = CalendarUtils::importFromIcsRawData(mIcsRawData, calendar); + } + + if (success) { storage->save(); + } storage->close(); - return true; + return success; } QHash CalendarImportModel::roleNames() const