presentation/RuleSentence.h
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include <QCoreApplication> | ||
| 4 | #include <QString> | ||
| 5 | #include <QStringList> | ||
| 6 | |||
| 7 | #include "data/SieveRuleCodec.h" | ||
| 8 | |||
| 9 | // Rule → readable sentence (Sprint 95 §6.2, principle 6). | ||
| 10 | // | ||
| 11 | // Every phrase is one complete translatable template per condition field, | ||
| 12 | // operator and action kind ("%1 contains %2", "move to %1"), so German word | ||
| 13 | // order and plurals come from the catalogue instead of concatenated | ||
| 14 | // fragments. Values are wrapped by the caller-supplied `value` function | ||
| 15 | // (plain text for tooltips and accessibility, rich text for list rows). | ||
| 16 | class RuleSentence { | ||
| 17 | 17186 | Q_DECLARE_TR_FUNCTIONS(RuleSentence) | |
| 18 | |||
| 19 | public: | ||
| 20 | using ValueStyle = QString (*)(const QString &); | ||
| 21 | |||
| 22 | 3331 | static QString plain(const QString &value) { return value; } | |
| 23 | static QString rich(const QString &value); // escaped and bold | ||
| 24 | |||
| 25 | static QString condition(const Sieve::Condition &condition, ValueStyle style = plain); | ||
| 26 | static QString conditions(const Sieve::Rule &rule, ValueStyle style = plain); | ||
| 27 | static QString action(const Sieve::Action &action, ValueStyle style = plain); | ||
| 28 | static QString actions(const Sieve::Rule &rule, ValueStyle style = plain); | ||
| 29 | // "<conditions> → <actions>" | ||
| 30 | static QString sentence(const Sieve::Rule &rule, ValueStyle style = plain); | ||
| 31 | // Short folder/target summary for the target column ("Dev/CI", "Junk"). | ||
| 32 | static QString target(const Sieve::Rule &rule); | ||
| 33 | // Name for an unnamed visual rule (written only when it is edited, D-3). | ||
| 34 | static QString generatedName(const Sieve::Rule &rule); | ||
| 35 | static QString fieldLabel(const QString &field); | ||
| 36 | static QString sizeText(quint64 bytes); | ||
| 37 | static QString vacationSummary(const Sieve::Vacation &vacation); | ||
| 38 | |||
| 39 | private: | ||
| 40 | static QString valueList(const QStringList &values, ValueStyle style); | ||
| 41 | }; | ||
| 42 |