diff options
author | Petr Mrázek <peterix@gmail.com> | 2016-08-18 21:31:37 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2016-08-19 08:05:43 +0200 |
commit | 67eca08b2260f19ff296c0b6cb73eb3b0479e4b2 (patch) | |
tree | 96027e6397b24ee87d8d116448387c959a7e197b /api/logic/launch/LogModel.h | |
parent | 9aff21c1810f366f599fc5d35dfd3d7bc216f759 (diff) | |
download | PrismLauncher-67eca08b2260f19ff296c0b6cb73eb3b0479e4b2.tar.gz PrismLauncher-67eca08b2260f19ff296c0b6cb73eb3b0479e4b2.tar.bz2 PrismLauncher-67eca08b2260f19ff296c0b6cb73eb3b0479e4b2.zip |
NOISSUE use model/view for Minecraft log data
Diffstat (limited to 'api/logic/launch/LogModel.h')
-rw-r--r-- | api/logic/launch/LogModel.h | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/api/logic/launch/LogModel.h b/api/logic/launch/LogModel.h new file mode 100644 index 00000000..87e6b583 --- /dev/null +++ b/api/logic/launch/LogModel.h @@ -0,0 +1,51 @@ +#pragma once + +#include <QAbstractListModel> +#include <QString> +#include "MessageLevel.h" + +#include <multimc_logic_export.h> + +class MULTIMC_LOGIC_EXPORT LogModel : public QAbstractListModel +{ + Q_OBJECT +public: + explicit LogModel(QObject *parent = 0); + + int rowCount(const QModelIndex &parent = QModelIndex()) const; + QVariant data(const QModelIndex &index, int role) const; + + void append(MessageLevel::Enum, QString line); + void clear(); + + QString toPlainText(); + + void setMaxLines(int maxLines); + void setStopOnOverflow(bool stop); + void setOverflowMessage(const QString & overflowMessage); + + enum Roles + { + LevelRole = Qt::UserRole + }; + +private /* types */: + struct entry + { + MessageLevel::Enum level; + QString line; + }; + +private: /* data */ + QVector <entry> m_content; + int m_maxLines = 1000; + // first line in the circular buffer + int m_firstLine = 0; + // number of lines occupied in the circular buffer + int m_numLines = 0; + bool m_stopOnOverflow = false; + QString m_overflowMessage = "OVERFLOW"; + +private: + Q_DISABLE_COPY(LogModel) +}; |