diff options
| author | Jeremy Lainé <jeremy.laine@m4x.org> | 2010-02-18 12:38:47 +0000 |
|---|---|---|
| committer | Jeremy Lainé <jeremy.laine@m4x.org> | 2010-02-18 12:38:47 +0000 |
| commit | 1c594fa50ba7c3fc53fe0ab5a8175a6737e0f8a7 (patch) | |
| tree | 1a70b57c23da8e2b9ae4acfc839c7be2dfa2b60b /source | |
| parent | 54576ab2d36c6736d3720fc4cfbcfc659c279e23 (diff) | |
| download | qxmpp-1c594fa50ba7c3fc53fe0ab5a8175a6737e0f8a7.tar.gz | |
use QXmppElementList and introduce QXmppIq::parse()
Diffstat (limited to 'source')
| -rw-r--r-- | source/QXmppIq.cpp | 19 | ||||
| -rw-r--r-- | source/QXmppIq.h | 7 |
2 files changed, 21 insertions, 5 deletions
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 <QDomElement> #include <QXmlStreamWriter> 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<QXmppElement> QXmppIq::getItems() const +QXmppElementList QXmppIq::getItems() const { return m_items; } -void QXmppIq::setItems(const QList<QXmppElement> &items) +void QXmppIq::setItems(const QXmppElementList &items) { m_items = items; } diff --git a/source/QXmppIq.h b/source/QXmppIq.h index 4b7f6b6b..0205daea 100644 --- a/source/QXmppIq.h +++ b/source/QXmppIq.h @@ -53,15 +53,16 @@ public: void setType(QXmppIq::Type); void setTypeFromStr(const QString& str); - QList<QXmppElement> getItems() const; - void setItems(const QList<QXmppElement> &items); + QXmppElementList getItems() const; + void setItems(const QXmppElementList &items); + void parse( QDomElement &element ); void toXml( QXmlStreamWriter *writer ) const; virtual void toXmlElementFromChild( QXmlStreamWriter *writer ) const; private: Type m_type; - QList<QXmppElement> m_items; + QXmppElementList m_items; }; #endif // QXMPPIQ_H |
