QXmlNodeModelIndex::DocumentOrder AccelTree::compareOrder(const QXmlNodeModelIndex &ni1, const QXmlNodeModelIndex &ni2) const { Q_ASSERT_X(ni1.model() == ni2.model(), Q_FUNC_INFO, "The API docs guarantees the two nodes are from the same model"); const PreNumber p1 = ni1.data(); const PreNumber p2 = ni2.data(); if(p1 == p2) return QXmlNodeModelIndex::Is; else if(p1 < p2) return QXmlNodeModelIndex::Precedes; else return QXmlNodeModelIndex::Follows; }
void tst_QXmlNodeModelIndex::model() const { /* Check default value. */ { const QXmlNodeModelIndex index; QCOMPARE(index.model(), static_cast<const QAbstractXmlNodeModel *>(0)); } }
void tst_QXmlNodeModelIndex::constCorrectness() const { const QXmlNodeModelIndex index; /* All these functions should be const. */ index.internalPointer(); index.data(); index.additionalData(); index.isNull(); index.model(); }
bool XsdInstanceReader::hasChildElement() const { const QXmlNodeModelIndex index = m_model.index(); QXmlNodeModelIndex::Iterator::Ptr it = index.model()->iterate(index, QXmlNodeModelIndex::AxisChild); QXmlNodeModelIndex currentIndex = it->next(); while (!currentIndex.isNull()) { if (currentIndex.kind() == QXmlNodeModelIndex::Element) return true; currentIndex = it->next(); } return false; }
QString XsdInstanceReader::text() const { const QXmlNodeModelIndex index = m_model.index(); QXmlNodeModelIndex::Iterator::Ptr it = index.model()->iterate(index, QXmlNodeModelIndex::AxisChild); QString result; QXmlNodeModelIndex currentIndex = it->next(); while (!currentIndex.isNull()) { if (currentIndex.kind() == QXmlNodeModelIndex::Text) { result.append(Item(currentIndex).stringValue()); } currentIndex = it->next(); } return result; }