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 | #ifndef TestSimpleNodeModel_h |
31 | #define TestSimpleNodeModel_h |
32 | |
33 | #include <QtXmlPatterns/QSimpleXmlNodeModel> |
34 | #include <QtXmlPatterns/QXmlNamePool> |
35 | |
36 | class TestSimpleNodeModel : public QSimpleXmlNodeModel |
37 | { |
38 | public: |
39 | |
40 | TestSimpleNodeModel(const QXmlNamePool &np); |
41 | |
42 | QXmlNodeModelIndex root() const; |
43 | |
44 | /*! |
45 | This function is made public, such that we can test its const qualification. |
46 | */ |
47 | virtual QXmlNodeModelIndex nextFromSimpleAxis(SimpleAxis axis, |
48 | const QXmlNodeModelIndex &origin) const; |
49 | |
50 | /*! |
51 | This function is made public, such that we can test its const qualification. |
52 | */ |
53 | virtual QVector<QXmlNodeModelIndex> attributes(const QXmlNodeModelIndex&) const; |
54 | |
55 | virtual QUrl documentUri(const QXmlNodeModelIndex&) const; |
56 | virtual QXmlNodeModelIndex::NodeKind kind(const QXmlNodeModelIndex&) const; |
57 | virtual QXmlNodeModelIndex::DocumentOrder compareOrder(const QXmlNodeModelIndex&, |
58 | const QXmlNodeModelIndex&) const; |
59 | virtual QXmlNodeModelIndex root(const QXmlNodeModelIndex&) const; |
60 | virtual QXmlName name(const QXmlNodeModelIndex&) const; |
61 | virtual QVariant typedValue(const QXmlNodeModelIndex&) const; |
62 | }; |
63 | |
64 | TestSimpleNodeModel::TestSimpleNodeModel(const QXmlNamePool &np) : QSimpleXmlNodeModel(np) |
65 | { |
66 | |
67 | /* If this fails to compile, QSimpleXmlNodeModel::namePool() |
68 | * does not return a mutable reference. */ |
69 | QXmlName(namePool(), QLatin1String("name" )); |
70 | } |
71 | |
72 | QXmlNodeModelIndex TestSimpleNodeModel::root() const |
73 | { |
74 | return createIndex(data: qint64(0), additionalData: 1); |
75 | } |
76 | |
77 | QXmlNodeModelIndex TestSimpleNodeModel::nextFromSimpleAxis(SimpleAxis, const QXmlNodeModelIndex &) const |
78 | { |
79 | return QXmlNodeModelIndex(); |
80 | } |
81 | |
82 | QVector<QXmlNodeModelIndex> TestSimpleNodeModel::attributes(const QXmlNodeModelIndex&) const |
83 | { |
84 | return QVector<QXmlNodeModelIndex>(); |
85 | } |
86 | |
87 | QUrl TestSimpleNodeModel::documentUri(const QXmlNodeModelIndex &) const |
88 | { |
89 | return QUrl(); |
90 | } |
91 | |
92 | QXmlNodeModelIndex::NodeKind TestSimpleNodeModel::kind(const QXmlNodeModelIndex &) const |
93 | { |
94 | return QXmlNodeModelIndex::Element; |
95 | } |
96 | |
97 | QXmlNodeModelIndex::DocumentOrder TestSimpleNodeModel::compareOrder(const QXmlNodeModelIndex &, |
98 | const QXmlNodeModelIndex &) const |
99 | { |
100 | return QXmlNodeModelIndex::Precedes; |
101 | } |
102 | |
103 | QXmlNodeModelIndex TestSimpleNodeModel::root(const QXmlNodeModelIndex &) const |
104 | { |
105 | return QXmlNodeModelIndex(); |
106 | } |
107 | |
108 | QXmlName TestSimpleNodeModel::name(const QXmlNodeModelIndex &) const |
109 | { |
110 | QXmlNamePool np(namePool()); |
111 | return QXmlName(np, QLatin1String("nodeName" )); |
112 | } |
113 | |
114 | QVariant TestSimpleNodeModel::typedValue(const QXmlNodeModelIndex&) const |
115 | { |
116 | return QVariant(); |
117 | } |
118 | |
119 | #endif |
120 | |