presentation/EventQuickInput.h
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include <QDate> | ||
| 4 | #include <QObject> | ||
| 5 | #include <QString> | ||
| 6 | #include <QVariantList> | ||
| 7 | #include <QVariantMap> | ||
| 8 | #include <functional> | ||
| 9 | |||
| 10 | // Sprint 93 S93.4.5: quick creation of an appointment from one line | ||
| 11 | // (console ":event <text>", same grammar style as the task console P-14): | ||
| 12 | // Title [date] [start[-end]] [@location] [/calendar] | ||
| 13 | // date: today/heute, tomorrow/morgen, a weekday (en/de, full or at least | ||
| 14 | // three letters — two letters clash with words like "so", "do", "mi"; the | ||
| 15 | // next such day, today included), 2026-10-05, 5.10. or | ||
| 16 | // 5.10.2026. time: 14, 14:30, 9.30, 14-15:30 (a bare hour 0–23 or h:mm). | ||
| 17 | // "@" takes the words up to the next "/calendar" token as the place; | ||
| 18 | // "/name" picks the first writable calendar whose name starts with it. | ||
| 19 | // Everything else is the title. QML reaches it as `backend.eventInput`. | ||
| 20 | namespace EventQuickParse { | ||
| 21 | |||
| 22 | struct Result { | ||
| 23 | QString summary; | ||
| 24 | QDate date; // invalid = not given | ||
| 25 | QString startTime; // "HH:mm", "" = not given | ||
| 26 | QString endTime; // "HH:mm", "" = not given | ||
| 27 | QString location; | ||
| 28 | QString calendarHint; // text after "/" | ||
| 29 | }; | ||
| 30 | |||
| 31 | Result parse(const QString &text, const QDate &today); | ||
| 32 | QDate parseDate(const QString &word, const QDate &today); | ||
| 33 | QString parseTime(const QString &word); | ||
| 34 | // Sprint 98 S98.1.5 (rule 8): the date words parseDate accepts, for the | ||
| 35 | // command-bar completion: relative words and the full weekday names (en/de). | ||
| 36 | QStringList dateWords(); | ||
| 37 | |||
| 38 | } // namespace EventQuickParse | ||
| 39 | |||
| 40 | class QuickEventInput final : public QObject { | ||
| 41 | 1 | Q_OBJECT | |
| 42 | public: | ||
| 43 | QuickEventInput(std::function<QVariantList()> calendarChoices, QObject *parent = nullptr); | ||
| 44 | // Editor defaults: {summary, dateIso, startTime, endTime, location, | ||
| 45 | // accountId, calendarPath} (only the given parts), or {error} when a | ||
| 46 | // "/calendar" matches no writable calendar. | ||
| 47 | Q_INVOKABLE QVariantMap parse(const QString &text) const; | ||
| 48 | |||
| 49 | private: | ||
| 50 | std::function<QVariantList()> m_calendarChoices; | ||
| 51 | }; | ||
| 52 |