app/SearchVocabulary.h
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include <QCoreApplication> | ||
| 4 | #include <QList> | ||
| 5 | #include <QString> | ||
| 6 | |||
| 7 | // Sprint 98 S98.1.5 (rule 8): the words the search query parser | ||
| 8 | // (SearchQuery.cpp, parseSearchQuery) accepts, exported for the command-bar | ||
| 9 | // completion. The parser and this list are one module; test_search_query | ||
| 10 | // checks that every value listed here is accepted by the parser. | ||
| 11 | namespace SearchVocabulary { | ||
| 12 | |||
| 13 | struct Word { | ||
| 14 | const char *word; // as typed and executed ("from:", "unread") | ||
| 15 | const char *keywords; // de/en words that find it, never executed | ||
| 16 | const char *description; // QT_TRANSLATE_NOOP("SearchVocabulary", …) | ||
| 17 | }; | ||
| 18 | |||
| 19 | 187 | inline const QList<Word> &prefixes() { | |
| 20 | static const QList<Word> words = { | ||
| 21 | {"from:", "von absender", QT_TRANSLATE_NOOP("SearchVocabulary", "Sender contains")}, | ||
| 22 | {"to:", "an empfänger", QT_TRANSLATE_NOOP("SearchVocabulary", "Recipient (To or Cc) contains")}, | ||
| 23 | {"subject:", "betreff titel", QT_TRANSLATE_NOOP("SearchVocabulary", "Subject contains")}, | ||
| 24 | {"folder:", "ordner", QT_TRANSLATE_NOOP("SearchVocabulary", "In a folder (repeat for several)")}, | ||
| 25 | {"date:", "datum zeit wann", QT_TRANSLATE_NOOP("SearchVocabulary", "Date, range or period")}, | ||
| 26 | {"is:", "ist status", QT_TRANSLATE_NOOP("SearchVocabulary", "Read, important or answered state")}, | ||
| 27 | {"has:", "hat anhang", QT_TRANSLATE_NOOP("SearchVocabulary", "Has an attachment")}, | ||
| 28 | {"tag:", "label markierung schlagwort", QT_TRANSLATE_NOOP("SearchVocabulary", "Has a label")}, | ||
| 29 | {"list:", "liste mailingliste", QT_TRANSLATE_NOOP("SearchVocabulary", "Mailing list (List-Id) contains")}, | ||
| 30 | {"about:", "über betreffend person kontakt verknüpft", QT_TRANSLATE_NOOP("SearchVocabulary", "Linked to a contact")}, | ||
| 31 | {"in:", "bereich aufgaben kalender kontakte", QT_TRANSLATE_NOOP("SearchVocabulary", "Search tasks, appointments or contacts")}, | ||
| 32 |
4/7✓ Branch 2 → 3 taken 5 times.
✓ Branch 2 → 8 taken 182 times.
✓ Branch 4 → 5 taken 5 times.
✗ Branch 4 → 8 not taken.
✓ Branch 5 → 6 taken 5 times.
✗ Branch 10 → 11 not taken.
✗ Branch 10 → 12 not taken.
|
201 | }; |
| 33 | 187 | return words; | |
| 34 | } | ||
| 35 | |||
| 36 | // Fixed values after a prefix; empty for free values (from:, subject:, …). | ||
| 37 | 52 | inline QList<Word> valuesFor(const QString &prefix) { | |
| 38 |
2/2✓ Branch 4 → 5 taken 37 times.
✓ Branch 4 → 6 taken 15 times.
|
52 | if (prefix == QLatin1String("is:")) |
| 39 | return {{"unread", "ungelesen neu", QT_TRANSLATE_NOOP("SearchVocabulary", "Unread")}, | ||
| 40 | {"read", "gelesen", QT_TRANSLATE_NOOP("SearchVocabulary", "Read")}, | ||
| 41 | {"flagged", "wichtig markiert stern starred", QT_TRANSLATE_NOOP("SearchVocabulary", "Important")}, | ||
| 42 | {"unflagged", "unwichtig unstarred", QT_TRANSLATE_NOOP("SearchVocabulary", "Not important")}, | ||
| 43 | {"answered", "beantwortet", QT_TRANSLATE_NOOP("SearchVocabulary", "Answered")}, | ||
| 44 | 37 | {"unanswered", "unbeantwortet", QT_TRANSLATE_NOOP("SearchVocabulary", "Not answered")}}; | |
| 45 |
2/2✓ Branch 8 → 9 taken 2 times.
✓ Branch 8 → 10 taken 13 times.
|
15 | if (prefix == QLatin1String("has:")) |
| 46 | return {{"attachment", "anhang anhänge", QT_TRANSLATE_NOOP("SearchVocabulary", "With attachment")}, | ||
| 47 | 2 | {"noattachment", "ohne anhang", QT_TRANSLATE_NOOP("SearchVocabulary", "Without attachment")}}; | |
| 48 |
2/2✓ Branch 12 → 13 taken 4 times.
✓ Branch 12 → 14 taken 9 times.
|
13 | if (prefix == QLatin1String("date:")) |
| 49 | return {{"today", "heute", QT_TRANSLATE_NOOP("SearchVocabulary", "Today")}, | ||
| 50 | {"yesterday", "gestern", QT_TRANSLATE_NOOP("SearchVocabulary", "Yesterday")}, | ||
| 51 | {"week", "woche", QT_TRANSLATE_NOOP("SearchVocabulary", "Last 7 days")}, | ||
| 52 | {"month", "monat", QT_TRANSLATE_NOOP("SearchVocabulary", "Last 30 days")}, | ||
| 53 | 4 | {"year", "jahr", QT_TRANSLATE_NOOP("SearchVocabulary", "Last 12 months")}}; | |
| 54 |
2/2✓ Branch 16 → 17 taken 2 times.
✓ Branch 16 → 18 taken 7 times.
|
9 | if (prefix == QLatin1String("in:")) |
| 55 | return {{"tasks", "aufgaben", QT_TRANSLATE_NOOP("SearchVocabulary", "Search the tasks")}, | ||
| 56 | {"calendar", "kalender termine", QT_TRANSLATE_NOOP("SearchVocabulary", "Search the appointments")}, | ||
| 57 | 2 | {"contacts", "kontakte", QT_TRANSLATE_NOOP("SearchVocabulary", "Search the contacts")}}; | |
| 58 | 7 | return {}; | |
| 59 | } | ||
| 60 | |||
| 61 | 403 | inline QString description(const Word &word) { | |
| 62 | 403 | return QCoreApplication::translate("SearchVocabulary", word.description); | |
| 63 | } | ||
| 64 | |||
| 65 | } // namespace SearchVocabulary | ||
| 66 |