presentation/CommandHistory.h
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include <QHash> | ||
| 4 | #include <QStringList> | ||
| 5 | #include <QVariantMap> | ||
| 6 | |||
| 7 | // Sprint 98 S98.1.6 (D-9): the command lines run from the command bar and | ||
| 8 | // the folders recently used, per profile. Only lines whose arguments come | ||
| 9 | // from a fixed vocabulary or name a place are kept (the catalog decides, | ||
| 10 | // NamedCommandCatalog::storable); free text — searches, task/event/rule | ||
| 11 | // lines, addresses, new folder names — never enters. Local only; the lines | ||
| 12 | // are never logged (rule 11). | ||
| 13 | class CommandHistory { | ||
| 14 | public: | ||
| 15 | static constexpr int Capacity = 50; | ||
| 16 | static constexpr int MaxLineLength = 1024; | ||
| 17 | static constexpr int RecentFolderCapacity = 20; | ||
| 18 | |||
| 19 | // Moves an existing line to the front; false when the line is not storable. | ||
| 20 | bool record(const QString &line); | ||
| 21 | 492 | QStringList lines() const { return m_lines; } // most recent first | |
| 22 | void clear(); | ||
| 23 | 4 | bool isEmpty() const { return m_lines.isEmpty(); } | |
| 24 | |||
| 25 | // D-20: recently used folders of an account (switch and move targets). | ||
| 26 | void recordFolder(const QString &account, const QString &path); | ||
| 27 | 224 | QStringList recentFolders(const QString &account) const { return m_folders.value(account); } | |
| 28 | |||
| 29 | // Persistence form: {"history": [...], "recentFolders": {account: [...]}}. | ||
| 30 | QVariantMap save() const; | ||
| 31 | void restore(const QVariantMap &state); | ||
| 32 | |||
| 33 | private: | ||
| 34 | QStringList m_lines; | ||
| 35 | QHash<QString, QStringList> m_folders; | ||
| 36 | }; | ||
| 37 |