BuildLogViewer/DomModel.cpp
author John Kern <johnk@symbian.org>
Thu, 26 Aug 2010 14:34:34 -0700
changeset 40 edc0144719a1
parent 1 8e9c5760ce6f
permissions -rwxr-xr-x
removed invariant from data() and rowCount(). Performance should be ok now.
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
1
8e9c5760ce6f working on a status view
John Kern <johnk@symbian.org>
parents: 0
diff changeset
    48
 DomModel::DomModel(QDomDocument *document, QObject *parent)
0
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
 {
1
8e9c5760ce6f working on a status view
John Kern <johnk@symbian.org>
parents: 0
diff changeset
    51
     rootItem = new DomItem(*domDocument, 0);
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;
1
8e9c5760ce6f working on a status view
John Kern <johnk@symbian.org>
parents: 0
diff changeset
    57
     delete this->domDocument;
0
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
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
    60
 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
    61
 {
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
    62
     return 3;
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
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
    65
 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
    66
 {
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
    67
     if (!index.isValid())
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
    68
         return QVariant();
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
     if (role != Qt::DisplayRole)
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
    71
         return QVariant();
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
     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
    74
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
    75
     QDomNode node = item->node();
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
    76
     QStringList attributes;
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
    77
     QDomNamedNodeMap attributeMap = node.attributes();
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
    78
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
    79
     switch (index.column()) {
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
    80
         case 0:
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
    81
             return node.nodeName();
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
    82
         case 1:
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
    83
             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
    84
                 QDomNode attribute = attributeMap.item(i);
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
    85
                 attributes << attribute.nodeName() + "=\""
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
    86
                               +attribute.nodeValue() + "\"";
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
    87
             }
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
    88
             return attributes.join(" ");
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
    89
         case 2:
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
    90
             return node.nodeValue().split("\n").join(" ");
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
    91
         default:
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
    92
             return QVariant();
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
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
    96
 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
    97
 {
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
    98
     if (!index.isValid())
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
    99
         return 0;
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   100
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   101
     return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
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
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   104
 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
   105
                               int role) const
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   106
 {
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   107
     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
   108
         switch (section) {
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   109
             case 0:
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   110
                 return tr("Name");
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   111
             case 1:
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   112
                 return tr("Attributes");
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   113
             case 2:
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   114
                 return tr("Value");
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   115
             default:
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   116
                 return QVariant();
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
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   120
     return QVariant();
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
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   123
 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
   124
             const
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   125
 {
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   126
     if (!hasIndex(row, column, parent))
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   127
         return QModelIndex();
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   128
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   129
     DomItem *parentItem;
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   130
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   131
     if (!parent.isValid())
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   132
         parentItem = rootItem;
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   133
     else
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   134
         parentItem = static_cast<DomItem*>(parent.internalPointer());
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   135
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   136
     DomItem *childItem = parentItem->child(row);
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   137
     if (childItem)
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   138
         return createIndex(row, column, childItem);
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   139
     else
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   140
         return QModelIndex();
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
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   143
 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
   144
 {
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   145
     if (!child.isValid())
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   146
         return QModelIndex();
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   147
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   148
     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
   149
     DomItem *parentItem = childItem->parent();
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   150
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   151
     if (!parentItem || parentItem == rootItem)
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   152
         return QModelIndex();
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   153
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   154
     return createIndex(parentItem->row(), 0, parentItem);
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
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   157
 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
   158
 {
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   159
     if (parent.column() > 0)
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   160
         return 0;
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   161
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   162
     DomItem *parentItem;
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   163
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   164
     if (!parent.isValid())
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   165
         parentItem = rootItem;
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   166
     else
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   167
         parentItem = static_cast<DomItem*>(parent.internalPointer());
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   168
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   169
     return parentItem->node().childNodes().count();
bbe0af256f1b here is a demo which reads and displays xml.
John Kern <johnk@symbian.org>
parents:
diff changeset
   170
 }