From 54576ab2d36c6736d3720fc4cfbcfc659c279e23 Mon Sep 17 00:00:00 2001 From: Jeremy Lainé Date: Thu, 18 Feb 2010 12:37:52 +0000 Subject: introduce QXmppElementList --- source/QXmppElement.cpp | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'source/QXmppElement.cpp') diff --git a/source/QXmppElement.cpp b/source/QXmppElement.cpp index 3820f35e..5bcbeed6 100644 --- a/source/QXmppElement.cpp +++ b/source/QXmppElement.cpp @@ -73,16 +73,24 @@ void QXmppElement::setAttribute(const QString &name, const QString &value) m_attributes.insert(name, value); } -QList QXmppElement::children() const +QXmppElementList QXmppElement::children() const { return m_children; } -void QXmppElement::setChildren(QList &children) +void QXmppElement::setChildren(const QXmppElementList &children) { m_children = children; } +QXmppElement QXmppElement::firstChild(const QString &name) const +{ + foreach (const QXmppElement &child, m_children) + if (child.tagName() == name) + return child; + return QXmppElement(); +} + bool QXmppElement::isNull() const { return m_tagName.isEmpty(); @@ -122,3 +130,18 @@ void QXmppElement::toXml(QXmlStreamWriter *writer) const writer->writeEndElement(); } +QXmppElementList::QXmppElementList() +{ +} + +QXmppElementList::QXmppElementList(const QXmppElement &element) +{ + append(element); +} + + +QXmppElementList::QXmppElementList(const QList &other) + : QList(other) +{ +} + -- cgit v1.2.3