1 | /* |
---|---|
2 | This file is part of KDE. |
3 | |
4 | SPDX-FileCopyrightText: 2008 Cornelius Schumacher <schumacher@kde.org> |
5 | SPDX-FileCopyrightText: 2009 Marco Martin <notmart@gmail.com> |
6 | |
7 | SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL |
8 | */ |
9 | |
10 | #include "knowledgebaseentryparser.h" |
11 | |
12 | using namespace Attica; |
13 | |
14 | KnowledgeBaseEntry KnowledgeBaseEntry::Parser::parseXml(QXmlStreamReader &xml) |
15 | { |
16 | KnowledgeBaseEntry knowledgeBase; |
17 | |
18 | while (!xml.atEnd()) { |
19 | xml.readNext(); |
20 | |
21 | if (xml.isStartElement()) { |
22 | if (xml.name() == QLatin1String("id")) { |
23 | knowledgeBase.setId(xml.readElementText()); |
24 | } else if (xml.name() == QLatin1String("status")) { |
25 | knowledgeBase.setStatus(xml.readElementText()); |
26 | } else if (xml.name() == QLatin1String("contentId")) { |
27 | knowledgeBase.setContentId(xml.readElementText().toInt()); |
28 | } else if (xml.name() == QLatin1String("user")) { |
29 | knowledgeBase.setUser(xml.readElementText()); |
30 | } else if (xml.name() == QLatin1String("changed")) { |
31 | knowledgeBase.setChanged(QDateTime::fromString(string: xml.readElementText(), format: Qt::ISODate)); |
32 | } else if (xml.name() == QLatin1String("description")) { |
33 | knowledgeBase.setDescription(xml.readElementText()); |
34 | } else if (xml.name() == QLatin1String("answer")) { |
35 | knowledgeBase.setAnswer(xml.readElementText()); |
36 | } else if (xml.name() == QLatin1String("comments")) { |
37 | knowledgeBase.setComments(xml.readElementText().toInt()); |
38 | } else if (xml.name() == QLatin1String("detailpage")) { |
39 | knowledgeBase.setDetailPage(QUrl(xml.readElementText())); |
40 | } else if (xml.name() == QLatin1String("contentid")) { |
41 | knowledgeBase.setContentId(xml.readElementText().toInt()); |
42 | } else if (xml.name() == QLatin1String("name")) { |
43 | knowledgeBase.setName(xml.readElementText()); |
44 | } else { |
45 | knowledgeBase.addExtendedAttribute(key: xml.name().toString(), value: xml.readElementText()); |
46 | } |
47 | } else if (xml.isEndElement() && xml.name() == QLatin1String("content")) { |
48 | break; |
49 | } |
50 | } |
51 | |
52 | return knowledgeBase; |
53 | } |
54 | |
55 | QStringList KnowledgeBaseEntry::Parser::xmlElement() const |
56 | { |
57 | return QStringList(QStringLiteral("content")); |
58 | } |
59 |