2 * Copyright (C) 2009 Sakari Poussa
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.
10 #define __SCORE_DATA_H
14 #include <QXmlAttributes>
15 #include <QDomElement>
16 #include <QDomDocument>
18 enum { TotalOut, TotalIn, Total };
23 Hole(int num, QString &shots);
24 Hole(int num, QString &par, QString &hcp);
25 Hole(const QDomElement node);
26 QDomElement toElement(QDomDocument doc);
29 void setHcp(QString& shots);
32 void setPar(QString& shots);
35 void setShots(QString& shots);
38 void setPutts(QString& shots);
40 QString greenInRegulation();
41 void setGreenInRegulation(QString& value);
44 void setFairwayHit(QString& value);
47 void setSandSave(QString& value);
50 void setPenalty(QString& value);
55 QString m_num; // Hole's number (1-18)
56 QString m_hcp; // Hole's HCP value
57 QString m_length; // Hole lenght in meters (todo: multiple)
58 QString m_par; // Hole's par
59 QString m_shots; // Number of shots
60 QString m_putts; // Number of putts
61 QString m_greenInRegulation; // Green in regulation
62 QString m_fairwayHit; // Fairway hit
63 QString m_sandSave; // Sandsave
64 QString m_penalty; // Other penalty
69 Score(const QXmlAttributes &attrs);
70 Score(QString &iClub, QString &iCourse, QString &iDate);
71 Score(const QDomElement node);
72 Score(QVector<QString> scores, QString &club, QString &course, QString &date);
74 bool operator< (const Score& val) const
76 return date < val.getDate();
79 bool operator> (const Score& val) const
81 return date > val.getDate();
84 QDomElement toElement(QDomDocument doc);
85 int update(QVector<QString> &scores);
86 void addHole(Hole *iHole);
87 QString getScore(int i) const;
88 QString getTotal(int what) const;
89 const QString& getClubName() const;
90 const QString& getCourseName() const;
91 const QString& getDate() const;
95 QList <Hole *> holeList;
96 QString club, course, date;
103 Course(const QXmlAttributes &attrs);
104 Course(const QDomElement node, Club * parent = 0);
105 Course(QString &name, QVector<QString> &, QVector<QString> &);
106 QDomElement toElement(QDomDocument doc);
107 int update(QVector<QString> &, QVector<QString> &, QVector<QString> &);
108 void addHole(Hole *iHole);
109 QString getPar(int i);
110 QString getHcp(int i);
112 QString getTotal(int what);
115 void setParent(Club *parent);
118 QList <Hole *> holeList;
125 Club(const QXmlAttributes &attrs, bool readOnly = false);
126 Club(const QDomElement node, bool readOnly = false);
127 Club(QString &name, bool readOnly = false);
129 QDomElement toElement(QDomDocument doc);
130 void addCourse(Course *iCourse);
131 void delCourse(Course *iCourse);
134 Course *getCourse(int pos);
135 Course *getCourse(const QString &courseName);
138 void setHomeClub(bool value) { m_homeClub = value; }
139 bool isHomeClub() { return m_homeClub; }
141 QList <Course *> getCourseList() { return courseList; } // HACK: fixme
146 QList <Course *> courseList;