YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
logmodel.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: LGPL-2.1-or-later
4 */
5
6#ifndef LOGMODEL_H
7#define LOGMODEL_H
8
9#include <QAbstractTableModel>
11#include <QFont>
12
13
14class LogModel : public QAbstractTableModel
15{
16 Q_OBJECT
17 Q_DISABLE_COPY(LogModel);
18
19public:
48
49 static constexpr int YARPRUNTIMESTAMP_COLUMN = 0;
50 static constexpr int LOCALTIMESTAMP_COLUMN = 1;
51 static constexpr int SYSTEMTIME_COLUMN = 2;
52 static constexpr int NETWORKTIME_COLUMN = 3;
53 static constexpr int EXTERNALTIME_COLUMN = 4;
54 static constexpr int LOGLEVEL_COLUMN = 5;
55 static constexpr int FILENAME_COLUMN = 6;
56 static constexpr int LINE_COLUMN = 7;
57 static constexpr int FUNCTION_COLUMN = 8;
58 static constexpr int HOSTNAME_COLUMN = 9;
59 static constexpr int PID_COLUMN = 10;
60 static constexpr int CMD_COLUMN = 11;
61 static constexpr int ARGS_COLUMN = 12;
62 static constexpr int THREADID_COLUMN = 13;
63 static constexpr int COMPONENT_COLUMN = 14;
64 static constexpr int ID_COLUMN = 15;
65 static constexpr int TEXT_COLUMN = 16;
66 static constexpr int COLUMN_COUNT = 17;
67
68 explicit LogModel(QObject *parent = nullptr);
69 ~LogModel() override;
70
71 int rowCount(const QModelIndex & parent = QModelIndex()) const override;
72 int columnCount(const QModelIndex &parent = QModelIndex()) const override;
73
74 QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
75 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
76
77 QHash<int, QByteArray> roleNames() const override;
78
79 void addMessages(const std::list<yarp::yarpLogger::MessageEntry> &messages);
80 void clear();
81
82 void setColor(bool enabled);
83 void setWordWrap(bool wordwrap);
84
86
87private:
88 QFont m_font;
89 QList<yarp::yarpLogger::MessageEntry> m_messages;
90 QHash<int, QByteArray> m_names;
91 bool m_color {true};
92 bool m_wordwrap {false};
93};
94
95
96#endif // LOGMODEL_H
static constexpr int YARPRUNTIMESTAMP_COLUMN
Definition logmodel.h:49
static constexpr int LINE_COLUMN
Definition logmodel.h:56
QHash< int, QByteArray > roleNames() const override
Definition logmodel.cpp:362
void setWordWrap(bool wordwrap)
Definition logmodel.cpp:392
static constexpr int SYSTEMTIME_COLUMN
Definition logmodel.h:51
static constexpr int FUNCTION_COLUMN
Definition logmodel.h:57
@ LogLevelStringRole
Definition logmodel.h:31
@ ExternalTimeRole
Definition logmodel.h:28
@ PidRole
Definition logmodel.h:37
@ SystemTimeRole
Definition logmodel.h:24
@ LocalTimestampRole
Definition logmodel.h:23
@ ComponentRole
Definition logmodel.h:43
@ PidStringRole
Definition logmodel.h:40
@ ArgsRole
Definition logmodel.h:39
@ LineStringRole
Definition logmodel.h:34
@ LogLevelRole
Definition logmodel.h:30
@ NetworkTimeRole
Definition logmodel.h:26
@ ThreadIdStringRole
Definition logmodel.h:42
@ NetworkTimeStringRole
Definition logmodel.h:27
@ ExternalTimeStringRole
Definition logmodel.h:29
@ HostnameRole
Definition logmodel.h:36
@ YarprunTimestampRole
Definition logmodel.h:22
@ SystemTimeStringRole
Definition logmodel.h:25
@ BacktraceRole
Definition logmodel.h:46
@ FunctionRole
Definition logmodel.h:35
@ LineRole
Definition logmodel.h:33
@ TextRole
Definition logmodel.h:45
@ FilenameRole
Definition logmodel.h:32
@ ThreadIdRole
Definition logmodel.h:41
@ CmdRole
Definition logmodel.h:38
void addMessages(const std::list< yarp::yarpLogger::MessageEntry > &messages)
Definition logmodel.cpp:367
static constexpr int TEXT_COLUMN
Definition logmodel.h:65
static constexpr int CMD_COLUMN
Definition logmodel.h:60
static constexpr int COMPONENT_COLUMN
Definition logmodel.h:63
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
Definition logmodel.cpp:72
~LogModel() override
static constexpr int LOCALTIMESTAMP_COLUMN
Definition logmodel.h:50
static constexpr int PID_COLUMN
Definition logmodel.h:59
static constexpr int LOGLEVEL_COLUMN
Definition logmodel.h:54
static constexpr int FILENAME_COLUMN
Definition logmodel.h:55
int columnCount(const QModelIndex &parent=QModelIndex()) const override
Definition logmodel.cpp:62
static constexpr int ARGS_COLUMN
Definition logmodel.h:61
void clear()
Definition logmodel.cpp:402
void setColor(bool enabled)
Definition logmodel.cpp:381
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Definition logmodel.cpp:122
static QString logLevelToString(yarp::yarpLogger::LogLevel l)
Definition logmodel.cpp:409
static constexpr int THREADID_COLUMN
Definition logmodel.h:62
static constexpr int HOSTNAME_COLUMN
Definition logmodel.h:58
static constexpr int NETWORKTIME_COLUMN
Definition logmodel.h:52
static constexpr int ID_COLUMN
Definition logmodel.h:64
static constexpr int EXTERNALTIME_COLUMN
Definition logmodel.h:53
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Definition logmodel.cpp:52
static constexpr int COLUMN_COUNT
Definition logmodel.h:66