2017-06-06 02:56:52 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2017-06-05 16:16:12 +00:00
|
|
|
#ifndef MESSAGEHANDLERMODEL_H
|
|
|
|
#define MESSAGEHANDLERMODEL_H
|
|
|
|
|
|
|
|
#include <QAbstractListModel>
|
|
|
|
|
|
|
|
|
|
|
|
class MessageHandlerModel : public QAbstractListModel {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
static MessageHandlerModel *self();
|
|
|
|
enum MsgTypes {Message = Qt::UserRole + 1, Severity};
|
|
|
|
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
|
|
|
|
QVariant data(const QModelIndex& idx, int role) const override;
|
|
|
|
QHash<int, QByteArray> roleNames() const override;
|
|
|
|
void addLog(QtMsgType type, const QString& message);
|
2018-05-16 14:50:17 +00:00
|
|
|
const QString logAsString();
|
2017-06-05 16:16:12 +00:00
|
|
|
|
|
|
|
/* call this to clear the debug data */
|
|
|
|
Q_INVOKABLE void reset();
|
|
|
|
|
|
|
|
private:
|
|
|
|
MessageHandlerModel(QObject *parent = 0);
|
|
|
|
struct MessageData {
|
|
|
|
QString message;
|
|
|
|
QtMsgType type;
|
|
|
|
};
|
|
|
|
QVector<MessageData> m_data;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|