1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the test suite of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:GPL-EXCEPT$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU
19** General Public License version 3 as published by the Free Software
20** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
21** included in the packaging of this file. Please review the following
22** information to ensure the GNU General Public License requirements will
23** be met: https://www.gnu.org/licenses/gpl-3.0.html.
24**
25** $QT_END_LICENSE$
26**
27****************************************************************************/
28
29
30#include <QSimpleXmlNodeModel>
31#include <QVector>
32
33class LoadingModel : public QSimpleXmlNodeModel
34{
35public:
36 virtual ~LoadingModel();
37 static QAbstractXmlNodeModel::Ptr create(const QXmlNamePool &np);
38
39 virtual QUrl documentUri(const QXmlNodeModelIndex &) const;
40 virtual QXmlNodeModelIndex::NodeKind kind(const QXmlNodeModelIndex &) const;
41 virtual QXmlNodeModelIndex::DocumentOrder compareOrder(const QXmlNodeModelIndex &, const QXmlNodeModelIndex&) const;
42 virtual QXmlNodeModelIndex root(const QXmlNodeModelIndex &) const;
43 virtual QXmlName name(const QXmlNodeModelIndex &) const;
44 virtual QVariant typedValue(const QXmlNodeModelIndex &) const;
45 virtual QString stringValue(const QXmlNodeModelIndex &) const;
46 virtual QXmlNodeModelIndex nextFromSimpleAxis(QAbstractXmlNodeModel::SimpleAxis, const QXmlNodeModelIndex &) const;
47 virtual QVector<QXmlNodeModelIndex> attributes(const QXmlNodeModelIndex &) const;
48
49private:
50 friend class Loader;
51 class Node
52 {
53 public:
54 inline Node(const QXmlNodeModelIndex::NodeKind k,
55 const Node *const p,
56 const QString &v = QString(),
57 const QXmlName &n = QXmlName()) : kind(k)
58 , value(v)
59 , parent(p)
60 , precedingSibling(0)
61 , followingSibling(0)
62 , firstChild(0)
63 , name(n)
64 {
65 }
66
67 typedef QVector<const Node *> Vector;
68 QXmlNodeModelIndex::NodeKind kind;
69 QString value;
70 const Node * parent;
71 const Node * precedingSibling;
72 const Node * followingSibling;
73 const Node * firstChild;
74 Node::Vector attributes;
75 QXmlName name;
76 };
77
78 inline const Node *toInternal(const QXmlNodeModelIndex &ni) const;
79 inline QXmlNodeModelIndex createIndex(const Node *const internal) const;
80
81 LoadingModel(const Node::Vector &content,
82 const QXmlNamePool &np);
83
84 Node::Vector m_nodes;
85};
86
87

source code of qtxmlpatterns/tests/auto/qabstractxmlnodemodel/LoadingModel.h