Fix compiler warnings
[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
20   Q_OBJECT
21
22 public:
23   enum { ViewMode = 0, EditMode = 1 };
24
25   ScoreTableModel(QObject *parent = 0) : QAbstractTableModel(parent) 
26   {
27     currentScore = 0;
28     score = 0;
29     club = 0;
30     course = 0;
31     currentMode = ViewMode;
32   }
33   Qt::ItemFlags flags ( const QModelIndex & index );
34   void setMode(int m);
35   int mode(void);
36   void setScore(QList<Score *> &sList, Score *score = 0);
37   void setClub(QList<Club *> &cList);
38   Score *getScore(void);
39   Club *getClub(void);
40   Course *getCourse(void);
41
42   Course *findCourse(const QString &clubName, const QString &courseName);
43   QString& clubName(void);
44   QString& courseName(void);
45   int rowCount(const QModelIndex & parent) const;
46   int columnCount(const QModelIndex & parent) const;
47   QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
48   QVariant data(const QModelIndex & index, int role) const;
49   QVariant headerData(int section, Qt::Orientation orientation, int role) const;
50
51   int setItem(int row, int col, int data);
52
53   QString getInfoText();
54   QString getCountText();
55
56   void next();
57   void prev();
58   void first();
59   void last();
60
61  private:
62   int currentMode;
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_SCORE = 3, 
72     ROW_HOLE_2 = 4, 
73     ROW_PAR_2 = 5, 
74     ROW_HCP_2 = 6, 
75     ROW_SCORE_2 = 7
76   };
77
78   QList<Score *> scoreList;
79   QList<Club *> clubList;
80
81   int currentScore;
82
83   // Current data pointers
84   Score *score;
85   Club *club;
86   Course *course;
87 };