8936e21f68dff6215bac276cfaa4d167e0f47640
[scorecard] / src / data.h
1 #ifndef __SCORE_DATA_H
2 #define __SCORE_DATA_H
3
4 #include <QDebug>
5 #include <QVector>
6 #include <QXmlAttributes>
7 #include <QDomElement>
8 #include <QDomDocument>
9
10 enum { TotalOut, TotalIn, Total };
11
12
13 class Hole {
14  public:
15   Hole(const QXmlAttributes &attrs);
16   Hole(const QDomElement node);
17   Hole(int num, QString &shots);
18   Hole(int num, QString &par, QString &hcp);
19   QDomElement toElement(QDomDocument doc);
20   QString getShots();
21   QString getHcp();
22   QString getPar();
23   void dump();
24
25  private:
26   QString num, shots, putts, hcp, length, par;
27 };
28
29 class Score {
30  public:
31
32   Score(const QXmlAttributes &attrs);
33   Score(QString &iClub, QString &iCourse, QString &iDate);
34   Score(const QDomElement node);
35   Score(QVector<QString> scores, QString &club, QString &course, QString &date);
36
37   QDomElement toElement(QDomDocument doc);
38   void addHole(Hole *iHole);
39   QString getScore(int i);
40   QString getTotal(int what);
41   QString& getClubName();
42   QString& getCourseName();
43   QString& getDate();
44   void dump();
45
46  private:
47   QList <Hole *> holeList;
48   QString club, course, date;
49
50 };
51
52 class Course {
53  public:
54   Course(const QXmlAttributes &attrs);
55   Course(const QDomElement node);
56   Course(QString &name, QVector<QString> &, QVector<QString> &);
57   QDomElement toElement(QDomDocument doc);
58   void addHole(Hole *iHole);
59   QString getPar(int i);
60   QString getHcp(int i);
61   QString& getName();
62   QString getTotal(int what);
63   void dump();
64
65  private:
66   QList <Hole *> holeList;
67   QString name;
68
69 };
70
71 class Club {
72  public:
73
74   Club(const QXmlAttributes &attrs);
75   Club(const QDomElement node);
76   Club(QString &name);
77
78   QDomElement toElement(QDomDocument doc);
79   void addCourse(Course *iCourse);
80   void dump();
81   QString& getName();
82   Course *getCourse(int pos);
83   Course *getCourse(QString &courseName);
84
85   QList <Course *> getCourseList() { return courseList; } // HACK: fixme
86
87  private:
88   QList <Course *> courseList;
89   QString name;
90
91 };
92 #endif