Verified Commit 839e08b9 authored by Fushan Wen's avatar Fushan Wen 💬
Browse files

alternatecalendar: Add plugin base

This adds the basic structure of the alternate calendar plugin.

CCBUG: 429892
parent f2a0de9a
......@@ -2,6 +2,15 @@
# SPDX-License-Identifier: GPL-2.0-or-later
set(alternatecalendar_LIB_SRCS
alternatecalendarplugin.cpp
)
set(alternatecalendar_LINK_LIBRARIES
KF5::ConfigCore
KF5::CalendarEvents
)
find_package(ICU 66.1 COMPONENTS uc i18n)
set_package_properties(ICU
PROPERTIES DESCRIPTION "Unicode and Globalization support for software applications"
......@@ -13,3 +22,6 @@ if(ICU_FOUND)
endif()
configure_file(config-ICU.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-ICU.h)
kcoreaddons_add_plugin(alternatecalendar SOURCES ${alternatecalendar_LIB_SRCS} INSTALL_NAMESPACE "plasmacalendarplugins")
target_link_libraries(alternatecalendar ${alternatecalendar_LINK_LIBRARIES})
/*
SPDX-FileCopyrightText: 2022 Fushan Wen <qydwhotmail@gmail.com>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "alternatecalendarplugin.h"
class AlternateCalendarPluginPrivate
{
public:
explicit AlternateCalendarPluginPrivate(AlternateCalendarPlugin *parent);
~AlternateCalendarPluginPrivate();
void init();
CalendarSystem::System m_calendarSystem;
private:
AlternateCalendarPlugin *q;
};
AlternateCalendarPluginPrivate::AlternateCalendarPluginPrivate(AlternateCalendarPlugin *parent)
: q(parent)
{
}
AlternateCalendarPluginPrivate::~AlternateCalendarPluginPrivate()
{
}
void AlternateCalendarPluginPrivate::init()
{
}
AlternateCalendarPlugin::AlternateCalendarPlugin(QObject *parent)
: CalendarEvents::CalendarEventsPlugin(parent)
, d(std::make_unique<AlternateCalendarPluginPrivate>(this))
{
}
AlternateCalendarPlugin::~AlternateCalendarPlugin()
{
}
void AlternateCalendarPlugin::loadEventsForDateRange(const QDate &startDate, const QDate &endDate)
{
if (!endDate.isValid() || d->m_calendarSystem == CalendarSystem::Gregorian) {
return;
}
QHash<QDate, QDate> alternateDatesData;
QHash<QDate, SubLabel> subLabelsData;
for (QDate date = startDate; date <= endDate && date.isValid(); date = date.addDays(1)) {
}
if (alternateDatesData.size() > 0) {
Q_EMIT alternateDateReady(alternateDatesData);
}
Q_EMIT subLabelReady(subLabelsData);
}
/*
SPDX-FileCopyrightText: 2022 Fushan Wen <qydwhotmail@gmail.com>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef ALTERNATECALENDARPLUGIN_H
#define ALTERNATECALENDARPLUGIN_H
#include <memory>
#include <CalendarEvents/CalendarEventsPlugin>
#include "calendarsystem.h"
class AlternateCalendarPlugin : public CalendarEvents::CalendarEventsPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.kde.CalendarEventsPlugin" FILE "alternatecalendarplugin.json")
Q_INTERFACES(CalendarEvents::CalendarEventsPlugin)
public:
AlternateCalendarPlugin(QObject *parent = nullptr);
~AlternateCalendarPlugin() override;
void loadEventsForDateRange(const QDate &startDate, const QDate &endDate) override;
private:
const std::unique_ptr<class AlternateCalendarPluginPrivate> d;
};
#endif
{
"KPlugin": {
"Description": "Calendar plugin for displaying dates from the alternate calendar system",
"Icon": "office-calendar",
"Name": "Alternate Calendar"
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment