File indexing completed on 2024-11-24 04:50:39

0001 // SPDX-FileCopyrightText: 2022 Carl Schwan <carl@carlschwan.eu>
0002 // SPDX-License-Identifier: LGPL-2.0-or-later
0003 
0004 #include "calendarplugin.h"
0005 #include "calendarapplication.h"
0006 #include "calendarconfig.h"
0007 #include "calendarmanager.h"
0008 #include "datetimestate.h"
0009 #include "filter.h"
0010 #include "incidencewrapper.h"
0011 #include "models/hourlyincidencemodel.h"
0012 #include "models/incidenceoccurrencemodel.h"
0013 #include "models/infinitecalendarviewmodel.h"
0014 #include "models/itemtagsmodel.h"
0015 #include "models/monthmodel.h"
0016 #include "models/multidayincidencemodel.h"
0017 #include "models/timezonelistmodel.h"
0018 #include "models/todosortfilterproxymodel.h"
0019 #include "remindersmodel.h"
0020 #include "utils.h"
0021 #include <Akonadi/AgentFilterProxyModel>
0022 
0023 #include <QAbstractListModel>
0024 #include <QQmlEngine>
0025 #include <QtQml>
0026 
0027 #include <Akonadi/FreeBusyManager>
0028 #include <akonadi/calendarsettings.h> //krazy:exclude=camelcase this is a generated file
0029 
0030 void CalendarPlugin::registerTypes(const char *uri)
0031 {
0032     Q_ASSERT(uri == QByteArray("org.kde.merkuro.calendar"));
0033 
0034     qmlRegisterSingletonType<Utils>(uri, 1, 0, "Utils", [](QQmlEngine *engine, QJSEngine *scriptEngine) {
0035         Q_UNUSED(engine)
0036         Q_UNUSED(scriptEngine)
0037         return new Utils;
0038     });
0039     qmlRegisterSingletonType<Akonadi::CalendarSettings>(uri, 1, 0, "CalendarSettings", [](QQmlEngine *engine, QJSEngine *scriptEngine) {
0040         Q_UNUSED(engine)
0041         Q_UNUSED(scriptEngine)
0042         return Akonadi::CalendarSettings::self();
0043     });
0044     qmlRegisterSingletonType<Akonadi::FreeBusyManager>(uri, 1, 0, "FreeBusyManager", [](QQmlEngine *engine, QJSEngine *scriptEngine) {
0045         Q_UNUSED(engine)
0046         Q_UNUSED(scriptEngine)
0047         return Akonadi::FreeBusyManager::self();
0048     });
0049     qmlRegisterType<RemindersModel>(uri, 1, 0, "RemindersModel");
0050     qmlRegisterModule(uri, 1, 0);
0051     qRegisterMetaType<KCalendarCore::Incidence::Ptr>();
0052 
0053     qmlRegisterSingletonType<CalendarManager>(uri, 1, 0, "CalendarManager", [](QQmlEngine *engine, QJSEngine *scriptEngine) {
0054         Q_UNUSED(engine)
0055         Q_UNUSED(scriptEngine)
0056         return new CalendarManager;
0057     });
0058 
0059     qmlRegisterSingletonType<DateTimeState>(uri, 1, 0, "DateTimeState", [](QQmlEngine *engine, QJSEngine *scriptEngine) {
0060         Q_UNUSED(engine)
0061         Q_UNUSED(scriptEngine)
0062         return new DateTimeState;
0063     });
0064     qmlRegisterSingletonType<CalendarConfig>(uri, 1, 0, "Config", [](QQmlEngine *engine, QJSEngine *scriptEngine) {
0065         Q_UNUSED(engine)
0066         Q_UNUSED(scriptEngine)
0067         return new CalendarConfig;
0068     });
0069     qmlRegisterSingletonType<CalendarApplication>(uri, 1, 0, "CalendarApplication", [](QQmlEngine *engine, QJSEngine *scriptEngine) {
0070         Q_UNUSED(engine)
0071         Q_UNUSED(scriptEngine)
0072         return new CalendarApplication;
0073     });
0074 
0075     qmlRegisterSingletonType<Filter>(uri, 1, 0, "Filter", [](QQmlEngine *engine, QJSEngine *scriptEngine) {
0076         Q_UNUSED(engine)
0077         Q_UNUSED(scriptEngine)
0078         return new Filter;
0079     });
0080 
0081     qmlRegisterUncreatableType<IncidenceWrapper>(uri, 1, 0, "IncidenceWrapper", QStringLiteral("Only returned from apis"));
0082     qmlRegisterType<AttendeesModel>(uri, 1, 0, "AttendeesModel");
0083     qmlRegisterType<MultiDayIncidenceModel>(uri, 1, 0, "MultiDayIncidenceModel");
0084     qmlRegisterType<IncidenceOccurrenceModel>(uri, 1, 0, "IncidenceOccurrenceModel");
0085     qmlRegisterType<TodoSortFilterProxyModel>(uri, 1, 0, "TodoSortFilterProxyModel");
0086     qmlRegisterType<ItemTagsModel>(uri, 1, 0, "ItemTagsModel");
0087     qmlRegisterType<HourlyIncidenceModel>(uri, 1, 0, "HourlyIncidenceModel");
0088     qmlRegisterType<TimeZoneListModel>(uri, 1, 0, "TimeZoneListModel");
0089     qmlRegisterType<MonthModel>(uri, 1, 0, "MonthModel");
0090     qmlRegisterType<InfiniteCalendarViewModel>(uri, 1, 0, "InfiniteCalendarViewModel");
0091 
0092     qmlRegisterSingletonType(QUrl(QStringLiteral("qrc:/CalendarUiUtils.qml")), "org.kde.merkuro.utils", 1, 0, "CalendarUiUtils");
0093 
0094     qRegisterMetaType<Akonadi::ETMCalendar::Ptr>();
0095     qRegisterMetaType<QAbstractProxyModel *>("QAbstractProxyModel*");
0096     qRegisterMetaType<Akonadi::AgentFilterProxyModel *>();
0097     qRegisterMetaType<Akonadi::CollectionFilterProxyModel *>();
0098     qRegisterMetaType<QAction *>();
0099 }
0100 
0101 #include "moc_calendarplugin.cpp"