data/MailSelectionSnapshot.h
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include <QDateTime> | ||
| 4 | #include <QHash> | ||
| 5 | #include <QTemporaryDir> | ||
| 6 | #include <atomic> | ||
| 7 | #include <memory> | ||
| 8 | |||
| 9 | // A selection is scoped to a query and a coherent cache revision, not a list | ||
| 10 | // of currently instantiated delegates. Range endpoints use date/UID order. | ||
| 11 | struct MailSelectionKey { | ||
| 12 | qint64 folderId = -1; | ||
| 13 | qint64 uid = -1; | ||
| 14 | QDateTime date; | ||
| 15 | }; | ||
| 16 | |||
| 17 | struct MailSelectionQuery { | ||
| 18 | QString accountId; | ||
| 19 | qint64 folderId = -1; | ||
| 20 | QString text; | ||
| 21 | bool unreadOnly = false; | ||
| 22 | bool starredOnly = false; | ||
| 23 | bool attachmentsOnly = false; | ||
| 24 | bool range = false; | ||
| 25 | MailSelectionKey first; | ||
| 26 | MailSelectionKey last; | ||
| 27 | // F-41 (SPRINT-104): explicit membership for range selections taken from | ||
| 28 | // the presented (sort/thread) order. When set (bounded, all UIDs ≥ 0), | ||
| 29 | // exactly these messages are captured — "between" is what the list | ||
| 30 | // visibly shows between the two clicks, not a date/UID span. The | ||
| 31 | // filter flags above still narrow the captured set. | ||
| 32 | QList<qint64> explicitUids; | ||
| 33 | static constexpr int MaximumExplicitUids = 4096; | ||
| 34 | }; | ||
| 35 | |||
| 36 | // Private, immutable sorted-UID spool. Its directory is released with the last | ||
| 37 | // owner. No body, metadata list or one-million-element QVariant array is kept. | ||
| 38 | struct MailSelectionSnapshot { | ||
| 39 | QString accountId; | ||
| 40 | qint64 folderId = -1; | ||
| 41 | QString folderPath; | ||
| 42 | quint32 uidValidity = 0; | ||
| 43 | qint64 count = 0; | ||
| 44 | std::shared_ptr<QTemporaryDir> storage; | ||
| 45 |
4/8✓ Branch 3 → 4 taken 598 times.
✗ Branch 3 → 7 not taken.
✓ Branch 5 → 6 taken 598 times.
✓ Branch 6 → 8 taken 598 times.
✓ Branch 9 → 10 taken 598 times.
✗ Branch 9 → 11 not taken.
✗ Branch 13 → 14 not taken.
✗ Branch 13 → 15 not taken.
|
598 | QString path() const { return storage ? storage->filePath("selection.uids") : QString{}; } |
| 46 | }; | ||
| 47 | |||
| 48 | struct MailSelectionResult { | ||
| 49 | enum class Outcome { Ready, Failed, MissingFolder, Limited, Cancelled, Busy }; | ||
| 50 | Outcome outcome = Outcome::Failed; | ||
| 51 | std::shared_ptr<const MailSelectionSnapshot> snapshot; | ||
| 52 | QList<qint64> uids; | ||
| 53 | QHash<qint64, bool> membership; | ||
| 54 | QString error; | ||
| 55 | }; | ||
| 56 | |||
| 57 | // File access belongs on a worker. The public bounds apply before allocation. | ||
| 58 | class MailSelectionReader final { | ||
| 59 | public: | ||
| 60 | static constexpr int MaxBatch = 128; | ||
| 61 | static MailSelectionResult page(std::shared_ptr<const MailSelectionSnapshot> snapshot, | ||
| 62 | qint64 offset, int limit); | ||
| 63 | static MailSelectionResult lookup(std::shared_ptr<const MailSelectionSnapshot> snapshot, | ||
| 64 | const QList<qint64> &uids); | ||
| 65 | static MailSelectionResult toggle(std::shared_ptr<const MailSelectionSnapshot> snapshot, | ||
| 66 | qint64 uid, const std::atomic_bool &cancelled); | ||
| 67 | }; | ||
| 68 |