Attica

messageparser.cpp
1/*
2 This file is part of KDE.
3
4 SPDX-FileCopyrightText: 2008 Cornelius Schumacher <schumacher@kde.org>
5
6 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
7*/
8
9#include "messageparser.h"
10
11using namespace Attica;
12
13Message Message::Parser::parseXml(QXmlStreamReader &xml)
14{
15 Message message;
16
17 while (!xml.atEnd()) {
18 xml.readNext();
19
20 if (xml.isStartElement()) {
21 if (xml.name() == QLatin1String("id")) {
22 message.setId(xml.readElementText());
23 } else if (xml.name() == QLatin1String("messagefrom")) {
24 message.setFrom(xml.readElementText());
25 } else if (xml.name() == QLatin1String("messageto")) {
26 message.setTo(xml.readElementText());
27 } else if (xml.name() == QLatin1String("senddate")) {
28 message.setSent(QDateTime::fromString(xml.readElementText(), Qt::ISODate));
29 } else if (xml.name() == QLatin1String("status")) {
30 message.setStatus(Message::Status(xml.readElementText().toInt()));
31 } else if (xml.name() == QLatin1String("subject")) {
32 message.setSubject(xml.readElementText());
33 } else if (xml.name() == QLatin1String("body")) {
34 message.setBody(xml.readElementText());
35 }
36 }
37
38 if (xml.isEndElement() && xml.name() == QLatin1String("message")) {
39 break;
40 }
41 }
42
43 return message;
44}
45
46QStringList Message::Parser::xmlElement() const
47{
48 return QStringList(QStringLiteral("message"));
49}
Represents a message.
Definition message.h:27
The Attica namespace,.
QDateTime fromString(QStringView string, QStringView format, QCalendar cal)
int toInt(bool *ok, int base) const const
bool atEnd() const const
bool isEndElement() const const
bool isStartElement() const const
QStringView name() const const
QString readElementText(ReadElementTextBehaviour behaviour)
TokenType readNext()
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:58:18 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.