| 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 QtXmlPatterns module of the Qt Toolkit. |
| 7 | ** |
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ |
| 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 Lesser General Public License Usage |
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
| 19 | ** General Public License version 3 as published by the Free Software |
| 20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the |
| 21 | ** packaging of this file. Please review the following information to |
| 22 | ** ensure the GNU Lesser General Public License version 3 requirements |
| 23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. |
| 24 | ** |
| 25 | ** GNU General Public License Usage |
| 26 | ** Alternatively, this file may be used under the terms of the GNU |
| 27 | ** General Public License version 2.0 or (at your option) the GNU General |
| 28 | ** Public license version 3 or any later version approved by the KDE Free |
| 29 | ** Qt Foundation. The licenses are as published by the Free Software |
| 30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 |
| 31 | ** included in the packaging of this file. Please review the following |
| 32 | ** information to ensure the GNU General Public License requirements will |
| 33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and |
| 34 | ** https://www.gnu.org/licenses/gpl-3.0.html. |
| 35 | ** |
| 36 | ** $QT_END_LICENSE$ |
| 37 | ** |
| 38 | ****************************************************************************/ |
| 39 | |
| 40 | #include "qxsdvalidatedxmlnodemodel_p.h" |
| 41 | |
| 42 | #include <QtCore/QUrl> |
| 43 | #include <QtCore/QVariant> |
| 44 | #include <QtCore/QVector> |
| 45 | |
| 46 | QT_BEGIN_NAMESPACE |
| 47 | |
| 48 | using namespace QPatternist; |
| 49 | |
| 50 | XsdValidatedXmlNodeModel::XsdValidatedXmlNodeModel(const QAbstractXmlNodeModel *model) |
| 51 | : m_internalModel(model) |
| 52 | { |
| 53 | } |
| 54 | |
| 55 | XsdValidatedXmlNodeModel::~XsdValidatedXmlNodeModel() |
| 56 | { |
| 57 | } |
| 58 | |
| 59 | QUrl XsdValidatedXmlNodeModel::baseUri(const QXmlNodeModelIndex &index) const |
| 60 | { |
| 61 | return m_internalModel->baseUri(ni: index); |
| 62 | } |
| 63 | |
| 64 | QUrl XsdValidatedXmlNodeModel::documentUri(const QXmlNodeModelIndex &index) const |
| 65 | { |
| 66 | return m_internalModel->documentUri(ni: index); |
| 67 | } |
| 68 | |
| 69 | QXmlNodeModelIndex::NodeKind XsdValidatedXmlNodeModel::kind(const QXmlNodeModelIndex &index) const |
| 70 | { |
| 71 | return m_internalModel->kind(ni: index); |
| 72 | } |
| 73 | |
| 74 | QXmlNodeModelIndex::DocumentOrder XsdValidatedXmlNodeModel::compareOrder(const QXmlNodeModelIndex &index, const QXmlNodeModelIndex &otherIndex) const |
| 75 | { |
| 76 | return m_internalModel->compareOrder(ni1: index, ni2: otherIndex); |
| 77 | } |
| 78 | |
| 79 | QXmlNodeModelIndex XsdValidatedXmlNodeModel::root(const QXmlNodeModelIndex &index) const |
| 80 | { |
| 81 | return m_internalModel->root(n: index); |
| 82 | } |
| 83 | |
| 84 | QXmlName XsdValidatedXmlNodeModel::name(const QXmlNodeModelIndex &index) const |
| 85 | { |
| 86 | return m_internalModel->name(ni: index); |
| 87 | } |
| 88 | |
| 89 | QString XsdValidatedXmlNodeModel::stringValue(const QXmlNodeModelIndex &index) const |
| 90 | { |
| 91 | return m_internalModel->stringValue(n: index); |
| 92 | } |
| 93 | |
| 94 | QVariant XsdValidatedXmlNodeModel::typedValue(const QXmlNodeModelIndex &index) const |
| 95 | { |
| 96 | return m_internalModel->typedValue(n: index); |
| 97 | } |
| 98 | |
| 99 | QExplicitlySharedDataPointer<QAbstractXmlForwardIterator<QXmlNodeModelIndex> > XsdValidatedXmlNodeModel::iterate(const QXmlNodeModelIndex &index, QXmlNodeModelIndex::Axis axis) const |
| 100 | { |
| 101 | return m_internalModel->iterate(ni: index, axis); |
| 102 | } |
| 103 | |
| 104 | QPatternist::ItemIteratorPtr XsdValidatedXmlNodeModel::sequencedTypedValue(const QXmlNodeModelIndex &index) const |
| 105 | { |
| 106 | return m_internalModel->sequencedTypedValue(ni: index); |
| 107 | } |
| 108 | |
| 109 | QPatternist::ItemTypePtr XsdValidatedXmlNodeModel::type(const QXmlNodeModelIndex &index) const |
| 110 | { |
| 111 | return m_internalModel->type(ni: index); |
| 112 | } |
| 113 | |
| 114 | QXmlName::NamespaceCode XsdValidatedXmlNodeModel::namespaceForPrefix(const QXmlNodeModelIndex &index, const QXmlName::PrefixCode prefix) const |
| 115 | { |
| 116 | return m_internalModel->namespaceForPrefix(ni: index, prefix); |
| 117 | } |
| 118 | |
| 119 | bool XsdValidatedXmlNodeModel::isDeepEqual(const QXmlNodeModelIndex &index, const QXmlNodeModelIndex &otherIndex) const |
| 120 | { |
| 121 | return m_internalModel->isDeepEqual(ni1: index, ni2: otherIndex); |
| 122 | } |
| 123 | |
| 124 | void XsdValidatedXmlNodeModel::sendNamespaces(const QXmlNodeModelIndex &index, QAbstractXmlReceiver *const receiver) const |
| 125 | { |
| 126 | m_internalModel->sendNamespaces(n: index, receiver); |
| 127 | } |
| 128 | |
| 129 | QVector<QXmlName> XsdValidatedXmlNodeModel::namespaceBindings(const QXmlNodeModelIndex &index) const |
| 130 | { |
| 131 | return m_internalModel->namespaceBindings(n: index); |
| 132 | } |
| 133 | |
| 134 | QXmlNodeModelIndex XsdValidatedXmlNodeModel::elementById(const QXmlName &name) const |
| 135 | { |
| 136 | return m_internalModel->elementById(NCName: name); |
| 137 | } |
| 138 | |
| 139 | QVector<QXmlNodeModelIndex> XsdValidatedXmlNodeModel::nodesByIdref(const QXmlName &name) const |
| 140 | { |
| 141 | return m_internalModel->nodesByIdref(NCName: name); |
| 142 | } |
| 143 | |
| 144 | void XsdValidatedXmlNodeModel::copyNodeTo(const QXmlNodeModelIndex &index, QAbstractXmlReceiver *const receiver, const NodeCopySettings &settings) const |
| 145 | { |
| 146 | return m_internalModel->copyNodeTo(node: index, receiver, settings); |
| 147 | } |
| 148 | |
| 149 | QXmlNodeModelIndex XsdValidatedXmlNodeModel::nextFromSimpleAxis(SimpleAxis axis, const QXmlNodeModelIndex &origin) const |
| 150 | { |
| 151 | return m_internalModel->nextFromSimpleAxis(axis, origin); |
| 152 | } |
| 153 | |
| 154 | QVector<QXmlNodeModelIndex> XsdValidatedXmlNodeModel::attributes(const QXmlNodeModelIndex &index) const |
| 155 | { |
| 156 | return m_internalModel->attributes(element: index); |
| 157 | } |
| 158 | |
| 159 | void XsdValidatedXmlNodeModel::setAssignedElement(const QXmlNodeModelIndex &index, const XsdElement::Ptr &element) |
| 160 | { |
| 161 | m_assignedElements.insert(akey: index, avalue: element); |
| 162 | } |
| 163 | |
| 164 | XsdElement::Ptr XsdValidatedXmlNodeModel::assignedElement(const QXmlNodeModelIndex &index) const |
| 165 | { |
| 166 | if (m_assignedElements.contains(akey: index)) |
| 167 | return m_assignedElements.value(akey: index); |
| 168 | else |
| 169 | return XsdElement::Ptr(); |
| 170 | } |
| 171 | |
| 172 | void XsdValidatedXmlNodeModel::setAssignedAttribute(const QXmlNodeModelIndex &index, const XsdAttribute::Ptr &attribute) |
| 173 | { |
| 174 | m_assignedAttributes.insert(akey: index, avalue: attribute); |
| 175 | } |
| 176 | |
| 177 | XsdAttribute::Ptr XsdValidatedXmlNodeModel::assignedAttribute(const QXmlNodeModelIndex &index) const |
| 178 | { |
| 179 | if (m_assignedAttributes.contains(akey: index)) |
| 180 | return m_assignedAttributes.value(akey: index); |
| 181 | else |
| 182 | return XsdAttribute::Ptr(); |
| 183 | } |
| 184 | |
| 185 | void XsdValidatedXmlNodeModel::setAssignedType(const QXmlNodeModelIndex &index, const SchemaType::Ptr &type) |
| 186 | { |
| 187 | m_assignedTypes.insert(akey: index, avalue: type); |
| 188 | } |
| 189 | |
| 190 | SchemaType::Ptr XsdValidatedXmlNodeModel::assignedType(const QXmlNodeModelIndex &index) const |
| 191 | { |
| 192 | if (m_assignedTypes.contains(akey: index)) |
| 193 | return m_assignedTypes.value(akey: index); |
| 194 | else |
| 195 | return SchemaType::Ptr(); |
| 196 | } |
| 197 | |
| 198 | void XsdValidatedXmlNodeModel::addIdIdRefBinding(const QString &id, const NamedSchemaComponent::Ptr &binding) |
| 199 | { |
| 200 | m_idIdRefBindings[id].insert(value: binding); |
| 201 | } |
| 202 | |
| 203 | QStringList XsdValidatedXmlNodeModel::idIdRefBindingIds() const |
| 204 | { |
| 205 | return m_idIdRefBindings.keys(); |
| 206 | } |
| 207 | |
| 208 | QSet<NamedSchemaComponent::Ptr> XsdValidatedXmlNodeModel::idIdRefBindings(const QString &id) const |
| 209 | { |
| 210 | return m_idIdRefBindings.value(akey: id); |
| 211 | } |
| 212 | |
| 213 | QT_END_NAMESPACE |
| 214 | |