-rw-r--r-- | libopie2/opiecore/xmltree.cc | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/libopie2/opiecore/xmltree.cc b/libopie2/opiecore/xmltree.cc index 3d03cc6..408e3c6 100644 --- a/libopie2/opiecore/xmltree.cc +++ b/libopie2/opiecore/xmltree.cc @@ -68,60 +68,62 @@ void XMLElement::insertAfter( XMLElement *newChild, XMLElement *refChild ) { appendChild( newChild ); return; } assert( refChild ); assert( refChild->m_parent ); assert( refChild->m_parent == this ); if ( newChild->m_parent && newChild != refChild ) newChild->m_parent->removeChild( newChild ); newChild->m_parent = this; XMLElement *next = refChild->m_next; refChild->m_next = newChild; newChild->m_prev = refChild; newChild->m_next = next; if ( next ) next->m_prev = newChild; } + QString XMLElement::attribute(const QString &attr )const { - if ( !m_attributes.contains( attr ) ) - return QString::null; AttributeMap::ConstIterator it = m_attributes.find( attr ); + if ( it == m_attributes.end() ) + return QString::null; return it.data(); } + void XMLElement::setAttribute(const QString &attr, const QString &value ) { - m_attributes.remove( attr ); - m_attributes.insert( attr, value ); + m_attributes.replace( attr, value ); } + void XMLElement::insertBefore( XMLElement *newChild, XMLElement *refChild ) { assert( refChild ); assert( refChild->m_parent ); assert( refChild->m_parent == this ); assert( newChild != refChild ); if ( newChild->m_parent && newChild != refChild ) newChild->m_parent->removeChild( newChild ); newChild->m_parent = this; XMLElement *prev = refChild->m_prev; refChild->m_prev = newChild; newChild->m_prev = prev; newChild->m_next = refChild; if ( prev ) prev->m_next = newChild; if ( refChild == m_first ) m_first = newChild; @@ -294,25 +296,26 @@ XMLElement *XMLElement::clone() const res->appendChild( e->clone() ); return res; } XMLElement *XMLElement::load( const QString &fileName ) { QFile f( fileName ); if ( !f.open( IO_ReadOnly ) ) return 0; QTextStream stream( &f ); stream.setEncoding( QTextStream::UnicodeUTF8 ); QXmlInputSource src( stream ); QXmlSimpleReader reader; Handler handler; reader.setFeature( "http://trolltech.com/xml/features/report-whitespace-only-CharData", false ); reader.setContentHandler( &handler ); reader.parse( src ); return handler.root();; } - +/* vim: et sw=4 + */ |