Statistics - initial version
[scorecard] / src / tree-model.h
1 #include <QStringList>
2 #include <QAbstractItemModel>
3
4 #include "tree-item.h"
5
6 class ScoreTreeModel : public QAbstractItemModel
7 {
8
9   Q_OBJECT
10
11 public:
12
13   enum Roles {Type=Qt::UserRole, Rounds, Total, TotalIn, TotalOut, ScoreBest, ScoreAvg };
14
15   ScoreTreeModel(QList <Score *> &scoreList, QObject *parent = 0);
16   int rowCount(const QModelIndex & parent) const;
17   int columnCount(const QModelIndex & parent) const;
18   QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
19   QModelIndex parent(const QModelIndex &index) const;
20   QVariant data(const QModelIndex & index, int role) const;
21   QVariant headerData(int section, Qt::Orientation orientation, int role) const;
22
23   void setupModelData(QList<Score *> &scoreList, TreeItem *parent);
24
25  private:
26   TreeItem *itemFromIndex(const QModelIndex &index) const;
27   TreeItem *rootItem;
28 };