Statistics - initial version
[scorecard] / src / table-model.h
1 #include <QStringList>
2 #include <QAbstractTableModel>
3
4 #include "data.h"
5
6 #define ROW_COUNT  3
7 #define COL_COUNT  9
8
9 // TODO: change name to ScoreTableModel
10 class ScoreTableModel : public QAbstractTableModel
11 {
12
13   Q_OBJECT
14
15 public:
16   enum { ViewMode = 0, EditMode = 1 };
17
18   ScoreTableModel(QObject *parent = 0) : QAbstractTableModel(parent) 
19   {
20     currentScore = 0;
21     score = 0;
22     club = 0;
23     course = 0;
24     currentMode = ViewMode;
25   }
26   Qt::ItemFlags flags ( const QModelIndex & index );
27   void setMode(int m);
28   int mode(void);
29   void setScore(QList<Score *> &sList, Score *score = 0);
30   Score *getScore(void);
31   void setClub(QList<Club *> &cList);
32   Club *getClub(void);
33   Course *getCourse(void);
34
35   Course *findCourse(const QString &clubName, const QString &courseName);
36   QString& clubName(void);
37   QString& courseName(void);
38   int rowCount(const QModelIndex & parent) const;
39   int columnCount(const QModelIndex & parent) const;
40   QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
41   QVariant data(const QModelIndex & index, int role) const;
42   QVariant headerData(int section, Qt::Orientation orientation, int role) const;
43
44   int setItem(int row, int col, int data);
45
46   QString getInfoText();
47   QString getCountText();
48
49   void next();
50   void prev();
51   void first();
52   void last();
53
54  private:
55   int currentMode;
56   enum { ROWS = 8, COLS = 9 };
57   enum { ROW_HOLE = 0, ROW_PAR = 1, ROW_HCP = 2, ROW_SCORE = 3, 
58          ROW_HOLE_2 = 4, ROW_PAR_2 = 5, ROW_HCP_2 = 6, ROW_SCORE_2 = 7};
59
60   QList<Score *> scoreList;
61   QList<Club *> clubList;
62
63   int currentScore;
64
65   // Current data pointers
66   Score *score;
67   Club *club;
68   Course *course;
69 };