author | John Kern <johnk@symbian.org> |
Thu, 12 Aug 2010 17:06:22 -0700 | |
changeset 26 | d9f0df25b6a3 |
parent 0 | bbe0af256f1b |
permissions | -rwxr-xr-x |
0
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
1 |
/**************************************************************************** |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
2 |
** |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
3 |
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
4 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
5 |
** |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
6 |
** This file is part of the examples of the Qt Toolkit. |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
7 |
** |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
8 |
** $QT_BEGIN_LICENSE:LGPL$ |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
9 |
** Commercial Usage |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
10 |
** Licensees holding valid Qt Commercial licenses may use this file in |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
11 |
** accordance with the Qt Commercial License Agreement provided with the |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
12 |
** Software or, alternatively, in accordance with the terms contained in |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
13 |
** a written agreement between you and Nokia. |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
14 |
** |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
15 |
** GNU Lesser General Public License Usage |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
16 |
** Alternatively, this file may be used under the terms of the GNU Lesser |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
17 |
** General Public License version 2.1 as published by the Free Software |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
18 |
** Foundation and appearing in the file LICENSE.LGPL included in the |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
19 |
** packaging of this file. Please review the following information to |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
20 |
** ensure the GNU Lesser General Public License version 2.1 requirements |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
21 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
22 |
** |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
23 |
** In addition, as a special exception, Nokia gives you certain |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
24 |
** additional rights. These rights are described in the Nokia Qt LGPL |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
25 |
** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
26 |
** package. |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
27 |
** |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
28 |
** GNU General Public License Usage |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
29 |
** Alternatively, this file may be used under the terms of the GNU |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
30 |
** General Public License version 3.0 as published by the Free Software |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
31 |
** Foundation and appearing in the file LICENSE.GPL included in the |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
32 |
** packaging of this file. Please review the following information to |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
33 |
** ensure the GNU General Public License version 3.0 requirements will be |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
34 |
** met: http://www.gnu.org/copyleft/gpl.html. |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
35 |
** |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
36 |
** If you are unsure which license is appropriate for your use, please |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
37 |
** contact the sales department at http://www.qtsoftware.com/contact. |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
38 |
** $QT_END_LICENSE$ |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
39 |
** |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
40 |
****************************************************************************/ |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
41 |
|
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
42 |
#include <QtXml> |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
43 |
|
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
44 |
#include "domitem.h" |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
45 |
|
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
46 |
DomItem::DomItem(QDomNode &node, int row, DomItem *parent) |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
47 |
{ |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
48 |
domNode = node; |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
49 |
// Record the item's location within its parent. |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
50 |
rowNumber = row; |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
51 |
parentItem = parent; |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
52 |
} |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
53 |
|
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
54 |
DomItem::~DomItem() |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
55 |
{ |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
56 |
QHash<int,DomItem*>::iterator it; |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
57 |
for (it = childItems.begin(); it != childItems.end(); ++it) |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
58 |
delete it.value(); |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
59 |
} |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
60 |
|
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
61 |
QDomNode DomItem::node() const |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
62 |
{ |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
63 |
return domNode; |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
64 |
} |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
65 |
|
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
66 |
DomItem *DomItem::parent() |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
67 |
{ |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
68 |
return parentItem; |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
69 |
} |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
70 |
|
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
71 |
DomItem *DomItem::child(int i) |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
72 |
{ |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
73 |
if (childItems.contains(i)) |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
74 |
return childItems[i]; |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
75 |
|
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
76 |
if (i >= 0 && i < domNode.childNodes().count()) { |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
77 |
QDomNode childNode = domNode.childNodes().item(i); |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
78 |
DomItem *childItem = new DomItem(childNode, i, this); |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
79 |
childItems[i] = childItem; |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
80 |
return childItem; |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
81 |
} |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
82 |
return 0; |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
83 |
} |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
84 |
|
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
85 |
int DomItem::row() |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
86 |
{ |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
87 |
return rowNumber; |
bbe0af256f1b
here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
88 |
} |