File indexing completed on 2024-05-12 16:25:50

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 
0011 #include <QAbstractListModel>
0012 
0013 struct NotificationPreferenceInfo {
0014     QString displayText;
0015     QString preference;
0016 };
0017 
0018 class LIBRUQOLACORE_EXPORT NotificationPreferenceModel : public QAbstractListModel
0019 {
0020     Q_OBJECT
0021 public:
0022     enum NotificationPreferenceRoles {
0023         NotificationPreferenceI18nRole = Qt::UserRole + 1,
0024         NotificationPreferenceRole,
0025     };
0026     Q_ENUM(NotificationPreferenceRoles)
0027 
0028     explicit NotificationPreferenceModel(QObject *parent = nullptr);
0029     ~NotificationPreferenceModel() override;
0030 
0031     [[nodiscard]] int rowCount(const QModelIndex &parent = QModelIndex()) const override;
0032     [[nodiscard]] QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
0033 
0034     [[nodiscard]] int setCurrentNotificationPreference(const QString &preference);
0035 
0036     [[nodiscard]] QString currentPreference(int index) const;
0037 
0038 Q_SIGNALS:
0039     void currentNotificationPreferenceChanged();
0040 
0041 private:
0042     LIBRUQOLACORE_NO_EXPORT void fillModel();
0043     QVector<NotificationPreferenceInfo> mNotificationPreferenceList;
0044     int mCurrentPreference = 0;
0045 };