Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'jb52660' into 'master'
Allow import to notebook from ics string

See merge request mer-core/nemo-qml-plugin-calendar!77
  • Loading branch information
llewelld committed Jan 20, 2021
2 parents cc59103 + dd67c87 commit 7d4d768
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 7d4d768

Please sign in to comment.