presentation/QuickMailSelection.h
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include "data/MailSelectionSnapshot.h" | ||
| 4 | #include <QObject> | ||
| 5 | #include <QSet> | ||
| 6 | #include <functional> | ||
| 7 | |||
| 8 | // Current mail and immutable selected identities are separate state. Only | ||
| 9 | // viewport membership is retained in memory; complete sets stay on the worker. | ||
| 10 | class QuickMailSelection final : public QObject { | ||
| 11 | Q_OBJECT | ||
| 12 | public: | ||
| 13 | explicit QuickMailSelection(QObject *parent = nullptr); | ||
| 14 | ~QuickMailSelection() override; | ||
| 15 | void configure(QString databasePath, MailSelectionQuery query, | ||
| 16 | std::function<bool(const MailSelectionSnapshot &)> admit, | ||
| 17 | MailSelectionKey initialSingle = {}); | ||
| 18 | // F-41: supplies the presented-order identities between two keys (the | ||
| 19 | // rows the list visibly shows between anchor and click). An empty or | ||
| 20 | // oversized answer falls back to the date/UID range capture. | ||
| 21 | 1036 | void setVisibleRangeProvider( | |
| 22 | std::function<QList<qint64>(const MailSelectionKey &anchor, | ||
| 23 | const MailSelectionKey &key)> provider) { | ||
| 24 | 1036 | m_visibleRange = std::move(provider); | |
| 25 | 1036 | } | |
| 26 | void clear(); | ||
| 27 | void cancelPending(); | ||
| 28 | void select(MailSelectionKey key, Qt::KeyboardModifiers modifiers = {}); | ||
| 29 | void selectAll(); | ||
| 30 | void watch(const QList<qint64> &uids); | ||
| 31 | bool contains(qint64 uid) const; | ||
| 32 | qint64 count() const; | ||
| 33 | 11 | qint64 folderId() const { return m_query.folderId; } | |
| 34 |
3/4✓ Branch 2 → 3 taken 11678 times.
✓ Branch 2 → 5 taken 205 times.
✗ Branch 4 → 5 not taken.
✓ Branch 4 → 6 taken 11678 times.
|
11883 | bool pending() const { return m_busy || !m_toggles.isEmpty(); } |
| 35 | 5758 | std::shared_ptr<const MailSelectionSnapshot> snapshot() const { return m_snapshot; } | |
| 36 | 2717 | MailSelectionKey single() const { return m_single; } | |
| 37 | signals: | ||
| 38 | void changed(); | ||
| 39 | void currentRequested(MailSelectionKey key); | ||
| 40 | void failed(); | ||
| 41 | private: | ||
| 42 | void invalidatePending(bool publish); | ||
| 43 | void startToggle(); | ||
| 44 | void toggle(MailSelectionKey key, quint64 generation); | ||
| 45 | bool accept(MailSelectionResult result, quint64 generation); | ||
| 46 | void refreshMembership(); | ||
| 47 | void readMembership(); | ||
| 48 | void fail(); | ||
| 49 | QObject m_captureOwner, m_membershipOwner; | ||
| 50 | QString m_databasePath; | ||
| 51 | MailSelectionQuery m_query; | ||
| 52 | std::function<bool(const MailSelectionSnapshot &)> m_admit; | ||
| 53 | std::function<QList<qint64>(const MailSelectionKey &anchor, | ||
| 54 | const MailSelectionKey &key)> | ||
| 55 | m_visibleRange; | ||
| 56 | MailSelectionKey m_single, m_anchor; | ||
| 57 | std::shared_ptr<const MailSelectionSnapshot> m_snapshot; | ||
| 58 | QList<MailSelectionKey> m_toggles; | ||
| 59 | QSet<qint64> m_visible; | ||
| 60 | QHash<qint64, bool> m_membership; | ||
| 61 | quint64 m_generation = 0, m_viewGeneration = 0; | ||
| 62 | bool m_busy = false, m_readingMembership = false; | ||
| 63 | }; | ||
| 64 |