Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[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.
  • Loading branch information
llewelld committed Jan 20, 2021
1 parent cc59103 commit dd67c87
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/calendarimportmodel.cpp
Expand Up @@ -143,6 +143,8 @@ bool CalendarImportModel::importToNotebook(const QString &notebookUid)
{
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;
Expand All @@ -161,12 +163,19 @@ bool CalendarImportModel::importToNotebook(const QString &notebookUid)
}
}

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<int, QByteArray> CalendarImportModel::roleNames() const
Expand Down

0 comments on commit dd67c87

Please sign in to comment.