/** * SPDX-FileCopyrightText: 2021 Bart De Vries * * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL */ #pragma once #include #include #include #include #include #include #include "error.h" class ErrorLogModel : public QAbstractListModel { Q_OBJECT QML_ELEMENT QML_SINGLETON public: static ErrorLogModel &instance() { static ErrorLogModel _instance; return _instance; } static ErrorLogModel *create(QQmlEngine *engine, QJSEngine *) { engine->setObjectOwnership(&instance(), QQmlEngine::CppOwnership); return &instance(); } QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; QHash roleNames() const override; int rowCount(const QModelIndex &parent) const override; Q_INVOKABLE void clearAll(); public: void monitorErrorMessages(const Error::Type type, const QString &url, const QString &id, const int errorCode, const QString &errorString, const QString &title); Q_SIGNALS: void newErrorLogged(Error *error); private: explicit ErrorLogModel(); QList m_errors; };