Sort scores based on dates not the entry date.
[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   bool operator< (const Score& val) const 
38   { 
39     return date < val.getDate();
40   }
41
42   QDomElement toElement(QDomDocument doc);
43   void addHole(Hole *iHole);
44   QString getScore(int i) const;
45   QString getTotal(int what) const;
46   const QString& getClubName() const;
47   const QString& getCourseName() const;
48   const QString& getDate() const;
49   void dump();
50
51  private:
52   QList <Hole *> holeList;
53   QString club, course, date;
54 };
55
56 class Course {
57  public:
58   Course(const QXmlAttributes &attrs);
59   Course(const QDomElement node);
60   Course(QString &name, QVector<QString> &, QVector<QString> &);
61   QDomElement toElement(QDomDocument doc);
62   void addHole(Hole *iHole);
63   QString getPar(int i);
64   QString getHcp(int i);
65   QString& getName();
66   QString getTotal(int what);
67   void dump();
68
69  private:
70   QList <Hole *> holeList;
71   QString name;
72
73 };
74
75 class Club {
76  public:
77
78   Club(const QXmlAttributes &attrs);
79   Club(const QDomElement node);
80   Club(QString &name);
81
82   QDomElement toElement(QDomDocument doc);
83   void addCourse(Course *iCourse);
84   void dump();
85   QString& getName();
86   Course *getCourse(int pos);
87   Course *getCourse(const QString &courseName);
88
89   QList <Course *> getCourseList() { return courseList; } // HACK: fixme
90
91  private:
92   QList <Course *> courseList;
93   QString name;
94
95 };
96 #endif