presentation/QuickMailEventLink.h
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include "data/MailRequest.h" | ||
| 4 | |||
| 5 | #include <QObject> | ||
| 6 | #include <QString> | ||
| 7 | #include <QVariantMap> | ||
| 8 | #include <functional> | ||
| 9 | |||
| 10 | class MailSessionCore; | ||
| 11 | class QuickPimBackend; | ||
| 12 | |||
| 13 | // Sprint 93 S93.5.6 (CAL-MAIL-LINK): appointments and mails point at each | ||
| 14 | // other. QML reaches it as `backend.mailEvent`. | ||
| 15 | // | ||
| 16 | // "Create appointment from mail" prefills the editor (eventDefaults: title | ||
| 17 | // = subject, notes = sender + the first lines, the canonical Message-ID). | ||
| 18 | // The saved appointment carries X-MAILJD-MESSAGE-ID (seedComponent() gives | ||
| 19 | // QuickPimBackend the VEVENT the codec patcher starts from, so the | ||
| 20 | // property survives every later edit and sync like any X- property), and | ||
| 21 | // the details popover offers "Open mail" (linkedMail/openLinkedMail, the | ||
| 22 | // same Message-ID resolution as tasks). "Email attendees" (attendeeDraft) | ||
| 23 | // prefills a new message with every attendee and the title. | ||
| 24 | class QuickMailEventLink final : public QObject { | ||
| 25 | 2 | Q_OBJECT | |
| 26 | public: | ||
| 27 | QuickMailEventLink(MailSessionCore &session, QuickPimBackend &pim, std::function<MailId()> currentMail, | ||
| 28 | QObject *parent = nullptr); | ||
| 29 | |||
| 30 | // {summary, description, messageId}; empty when no mail is shown. | ||
| 31 | Q_INVOKABLE QVariantMap eventDefaults() const; | ||
| 32 | // {messageId, available, subject, sender}; empty without a link. | ||
| 33 | Q_INVOKABLE QVariantMap linkedMail(const QVariantMap &occurrence) const; | ||
| 34 | Q_INVOKABLE bool openLinkedMail(const QVariantMap &occurrence); | ||
| 35 | // {to, subject}; `to` empty when the appointment has no attendees. | ||
| 36 | Q_INVOKABLE QVariantMap attendeeDraft(const QVariantMap &occurrence) const; | ||
| 37 | |||
| 38 | // The VEVENT a new appointment linked to `messageId` starts from. | ||
| 39 | static QString seedComponent(const QString &uid, const QString &messageId); | ||
| 40 | // X-MAILJD-MESSAGE-ID of a stored VEVENT ("" without a link). | ||
| 41 | static QString messageIdOf(const QString &veventText); | ||
| 42 | |||
| 43 | private: | ||
| 44 | QString storedComponent(const QVariantMap &occurrence) const; | ||
| 45 | |||
| 46 | MailSessionCore &m_session; | ||
| 47 | QuickPimBackend &m_pim; | ||
| 48 | std::function<MailId()> m_currentMail; | ||
| 49 | }; | ||
| 50 |