| 1 | /* |
| 2 | This file is part of KDE. |
| 3 | |
| 4 | SPDX-FileCopyrightText: 2011 Laszlo Papp <djszapi@archlinux.us> |
| 5 | |
| 6 | SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL |
| 7 | */ |
| 8 | |
| 9 | #include "topicparser.h" |
| 10 | #include "atticautils.h" |
| 11 | |
| 12 | using namespace Attica; |
| 13 | |
| 14 | Topic Topic::Parser::parseXml(QXmlStreamReader &xml) |
| 15 | { |
| 16 | Topic topic; |
| 17 | |
| 18 | while (!xml.atEnd()) { |
| 19 | xml.readNext(); |
| 20 | |
| 21 | if (xml.isStartElement()) { |
| 22 | if (xml.name() == QLatin1String("id" )) { |
| 23 | topic.setId(xml.readElementText()); |
| 24 | } else if (xml.name() == QLatin1String("forumId" )) { |
| 25 | topic.setForumId(xml.readElementText()); |
| 26 | } else if (xml.name() == QLatin1String("user" )) { |
| 27 | topic.setUser(xml.readElementText()); |
| 28 | } else if (xml.name() == QLatin1String("date" )) { |
| 29 | topic.setDate(Utils::parseQtDateTimeIso8601(str: xml.readElementText())); |
| 30 | } else if (xml.name() == QLatin1String("subject" )) { |
| 31 | topic.setSubject(xml.readElementText()); |
| 32 | } else if (xml.name() == QLatin1String("content" )) { |
| 33 | topic.setContent(xml.readElementText()); |
| 34 | } else if (xml.name() == QLatin1String("comments" )) { |
| 35 | topic.setComments(xml.readElementText().toInt()); |
| 36 | } |
| 37 | } else if (xml.isEndElement() && xml.name() == QLatin1String("topic" )) { |
| 38 | break; |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | return topic; |
| 43 | } |
| 44 | |
| 45 | QStringList Topic::Parser::xmlElement() const |
| 46 | { |
| 47 | return QStringList(QStringLiteral("topic" )); |
| 48 | } |
| 49 | |