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