Verified Commit 37ff5f67 authored by Fushan Wen's avatar Fushan Wen 💬
Browse files

alternatecalendar: Add calendarProvider in plugin base

The plugin will use the calendar provider to convert date and get
sub-labels.

CCBUG: 429892
parent 37335d80
......@@ -15,10 +15,13 @@ public:
~AlternateCalendarPluginPrivate();
void init();
AbstractCalendarProvider *calendarProvider() const;
CalendarSystem::System m_calendarSystem;
private:
std::unique_ptr<AbstractCalendarProvider> m_calendarProvider;
AlternateCalendarPlugin *q;
};
......@@ -33,6 +36,16 @@ AlternateCalendarPluginPrivate::~AlternateCalendarPluginPrivate()
void AlternateCalendarPluginPrivate::init()
{
// Load/Reload the calendar provider
switch (m_calendarSystem) {
default:
m_calendarProvider.reset(new AbstractCalendarProvider(p, m_calendarSystem));
}
}
AbstractCalendarProvider *AlternateCalendarPluginPrivate::calendarProvider() const
{
return m_calendarProvider.get();
}
AlternateCalendarPlugin::AlternateCalendarPlugin(QObject *parent)
......@@ -55,6 +68,10 @@ void AlternateCalendarPlugin::loadEventsForDateRange(const QDate &startDate, con
QHash<QDate, SubLabel> subLabelsData;
for (QDate date = startDate; date <= endDate && date.isValid(); date = date.addDays(1)) {
if (const QDate alt = d->calendarProvider()->fromGregorian(date); alt != date) {
alternateDatesData.insert(date, alt);
}
subLabelsData.insert(date, d->calendarProvider()->subLabels(date));
}
if (alternateDatesData.size() > 0) {
......
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