Big refactoring: new UI logic, Qt 4.6 support, more Maemo5 features
[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
9 #include <QStringList>
10 #include <QAbstractTableModel>
11
12 #include "data.h"
13
14 #define ROW_COUNT  3
15 #define COL_COUNT  9
16
17 class ScoreTableModel : public QAbstractTableModel
18 {
19     Q_OBJECT
20
21 public:
22     ScoreTableModel(Score *, Course *, QObject *parent = 0);
23
24     int rowCount(const QModelIndex & parent) const;
25     int columnCount(const QModelIndex & parent) const;
26     QVariant data(const QModelIndex & index, int role) const;
27     QVariant headerData(int section, Qt::Orientation orientation, int role) const;
28
29 private:
30     enum { 
31         ROWS = 8, 
32         COLS = 9 
33     };
34     enum { 
35         ROW_HOLE = 0, 
36         ROW_PAR = 1, 
37         ROW_HCP = 2, 
38         ROW_SCORE = 3, 
39         ROW_HOLE_2 = 4, 
40         ROW_PAR_2 = 5, 
41         ROW_HCP_2 = 6, 
42         ROW_SCORE_2 = 7
43     };
44     // Current data pointers
45     Score *score;
46     Club *club;
47     Course *course;
48 };
49
50 class CourseTableModel : public QAbstractTableModel
51 {
52     Q_OBJECT
53
54 public:
55     CourseTableModel(Course *, QObject *parent = 0);
56
57     int rowCount(const QModelIndex & parent) const;
58     int columnCount(const QModelIndex & parent) const;
59     QVariant data(const QModelIndex & index, int role) const;
60     QVariant headerData(int section, Qt::Orientation orientation, int role) const;
61
62 private:
63     enum { 
64         ROWS = 8, 
65         COLS = 9 
66     };
67     enum { 
68         ROW_HOLE = 0, 
69         ROW_PAR = 1, 
70         ROW_HCP = 2, 
71         ROW_LEN = 3, 
72         ROW_HOLE_2 = 4, 
73         ROW_PAR_2 = 5, 
74         ROW_HCP_2 = 6, 
75         ROW_LEN_2 = 7
76     };
77     // Current data pointers
78     Club *club;
79     Course *course;
80 };