Verified Commit 3d5b448d authored by Fushan Wen's avatar Fushan Wen 💬
Browse files

alternatecalendar: Add abstract calendar provider class

This base class will be used in alternate calendar provider
implementations.

CCBUG: 429892
parent d447eb95
......@@ -4,6 +4,7 @@
set(alternatecalendar_LIB_SRCS
alternatecalendarplugin.cpp
provider/abstractcalendarprovider.cpp
)
set(alternatecalendar_LINK_LIBRARIES
......
/*
SPDX-FileCopyrightText: 2022 Fushan Wen <qydwhotmail@gmail.com>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "abstractcalendarprovider.h"
AbstractCalendarProvider::AbstractCalendarProvider(QObject *parent, CalendarSystem::System calendarSystem)
: QObject(parent)
, m_calendarSystem(calendarSystem)
{
}
AbstractCalendarProvider::~AbstractCalendarProvider()
{
}
QDate AbstractCalendarProvider::fromGregorian(const QDate &date) const
{
if (!date.isValid()) {
return QDate();
}
return date;
}
CalendarEvents::CalendarEventsPlugin::SubLabel AbstractCalendarProvider::subLabels([[maybe_unused]] const QDate &date) const
{
auto sublabel = CalendarEvents::CalendarEventsPlugin::SubLabel{};
sublabel.priority = CalendarEvents::CalendarEventsPlugin::SubLabelPriority::Low;
return sublabel;
}
/*
SPDX-FileCopyrightText: 2022 Fushan Wen <qydwhotmail@gmail.com>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#pragma once
#include "../alternatecalendarplugin.h"
/**
* @short An abstract base class for alternate calendar providers.
*
* This class serves as abstract base class for alternate calendar
* provider implementations.
*/
class AbstractCalendarProvider : public QObject
{
Q_OBJECT
public:
explicit AbstractCalendarProvider(QObject *parent, CalendarSystem::System calendarSystem);
~AbstractCalendarProvider() override;
/**
* Converts Gregorian date to alternate calendar date
*
* @param date Gregorian date
* @return Alternate calendar date
*/
virtual QDate fromGregorian(const QDate &date) const;
/**
* Gets the sub-labels for the specific Gregorian date
*
* @param date Gregorian date
* @return Sub-labels for the specific Gregorian date
*/
virtual CalendarEvents::CalendarEventsPlugin::SubLabel subLabels(const QDate &date) const;
protected:
const CalendarSystem::System m_calendarSystem;
};
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