In main window, update also course data after entering new score
[scorecard] / src / tree-model.h
1 /*
2  * Copyright (C) 2009 Sakari Poussa
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, version 2.
7  */
8
9 #include <QStringList>
10 #include <QAbstractItemModel>
11
12 #include "tree-item.h"
13
14 class ScoreTreeModel : public QAbstractItemModel
15 {
16
17   Q_OBJECT
18
19 public:
20
21   enum Roles {Type=Qt::UserRole, Rounds, Total, TotalIn, TotalOut, ScoreBest, ScoreAvg };
22
23   ScoreTreeModel(QList <Score *> &scoreList, QObject *parent = 0);
24   int rowCount(const QModelIndex & parent) const;
25   int columnCount(const QModelIndex & parent) const;
26   QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
27   QModelIndex parent(const QModelIndex &index) const;
28   QVariant data(const QModelIndex & index, int role) const;
29   QVariant headerData(int section, Qt::Orientation orientation, int role) const;
30
31   void setupModelData(QList<Score *> &scoreList, TreeItem *parent);
32
33  private:
34   TreeItem *itemFromIndex(const QModelIndex &index) const;
35   TreeItem *rootItem;
36 };