-rw-r--r-- | libopie/tododb.cpp | 2 | ||||
-rw-r--r-- | libopie/xmltree.cc | 1 | ||||
-rw-r--r-- | libopie/xmltree.h | 5 | ||||
-rw-r--r-- | libopie2/opiecore/xmltree.cc | 1 | ||||
-rw-r--r-- | libopie2/opiecore/xmltree.h | 5 |
5 files changed, 14 insertions, 0 deletions
diff --git a/libopie/tododb.cpp b/libopie/tododb.cpp index 33fa177..fe8b8bf 100644 --- a/libopie/tododb.cpp +++ b/libopie/tododb.cpp | |||
@@ -1,56 +1,58 @@ | |||
1 | 1 | ||
2 | #include <qdir.h> | 2 | #include <qdir.h> |
3 | #include <opie/tododb.h> | 3 | #include <opie/tododb.h> |
4 | #include <opie/xmltree.h> | 4 | #include <opie/xmltree.h> |
5 | #include <opie/todoresource.h> | 5 | #include <opie/todoresource.h> |
6 | #include <qpe/palmtoprecord.h> | 6 | #include <qpe/palmtoprecord.h> |
7 | #include <qpe/global.h> | 7 | #include <qpe/global.h> |
8 | 8 | ||
9 | using namespace Opie; | ||
10 | |||
9 | namespace { | 11 | namespace { |
10 | 12 | ||
11 | class FileToDoResource : public ToDoResource { | 13 | class FileToDoResource : public ToDoResource { |
12 | public: | 14 | public: |
13 | FileToDoResource() {}; | 15 | FileToDoResource() {}; |
14 | bool save(const QString &name, const QValueList<ToDoEvent> &m_todos ){ | 16 | bool save(const QString &name, const QValueList<ToDoEvent> &m_todos ){ |
15 | // prepare the XML | 17 | // prepare the XML |
16 | XMLElement *tasks = new XMLElement( ); | 18 | XMLElement *tasks = new XMLElement( ); |
17 | tasks->setTagName("Tasks" ); | 19 | tasks->setTagName("Tasks" ); |
18 | for( QValueList<ToDoEvent>::ConstIterator it = m_todos.begin(); it != m_todos.end(); ++it ){ | 20 | for( QValueList<ToDoEvent>::ConstIterator it = m_todos.begin(); it != m_todos.end(); ++it ){ |
19 | XMLElement::AttributeMap map; | 21 | XMLElement::AttributeMap map; |
20 | XMLElement *task = new XMLElement(); | 22 | XMLElement *task = new XMLElement(); |
21 | map.insert( "Completed", QString::number((int)(*it).isCompleted() ) ); | 23 | map.insert( "Completed", QString::number((int)(*it).isCompleted() ) ); |
22 | map.insert( "HasDate", QString::number((int)(*it).hasDate() ) ); | 24 | map.insert( "HasDate", QString::number((int)(*it).hasDate() ) ); |
23 | map.insert( "Priority", QString::number( (*it).priority() ) ); | 25 | map.insert( "Priority", QString::number( (*it).priority() ) ); |
24 | QArray<int> arrat = (*it).categories(); | 26 | QArray<int> arrat = (*it).categories(); |
25 | QString attr; | 27 | QString attr; |
26 | for(uint i=0; i < arrat.count(); i++ ){ | 28 | for(uint i=0; i < arrat.count(); i++ ){ |
27 | attr.append(QString::number(arrat[i])+";" ); | 29 | attr.append(QString::number(arrat[i])+";" ); |
28 | } | 30 | } |
29 | if(!attr.isEmpty() ) // remove the last ; | 31 | if(!attr.isEmpty() ) // remove the last ; |
30 | attr.remove(attr.length()-1, 1 ); | 32 | attr.remove(attr.length()-1, 1 ); |
31 | map.insert( "Categories", attr ); | 33 | map.insert( "Categories", attr ); |
32 | //else | 34 | //else |
33 | //map.insert( "Categories", QString::null ); | 35 | //map.insert( "Categories", QString::null ); |
34 | map.insert( "Description", (*it).description() ); | 36 | map.insert( "Description", (*it).description() ); |
35 | if( (*it).hasDate() ){ | 37 | if( (*it).hasDate() ){ |
36 | map.insert("DateYear", QString::number( (*it).date().year() ) ); | 38 | map.insert("DateYear", QString::number( (*it).date().year() ) ); |
37 | map.insert("DateMonth", QString::number( (*it).date().month() ) ); | 39 | map.insert("DateMonth", QString::number( (*it).date().month() ) ); |
38 | map.insert("DateDay", QString::number( (*it).date().day() ) ); | 40 | map.insert("DateDay", QString::number( (*it).date().day() ) ); |
39 | } | 41 | } |
40 | map.insert("Uid", QString::number( (*it).uid() ) ); | 42 | map.insert("Uid", QString::number( (*it).uid() ) ); |
41 | task->setTagName("Task" ); | 43 | task->setTagName("Task" ); |
42 | task->setAttributes( map ); | 44 | task->setAttributes( map ); |
43 | tasks->appendChild(task); | 45 | tasks->appendChild(task); |
44 | } | 46 | } |
45 | QFile file( name); | 47 | QFile file( name); |
46 | if( file.open(IO_WriteOnly ) ){ | 48 | if( file.open(IO_WriteOnly ) ){ |
47 | QTextStream stream(&file ); | 49 | QTextStream stream(&file ); |
48 | stream.setEncoding( QTextStream::UnicodeUTF8 ); | 50 | stream.setEncoding( QTextStream::UnicodeUTF8 ); |
49 | stream << "<!DOCTYPE Tasks>" << endl; | 51 | stream << "<!DOCTYPE Tasks>" << endl; |
50 | tasks->save(stream ); | 52 | tasks->save(stream ); |
51 | delete tasks; | 53 | delete tasks; |
52 | stream << "</Tasks>" << endl; | 54 | stream << "</Tasks>" << endl; |
53 | file.close(); | 55 | file.close(); |
54 | return true; | 56 | return true; |
55 | } | 57 | } |
56 | return false; | 58 | return false; |
diff --git a/libopie/xmltree.cc b/libopie/xmltree.cc index 408e3c6..27db5b3 100644 --- a/libopie/xmltree.cc +++ b/libopie/xmltree.cc | |||
@@ -1,74 +1,75 @@ | |||
1 | /* This file is part of the KDE project | 1 | /* This file is part of the KDE project |
2 | Copyright (C) 2001 Simon Hausmann <hausmann@kde.org> | 2 | Copyright (C) 2001 Simon Hausmann <hausmann@kde.org> |
3 | 3 | ||
4 | This library is free software; you can redistribute it and/or | 4 | This library is free software; you can redistribute it and/or |
5 | modify it under the terms of the GNU Library General Public | 5 | modify it under the terms of the GNU Library General Public |
6 | License as published by the Free Software Foundation; either | 6 | License as published by the Free Software Foundation; either |
7 | version 2 of the License, or (at your option) any later version. | 7 | version 2 of the License, or (at your option) any later version. |
8 | 8 | ||
9 | This library is distributed in the hope that it will be useful, | 9 | This library is distributed in the hope that it will be useful, |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | Library General Public License for more details. | 12 | Library General Public License for more details. |
13 | 13 | ||
14 | You should have received a copy of the GNU Library General Public License | 14 | You should have received a copy of the GNU Library General Public License |
15 | along with this library; see the file COPYING.LIB. If not, write to | 15 | along with this library; see the file COPYING.LIB. If not, write to |
16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
17 | Boston, MA 02111-1307, USA. | 17 | Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <qpe/stringutil.h> | 20 | #include <qpe/stringutil.h> |
21 | #include <opie/xmltree.h> | 21 | #include <opie/xmltree.h> |
22 | 22 | ||
23 | #include <qxml.h> | 23 | #include <qxml.h> |
24 | 24 | ||
25 | #include <assert.h> | 25 | #include <assert.h> |
26 | 26 | ||
27 | using namespace Opie; | ||
27 | 28 | ||
28 | XMLElement::XMLElement() | 29 | XMLElement::XMLElement() |
29 | : m_parent( 0 ), m_next( 0 ), m_prev( 0 ), m_first( 0 ), m_last( 0 ) | 30 | : m_parent( 0 ), m_next( 0 ), m_prev( 0 ), m_first( 0 ), m_last( 0 ) |
30 | { | 31 | { |
31 | } | 32 | } |
32 | 33 | ||
33 | XMLElement::~XMLElement() | 34 | XMLElement::~XMLElement() |
34 | { | 35 | { |
35 | XMLElement *n = m_first; | 36 | XMLElement *n = m_first; |
36 | 37 | ||
37 | while ( n ) | 38 | while ( n ) |
38 | { | 39 | { |
39 | XMLElement *tmp = n; | 40 | XMLElement *tmp = n; |
40 | n = n->m_next; | 41 | n = n->m_next; |
41 | delete tmp; | 42 | delete tmp; |
42 | } | 43 | } |
43 | } | 44 | } |
44 | 45 | ||
45 | void XMLElement::appendChild( XMLElement *child ) | 46 | void XMLElement::appendChild( XMLElement *child ) |
46 | { | 47 | { |
47 | if ( child->m_parent ) | 48 | if ( child->m_parent ) |
48 | child->m_parent->removeChild( child ); | 49 | child->m_parent->removeChild( child ); |
49 | 50 | ||
50 | child->m_parent = this; | 51 | child->m_parent = this; |
51 | 52 | ||
52 | if ( m_last ) | 53 | if ( m_last ) |
53 | m_last->m_next = child; | 54 | m_last->m_next = child; |
54 | 55 | ||
55 | child->m_prev = m_last; | 56 | child->m_prev = m_last; |
56 | 57 | ||
57 | if ( !m_first ) | 58 | if ( !m_first ) |
58 | m_first = child; | 59 | m_first = child; |
59 | 60 | ||
60 | m_last = child; | 61 | m_last = child; |
61 | } | 62 | } |
62 | 63 | ||
63 | void XMLElement::insertAfter( XMLElement *newChild, XMLElement *refChild ) | 64 | void XMLElement::insertAfter( XMLElement *newChild, XMLElement *refChild ) |
64 | { | 65 | { |
65 | assert( newChild != refChild ); | 66 | assert( newChild != refChild ); |
66 | 67 | ||
67 | if ( refChild == m_last ) | 68 | if ( refChild == m_last ) |
68 | { | 69 | { |
69 | appendChild( newChild ); | 70 | appendChild( newChild ); |
70 | return; | 71 | return; |
71 | } | 72 | } |
72 | 73 | ||
73 | assert( refChild ); | 74 | assert( refChild ); |
74 | assert( refChild->m_parent ); | 75 | assert( refChild->m_parent ); |
diff --git a/libopie/xmltree.h b/libopie/xmltree.h index ed93c23..4a6b6d9 100644 --- a/libopie/xmltree.h +++ b/libopie/xmltree.h | |||
@@ -1,112 +1,117 @@ | |||
1 | /* This file is part of the KDE project | 1 | /* This file is part of the KDE project |
2 | Copyright (C) 2000,2001 Simon Hausmann <hausmann@kde.org> | 2 | Copyright (C) 2000,2001 Simon Hausmann <hausmann@kde.org> |
3 | 3 | ||
4 | This library is free software; you can redistribute it and/or | 4 | This library is free software; you can redistribute it and/or |
5 | modify it under the terms of the GNU Library General Public | 5 | modify it under the terms of the GNU Library General Public |
6 | License as published by the Free Software Foundation; either | 6 | License as published by the Free Software Foundation; either |
7 | version 2 of the License, or (at your option) any later version. | 7 | version 2 of the License, or (at your option) any later version. |
8 | 8 | ||
9 | This library is distributed in the hope that it will be useful, | 9 | This library is distributed in the hope that it will be useful, |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | Library General Public License for more details. | 12 | Library General Public License for more details. |
13 | 13 | ||
14 | You should have received a copy of the GNU Library General Public License | 14 | You should have received a copy of the GNU Library General Public License |
15 | along with this library; see the file COPYING.LIB. If not, write to | 15 | along with this library; see the file COPYING.LIB. If not, write to |
16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
17 | Boston, MA 02111-1307, USA. | 17 | Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | 20 | ||
21 | #ifndef __bookmarks_h__ | 21 | #ifndef __bookmarks_h__ |
22 | #define __bookmarks_h__ | 22 | #define __bookmarks_h__ |
23 | 23 | ||
24 | #include <qstring.h> | 24 | #include <qstring.h> |
25 | #include <qmap.h> | 25 | #include <qmap.h> |
26 | #include <qtextstream.h> | 26 | #include <qtextstream.h> |
27 | 27 | ||
28 | namespace Opie | ||
29 | { | ||
30 | |||
28 | /** | 31 | /** |
29 | * A small xml lib written by Simon Hausmann. | 32 | * A small xml lib written by Simon Hausmann. |
30 | */ | 33 | */ |
31 | class XMLElement | 34 | class XMLElement |
32 | { | 35 | { |
33 | public: | 36 | public: |
34 | typedef QMap<QString, QString> AttributeMap; | 37 | typedef QMap<QString, QString> AttributeMap; |
35 | 38 | ||
36 | /** | 39 | /** |
37 | * The constructor of XMLElement | 40 | * The constructor of XMLElement |
38 | */ | 41 | */ |
39 | XMLElement(); | 42 | XMLElement(); |
40 | ~XMLElement(); | 43 | ~XMLElement(); |
41 | 44 | ||
42 | /** appendChild appends a child to the XMLElement behind the last element. | 45 | /** appendChild appends a child to the XMLElement behind the last element. |
43 | * The ownership of the child get's transfered to the | 46 | * The ownership of the child get's transfered to the |
44 | * this XMLElement. | 47 | * this XMLElement. |
45 | * If child is already the child of another parent | 48 | * If child is already the child of another parent |
46 | * it's get removed from the other parent first. | 49 | * it's get removed from the other parent first. |
47 | */ | 50 | */ |
48 | void appendChild( XMLElement *child ); | 51 | void appendChild( XMLElement *child ); |
49 | 52 | ||
50 | /** inserts newChild after refChild. If newChild is the child | 53 | /** inserts newChild after refChild. If newChild is the child |
51 | * of another parent the child will get removed. | 54 | * of another parent the child will get removed. |
52 | * The ownership of child gets transfered. | 55 | * The ownership of child gets transfered. |
53 | * | 56 | * |
54 | */ | 57 | */ |
55 | void insertAfter( XMLElement *newChild, XMLElement *refChild ); | 58 | void insertAfter( XMLElement *newChild, XMLElement *refChild ); |
56 | 59 | ||
57 | /** same as insertAfter but the element get's inserted before refChild. | 60 | /** same as insertAfter but the element get's inserted before refChild. |
58 | * | 61 | * |
59 | */ | 62 | */ |
60 | void insertBefore( XMLElement *newChild, XMLElement *refChild ); | 63 | void insertBefore( XMLElement *newChild, XMLElement *refChild ); |
61 | 64 | ||
62 | /** removeChild removes the child from the XMLElement. | 65 | /** removeChild removes the child from the XMLElement. |
63 | * The ownership gets dropped. You need to delete the | 66 | * The ownership gets dropped. You need to delete the |
64 | * child yourself. | 67 | * child yourself. |
65 | */ | 68 | */ |
66 | void removeChild( XMLElement *child ); | 69 | void removeChild( XMLElement *child ); |
67 | 70 | ||
68 | /** parent() returns the parent of this XMLElement | 71 | /** parent() returns the parent of this XMLElement |
69 | * If there is no parent 0l gets returned | 72 | * If there is no parent 0l gets returned |
70 | */ | 73 | */ |
71 | XMLElement *parent() const { return m_parent; } | 74 | XMLElement *parent() const { return m_parent; } |
72 | XMLElement *firstChild() const { return m_first; } | 75 | XMLElement *firstChild() const { return m_first; } |
73 | XMLElement *nextChild() const { return m_next; } | 76 | XMLElement *nextChild() const { return m_next; } |
74 | XMLElement *prevChild() const { return m_prev; } | 77 | XMLElement *prevChild() const { return m_prev; } |
75 | XMLElement *lastChild() const { return m_last; } | 78 | XMLElement *lastChild() const { return m_last; } |
76 | 79 | ||
77 | void setTagName( const QString &tag ) { m_tag = tag; } | 80 | void setTagName( const QString &tag ) { m_tag = tag; } |
78 | QString tagName() const { return m_tag; } | 81 | QString tagName() const { return m_tag; } |
79 | 82 | ||
80 | void setValue( const QString &val ) { m_value = val; } | 83 | void setValue( const QString &val ) { m_value = val; } |
81 | QString value() const { return m_value; } | 84 | QString value() const { return m_value; } |
82 | 85 | ||
83 | void setAttributes( const AttributeMap &attrs ) { m_attributes = attrs; } | 86 | void setAttributes( const AttributeMap &attrs ) { m_attributes = attrs; } |
84 | AttributeMap attributes() const { return m_attributes; } | 87 | AttributeMap attributes() const { return m_attributes; } |
85 | AttributeMap &attributes() { return m_attributes; } | 88 | AttributeMap &attributes() { return m_attributes; } |
86 | 89 | ||
87 | QString attribute( const QString & ) const; | 90 | QString attribute( const QString & ) const; |
88 | void setAttribute( const QString &attr, const QString &value ); | 91 | void setAttribute( const QString &attr, const QString &value ); |
89 | void save( QTextStream &stream, uint indent = 0 ); | 92 | void save( QTextStream &stream, uint indent = 0 ); |
90 | 93 | ||
91 | XMLElement *namedItem( const QString &name ); | 94 | XMLElement *namedItem( const QString &name ); |
92 | 95 | ||
93 | XMLElement *clone() const; | 96 | XMLElement *clone() const; |
94 | 97 | ||
95 | static XMLElement *load( const QString &fileName ); | 98 | static XMLElement *load( const QString &fileName ); |
96 | 99 | ||
97 | private: | 100 | private: |
98 | QString m_tag; | 101 | QString m_tag; |
99 | QString m_value; | 102 | QString m_value; |
100 | AttributeMap m_attributes; | 103 | AttributeMap m_attributes; |
101 | 104 | ||
102 | XMLElement *m_parent; | 105 | XMLElement *m_parent; |
103 | XMLElement *m_next; | 106 | XMLElement *m_next; |
104 | XMLElement *m_prev; | 107 | XMLElement *m_prev; |
105 | XMLElement *m_first; | 108 | XMLElement *m_first; |
106 | XMLElement *m_last; | 109 | XMLElement *m_last; |
107 | 110 | ||
108 | XMLElement( const XMLElement &rhs ); | 111 | XMLElement( const XMLElement &rhs ); |
109 | XMLElement &operator=( const XMLElement &rhs ); | 112 | XMLElement &operator=( const XMLElement &rhs ); |
110 | }; | 113 | }; |
111 | 114 | ||
115 | } // namespace Opie | ||
116 | |||
112 | #endif | 117 | #endif |
diff --git a/libopie2/opiecore/xmltree.cc b/libopie2/opiecore/xmltree.cc index 408e3c6..27db5b3 100644 --- a/libopie2/opiecore/xmltree.cc +++ b/libopie2/opiecore/xmltree.cc | |||
@@ -1,74 +1,75 @@ | |||
1 | /* This file is part of the KDE project | 1 | /* This file is part of the KDE project |
2 | Copyright (C) 2001 Simon Hausmann <hausmann@kde.org> | 2 | Copyright (C) 2001 Simon Hausmann <hausmann@kde.org> |
3 | 3 | ||
4 | This library is free software; you can redistribute it and/or | 4 | This library is free software; you can redistribute it and/or |
5 | modify it under the terms of the GNU Library General Public | 5 | modify it under the terms of the GNU Library General Public |
6 | License as published by the Free Software Foundation; either | 6 | License as published by the Free Software Foundation; either |
7 | version 2 of the License, or (at your option) any later version. | 7 | version 2 of the License, or (at your option) any later version. |
8 | 8 | ||
9 | This library is distributed in the hope that it will be useful, | 9 | This library is distributed in the hope that it will be useful, |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | Library General Public License for more details. | 12 | Library General Public License for more details. |
13 | 13 | ||
14 | You should have received a copy of the GNU Library General Public License | 14 | You should have received a copy of the GNU Library General Public License |
15 | along with this library; see the file COPYING.LIB. If not, write to | 15 | along with this library; see the file COPYING.LIB. If not, write to |
16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
17 | Boston, MA 02111-1307, USA. | 17 | Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <qpe/stringutil.h> | 20 | #include <qpe/stringutil.h> |
21 | #include <opie/xmltree.h> | 21 | #include <opie/xmltree.h> |
22 | 22 | ||
23 | #include <qxml.h> | 23 | #include <qxml.h> |
24 | 24 | ||
25 | #include <assert.h> | 25 | #include <assert.h> |
26 | 26 | ||
27 | using namespace Opie; | ||
27 | 28 | ||
28 | XMLElement::XMLElement() | 29 | XMLElement::XMLElement() |
29 | : m_parent( 0 ), m_next( 0 ), m_prev( 0 ), m_first( 0 ), m_last( 0 ) | 30 | : m_parent( 0 ), m_next( 0 ), m_prev( 0 ), m_first( 0 ), m_last( 0 ) |
30 | { | 31 | { |
31 | } | 32 | } |
32 | 33 | ||
33 | XMLElement::~XMLElement() | 34 | XMLElement::~XMLElement() |
34 | { | 35 | { |
35 | XMLElement *n = m_first; | 36 | XMLElement *n = m_first; |
36 | 37 | ||
37 | while ( n ) | 38 | while ( n ) |
38 | { | 39 | { |
39 | XMLElement *tmp = n; | 40 | XMLElement *tmp = n; |
40 | n = n->m_next; | 41 | n = n->m_next; |
41 | delete tmp; | 42 | delete tmp; |
42 | } | 43 | } |
43 | } | 44 | } |
44 | 45 | ||
45 | void XMLElement::appendChild( XMLElement *child ) | 46 | void XMLElement::appendChild( XMLElement *child ) |
46 | { | 47 | { |
47 | if ( child->m_parent ) | 48 | if ( child->m_parent ) |
48 | child->m_parent->removeChild( child ); | 49 | child->m_parent->removeChild( child ); |
49 | 50 | ||
50 | child->m_parent = this; | 51 | child->m_parent = this; |
51 | 52 | ||
52 | if ( m_last ) | 53 | if ( m_last ) |
53 | m_last->m_next = child; | 54 | m_last->m_next = child; |
54 | 55 | ||
55 | child->m_prev = m_last; | 56 | child->m_prev = m_last; |
56 | 57 | ||
57 | if ( !m_first ) | 58 | if ( !m_first ) |
58 | m_first = child; | 59 | m_first = child; |
59 | 60 | ||
60 | m_last = child; | 61 | m_last = child; |
61 | } | 62 | } |
62 | 63 | ||
63 | void XMLElement::insertAfter( XMLElement *newChild, XMLElement *refChild ) | 64 | void XMLElement::insertAfter( XMLElement *newChild, XMLElement *refChild ) |
64 | { | 65 | { |
65 | assert( newChild != refChild ); | 66 | assert( newChild != refChild ); |
66 | 67 | ||
67 | if ( refChild == m_last ) | 68 | if ( refChild == m_last ) |
68 | { | 69 | { |
69 | appendChild( newChild ); | 70 | appendChild( newChild ); |
70 | return; | 71 | return; |
71 | } | 72 | } |
72 | 73 | ||
73 | assert( refChild ); | 74 | assert( refChild ); |
74 | assert( refChild->m_parent ); | 75 | assert( refChild->m_parent ); |
diff --git a/libopie2/opiecore/xmltree.h b/libopie2/opiecore/xmltree.h index ed93c23..4a6b6d9 100644 --- a/libopie2/opiecore/xmltree.h +++ b/libopie2/opiecore/xmltree.h | |||
@@ -1,112 +1,117 @@ | |||
1 | /* This file is part of the KDE project | 1 | /* This file is part of the KDE project |
2 | Copyright (C) 2000,2001 Simon Hausmann <hausmann@kde.org> | 2 | Copyright (C) 2000,2001 Simon Hausmann <hausmann@kde.org> |
3 | 3 | ||
4 | This library is free software; you can redistribute it and/or | 4 | This library is free software; you can redistribute it and/or |
5 | modify it under the terms of the GNU Library General Public | 5 | modify it under the terms of the GNU Library General Public |
6 | License as published by the Free Software Foundation; either | 6 | License as published by the Free Software Foundation; either |
7 | version 2 of the License, or (at your option) any later version. | 7 | version 2 of the License, or (at your option) any later version. |
8 | 8 | ||
9 | This library is distributed in the hope that it will be useful, | 9 | This library is distributed in the hope that it will be useful, |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | Library General Public License for more details. | 12 | Library General Public License for more details. |
13 | 13 | ||
14 | You should have received a copy of the GNU Library General Public License | 14 | You should have received a copy of the GNU Library General Public License |
15 | along with this library; see the file COPYING.LIB. If not, write to | 15 | along with this library; see the file COPYING.LIB. If not, write to |
16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
17 | Boston, MA 02111-1307, USA. | 17 | Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | 20 | ||
21 | #ifndef __bookmarks_h__ | 21 | #ifndef __bookmarks_h__ |
22 | #define __bookmarks_h__ | 22 | #define __bookmarks_h__ |
23 | 23 | ||
24 | #include <qstring.h> | 24 | #include <qstring.h> |
25 | #include <qmap.h> | 25 | #include <qmap.h> |
26 | #include <qtextstream.h> | 26 | #include <qtextstream.h> |
27 | 27 | ||
28 | namespace Opie | ||
29 | { | ||
30 | |||
28 | /** | 31 | /** |
29 | * A small xml lib written by Simon Hausmann. | 32 | * A small xml lib written by Simon Hausmann. |
30 | */ | 33 | */ |
31 | class XMLElement | 34 | class XMLElement |
32 | { | 35 | { |
33 | public: | 36 | public: |
34 | typedef QMap<QString, QString> AttributeMap; | 37 | typedef QMap<QString, QString> AttributeMap; |
35 | 38 | ||
36 | /** | 39 | /** |
37 | * The constructor of XMLElement | 40 | * The constructor of XMLElement |
38 | */ | 41 | */ |
39 | XMLElement(); | 42 | XMLElement(); |
40 | ~XMLElement(); | 43 | ~XMLElement(); |
41 | 44 | ||
42 | /** appendChild appends a child to the XMLElement behind the last element. | 45 | /** appendChild appends a child to the XMLElement behind the last element. |
43 | * The ownership of the child get's transfered to the | 46 | * The ownership of the child get's transfered to the |
44 | * this XMLElement. | 47 | * this XMLElement. |
45 | * If child is already the child of another parent | 48 | * If child is already the child of another parent |
46 | * it's get removed from the other parent first. | 49 | * it's get removed from the other parent first. |
47 | */ | 50 | */ |
48 | void appendChild( XMLElement *child ); | 51 | void appendChild( XMLElement *child ); |
49 | 52 | ||
50 | /** inserts newChild after refChild. If newChild is the child | 53 | /** inserts newChild after refChild. If newChild is the child |
51 | * of another parent the child will get removed. | 54 | * of another parent the child will get removed. |
52 | * The ownership of child gets transfered. | 55 | * The ownership of child gets transfered. |
53 | * | 56 | * |
54 | */ | 57 | */ |
55 | void insertAfter( XMLElement *newChild, XMLElement *refChild ); | 58 | void insertAfter( XMLElement *newChild, XMLElement *refChild ); |
56 | 59 | ||
57 | /** same as insertAfter but the element get's inserted before refChild. | 60 | /** same as insertAfter but the element get's inserted before refChild. |
58 | * | 61 | * |
59 | */ | 62 | */ |
60 | void insertBefore( XMLElement *newChild, XMLElement *refChild ); | 63 | void insertBefore( XMLElement *newChild, XMLElement *refChild ); |
61 | 64 | ||
62 | /** removeChild removes the child from the XMLElement. | 65 | /** removeChild removes the child from the XMLElement. |
63 | * The ownership gets dropped. You need to delete the | 66 | * The ownership gets dropped. You need to delete the |
64 | * child yourself. | 67 | * child yourself. |
65 | */ | 68 | */ |
66 | void removeChild( XMLElement *child ); | 69 | void removeChild( XMLElement *child ); |
67 | 70 | ||
68 | /** parent() returns the parent of this XMLElement | 71 | /** parent() returns the parent of this XMLElement |
69 | * If there is no parent 0l gets returned | 72 | * If there is no parent 0l gets returned |
70 | */ | 73 | */ |
71 | XMLElement *parent() const { return m_parent; } | 74 | XMLElement *parent() const { return m_parent; } |
72 | XMLElement *firstChild() const { return m_first; } | 75 | XMLElement *firstChild() const { return m_first; } |
73 | XMLElement *nextChild() const { return m_next; } | 76 | XMLElement *nextChild() const { return m_next; } |
74 | XMLElement *prevChild() const { return m_prev; } | 77 | XMLElement *prevChild() const { return m_prev; } |
75 | XMLElement *lastChild() const { return m_last; } | 78 | XMLElement *lastChild() const { return m_last; } |
76 | 79 | ||
77 | void setTagName( const QString &tag ) { m_tag = tag; } | 80 | void setTagName( const QString &tag ) { m_tag = tag; } |
78 | QString tagName() const { return m_tag; } | 81 | QString tagName() const { return m_tag; } |
79 | 82 | ||
80 | void setValue( const QString &val ) { m_value = val; } | 83 | void setValue( const QString &val ) { m_value = val; } |
81 | QString value() const { return m_value; } | 84 | QString value() const { return m_value; } |
82 | 85 | ||
83 | void setAttributes( const AttributeMap &attrs ) { m_attributes = attrs; } | 86 | void setAttributes( const AttributeMap &attrs ) { m_attributes = attrs; } |
84 | AttributeMap attributes() const { return m_attributes; } | 87 | AttributeMap attributes() const { return m_attributes; } |
85 | AttributeMap &attributes() { return m_attributes; } | 88 | AttributeMap &attributes() { return m_attributes; } |
86 | 89 | ||
87 | QString attribute( const QString & ) const; | 90 | QString attribute( const QString & ) const; |
88 | void setAttribute( const QString &attr, const QString &value ); | 91 | void setAttribute( const QString &attr, const QString &value ); |
89 | void save( QTextStream &stream, uint indent = 0 ); | 92 | void save( QTextStream &stream, uint indent = 0 ); |
90 | 93 | ||
91 | XMLElement *namedItem( const QString &name ); | 94 | XMLElement *namedItem( const QString &name ); |
92 | 95 | ||
93 | XMLElement *clone() const; | 96 | XMLElement *clone() const; |
94 | 97 | ||
95 | static XMLElement *load( const QString &fileName ); | 98 | static XMLElement *load( const QString &fileName ); |
96 | 99 | ||
97 | private: | 100 | private: |
98 | QString m_tag; | 101 | QString m_tag; |
99 | QString m_value; | 102 | QString m_value; |
100 | AttributeMap m_attributes; | 103 | AttributeMap m_attributes; |
101 | 104 | ||
102 | XMLElement *m_parent; | 105 | XMLElement *m_parent; |
103 | XMLElement *m_next; | 106 | XMLElement *m_next; |
104 | XMLElement *m_prev; | 107 | XMLElement *m_prev; |
105 | XMLElement *m_first; | 108 | XMLElement *m_first; |
106 | XMLElement *m_last; | 109 | XMLElement *m_last; |
107 | 110 | ||
108 | XMLElement( const XMLElement &rhs ); | 111 | XMLElement( const XMLElement &rhs ); |
109 | XMLElement &operator=( const XMLElement &rhs ); | 112 | XMLElement &operator=( const XMLElement &rhs ); |
110 | }; | 113 | }; |
111 | 114 | ||
115 | } // namespace Opie | ||
116 | |||
112 | #endif | 117 | #endif |