data/MailHeaderPage.h
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include "data/MailSort.h" | ||
| 4 | #include "data/Models.h" | ||
| 5 | |||
| 6 | #include <QSet> | ||
| 7 | |||
| 8 | // Flat-list quick filter evaluated by the page reader, so pages come from the | ||
| 9 | // whole folder instead of only the loaded window. It must accept a superset | ||
| 10 | // of MailFilterProxyModel (which still filters the window): text is matched | ||
| 11 | // case-folded against the raw subject and From header. | ||
| 12 | struct MailHeaderFilter { | ||
| 13 | QString text; // case-folded | ||
| 14 | bool unread = false; | ||
| 15 | bool starred = false; | ||
| 16 | bool attachments = false; | ||
| 17 | // Mails the unread view already showed stay listed after being read. | ||
| 18 | QSet<qint64> retainedUnread; | ||
| 19 |
8/8✓ Branch 3 → 4 taken 3568 times.
✓ Branch 3 → 7 taken 165 times.
✓ Branch 4 → 5 taken 3516 times.
✓ Branch 4 → 7 taken 52 times.
✓ Branch 5 → 6 taken 3441 times.
✓ Branch 5 → 7 taken 75 times.
✓ Branch 6 → 7 taken 33 times.
✓ Branch 6 → 8 taken 3408 times.
|
3733 | bool active() const { return !text.isEmpty() || unread || starred || attachments; } |
| 20 | 158 | bool operator==(const MailHeaderFilter &other) const { | |
| 21 |
4/4✓ Branch 4 → 5 taken 119 times.
✓ Branch 4 → 10 taken 9 times.
✓ Branch 5 → 6 taken 107 times.
✓ Branch 5 → 10 taken 12 times.
|
286 | return text == other.text && unread == other.unread && starred == other.starred && |
| 22 |
5/6✓ Branch 3 → 4 taken 128 times.
✓ Branch 3 → 10 taken 30 times.
✓ Branch 6 → 7 taken 100 times.
✓ Branch 6 → 10 taken 7 times.
✓ Branch 8 → 9 taken 100 times.
✗ Branch 8 → 10 not taken.
|
286 | attachments == other.attachments && retainedUnread == other.retainedUnread; |
| 23 | } | ||
| 24 | }; | ||
| 25 | |||
| 26 | // A page demand retains only mailbox identity and a compact date/UID anchor. | ||
| 27 | struct MailHeaderPageRequest { | ||
| 28 | QString account; | ||
| 29 | QString folder; | ||
| 30 | qint64 folderId = -1; | ||
| 31 | quint32 uidValidity = 0; | ||
| 32 | qint64 anchorUid = 0; | ||
| 33 | QDateTime anchorDate; | ||
| 34 | bool before = false; | ||
| 35 | int limit = 200; | ||
| 36 | // First-page presentation: also return authoritative folder totals so the | ||
| 37 | // GUI thread performs no count SQL while restoring a folder. | ||
| 38 | bool includeCounts = false; | ||
| 39 | // Indexed Quick presentation already owns the visible header page. Read | ||
| 40 | // identity and totals in the same worker snapshot without a flat page. | ||
| 41 | bool countsOnly = false; | ||
| 42 | // Session restoration: resolve anchorUid, then return a balanced window | ||
| 43 | // around that row (plus its totals). A missing anchor degrades to the | ||
| 44 | // plain first page and reports anchored = false. | ||
| 45 | bool anchoredRestore = false; | ||
| 46 | // T-87.D1 random seek: include the anchor uid itself in a forward | ||
| 47 | // (before=false) page, so the seek target appears in the list. | ||
| 48 | bool includeAnchor = false; | ||
| 49 | MailHeaderFilter filter; | ||
| 50 | // F100-66: order of the pages (default: date, newest first) and the | ||
| 51 | // fields a non-date sort keys on (MailSort::key of the anchor). Kept last: | ||
| 52 | // callers initialise the leading members positionally. | ||
| 53 | MailSortOrder sort; | ||
| 54 | QString anchorFrom, anchorTo, anchorSubject; | ||
| 55 | qint64 anchorSize = 0; | ||
| 56 | quint32 anchorFlags = 0; | ||
| 57 | }; | ||
| 58 | |||
| 59 | struct MailHeaderPageSnapshot { | ||
| 60 | enum class Outcome { Ready, Failed, Limited, Busy }; | ||
| 61 | static constexpr int MaximumRows = 200; | ||
| 62 | static constexpr qint64 MaximumBytes = 8LL * 1024 * 1024; | ||
| 63 | Outcome outcome = Outcome::Failed; | ||
| 64 | QList<MailHeader> headers; | ||
| 65 | QString error; | ||
| 66 | // Filled only when MailHeaderPageRequest::includeCounts was set. | ||
| 67 | int totalCount = -1; | ||
| 68 | int unreadCount = -1; | ||
| 69 | // True when anchoredRestore found its anchor and built the window around it. | ||
| 70 | bool anchored = false; | ||
| 71 | }; | ||
| 72 |