BuildLogViewer/DomModel.cpp
author John Kern <johnk@symbian.org>
Fri, 28 Aug 2009 15:16:29 -0700
changeset 0 bbe0af256f1b
child 1 8e9c5760ce6f
permissions -rwxr-xr-x
here is a demo which reads and displays xml.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 <QtGui>
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
    43
 #include <QtXml>
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
    44
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
    45
 #include "domitem.h"
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
    46
 #include "dommodel.h"
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
 DomModel::DomModel(QDomDocument document, QObject *parent)
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
    49
     : QAbstractItemModel(parent), domDocument(document)
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
    50
 {
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
    51
     rootItem = new DomItem(domDocument, 0);
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
 DomModel::~DomModel()
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
     delete rootItem;
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
    57
 }
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
    58
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
    59
 int DomModel::columnCount(const QModelIndex &/*parent*/) const
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
     return 3;
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
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
    64
 QVariant DomModel::data(const QModelIndex &index, int role) const
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
     if (!index.isValid())
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
    67
         return QVariant();
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
    68
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
    69
     if (role != Qt::DisplayRole)
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
    70
         return QVariant();
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
    71
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
    72
     DomItem *item = static_cast<DomItem*>(index.internalPointer());
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
    73
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
    74
     QDomNode node = item->node();
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
    75
     QStringList attributes;
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
    76
     QDomNamedNodeMap attributeMap = node.attributes();
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
    77
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
    78
     switch (index.column()) {
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
    79
         case 0:
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
    80
             return node.nodeName();
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
    81
         case 1:
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
    82
             for (int i = 0; i < attributeMap.count(); ++i) {
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
    83
                 QDomNode attribute = attributeMap.item(i);
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
    84
                 attributes << attribute.nodeName() + "=\""
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
    85
                               +attribute.nodeValue() + "\"";
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 attributes.join(" ");
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
    88
         case 2:
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
    89
             return node.nodeValue().split("\n").join(" ");
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
    90
         default:
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
    91
             return QVariant();
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
    92
     }
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
    93
 }
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
    94
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
    95
 Qt::ItemFlags DomModel::flags(const QModelIndex &index) const
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
    96
 {
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
    97
     if (!index.isValid())
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
    98
         return 0;
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
    99
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   100
     return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   101
 }
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   102
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   103
 QVariant DomModel::headerData(int section, Qt::Orientation orientation,
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   104
                               int role) const
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   105
 {
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   106
     if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   107
         switch (section) {
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   108
             case 0:
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   109
                 return tr("Name");
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   110
             case 1:
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   111
                 return tr("Attributes");
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   112
             case 2:
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   113
                 return tr("Value");
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   114
             default:
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   115
                 return QVariant();
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   116
         }
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   117
     }
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   118
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   119
     return QVariant();
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   120
 }
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   121
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   122
 QModelIndex DomModel::index(int row, int column, const QModelIndex &parent)
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   123
             const
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   124
 {
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   125
     if (!hasIndex(row, column, parent))
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   126
         return QModelIndex();
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   127
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   128
     DomItem *parentItem;
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   129
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   130
     if (!parent.isValid())
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   131
         parentItem = rootItem;
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   132
     else
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   133
         parentItem = static_cast<DomItem*>(parent.internalPointer());
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   134
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   135
     DomItem *childItem = parentItem->child(row);
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   136
     if (childItem)
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   137
         return createIndex(row, column, childItem);
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   138
     else
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   139
         return QModelIndex();
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   140
 }
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   141
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   142
 QModelIndex DomModel::parent(const QModelIndex &child) const
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   143
 {
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   144
     if (!child.isValid())
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   145
         return QModelIndex();
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   146
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   147
     DomItem *childItem = static_cast<DomItem*>(child.internalPointer());
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   148
     DomItem *parentItem = childItem->parent();
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   149
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   150
     if (!parentItem || parentItem == rootItem)
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   151
         return QModelIndex();
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   152
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   153
     return createIndex(parentItem->row(), 0, parentItem);
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   154
 }
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   155
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   156
 int DomModel::rowCount(const QModelIndex &parent) const
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   157
 {
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   158
     if (parent.column() > 0)
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   159
         return 0;
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   160
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   161
     DomItem *parentItem;
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   162
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   163
     if (!parent.isValid())
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   164
         parentItem = rootItem;
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   165
     else
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   166
         parentItem = static_cast<DomItem*>(parent.internalPointer());
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   167
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   168
     return parentItem->node().childNodes().count();
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   169
 }