Maki
Formally verfied low-code orchestration
Loading...
Searching...
No Matches
log_table_model.h
1#pragma once
2
3#include <QAbstractTableModel>
4#include <QComboBox>
5#include <QDateTime>
6#include <QHBoxLayout>
7#include <QHeaderView>
8#include <QLineEdit>
9#include <QTableView>
10#include <QVBoxLayout>
11#include <QWidget>
12
13#include "logging.h"
14
18class LogTableModel : public QAbstractTableModel
19{
20 Q_OBJECT
21
22public:
33
34 struct LogEntry
35 {
36 QDateTime timestamp;
37 logging::LogLevel level;
38 QString file;
39 uint32_t line;
40 QString source;
41 QString message;
42 };
43
49 LogTableModel(QObject* parent = nullptr);
50
57 int rowCount(const QModelIndex& parent = {}) const override;
58
65 int columnCount(const QModelIndex& parent = {}) const override;
66
74 QVariant data(const QModelIndex& index, int role) const override;
75
84 QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
85
95 void append(logging::LogLevel level, const QString& source, const QString& file, const uint32_t line, const QString& message);
96
100 void clear();
101
108 QString toString(logging::LogLevel level) const;
109
116 QIcon toIcon(logging::LogLevel level) const;
117
118private:
119 QVector<LogEntry> mEntries;
120};
QIcon toIcon(logging::LogLevel level) const
Converts a log level to an icon.
Definition log_table_model.cpp:149
QVariant data(const QModelIndex &index, int role) const override
Returns the data for a given role and index.
Definition log_table_model.cpp:28
int columnCount(const QModelIndex &parent={}) const override
Returns the number of columns in the model.
Definition log_table_model.cpp:20
QVariant headerData(int section, Qt::Orientation orientation, int role) const override
Returns the header data for a given section and orientation.
Definition log_table_model.cpp:85
Column
Definition log_table_model.h:24
@ TimeColumn
The column index for the log level.
Definition log_table_model.h:26
@ LineColumn
The column index for the file where the log entry was generated.
Definition log_table_model.h:30
@ MessageColumn
The column index for the timestamp.
Definition log_table_model.h:27
@ ColumnCount
The column index for the line number in the file.
Definition log_table_model.h:31
@ SourceColumn
The column index for the log message.
Definition log_table_model.h:28
@ FileColumn
The column index for the source of the log entry.
Definition log_table_model.h:29
void append(logging::LogLevel level, const QString &source, const QString &file, const uint32_t line, const QString &message)
Appends a new log entry to the model.
Definition log_table_model.cpp:109
void clear()
Clears all log entries from the model.
Definition log_table_model.cpp:123
QString toString(logging::LogLevel level) const
Converts a log level to a string representation.
Definition log_table_model.cpp:130
LogTableModel(QObject *parent=nullptr)
Constructs a new LogTableModel object.
Definition log_table_model.cpp:7
int rowCount(const QModelIndex &parent={}) const override
Returns the number of rows in the model.
Definition log_table_model.cpp:12
Definition log_table_model.h:35
QString file
The log level of the entry.
Definition log_table_model.h:38
QString message
The source of the log entry.
Definition log_table_model.h:41
logging::LogLevel level
The timestamp of the log entry.
Definition log_table_model.h:37
QString source
The line number in the file.
Definition log_table_model.h:40
uint32_t line
The file where the log entry was generated.
Definition log_table_model.h:39