dc3832b4734b5d8f0fe592c1030c7fb8553f0cd3
[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 *);
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
53 class CourseTableModel : public QAbstractTableModel
54 {
55     Q_OBJECT
56
57 public:
58     CourseTableModel(QObject *parent = 0);
59
60     void set(Course *);
61     int rowCount(const QModelIndex & parent) const;
62     int columnCount(const QModelIndex & parent) const;
63     QVariant data(const QModelIndex & index, int role) const;
64     QVariant headerData(int section, Qt::Orientation orientation, int role) const;
65
66 private:
67     enum { 
68         ROWS = 8, 
69         COLS = 9 
70     };
71     enum { 
72         ROW_HOLE = 0, 
73         ROW_PAR = 1, 
74         ROW_HCP = 2, 
75         ROW_LEN = 3, 
76         ROW_HOLE_2 = 4, 
77         ROW_PAR_2 = 5, 
78         ROW_HCP_2 = 6, 
79         ROW_LEN_2 = 7
80     };
81     // Current data pointers
82     Club *club;
83     Course *course;
84 };
85 #endif