fort/src/ui/log/logmanager.h

68 lines
1.4 KiB
C
Raw Normal View History

2017-11-10 13:36:29 +00:00
#ifndef LOGMANAGER_H
#define LOGMANAGER_H
#include <QObject>
2020-01-01 11:28:59 +00:00
QT_FORWARD_DECLARE_CLASS(AppListModel)
2017-12-06 02:51:40 +00:00
QT_FORWARD_DECLARE_CLASS(AppStatModel)
2020-01-31 10:00:36 +00:00
QT_FORWARD_DECLARE_CLASS(FortManager)
2017-12-06 02:51:40 +00:00
QT_FORWARD_DECLARE_CLASS(DriverWorker)
QT_FORWARD_DECLARE_CLASS(LogBuffer)
QT_FORWARD_DECLARE_CLASS(LogEntry)
2017-11-10 13:36:29 +00:00
class LogManager : public QObject
{
Q_OBJECT
public:
2020-08-20 09:36:41 +00:00
explicit LogManager(FortManager *fortManager, QObject *parent = nullptr);
2017-11-10 13:36:29 +00:00
2020-01-31 10:00:36 +00:00
FortManager *fortManager() const { return m_fortManager; }
DriverWorker *driverWorker() const;
AppListModel *appListModel() const;
AppStatModel *appStatModel() const;
2017-11-17 11:44:33 +00:00
2017-12-08 02:38:02 +00:00
void setActive(bool active);
2017-11-10 13:36:29 +00:00
QString errorMessage() const { return m_errorMessage; }
2017-12-05 05:06:15 +00:00
void initialize();
2017-11-10 13:36:29 +00:00
signals:
2017-12-08 02:38:02 +00:00
void activeChanged();
2017-11-10 13:36:29 +00:00
void errorMessageChanged();
public slots:
2018-12-24 09:27:52 +00:00
void close();
2017-11-10 13:36:29 +00:00
private slots:
2020-08-20 09:36:41 +00:00
void processLogBuffer(LogBuffer *logBuffer, bool success, quint32 errorCode);
2017-11-10 13:36:29 +00:00
private:
void setErrorMessage(const QString &errorMessage);
qint64 currentUnixTime() const;
void setCurrentUnixTime(qint64 unixTime);
2018-02-23 10:33:28 +00:00
void readLogAsync();
2017-11-10 13:36:29 +00:00
void cancelAsyncIo();
2017-11-17 03:46:35 +00:00
LogBuffer *getFreeBuffer();
2018-02-23 09:56:52 +00:00
void addFreeBuffer(LogBuffer *logBuffer);
2017-11-17 03:46:35 +00:00
void readLogEntries(LogBuffer *logBuffer);
2017-11-10 13:36:29 +00:00
private:
2020-01-01 11:28:59 +00:00
bool m_active = false;
2017-11-10 13:36:29 +00:00
2020-01-31 10:00:36 +00:00
FortManager *m_fortManager = nullptr;
2017-11-17 03:46:35 +00:00
2020-01-01 11:28:59 +00:00
QList<LogBuffer *> m_freeBuffers;
2017-11-10 13:36:29 +00:00
QString m_errorMessage;
qint64 m_currentUnixTime = 0;
2017-11-10 13:36:29 +00:00
};
#endif // LOGMANAGER_H