Statistics - new files
[scorecard] / src / stat-model.h
1 #include <QAbstractTableModel>
2
3 #include "data.h"
4
5 class StatItem
6 {
7  public:
8   StatItem() {}
9
10   void setYear(QString &year) { m_year = year.toInt(); }
11   int year() { return m_year; }
12
13   void setRounds(int n) { m_rounds = n; }
14   int rounds() { return m_rounds; }
15
16   void setAverage(int n) { m_average = n; }
17   int average() { return m_average; }
18
19   void setMin(int n) { m_min = n; }
20   int min() { return m_min; }
21
22   void setMax(int n) { m_max = n; }
23   int max() { return m_max; }
24
25  private:
26
27   int m_year;
28   int m_rounds;
29   int m_average;
30   int m_min;
31   int m_max;
32   int m_birdies;
33   int m_pars;
34   int m_bogeys;
35   int m_more;
36 };
37
38 class StatModel : public QAbstractTableModel
39 {
40   Q_OBJECT
41
42 public:
43   StatModel(QList<Club *> &clubList, QList<Score *> &scoreList);
44
45   int rowCount(const QModelIndex & parent) const;
46   int columnCount(const QModelIndex & parent) const;
47   QVariant data(const QModelIndex & index, int role) const;
48   QVariant headerData(int section, Qt::Orientation orientation, int role) const;
49
50
51  private:
52   
53   enum { ROWS = 8, COLS = 4 };
54   enum { ROW_ROUNDS = 0, 
55          ROW_AVERAGE, 
56          ROW_MIN, 
57          ROW_MAX, 
58          ROW_BIRDIE, 
59          ROW_PAR, 
60          ROW_BOGEY, 
61          ROW_MORE
62   };
63   enum { COL_TOTAL = 0, 
64          COL_1ST_YEAR, // Latest year
65          COL_2ND_YEAR, // One before latest
66          COL_3RD_YEAR  // Two before latest
67   };
68
69
70   QList<Club *> &clubList;
71   QList<Score *> &scoreList;
72
73   QList<StatItem *> stat;
74
75   void update();
76 };