File indexing completed on 2025-04-20 07:58:50
0001 /* 0002 * SPDX-FileCopyrightText: 2019 Dimitris Kardarakos <dimkard@posteo.net> 0003 * 0004 * SPDX-License-Identifier: GPL-3.0-or-later 0005 */ 0006 0007 #ifndef RECURRENCEPERIODMODEL_H 0008 #define RECURRENCEPERIODMODEL_H 0009 0010 #include <QAbstractListModel> 0011 0012 struct PeriodModelType { 0013 ushort periodType; 0014 QString periodTypeDesc; 0015 }; 0016 0017 class ReccurencePeriodModel : public QAbstractListModel 0018 { 0019 Q_OBJECT 0020 0021 Q_PROPERTY(ushort noRepeat READ noRepeat CONSTANT) 0022 Q_PROPERTY(ushort repeatYearlyDay READ repeatYearlyDay CONSTANT) 0023 Q_PROPERTY(ushort repeatYearlyMonth READ repeatYearlyMonth CONSTANT) 0024 Q_PROPERTY(ushort repeatYearlyPos READ repeatYearlyPos CONSTANT) 0025 Q_PROPERTY(ushort repeatMonthlyDay READ repeatMonthlyDay CONSTANT) 0026 Q_PROPERTY(ushort repeatMonthlyPos READ repeatMonthlyPos CONSTANT) 0027 Q_PROPERTY(ushort repeatWeekly READ repeatWeekly CONSTANT) 0028 Q_PROPERTY(ushort repeatDaily READ repeatDaily CONSTANT) 0029 0030 public: 0031 enum RoleNames { 0032 RepeatDescriptionRole = Qt::UserRole + 1, 0033 RepeatCodeRole 0034 }; 0035 0036 explicit ReccurencePeriodModel(QObject *parent = nullptr); 0037 ~ReccurencePeriodModel() override; 0038 0039 QHash<int, QByteArray> roleNames() const override; 0040 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; 0041 int rowCount(const QModelIndex &parent) const override; 0042 0043 ushort noRepeat() const; 0044 ushort repeatYearlyDay() const; 0045 ushort repeatYearlyMonth() const; 0046 ushort repeatYearlyPos() const; 0047 ushort repeatMonthlyDay() const; 0048 ushort repeatMonthlyPos() const; 0049 ushort repeatWeekly() const; 0050 ushort repeatDaily() const; 0051 0052 Q_INVOKABLE QString periodDecription(const int periodType) const; 0053 Q_INVOKABLE QString repeatDescription(const int repeatType, const int repeatEvery, const int stopAfter) const; 0054 0055 private: 0056 void initialize(); 0057 QVector<PeriodModelType> m_periodtypes; 0058 }; 0059 0060 #endif