+/*
+ * Copyright (C) 2009 Sakari Poussa
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 2.
+ */
+
#include "data.h"
////////////////////////////////////////////////////////////////////////
return shots;
}
+void Hole::setShots(QString& s) {
+ shots = s;
+}
+
QString Hole::getHcp() {
return hcp;
}
+void Hole::setHcp(QString& s) {
+ hcp = s;
+}
+
QString Hole::getPar() {
return par;
}
+void Hole::setPar(QString& s) {
+ par = s;
+}
+
void Hole::dump() {
qDebug() << num << "(" << par << ") : " << shots << "/" << putts ;
}
return node;
}
+int Score::update(QVector<QString> &scores)
+{
+ for (int i = 0; i < scores.size(); i++) {
+ Hole *hole = holeList.at(i);
+ if (hole->getShots() != scores[i])
+ hole->setShots(scores[i]);
+ }
+ return 0;
+}
+
void Score::addHole(Hole *iHole) {
holeList << iHole;
}
-QString Score::getScore(int i) {
+QString Score::getScore(int i) const
+{
if (i >= 0 && i < holeList.size())
return holeList.at(i)->getShots();
else
return QString("-");
}
-QString Score::getTotal(int what) {
+QString Score::getTotal(int what) const
+{
int tot = 0;
if (what == Total)
return QString("%1").arg(tot);
}
-QString& Score::getClubName() {
+const QString& Score::getClubName() const
+{
return club;
}
-QString& Score::getCourseName() {
+const QString& Score::getCourseName() const
+{
return course;
}
-QString& Score::getDate() {
+const QString& Score::getDate() const
+{
return date;
}
-void Score::dump() {
- qDebug() << club << " " << course << " " << date ;
+void Score::dump()
+{
+ qDebug() << club << course << date ;
for (int i=0; i<holeList.size(); i++)
holeList.at(i)->dump();
}
name = attrs.value("name");
}
-Course::Course(const QDomElement node) {
- name = node.attribute("name", "");
+Course::Course(const QDomElement node, Club * parent)
+ : club(parent)
+{
+ name = node.attribute("name", "");
}
Course::Course(QString &name,
}
}
+Club * Course::parent()
+{
+ return club;
+}
+
+void Course::setParent(Club *parent)
+{
+ club = parent;
+}
+
QDomElement Course::toElement(QDomDocument doc)
{
QDomElement node = doc.createElement("course");
return node;
}
+int Course::update(QVector<QString> &par,
+ QVector<QString> &hcp,
+ QVector<QString> &len)
+{
+ Q_UNUSED(len);
+ for (int i = 0; i < par.size(); i++) {
+ Hole *hole = holeList.at(i);
+ if (hole->getPar() != par[i])
+ hole->setPar(par[i]);
+ if (hole->getHcp() != hcp[i])
+ hole->setHcp(hcp[i]);
+ }
+ return 0;
+}
+
void Course::addHole(Hole *iHole) {
holeList << iHole;
}
void Club::addCourse(Course *iCourse) {
courseList << iCourse;
+ iCourse->setParent(this);
+}
+
+void Club::delCourse(Course * course) {
+ int index = courseList.indexOf(course);
+
+ if (index != -1)
+ courseList.removeAt(index);
+}
+
+bool Club::isEmpty()
+{
+ bool rc = false;
+ if (courseList.count() == 0)
+ rc = true;
+ return rc;
}
QDomElement Club::toElement(QDomDocument doc)
return courseList.at(pos);
}
-Course *Club::getCourse(QString &courseName)
+Course *Club::getCourse(const QString &courseName)
{
QListIterator<Course *> i(courseList);
Course *c = 0;