- New course: Default HCP values are odd for front nine, and even for
[scorecard] / src / table-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 #ifndef TABLE_MODEL_H
9 #define TABLE_MODEL_H
10
11 #include <QStringList>
12 #include <QAbstractTableModel>
13
14 #include "data.h"
15
16 #define ROW_COUNT  3
17 #define COL_COUNT  9
18
19 class ScoreTableModel : public QAbstractTableModel
20 {
21     Q_OBJECT
22
23 public:
24     ScoreTableModel(QObject *parent = 0);
25
26     void set(Score *, Course *, int handicap = -1);
27     int rowCount(const QModelIndex & parent) const;
28     int columnCount(const QModelIndex & parent) const;
29     QVariant data(const QModelIndex & index, int role) const;
30     QVariant headerData(int section, Qt::Orientation orientation, int role) const;
31
32 private:
33     enum { 
34         ROWS = 8, 
35         COLS = 9 
36     };
37     enum { 
38         ROW_HOLE = 0, 
39         ROW_PAR = 1, 
40         ROW_HCP = 2, 
41         ROW_SCORE = 3, 
42         ROW_HOLE_2 = 4, 
43         ROW_PAR_2 = 5, 
44         ROW_HCP_2 = 6, 
45         ROW_SCORE_2 = 7
46     };
47     // Current data pointers
48     Score *score;
49     Club *club;
50     Course *course;
51
52     // Current handicap
53     int handicap;
54 };
55
56 class CourseTableModel : public QAbstractTableModel
57 {
58     Q_OBJECT
59
60 public:
61     CourseTableModel(QObject *parent = 0);
62
63     void set(Course *);
64     int rowCount(const QModelIndex & parent) const;
65     int columnCount(const QModelIndex & parent) const;
66     QVariant data(const QModelIndex & index, int role) const;
67     QVariant headerData(int section, Qt::Orientation orientation, int role) const;
68
69 private:
70     enum { 
71         ROWS = 8, 
72         COLS = 9 
73     };
74     enum { 
75         ROW_HOLE = 0, 
76         ROW_PAR = 1, 
77         ROW_HCP = 2, 
78         ROW_LEN = 3, 
79         ROW_HOLE_2 = 4, 
80         ROW_PAR_2 = 5, 
81         ROW_HCP_2 = 6, 
82         ROW_LEN_2 = 7
83     };
84     // Current data pointers
85     Club *club;
86     Course *course;
87 };
88 #endif