-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlog.h
57 lines (46 loc) · 1.23 KB
/
log.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#ifndef LOG_H
#define LOG_H
#include <QObject>
#include <QAbstractListModel>
class Log
{
public:
enum MessageType {
UNDEFINED=0x00,
INFO=0x01,
WARNING=0x02,
ERROR=0x03
};
Log(uint id,uint timestamp,const QString& messageType,const QString& message,bool hasRebooted);
inline uint getId() const {return m_id;}
inline uint getTimestamp() const {return m_timestamp;}
inline QString getMessageType() const {return m_messageType;}
inline QString getMessage() const {return m_message;}
inline bool getHasRebooted() const {return m_hasRebooted;}
private:
uint m_id;
uint m_timestamp;
QString m_messageType;
QString m_message;
bool m_hasRebooted;
};
class LogModel : public QAbstractListModel
{
Q_OBJECT
public:
enum LogRoles {
IdRole = Qt::UserRole + 1,
TimestampRole,
MessageTypeRole,
MessageRole
};
LogModel(QObject *parent = 0);
void addLog(const Log &log);
int rowCount(const QModelIndex & parent = QModelIndex()) const;
QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
protected:
QHash<int, QByteArray> roleNames() const;
private:
QList<Log> m_logs;
};
#endif // LOG_H