presentation/QuickContactLookup.h
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include <QHash> | ||
| 4 | #include <QObject> | ||
| 5 | #include <QVariantList> | ||
| 6 | #include <QVariantMap> | ||
| 7 | #include <functional> | ||
| 8 | |||
| 9 | class ContactSyncCoordinator; | ||
| 10 | class QuickContactModel; | ||
| 11 | |||
| 12 | // People behind the addresses of a mail (Sprint 97 S97.5.1, P-21): the | ||
| 13 | // reader shows sender and recipients as links; `people(header)` parses the | ||
| 14 | // header and looks every address up in the address index (one indexed query | ||
| 15 | // per address, cached per header until a contact changes). MED-16: the | ||
| 16 | // result is factual ("in a book" / "not in your contacts"); it is never a | ||
| 17 | // trust signal for the mail. | ||
| 18 | class QuickContactLookup final : public QObject { | ||
| 19 | 22 | Q_OBJECT | |
| 20 | Q_PROPERTY(int revision READ revision NOTIFY changed) | ||
| 21 | public: | ||
| 22 | using CoordinatorProvider = std::function<ContactSyncCoordinator *()>; | ||
| 23 | QuickContactLookup(CoordinatorProvider coordinator, QuickContactModel &model, QObject *parent = nullptr); | ||
| 24 | |||
| 25 | 6191 | int revision() const { return m_revision; } | |
| 26 | // [{name, address, label, known, collected, key, bookName, displayName, | ||
| 27 | // subtitle, initials, avatarColor, hasPhoto}] — label is the name or, | ||
| 28 | // without one, the address. | ||
| 29 | Q_INVOKABLE QVariantList people(const QString &header); | ||
| 30 | Q_INVOKABLE QVariantMap person(const QString &name, const QString &address); | ||
| 31 | |||
| 32 | public slots: | ||
| 33 | void invalidate(); | ||
| 34 | |||
| 35 | signals: | ||
| 36 | void changed(); | ||
| 37 | |||
| 38 | private: | ||
| 39 | CoordinatorProvider m_coordinator; | ||
| 40 | QuickContactModel &m_model; | ||
| 41 | QHash<QString, QVariantList> m_cache; | ||
| 42 | int m_revision = 0; | ||
| 43 | }; | ||
| 44 |