File indexing completed on 2024-11-17 04:45:02

0001 /*
0002     SPDX-FileCopyrightText: 2009 David Jarvie <djarvie@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "notesresource.h"
0008 
0009 #include <KCalendarCore/Incidence>
0010 
0011 #include <KConfigSkeleton>
0012 #include <QStandardPaths>
0013 
0014 using namespace Akonadi;
0015 using namespace KCalendarCore;
0016 
0017 static const QLatin1StringView sNotesType("application/x-vnd.kde.notes");
0018 
0019 NotesResource::NotesResource(const QString &id)
0020     : ICalResource(id, allMimeTypes(), QStringLiteral("knotes"))
0021 {
0022     KConfigSkeleton::ItemPath *item = static_cast<KConfigSkeleton::ItemPath *>(mSettings->findItem(QStringLiteral("Path")));
0023     if (item) {
0024         item->setDefaultValue(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1Char('/') + QLatin1StringView("knotes/"));
0025     }
0026 }
0027 
0028 NotesResource::~NotesResource() = default;
0029 
0030 QStringList NotesResource::allMimeTypes() const
0031 {
0032     return {sNotesType};
0033 }
0034 
0035 QString NotesResource::mimeType(const KCalendarCore::IncidenceBase::Ptr &) const
0036 {
0037     return sNotesType;
0038 }
0039 
0040 AKONADI_RESOURCE_MAIN(NotesResource)
0041 
0042 #include "moc_notesresource.cpp"