-
Notifications
You must be signed in to change notification settings - Fork 0
/
commitmodel.h
39 lines (29 loc) · 889 Bytes
/
commitmodel.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#ifndef COMMITMODEL_H
#define COMMITMODEL_H
#include <QAbstractListModel>
#include <QHash>
class Commit;
class CommitDao;
class CommitModel : public QAbstractListModel
{
Q_OBJECT
public:
enum Roles {
HashRole = Qt::UserRole + 1, // Id
SummaryRole,
AuthorNameRole,
AuthorEmailRole,
TimeRole,
};
CommitModel(QObject *parent = 0);
void reset(CommitDao *CommitDao);
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
QHash<int, QByteArray> roleNames() const override;
Q_INVOKABLE Commit *getCommit(const QString &hash) const;
Q_INVOKABLE QVariantMap get(const int row) const;
private:
bool isIndexValid(const QModelIndex &index) const;
QList<Commit *> m_commits;
};
#endif // COMMITMODEL_H