2016-08-19 01:01:37 +05:30
|
|
|
#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();
|
2016-10-12 01:04:02 +05:30
|
|
|
void suspend(bool suspend);
|
2016-08-19 01:01:37 +05:30
|
|
|
|
|
|
|
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";
|
2016-10-12 01:04:02 +05:30
|
|
|
bool m_suspended = false;
|
2016-08-19 01:01:37 +05:30
|
|
|
|
|
|
|
private:
|
|
|
|
Q_DISABLE_COPY(LogModel)
|
|
|
|
};
|