Attica

knowledgebaseentryparser.cpp
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
12using namespace Attica;
13
14KnowledgeBaseEntry 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(xml.readElementText(), 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(xml.name().toString(), xml.readElementText());
46 }
47 } else if (xml.isEndElement() && xml.name() == QLatin1String("content")) {
48 break;
49 }
50 }
51
52 return knowledgeBase;
53}
54
55QStringList KnowledgeBaseEntry::Parser::xmlElement() const
56{
57 return QStringList(QStringLiteral("content"));
58}
Represents a knowledge base entry.
The Attica namespace,.
QDateTime fromString(QStringView string, QStringView format, QCalendar cal)
int toInt(bool *ok, int base) const const
QString toString() const const
bool atEnd() const const
bool isEndElement() const const
bool isStartElement() const const
QStringView name() const const
QString readElementText(ReadElementTextBehaviour behaviour)
TokenType readNext()
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 22 2024 12:04:50 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.