presentation/ConflictValueText.h
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include <QCoreApplication> | ||
| 4 | #include <QHash> | ||
| 5 | #include <QList> | ||
| 6 | #include <QString> | ||
| 7 | #include <QTimeZone> | ||
| 8 | #include <functional> | ||
| 9 | |||
| 10 | #include "data/MergePlan.h" | ||
| 11 | |||
| 12 | // Human text of every value in the conflict resolver (Sprint 107 S107.4.1, | ||
| 13 | // D-11, §4.3): an item's value on one side as the user reads it in the | ||
| 14 | // area — dates and times in the user's zone (with the original zone when it | ||
| 15 | // differs), all-day and durations, recurrence as a sentence, attendees with | ||
| 16 | // their answer, reminders ("15 minutes before"), status/priority/progress | ||
| 17 | // words, typed phone numbers and addresses, a rule as its rule sentence, | ||
| 18 | // settings with their labels. Raw values without a better reading are shown | ||
| 19 | // unescaped; *Show source* (the item's raw lines) is always available. | ||
| 20 | // | ||
| 21 | // Pure: no store, network or QML. Lookups the plan cannot answer (the title | ||
| 22 | // of a parent task, a contact's name for a relation) come from the context. | ||
| 23 | class ConflictValueText { | ||
| 24 | 3145 | Q_DECLARE_TR_FUNCTIONS(ConflictValueText) | |
| 25 | |||
| 26 | public: | ||
| 27 | enum class Side { Base, Local, Server }; | ||
| 28 | |||
| 29 | struct Context { | ||
| 30 | QTimeZone zone = QTimeZone::systemTimeZone(); | ||
| 31 | std::function<QString(const QString &uid)> taskTitle; // RELATED-TO | ||
| 32 | std::function<QString(const QString &uri)> contactName; // RELATED | ||
| 33 | }; | ||
| 34 | |||
| 35 | // The label of an item's row ("Title", "Start", "Attendees", "Note", | ||
| 36 | // "Projects — icon", a rule's name, …). | ||
| 37 | static QString label(const Merge::Plan &plan, const Merge::Item &item); | ||
| 38 | // The label of a coupled group (D-4): "Time", "Completion", | ||
| 39 | // "Recurrence", "Name", "Selections of <account>". | ||
| 40 | static QString groupLabel(const QString &group); | ||
| 41 | // One side's value of an item ("" when the side has none). | ||
| 42 | static QString value(const Merge::Plan &plan, const Merge::Item &item, Side side, const Context &context); | ||
| 43 | // One side's value of a coupled group, e.g. "Tue 21 Oct 10:00–11:00". | ||
| 44 | static QString groupValue(const Merge::Plan &plan, const QList<const Merge::Item *> &members, Side side, | ||
| 45 | const Context &context); | ||
| 46 | // The label of a component row ("Occurrence Wed 28 Oct", "Reminder"). | ||
| 47 | static QString componentLabel(const Merge::Plan &plan, const Merge::Item &item, const Context &context); | ||
| 48 | // What the side's value is when absent ("(none)", "Cancelled", "Deleted"). | ||
| 49 | static QString absent(const Merge::Item &item); | ||
| 50 | // The raw lines of the side (Show source). | ||
| 51 | static QString source(const Merge::Item &item, Side side); | ||
| 52 | // A user message per validation rule (D-10). | ||
| 53 | static QString problemText(const QString &rule); | ||
| 54 | // One-line text of a date/time value of the iCalendar plan. | ||
| 55 | static QString dateTimeText(const QString &contentLine, const Context &context); | ||
| 56 | |||
| 57 | private: | ||
| 58 | static const Merge::Value &valueOf(const Merge::Item &item, Side side); | ||
| 59 | }; | ||
| 60 |