|
1 #include <QAbstractTableModel> |
|
2 #include "basics.h" |
|
3 |
|
4 class MessageLog final : public QAbstractTableModel |
|
5 { |
|
6 Q_OBJECT |
|
7 std::vector<Message> messages; |
|
8 public: |
|
9 enum Column { |
|
10 TimeColumn, |
|
11 MessageColumn, |
|
12 }; |
|
13 static constexpr int NUM_COLUMNS = int(MessageColumn) + 1; |
|
14 explicit MessageLog(QObject *parent = nullptr); |
|
15 Q_SLOT void addMessage(const Message& message); |
|
16 |
|
17 // QAbstractItemModel interface |
|
18 public: |
|
19 QVariant headerData(int section, Qt::Orientation orientation, int role) const override; |
|
20 int rowCount(const QModelIndex& parent) const override; |
|
21 int columnCount(const QModelIndex& parent) const override; |
|
22 QVariant data(const QModelIndex& index, int role) const override; |
|
23 }; |