File indexing completed on 2024-12-08 03:37:12
0001 /* 0002 This file is part of KDE. 0003 0004 SPDX-FileCopyrightText: 2010 Sebastian Kügler <sebas@kde.org> 0005 0006 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0007 */ 0008 0009 #include "projectparser.h" 0010 #include <qdebug.h> 0011 0012 using namespace Attica; 0013 0014 Project Project::Parser::parseXml(QXmlStreamReader &xml) 0015 { 0016 Project project; 0017 0018 // For specs about the XML provided, see here: 0019 // http://www.freedesktop.org/wiki/Specifications/open-collaboration-services-draft#Projects 0020 while (!xml.atEnd()) { 0021 // qCDebug(ATTICA) << "XML returned:" << xml.text().toString(); 0022 xml.readNext(); 0023 0024 if (xml.isStartElement()) { 0025 if (xml.name() == QLatin1String("projectid")) { 0026 project.setId(xml.readElementText()); 0027 } else if (xml.name() == QLatin1String("name")) { 0028 project.setName(xml.readElementText()); 0029 } else if (xml.name() == QLatin1String("version")) { 0030 project.setVersion(xml.readElementText()); 0031 } else if (xml.name() == QLatin1String("license")) { 0032 project.setLicense(xml.readElementText()); 0033 } else if (xml.name() == QLatin1String("url")) { 0034 project.setUrl(xml.readElementText()); 0035 } else if (xml.name() == QLatin1String("summary")) { 0036 project.setSummary(xml.readElementText()); 0037 } else if (xml.name() == QLatin1String("description")) { 0038 project.setDescription(xml.readElementText()); 0039 } else if (xml.name() == QLatin1String("specfile")) { 0040 project.setSpecFile(xml.readElementText()); 0041 } else if (xml.name() == QLatin1String("developers")) { 0042 project.setDevelopers(xml.readElementText().split(QLatin1Char('\n'))); 0043 } else if (xml.name() == QLatin1String("projectlist")) { 0044 QXmlStreamReader list_xml(xml.readElementText()); 0045 while (!list_xml.atEnd()) { 0046 list_xml.readNext(); 0047 if (xml.name() == QLatin1String("projectid")) { 0048 project.setSpecFile(xml.readElementText()); 0049 } 0050 } 0051 } 0052 } else if (xml.isEndElement() && (xml.name() == QLatin1String("project") || xml.name() == QLatin1String("user"))) { 0053 break; 0054 } 0055 } 0056 return project; 0057 } 0058 0059 QStringList Project::Parser::xmlElement() const 0060 { 0061 return QStringList(QStringLiteral("project")) << QStringLiteral("user"); 0062 }