File indexing completed on 2024-04-14 14:16:52

0001 /*
0002     This file is part of KDE.
0003 
0004     SPDX-FileCopyrightText: 2008 Cornelius Schumacher <schumacher@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 "categoryparser.h"
0010 
0011 using namespace Attica;
0012 
0013 Category Category::Parser::parseXml(QXmlStreamReader &xml)
0014 {
0015     Category category;
0016 
0017     while (!xml.atEnd()) {
0018         xml.readNext();
0019 
0020         if (xml.isStartElement()) {
0021             if (xml.name() == QLatin1String("id")) {
0022                 category.setId(xml.readElementText());
0023             } else if (xml.name() == QLatin1String("name")) {
0024                 category.setName(xml.readElementText());
0025             } else if (xml.name() == QLatin1String("display_name")) {
0026                 category.setDisplayName(xml.readElementText());
0027             }
0028         } else if (xml.isEndElement() && xml.name() == QLatin1String("category")) {
0029             break;
0030         }
0031     }
0032 
0033     return category;
0034 }
0035 
0036 QStringList Category::Parser::xmlElement() const
0037 {
0038     return QStringList(QStringLiteral("category"));
0039 }