diff options
| author | isanae <14251494+isanae@users.noreply.github.com> | 2019-07-16 05:38:32 -0400 |
|---|---|---|
| committer | isanae <14251494+isanae@users.noreply.github.com> | 2019-07-22 07:33:37 -0400 |
| commit | 54d98e291701f2187174a67c186f1ea762c6b959 (patch) | |
| tree | 5ef78396bf9bc364146ae7bd4dd9a9fee2529504 /src/logbuffer.h | |
| parent | bc9f286bce224743d244e540d55f26b55affbd4a (diff) | |
removed unused or redundant stuff in error_report.h
renamed log() to vlog() for now
extracted console creation to Console class
rewrote LogBuffer to work with logging from uibase, renamed to LogModel
added fmt dependency
Diffstat (limited to 'src/logbuffer.h')
| -rw-r--r-- | src/logbuffer.h | 70 |
1 files changed, 18 insertions, 52 deletions
diff --git a/src/logbuffer.h b/src/logbuffer.h index 0cfecfa2..1bf8901b 100644 --- a/src/logbuffer.h +++ b/src/logbuffer.h @@ -26,70 +26,36 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>. #include <QStringListModel>
#include <QTime>
#include <vector>
+#include <log.h>
-
-class LogBuffer : public QAbstractItemModel
+class LogModel : public QAbstractItemModel
{
Q_OBJECT
public:
+ static void create();
+ static LogModel& instance();
- static void init(int messageCount, QtMsgType minMsgType, const QString &outputFileName);
- static void log(QtMsgType type, const QMessageLogContext &context, const QString &message);
-
- static void writeNow();
- static void cleanQuit();
-
- static LogBuffer *instance() { return s_Instance.data(); }
-
-public:
-
- virtual ~LogBuffer();
-
- void logMessage(QtMsgType type, const QString &message);
+ void add(MOBase::log::Entry e);
- // QAbstractItemModel interface
-public:
- QModelIndex index(int row, int column, const QModelIndex &parent) const;
- QModelIndex parent(const QModelIndex &child) const;
- int rowCount(const QModelIndex &parent) const;
- int columnCount(const QModelIndex &parent) const;
- QVariant data(const QModelIndex &index, int role) const;
+protected:
+ QModelIndex index(int row, int column, const QModelIndex& parent) const override;
+ QModelIndex parent(const QModelIndex &child) const override;
+ int rowCount(const QModelIndex &parent) const override;
+ int columnCount(const QModelIndex &parent) const override;
+ QVariant data(const QModelIndex &index, int role) const override;
+
+ QVariant headerData(
+ int section, Qt::Orientation ori, int role=Qt::DisplayRole) const override;
signals:
-
-public slots:
+ void entryAdded(MOBase::log::Entry e);
private:
+ std::deque<MOBase::log::Entry> m_messages;
- explicit LogBuffer(int messageCount, QtMsgType minMsgType, const QString &outputFileName);
- LogBuffer(const LogBuffer &reference); // not implemented
- LogBuffer &operator=(const LogBuffer &reference); // not implemented
-
- void write() const;
-
- static char msgTypeID(QtMsgType type);
-
-private:
-
- struct Message {
- QtMsgType type;
- QTime time;
- QString message;
- QString toString() const;
- };
-
-private:
-
- static QScopedPointer<LogBuffer> s_Instance;
- static QMutex s_Mutex;
-
- QString m_OutFileName;
- bool m_ShutDown;
- QtMsgType m_MinMsgType;
- size_t m_NumMessages;
- std::vector<Message> m_Messages;
-
+ LogModel();
+ void onEntryAdded(MOBase::log::Entry e);
};
#endif // LOGBUFFER_H
|
