presentation/FolderSubscriptionEditor.h
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #pragma once | ||
| 2 | #include <QAbstractListModel> | ||
| 3 | #include <QSet> | ||
| 4 | #include <functional> | ||
| 5 | |||
| 6 | class FolderSubscriptionEditor final : public QAbstractListModel { | ||
| 7 | 1 | Q_OBJECT | |
| 8 | Q_PROPERTY(QString account READ account NOTIFY stateChanged) | ||
| 9 | Q_PROPERTY(QString error READ error NOTIFY stateChanged) | ||
| 10 | public: | ||
| 11 | enum Role { Path = Qt::UserRole + 1, Selected }; | ||
| 12 | explicit FolderSubscriptionEditor(QString profileDirectory, QObject *parent = nullptr); | ||
| 13 | int rowCount(const QModelIndex &parent = {}) const override; | ||
| 14 | QVariant data(const QModelIndex &index, int role) const override; | ||
| 15 | QHash<int, QByteArray> roleNames() const override; | ||
| 16 | 770 | QString account() const { return m_account; } | |
| 17 | 771 | QString error() const { return m_error; } | |
| 18 | void begin(QString account, QStringList available, const QStringList &selected, | ||
| 19 | std::function<bool(const QString &, const QStringList &)> admit); | ||
| 20 | Q_INVOKABLE void setSelected(int row, bool selected); | ||
| 21 | Q_INVOKABLE void selectAll(bool selected); | ||
| 22 | Q_INVOKABLE bool save(); | ||
| 23 | signals: | ||
| 24 | void stateChanged(); | ||
| 25 | void saved(const QString &account, const QStringList &folders); | ||
| 26 | private: | ||
| 27 | QString m_profileDirectory, m_account, m_error; | ||
| 28 | QStringList m_paths; | ||
| 29 | QSet<QString> m_selected; | ||
| 30 | std::function<bool(const QString &, const QStringList &)> m_admit; | ||
| 31 | }; | ||
| 32 |