LogModel.h 774 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #ifndef LOGMODEL_H
  2. #define LOGMODEL_H
  3. #include <QAbstractTableModel>
  4. #include <QTime>
  5. class LogEntry
  6. {
  7. public:
  8. LogEntry(const QString & message);
  9. ~LogEntry();
  10. QString message;
  11. QTime time;
  12. };
  13. class LogModel : public QAbstractTableModel
  14. {
  15. Q_OBJECT
  16. public:
  17. enum Columns {
  18. TimeColumn = 0,
  19. MessageColumn,
  20. ColumnCount
  21. };
  22. explicit LogModel(QObject *parent = 0);
  23. ~LogModel();
  24. signals:
  25. public slots:
  26. void log(const QString & message);
  27. protected:
  28. int rowCount(const QModelIndex &parent = QModelIndex()) const;
  29. int columnCount(const QModelIndex &parent = QModelIndex()) const;
  30. QVariant data(const QModelIndex &index, int role) const;
  31. private:
  32. QList<LogEntry> m_entries;
  33. };
  34. #endif // LOGMODEL_H