presentation/ConflictCenter.h
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include <QObject> | ||
| 4 | #include <QTimer> | ||
| 5 | #include <QVariantList> | ||
| 6 | #include <functional> | ||
| 7 | |||
| 8 | class CalendarOutbox; | ||
| 9 | class CalendarStore; | ||
| 10 | class ContactOutbox; | ||
| 11 | class ContactStore; | ||
| 12 | class QuickRulesBackend; | ||
| 13 | class SettingsSyncSession; | ||
| 14 | |||
| 15 | // Every open conflict across the areas (Sprint 107 S107.4.4, D-15): the | ||
| 16 | // status-line chip, the conflict list and the warning dots on the area tabs | ||
| 17 | // read it. Sources: the calendar store's outbox (events and tasks), the | ||
| 18 | // contact store's outbox, the rules backend's held conflict and the | ||
| 19 | // settings sync session. *Recently resolved* comes from the stores' | ||
| 20 | // conflict histories (D-21). No polling: the sources' change signals | ||
| 21 | // schedule one refresh per event-loop turn. | ||
| 22 | class ConflictCenter : public QObject { | ||
| 23 | 3 | Q_OBJECT | |
| 24 | Q_PROPERTY(int total READ total NOTIFY changed) | ||
| 25 | Q_PROPERTY(int calendarCount READ calendarCount NOTIFY changed) | ||
| 26 | Q_PROPERTY(int taskCount READ taskCount NOTIFY changed) | ||
| 27 | Q_PROPERTY(int contactCount READ contactCount NOTIFY changed) | ||
| 28 | Q_PROPERTY(int rulesCount READ rulesCount NOTIFY changed) | ||
| 29 | Q_PROPERTY(int settingsCount READ settingsCount NOTIFY changed) | ||
| 30 | // [{area, domain, identity, title, kind, since}] — grouped by area. | ||
| 31 | Q_PROPERTY(QVariantList entries READ entries NOTIFY changed) | ||
| 32 | // [{store, id, title, keptSide, resolvedAt, area}] — newest first. | ||
| 33 | Q_PROPERTY(QVariantList recent READ recent NOTIFY changed) | ||
| 34 | |||
| 35 | public: | ||
| 36 | struct Deps { | ||
| 37 | std::function<CalendarStore *()> calendarStore; | ||
| 38 | std::function<CalendarOutbox *()> calendarOutbox; | ||
| 39 | std::function<ContactStore *()> contactStore; | ||
| 40 | std::function<ContactOutbox *()> contactOutbox; | ||
| 41 | std::function<QuickRulesBackend *()> rules; | ||
| 42 | std::function<SettingsSyncSession *()> settings; | ||
| 43 | }; | ||
| 44 | explicit ConflictCenter(Deps deps, QObject *parent = nullptr); | ||
| 45 | |||
| 46 | 866 | int total() const { return int(m_entries.size()); } | |
| 47 |
1/1✓ Branch 5 → 6 taken 4862 times.
|
9724 | int calendarCount() const { return countOf(QStringLiteral("calendar")); } |
| 48 |
1/1✓ Branch 5 → 6 taken 4892 times.
|
9784 | int taskCount() const { return countOf(QStringLiteral("tasks")); } |
| 49 |
1/1✓ Branch 5 → 6 taken 4861 times.
|
9722 | int contactCount() const { return countOf(QStringLiteral("contacts")); } |
| 50 |
1/1✓ Branch 5 → 6 taken 9720 times.
|
19440 | int rulesCount() const { return countOf(QStringLiteral("rules")); } |
| 51 |
1/1✓ Branch 5 → 6 taken 4871 times.
|
9742 | int settingsCount() const { return countOf(QStringLiteral("settings")); } |
| 52 | 3225 | QVariantList entries() const { return m_entries; } | |
| 53 | 2433 | QVariantList recent() const { return m_recent; } | |
| 54 | |||
| 55 | // Connects the sources' change signals (call once the session exists). | ||
| 56 | void connectSources(); | ||
| 57 | Q_INVOKABLE void refresh(); | ||
| 58 | ✗ | Q_INVOKABLE int countFor(const QString &area) const { return countOf(area); } | |
| 59 | // D-21: restores the version a resolution replaced as a new local edit. | ||
| 60 | Q_INVOKABLE bool undo(const QString &store, qint64 id); | ||
| 61 | |||
| 62 | signals: | ||
| 63 | void changed(); | ||
| 64 | |||
| 65 | private: | ||
| 66 | int countOf(const QString &area) const; | ||
| 67 | void scheduleRefresh(); | ||
| 68 | |||
| 69 | Deps m_deps; | ||
| 70 | QVariantList m_entries; | ||
| 71 | QVariantList m_recent; | ||
| 72 | QTimer m_refresh; | ||
| 73 | }; | ||
| 74 |