fort/src/ui/log/logmanager.h

57 lines
1.1 KiB
C
Raw Normal View History

2017-11-10 13:36:29 +00:00
#ifndef LOGMANAGER_H
#define LOGMANAGER_H
#include <QObject>
2021-12-25 09:40:28 +00:00
#include <util/ioc/iocservice.h>
2021-06-02 10:59:10 +00:00
class LogBuffer;
class LogEntry;
2017-11-10 13:36:29 +00:00
2021-06-02 10:59:10 +00:00
class LogManager : public QObject, public IocService
2017-11-10 13:36:29 +00:00
{
Q_OBJECT
public:
2021-06-02 10:59:10 +00:00
explicit LogManager(QObject *parent = nullptr);
2017-11-17 11:44:33 +00:00
2021-04-24 14:35:15 +00:00
virtual void setActive(bool active);
2017-12-08 02:38:02 +00:00
2017-11-10 13:36:29 +00:00
QString errorMessage() const { return m_errorMessage; }
2021-06-02 10:59:10 +00:00
void setUp() override;
void tearDown() override;
2017-12-05 05:06:15 +00:00
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();
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-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