12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- #ifndef LOGMODEL_H
- #define LOGMODEL_H
- #include <QAbstractTableModel>
- #include <QTime>
- class LogEntry
- {
- public:
- LogEntry(const QString & message);
- ~LogEntry();
- QString message;
- QTime time;
- };
- class LogModel : public QAbstractTableModel
- {
- Q_OBJECT
- public:
- enum Columns {
- TimeColumn = 0,
- MessageColumn,
- ColumnCount
- };
- explicit LogModel(QObject *parent = 0);
- ~LogModel();
- signals:
- public slots:
- void log(const QString & message);
- protected:
- int rowCount(const QModelIndex &parent = QModelIndex()) const;
- int columnCount(const QModelIndex &parent = QModelIndex()) const;
- QVariant data(const QModelIndex &index, int role) const;
- private:
- QList<LogEntry> m_entries;
- };
- #endif // LOGMODEL_H
|