/* SPDX-FileCopyrightText: 2013 Mark Gaiser SPDX-FileCopyrightText: 2016 Martin Klapetek SPDX-License-Identifier: GPL-2.0-or-later */ #pragma once #include #include #include "daydata.h" #include "eventpluginsmanager.h" #include class DaysModelPrivate; class DaysModel : public QAbstractItemModel { Q_OBJECT QML_ELEMENT QML_UNCREATABLE("") public: enum Roles { isCurrent = Qt::UserRole + 1, // containsHolidayItems, containsEventItems, containsMajorEventItems, containsMinorEventItems, // containsTodoItems, // containsJournalItems, dayNumber, monthNumber, yearNumber, DayLabel, //< For numbering systems other than "latn" Events, EventColor, EventCount, AlternateDayNumber, /**< The day number from the alternate calendar system @since 5.26 */ AlternateMonthNumber, /**< The month number from the alternate calendar system @since 5.26 */ AlternateYearNumber, /**< The year number from the alternate calendar system @since 5.26 */ SubLabel, /**< The label that is displayed in the tooltip or beside the full date @since 5.26 */ SubDayLabel, /**< The label that is displayed under the day number @since 5.26 */ SubMonthLabel, /**< The label that is displayed under the month number @since 5.26 */ SubYearLabel, /**< The label that is displayed under the year number @since 5.26 */ }; explicit DaysModel(QObject *parent = nullptr); ~DaysModel() override; void setSourceData(QList *data); int rowCount(const QModelIndex &parent = QModelIndex()) const override; int columnCount(const QModelIndex &parent) const override; QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override; QModelIndex parent(const QModelIndex &index) const override; QVariant data(const QModelIndex &index, int role) const override; Q_INVOKABLE void setPluginsManager(EventPluginsManager *manager); // It could've been QList, but that won't usable in QML Q_INVOKABLE QVariantList eventsForDate(const QDate &date); QHash roleNames() const override; Q_SIGNALS: void agendaUpdated(const QDate &updatedDate); public Q_SLOTS: void update(); private Q_SLOTS: void onDataReady(const QMultiHash &data); void onEventModified(const CalendarEvents::EventData &data); void onEventRemoved(const QString &uid); void onAlternateCalendarDateReady(const QHash &data); void onSubLabelReady(const QHash &data); private: DaysModelPrivate *const d; QModelIndex indexForDate(const QDate &date); bool hasMajorEventAtDate(const QDate &date) const; bool hasMinorEventAtDate(const QDate &date) const; };