summaryrefslogtreecommitdiffstats
path: root/api/logic/launch/LogModel.h
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2016-08-08 00:00:11 +0200
committerPetr Mrázek <peterix@gmail.com>2016-08-10 00:28:33 +0200
commitfc198dd3085a2cd33fbaa7a3d2c95c2c8d3ee31a (patch)
tree26d0c907fcfdbf93da37d19f731962609c65464f /api/logic/launch/LogModel.h
parent74b4343c43cb0f3fc85cf27d1159349d0b3f32e6 (diff)
downloadMultiMC-fc198dd3085a2cd33fbaa7a3d2c95c2c8d3ee31a.tar
MultiMC-fc198dd3085a2cd33fbaa7a3d2c95c2c8d3ee31a.tar.gz
MultiMC-fc198dd3085a2cd33fbaa7a3d2c95c2c8d3ee31a.tar.lz
MultiMC-fc198dd3085a2cd33fbaa7a3d2c95c2c8d3ee31a.tar.xz
MultiMC-fc198dd3085a2cd33fbaa7a3d2c95c2c8d3ee31a.zip
NOISSUE rework of minecraft log
Now uses a model and a list view instead of text This lets mmc keep track of the contents regardless of whether the instance windows are open This is currently missing a way to select and copy text from the log.
Diffstat (limited to 'api/logic/launch/LogModel.h')
-rw-r--r--api/logic/launch/LogModel.h51
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)
+};