logging changes
[scorecard] / src / data.cpp
index edfff01..9885c75 100644 (file)
@@ -73,10 +73,18 @@ 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 ; 
 }
@@ -132,7 +140,7 @@ QDomElement Score::toElement(QDomDocument doc)
   return node;
 }
 
-int Score::update(QVector<QString> scores)
+int Score::update(QVector<QString> &scores)
 {
   for (int i = 0; i < scores.size(); i++) {
     Hole *hole = holeList.at(i);
@@ -190,7 +198,7 @@ const QString& Score::getDate() const
 
 void Score::dump()
 {
-  qDebug() << club << " " << course << " " << date ; 
+  qDebug() << club << course << date ; 
   for (int i=0; i<holeList.size(); i++)
     holeList.at(i)->dump();
 }
@@ -232,6 +240,20 @@ QDomElement Course::toElement(QDomDocument doc)
   return node;
 }
 
+int Course::update(QVector<QString> &par,
+                  QVector<QString> &hcp,
+                  QVector<QString> &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;
 }