File indexing completed on 2024-11-24 03:56:26
0001 /* 0002 * SPDX-FileCopyrightText: 2019-2023 Mattia Basaglia <dev@dragon.best> 0003 * 0004 * SPDX-License-Identifier: GPL-3.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include <QAbstractTableModel> 0010 #include <QIcon> 0011 0012 #include "app/log/logger.hpp" 0013 0014 namespace app::log { 0015 0016 class LogModel : public QAbstractTableModel 0017 { 0018 Q_OBJECT 0019 0020 public: 0021 enum Columns 0022 { 0023 Time, 0024 Source, 0025 SourceDetail, 0026 Message, 0027 0028 Count 0029 }; 0030 0031 LogModel(); 0032 0033 void populate(const std::vector<LogLine>& lines); 0034 0035 int rowCount(const QModelIndex &) const override; 0036 0037 int columnCount(const QModelIndex &) const override; 0038 0039 QVariant headerData(int section, Qt::Orientation orientation, int role) const override; 0040 0041 QVariant data(const QModelIndex & index, int role) const override; 0042 0043 private Q_SLOTS: 0044 void on_line(const LogLine& line); 0045 0046 private: 0047 std::vector<LogLine> lines; 0048 }; 0049 0050 } // namespace app::log