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.
13 #include "xml-parser.h"
19 ScoreHandler::ScoreHandler(QList<Score *> &scoreList) : scoreList(scoreList)
25 bool ScoreHandler::startDocument()
31 bool ScoreHandler::endDocument()
36 bool ScoreHandler::startElement(const QString & /* namespaceURI */,
37 const QString & /* localName */,
39 const QXmlAttributes &attrs)
41 if (inScore && name == "hole") {
42 hole = new Hole(attrs);
44 else if (name == "score") {
45 score = new Score(attrs);
51 bool ScoreHandler::endElement(const QString & /* namespaceURI */,
52 const QString & /* localName */,
55 if (name == "score") {
58 } else if (name == "hole")
64 bool ScoreHandler::fatalError(const QXmlParseException &exception)
66 qWarning() << "Fatal error on line" << exception.lineNumber()
67 << ", column" << exception.columnNumber() << ":"
68 << exception.message();
73 QString ScoreHandler::errorString() const
81 ClubHandler::ClubHandler(QList<Club *> &clubList) : clubList(clubList)
87 bool ClubHandler::startDocument()
94 bool ClubHandler::endDocument()
99 bool ClubHandler::startElement(const QString & /* namespaceURI */,
100 const QString & /* localName */,
102 const QXmlAttributes &attrs)
104 if (inCourse && name == "hole") {
105 hole = new Hole(attrs);
107 else if (name == "course") {
108 course = new Course(attrs);
111 else if (name == "club") {
112 club = new Club(attrs);
118 bool ClubHandler::endElement(const QString & /* namespaceURI */,
119 const QString & /* localName */,
122 if (name == "club") {
126 else if (name == "course") {
128 club->addCourse(course);
130 else if (name == "hole")
131 course->addHole(hole);
136 bool ClubHandler::fatalError(const QXmlParseException &exception)
138 qWarning() << "Fatal error on line" << exception.lineNumber()
139 << ", column" << exception.columnNumber() << ":"
140 << exception.message();
145 QString ClubHandler::errorString() const