pollymc/launcher/launch/LogModel.h

59 lines
1.2 KiB
C
Raw Normal View History

#pragma once
#include <QAbstractListModel>
#include <QString>
#include "MessageLevel.h"
class LogModel : public QAbstractListModel
{
2018-07-15 18:21:05 +05:30
Q_OBJECT
public:
2018-07-15 18:21:05 +05:30
explicit LogModel(QObject *parent = 0);
2018-07-15 18:21:05 +05:30
int rowCount(const QModelIndex &parent = QModelIndex()) const;
QVariant data(const QModelIndex &index, int role) const;
2018-07-15 18:21:05 +05:30
void append(MessageLevel::Enum, QString line);
void clear();
2018-07-15 18:21:05 +05:30
void suspend(bool suspend);
bool suspended();
2018-07-15 18:21:05 +05:30
QString toPlainText();
2018-07-15 18:21:05 +05:30
int getMaxLines();
void setMaxLines(int maxLines);
void setStopOnOverflow(bool stop);
void setOverflowMessage(const QString & overflowMessage);
2018-07-15 18:21:05 +05:30
void setLineWrap(bool state);
bool wrapLines() const;
2018-07-15 18:21:05 +05:30
enum Roles
{
LevelRole = Qt::UserRole
};
private /* types */:
2018-07-15 18:21:05 +05:30
struct entry
{
MessageLevel::Enum level;
QString line;
};
private: /* data */
2018-07-15 18:21:05 +05:30
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";
bool m_suspended = false;
bool m_lineWrap = true;
private:
2018-07-15 18:21:05 +05:30
Q_DISABLE_COPY(LogModel)
};