presentation/StatusMessageState.h
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #pragma once | ||
| 2 | #include <QObject> | ||
| 3 | #include <QTimer> | ||
| 4 | #include <QString> | ||
| 5 | #include <QStringList> | ||
| 6 | #include <QMap> | ||
| 7 | |||
| 8 | // Presentation ownership for the single status line. Background progress may | ||
| 9 | // coalesce; errors appear immediately, direct action feedback too — or, | ||
| 10 | // while an error is held, right after it (the newest one). | ||
| 11 | class StatusMessageState final : public QObject { | ||
| 12 | Q_OBJECT | ||
| 13 | public: | ||
| 14 | explicit StatusMessageState(QObject *parent = nullptr); | ||
| 15 | 1983 | QString text() const { return m_text; } | |
| 16 | void feedback(const QString &text); | ||
| 17 | void error(const QString &text); | ||
| 18 | void progress(const QString &text); | ||
| 19 | // Empty text resolves exactly this action, including a notice waiting | ||
| 20 | // behind an unrelated error. Operation notices are not terminal errors. | ||
| 21 | void pendingAction(qint64 token, const QString &text); | ||
| 22 | void clearPendingActions(); | ||
| 23 | void reset(); | ||
| 24 | 1 | void setErrorHoldMs(int ms) { m_errorHold.setInterval(ms); } // tests | |
| 25 | signals: | ||
| 26 | void changed(); | ||
| 27 | private: | ||
| 28 | void publish(const QString &text, qint64 action = 0); | ||
| 29 | bool showPendingAction(); | ||
| 30 | QMap<qint64, QString> m_pendingActions; | ||
| 31 | qint64 m_visibleAction = 0; | ||
| 32 | QString m_text; | ||
| 33 | QString m_pendingFeedback; // waits behind a held error (S106-356) | ||
| 34 | QString m_pendingProgress; | ||
| 35 | QStringList m_pendingErrors; | ||
| 36 | QTimer m_progressTimer; | ||
| 37 | QTimer m_feedbackHold; | ||
| 38 | QTimer m_errorHold; | ||
| 39 | }; | ||
| 40 |