1 | /* |
2 | SPDX-FileCopyrightText: 2010 Frederik Gladhorn <gladhorn@kde.org> |
3 | |
4 | SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL |
5 | */ |
6 | |
7 | #include "licenseparser.h" |
8 | |
9 | using namespace Attica; |
10 | |
11 | QStringList License::Parser::xmlElement() const |
12 | { |
13 | return QStringList(QStringLiteral("license" )); |
14 | } |
15 | |
16 | License License::Parser::parseXml(QXmlStreamReader &xml) |
17 | { |
18 | License item; |
19 | |
20 | while (!xml.atEnd()) { |
21 | xml.readNext(); |
22 | if (xml.isStartElement()) { |
23 | if (xml.name() == QLatin1String("id" )) { |
24 | item.setId(xml.readElementText().toInt()); |
25 | } else if (xml.name() == QLatin1String("name" )) { |
26 | item.setName(xml.readElementText()); |
27 | } else if (xml.name() == QLatin1String("link" )) { |
28 | item.setUrl(QUrl(xml.readElementText())); |
29 | } |
30 | } |
31 | if (xml.isEndElement() && xml.name() == QLatin1String("license" )) { |
32 | break; |
33 | } |
34 | } |
35 | return item; |
36 | } |
37 | |