presentation/MailSelectionSummary.h
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include "data/MailSelectionSnapshot.h" | ||
| 4 | #include "data/Models.h" | ||
| 5 | #include "data/MailRequest.h" | ||
| 6 | #include <QObject> | ||
| 7 | #include <QVariantList> | ||
| 8 | #include <functional> | ||
| 9 | #include <memory> | ||
| 10 | |||
| 11 | // F100-77: what a multiple selection holds, for the reader's summary | ||
| 12 | // (SelectionSummary.qml) instead of the body of one of the mails. Reads the | ||
| 13 | // first uids of the selection snapshot on the selection worker, then their | ||
| 14 | // headers from the cache; the complete set never enters the GUI thread. | ||
| 15 | class MailSelectionSummary final : public QObject { | ||
| 16 | Q_OBJECT | ||
| 17 | Q_PROPERTY(qint64 count READ count NOTIFY changed) | ||
| 18 | // Up to MaxMails maps {subject, sender, date, unread, starred}, newest first. | ||
| 19 | Q_PROPERTY(QVariantList mails READ mails NOTIFY changed) | ||
| 20 | public: | ||
| 21 | static constexpr int MaxMails = 8; | ||
| 22 | using HeaderLookup = std::function<QList<MailHeader>(const QList<MailId> &)>; | ||
| 23 | explicit MailSelectionSummary(HeaderLookup headers, QObject *parent = nullptr); | ||
| 24 | 795 | void setHeaderLookup(HeaderLookup headers) { m_headers = std::move(headers); } | |
| 25 | ✗ | qint64 count() const { return m_count; } | |
| 26 | 5122 | QVariantList mails() const { return m_mails; } | |
| 27 | // A selection of `count` mails; `snapshot` is null for a search tab's | ||
| 28 | // marked rows (the count alone is shown) and for single selections. | ||
| 29 | void update(const std::shared_ptr<const MailSelectionSnapshot> &snapshot, qint64 count); | ||
| 30 | signals: | ||
| 31 | void changed(); | ||
| 32 | private: | ||
| 33 | HeaderLookup m_headers; | ||
| 34 | std::shared_ptr<const MailSelectionSnapshot> m_snapshot; | ||
| 35 | qint64 m_count = 0; | ||
| 36 | QVariantList m_mails; | ||
| 37 | quint64 m_generation = 0; | ||
| 38 | }; | ||
| 39 |