presentation/DavServerHints.h
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #pragma once | ||
| 2 | #include "DavCollectionDiscovery.h" | ||
| 3 | #include <QObject> | ||
| 4 | #include <QVariantList> | ||
| 5 | |||
| 6 | // Sprint 100 S100.4.8 (D-21, D-22): what the calendar, task and contact | ||
| 7 | // sidebars say about collections that are on the server but not on this | ||
| 8 | // computer. Read from the per-account collection cache that every calendar | ||
| 9 | // sync and every settings discovery refreshes (no extra request): | ||
| 10 | // "New on the server: Holidays · Add · ✕" — never offered before, not | ||
| 11 | // dismissed (known set of DavCollectionDiscovery); | ||
| 12 | // "2 more on the server" — the rest that is not downloaded. | ||
| 13 | // Add stores the collection in the account's selection and announces | ||
| 14 | // `added`; the owner re-arms the sync like an applied discovery. | ||
| 15 | class DavServerHints final : public QObject { | ||
| 16 | Q_OBJECT | ||
| 17 | Q_PROPERTY(int revision READ revision NOTIFY changed) | ||
| 18 | public: | ||
| 19 | 797 | explicit DavServerHints(QObject *parent = nullptr) : QObject(parent) {} | |
| 20 | 2273 | int revision() const { return m_revision; } | |
| 21 | // One entry per DAV account with something to say for `area` ("calendar", | ||
| 22 | // "tasks", "contacts"): {accountId, label, fresh: [{key, name}], more}. | ||
| 23 | Q_INVOKABLE QVariantList hints(const QString &area) const; | ||
| 24 | // {ok, name}; the collection is selected and known afterwards. | ||
| 25 | Q_INVOKABLE QVariantMap add(const QString &accountId, const QString &key); | ||
| 26 | Q_INVOKABLE void dismiss(const QString &accountId, const QString &key); | ||
| 27 | // New collections of an account in any area (the attention glyph). | ||
| 28 | int freshCount(const QString &accountId) const; | ||
| 29 | // A calendar sync of `accountId` discovered `calendars`. | ||
| 30 | void recordCalendars(const QString &accountId, const QList<DavCollectionDiscovery::Item> &calendars); | ||
| 31 | void refresh(); | ||
| 32 | signals: | ||
| 33 | void changed(); | ||
| 34 | void added(const QString &accountId); | ||
| 35 | private: | ||
| 36 | struct Entry { QString accountId, label; QList<DavCollectionDiscovery::CachedCollection> fresh; int more = 0; }; | ||
| 37 | QList<Entry> entries(const QString &area) const; | ||
| 38 | int m_revision = 0; | ||
| 39 | }; | ||
| 40 |