89c0ab1a708730a8c67491cee58b8945199ecf06
[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
17   ScoreTableModel(QObject *parent = 0) : QAbstractTableModel(parent) 
18   {
19     currentScore = 0;
20   }
21   Qt::ItemFlags flags ( const QModelIndex & index );
22   void setScore(QList<Score *> &sList);
23   void setClub(QList<Club *> &cList);
24   Course *findCourse(QString &clubName, QString &courseName);
25   int rowCount(const QModelIndex & parent) const;
26   int columnCount(const QModelIndex & parent) const;
27   QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
28   QVariant data(const QModelIndex & index, int role) const;
29   QVariant headerData(int section, Qt::Orientation orientation, int role) const;
30
31   int setItem(int row, int col, int data);
32
33   QString getInfoText();
34   QString getCountText();
35
36   void next();
37   void prev();
38   void first();
39   void last();
40
41  private:
42   QList<Score *> scoreList;
43   QList<Club *> clubList;
44
45   int currentScore;
46
47   // Current data pointers
48   Score *score;
49   Club *club;
50   Course *course;
51 };