From 1c594fa50ba7c3fc53fe0ab5a8175a6737e0f8a7 Mon Sep 17 00:00:00 2001 From: Jeremy Lainé Date: Thu, 18 Feb 2010 12:38:47 +0000 Subject: use QXmppElementList and introduce QXmppIq::parse() --- source/QXmppIq.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'source/QXmppIq.cpp') diff --git a/source/QXmppIq.cpp b/source/QXmppIq.cpp index a28e6f8d..981ffeb7 100644 --- a/source/QXmppIq.cpp +++ b/source/QXmppIq.cpp @@ -25,6 +25,7 @@ #include "QXmppUtils.h" #include "QXmppIq.h" +#include #include QXmppIq::QXmppIq(QXmppIq::Type type) @@ -55,6 +56,20 @@ void QXmppIq::setType(QXmppIq::Type type) m_type = type; } +void QXmppIq::parse( QDomElement &element ) +{ + setFrom(element.attribute("from")); + setTo(element.attribute("to")); + setTypeFromStr(element.attribute("type")); + + QDomElement itemElement = element.firstChildElement(); + while (!itemElement.isNull()) + { + m_items.append(QXmppElement(itemElement)); + itemElement = itemElement.nextSiblingElement(); + } +} + void QXmppIq::toXml( QXmlStreamWriter *xmlWriter ) const { xmlWriter->writeStartElement("iq"); @@ -126,12 +141,12 @@ void QXmppIq::setTypeFromStr(const QString& str) } } -QList QXmppIq::getItems() const +QXmppElementList QXmppIq::getItems() const { return m_items; } -void QXmppIq::setItems(const QList &items) +void QXmppIq::setItems(const QXmppElementList &items) { m_items = items; } -- cgit v1.2.3