File indexing completed on 2025-02-09 04:18:56
0001 /* 0002 This file is part of KDE. 0003 0004 SPDX-FileCopyrightText: 2011 Laszlo Papp <djszapi@archlinux.us> 0005 0006 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0007 */ 0008 0009 #include "topicparser.h" 0010 #include "atticautils.h" 0011 0012 using namespace Attica; 0013 0014 Topic Topic::Parser::parseXml(QXmlStreamReader &xml) 0015 { 0016 Topic topic; 0017 0018 while (!xml.atEnd()) { 0019 xml.readNext(); 0020 0021 if (xml.isStartElement()) { 0022 if (xml.name() == QLatin1String("id")) { 0023 topic.setId(xml.readElementText()); 0024 } else if (xml.name() == QLatin1String("forumId")) { 0025 topic.setForumId(xml.readElementText()); 0026 } else if (xml.name() == QLatin1String("user")) { 0027 topic.setUser(xml.readElementText()); 0028 } else if (xml.name() == QLatin1String("date")) { 0029 topic.setDate(Utils::parseQtDateTimeIso8601(xml.readElementText())); 0030 } else if (xml.name() == QLatin1String("subject")) { 0031 topic.setSubject(xml.readElementText()); 0032 } else if (xml.name() == QLatin1String("content")) { 0033 topic.setContent(xml.readElementText()); 0034 } else if (xml.name() == QLatin1String("comments")) { 0035 topic.setComments(xml.readElementText().toInt()); 0036 } 0037 } else if (xml.isEndElement() && xml.name() == QLatin1String("topic")) { 0038 break; 0039 } 0040 } 0041 0042 return topic; 0043 } 0044 0045 QStringList Topic::Parser::xmlElement() const 0046 { 0047 return QStringList(QStringLiteral("topic")); 0048 }