| 5 | #include "MessageLevel.h" |
| 6 | |
| 7 | class LogModel : public QAbstractListModel |
| 8 | { |
| 9 | Q_OBJECT |
| 10 | public: |
| 11 | explicit LogModel(QObject *parent = 0); |
| 12 | |
| 13 | int rowCount(const QModelIndex &parent = QModelIndex()) const; |
| 14 | QVariant data(const QModelIndex &index, int role) const; |
| 15 | |
| 16 | void append(MessageLevel::Enum, QString line); |
| 17 | void clear(); |
| 18 | |
| 19 | void suspend(bool suspend); |
| 20 | bool suspended(); |
| 21 | |
| 22 | QString toPlainText(); |
| 23 | |
| 24 | int getMaxLines(); |
| 25 | void setMaxLines(int maxLines); |
| 26 | void setStopOnOverflow(bool stop); |
| 27 | void setOverflowMessage(const QString & overflowMessage); |
| 28 | |
| 29 | void setLineWrap(bool state); |
| 30 | bool wrapLines() const; |
| 31 | |
| 32 | enum Roles |
| 33 | { |
| 34 | LevelRole = Qt::UserRole |
| 35 | }; |
| 36 | |
| 37 | private /* types */: |
| 38 | struct entry |
| 39 | { |
| 40 | MessageLevel::Enum level; |
| 41 | QString line; |
| 42 | }; |
| 43 | |
| 44 | private: /* data */ |
| 45 | QVector <entry> m_content; |
| 46 | int m_maxLines = 1000; |
| 47 | // first line in the circular buffer |
| 48 | int m_firstLine = 0; |
| 49 | // number of lines occupied in the circular buffer |
| 50 | int m_numLines = 0; |
| 51 | bool m_stopOnOverflow = false; |
| 52 | QString m_overflowMessage = "OVERFLOW"; |
| 53 | bool m_suspended = false; |
| 54 | bool m_lineWrap = true; |
| 55 | |
| 56 | private: |
| 57 | Q_DISABLE_COPY(LogModel) |
| 58 | }; |
nothing calls this directly
no test coverage detected