File indexing completed on 2024-03-24 15:23:50

0001 /*
0002     SPDX-FileCopyrightText: 2010 Frederik Gladhorn <gladhorn@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005 */
0006 
0007 #include "licenseparser.h"
0008 
0009 using namespace Attica;
0010 
0011 QStringList License::Parser::xmlElement() const
0012 {
0013     return QStringList(QStringLiteral("license"));
0014 }
0015 
0016 License License::Parser::parseXml(QXmlStreamReader &xml)
0017 {
0018     License item;
0019 
0020     while (!xml.atEnd()) {
0021         xml.readNext();
0022         if (xml.isStartElement()) {
0023             if (xml.name() == QLatin1String("id")) {
0024                 item.setId(xml.readElementText().toInt());
0025             } else if (xml.name() == QLatin1String("name")) {
0026                 item.setName(xml.readElementText());
0027             } else if (xml.name() == QLatin1String("link")) {
0028                 item.setUrl(QUrl(xml.readElementText()));
0029             }
0030         }
0031         if (xml.isEndElement() && xml.name() == QLatin1String("license")) {
0032             break;
0033         }
0034     }
0035     return item;
0036 }