Attica

downloaditemparser.cpp
1 /*
2  This file is part of KDE.
3 
4  SPDX-FileCopyrightText: 2009 Frederik Gladhorn <[email protected]>
5 
6  SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
7 */
8 
9 #include "downloaditemparser.h"
10 
11 #include <QXmlStreamReader>
12 
13 using namespace Attica;
14 
15 QStringList DownloadItem::Parser::xmlElement() const
16 {
17  return QStringList(QStringLiteral("content"));
18 }
19 
20 DownloadItem DownloadItem::Parser::parseXml(QXmlStreamReader &xml)
21 {
22  DownloadItem item;
23 
24  while (!xml.atEnd()) {
25  xml.readNext();
26  if (xml.isStartElement()) {
27  if (xml.name() == QLatin1String("downloadlink")) {
28  item.setUrl(QUrl(xml.readElementText()));
29  } else if (xml.name() == QLatin1String("mimetype")) {
30  item.setMimeType(xml.readElementText());
31  } else if (xml.name() == QLatin1String("packagename")) {
32  item.setPackageName(xml.readElementText());
33  } else if (xml.name() == QLatin1String("packagerepository")) {
34  item.setPackageRepository(xml.readElementText());
35  } else if (xml.name() == QLatin1String("gpgfingerprint")) {
36  item.setGpgFingerprint(xml.readElementText());
37  } else if (xml.name() == QLatin1String("gpgsignature")) {
38  item.setGpgSignature(xml.readElementText());
39  } else if (xml.name() == QLatin1String("downloadway")) {
40  item.setType(DownloadDescription::Type(xml.readElementText().toInt()));
41  }
42  }
43  }
44  return item;
45 }
QStringRef name() const const
QXmlStreamReader::TokenType readNext()
int toInt(bool *ok, int base) const const
QString readElementText(QXmlStreamReader::ReadElementTextBehaviour behaviour)
The Attica namespace,.
bool isStartElement() const const
bool atEnd() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Dec 11 2023 04:05:13 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.