Sun, 09 Apr 2023 15:59:08 +0300
Extracted the state of the program into a MainState structure, and extracted local functions of main() into static functions.
I was planning to make the core logic and state of the program into a Main class, which would be a QObject that would
have lots of signals and slots, but it looks like this works even without it
#include <QAbstractTableModel> #include "src/basics.h" class MessageLog final : public QAbstractTableModel { Q_OBJECT std::vector<Message> messages; public: enum Column { TimeColumn, MessageColumn, }; static constexpr int NUM_COLUMNS = int(MessageColumn) + 1; explicit MessageLog(QObject *parent = nullptr); Q_SLOT void addMessage(const Message& message); // QAbstractItemModel interface public: QVariant headerData(int section, Qt::Orientation orientation, int role) const override; int rowCount(const QModelIndex& parent) const override; int columnCount(const QModelIndex& parent) const override; QVariant data(const QModelIndex& index, int role) const override; };