File indexing completed on 2024-12-01 13:09:05

0001 /*
0002    SPDX-FileCopyrightText: 2019-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "libruqolacore_export.h"
0010 #include <QAbstractListModel>
0011 
0012 struct NotificationDesktopDurationPreferenceInfo {
0013     QString displayText;
0014     QString preference;
0015 };
0016 
0017 class LIBRUQOLACORE_EXPORT NotificationDesktopDurationPreferenceModel : public QAbstractListModel
0018 {
0019     Q_OBJECT
0020 public:
0021     enum NotificationPreferenceRoles {
0022         NotificationPreferenceI18n = Qt::UserRole + 1,
0023         NotificationPreference,
0024     };
0025     Q_ENUM(NotificationPreferenceRoles)
0026 
0027     explicit NotificationDesktopDurationPreferenceModel(QObject *parent = nullptr);
0028     ~NotificationDesktopDurationPreferenceModel() override;
0029 
0030     [[nodiscard]] int rowCount(const QModelIndex &parent = QModelIndex()) const override;
0031     [[nodiscard]] QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
0032 
0033     [[nodiscard]] int setCurrentNotificationPreference(const QString &preference);
0034 
0035     [[nodiscard]] QString currentPreference(int index) const;
0036 
0037 Q_SIGNALS:
0038     void currentNotificationPreferenceChanged();
0039 
0040 private:
0041     LIBRUQOLACORE_NO_EXPORT void fillModel();
0042     QVector<NotificationDesktopDurationPreferenceInfo> mNotificationDestktopDurationPreferenceList;
0043     int mCurrentPreference = 0;
0044 };