File indexing completed on 2024-05-05 05:28:18
0001 /* 0002 * SPDX-FileCopyrightText: 2019 Dimitris Kardarakos <dimkard@posteo.net> 0003 * 0004 * SPDX-License-Identifier: GPL-3.0-or-later 0005 */ 0006 0007 #ifndef ALARMSMODEL_H 0008 #define ALARMSMODEL_H 0009 0010 #include <QAbstractListModel> 0011 #include <KCalendarCore/Alarm> 0012 #include <KCalendarCore/FileStorage> 0013 #include <QDateTime> 0014 0015 using namespace KCalendarCore; 0016 0017 struct FilterPeriod { 0018 QDateTime from; 0019 QDateTime to; 0020 }; 0021 0022 /** 0023 * @brief Model that serves the alarms found in a set of calendar files for a specific time period 0024 * 0025 */ 0026 class AlarmsModel : public QObject 0027 { 0028 Q_OBJECT 0029 0030 public: 0031 explicit AlarmsModel(QObject *parent = nullptr); 0032 ~AlarmsModel() override; 0033 0034 /** 0035 * @return The start/end date time to use to look for alarms 0036 */ 0037 FilterPeriod period() const; 0038 0039 /** 0040 * @brief Set the start date /end time to look for alarms 0041 */ 0042 void setPeriod(const FilterPeriod &filterPeriod); 0043 0044 /** 0045 * @brief The list of calendar files to look for alarms into 0046 */ 0047 QStringList calendarFiles() const; 0048 0049 /** 0050 * @brief Set the list of calendar files to look for alarms into 0051 */ 0052 void setCalendarFiles(const QStringList &fileList); 0053 0054 /** 0055 * @brief List of alarms scheduled into the interval specified 0056 */ 0057 Alarm::List alarms() const; 0058 0059 /** 0060 * @brief Returns the date time of the first alarm to be triggered after a specific date. If no alarm exists, it returns an invalid date time. 0061 */ 0062 QDateTime firstAlarmTime() const; 0063 0064 Q_SIGNALS: 0065 void uidsChanged(); 0066 void calendarsChanged(); 0067 void periodChanged(); 0068 0069 private: 0070 void loadAlarms(); 0071 void setCalendars(); 0072 void openLoadStorages(); 0073 void closeStorages(); 0074 QDateTime parentStartDt(const int idx) const; 0075 0076 QVector<Calendar::Ptr> m_calendars; 0077 QVector<FileStorage::Ptr> m_file_storages; 0078 Alarm::List m_alarms; 0079 QStringList m_calendar_files; 0080 FilterPeriod m_period; 0081 }; 0082 #endif