QXmlNodeModelIndex Class

The QXmlNodeModelIndex class identifies a node in an XML node model subclassed from QAbstractXmlNodeModel. More...

Header: #include <QXmlNodeModelIndex>
qmake: QT += xmlpatterns
Since: Qt 4.4

Note: All functions in this class are reentrant.

Public Types

enum DocumentOrder { Precedes, Follows, Is }
typedef List
enum NodeKind { Attribute, Text, Comment, Document, ..., ProcessingInstruction }

Public Functions

QXmlNodeModelIndex()
QXmlNodeModelIndex(const QXmlNodeModelIndex &other)
qint64 additionalData() const
QUrl baseUri() const
QXmlNodeModelIndex::DocumentOrder compareOrder(const QXmlNodeModelIndex &other) const
qint64 data() const
QUrl documentUri() const
void *internalPointer() const
bool is(const QXmlNodeModelIndex &other) const
bool isDeepEqual(const QXmlNodeModelIndex &other) const
bool isNull() const
QExplicitlySharedDataPointer<QAbstractXmlForwardIterator<QXmlNodeModelIndex> > iterate(const QXmlNodeModelIndex::Axis axis) const
QXmlNodeModelIndex::NodeKind kind() const
const QAbstractXmlNodeModel *model() const
QXmlName name() const
QVector<QXmlName> namespaceBindings() const
QXmlName::NamespaceCode namespaceForPrefix(const QXmlName::PrefixCode prefix) const
void reset()
QXmlNodeModelIndex root() const
void sendNamespaces(QAbstractXmlReceiver *const receiver) const
QExplicitlySharedDataPointer<QAbstractXmlForwardIterator<QPatternist::Item> > sequencedTypedValue() const
QString stringValue() const
QPatternist::ItemTypePtr type() const
bool operator!=(const QXmlNodeModelIndex &other) const
bool operator==(const QXmlNodeModelIndex &other) const

Detailed Description

The QXmlNodeModelIndex class identifies a node in an XML node model subclassed from QAbstractXmlNodeModel.

QXmlNodeModelIndex is an index into an XML node model. It contains:

Because QXmlNodeModelIndex is intentionally a simple class, it doesn't have member functions for accessing the properties of nodes. For example, it doesn't have functions for getting a node's name or its list of attributes or child nodes. If you find that you need to retrieve this kind of information from your query results, there are two ways to proceed.

The second case is explained by example. Suppose you want to populate a list widget with the values of certain attributes from a set of result elements. You could write an XQuery to return the set of elements, and then you would write the code to iterate over the result elements, get their attributes, and extract the desired string values. But the simpler way is to just augment your XQuery to finding the desired attribute values. Then all you have to do is evaluate the XQuery using the version of QXmlQuery::evaluateTo() that populates a QStringList, which you can send directly to your widget.

QXmlNodeModelIndex doesn't impose any restrictions on the data value an QXmlNodeModelIndex should contain. The meaning of the data left to the associated node model. Because QXmlNodeModelIndex depends on a particular subclass of QAbstractXmlNodeModel for its existence, the only way you can create an instance of QXmlNodeModelIndex is by asking the node model to create one for you with QAbstractXmlNodeModel::createIndex(). Since that function is protected, it is usually a good idea to write a public function that creates a QXmlNodeModelIndex from arguments that are appropriate for your particular node model.

A default constructed node index is said to be null, i.e., isNull() returns true.

QXmlNodeModelIndex and QAbstractXmlNodeModel follow the same design pattern used for QModelIndex and QAbstractItemModel.

Member Type Documentation

enum QXmlNodeModelIndex::DocumentOrder

Identifies the specific node comparison operator that should be used.

ConstantValueDescription
QXmlNodeModelIndex::Precedes-1Signifies the \<\< operator. Test whether the first operand precedes the second in the document.
QXmlNodeModelIndex::Follows1Signifies the \>\> operator. Test whether the first operand follows the second in the document.
QXmlNodeModelIndex::Is0Signifies the is operator. Test whether two nodes have the same node identity.

typedef QXmlNodeModelIndex::List

Typedef for QList<QXmlNodeModelIndex>.

enum QXmlNodeModelIndex::NodeKind

Identifies a kind of node.

ConstantValueDescription
QXmlNodeModelIndex::Attribute1Identifies an attribute node
QXmlNodeModelIndex::Text64Identifies a text node
QXmlNodeModelIndex::Comment2Identifies a comment node
QXmlNodeModelIndex::Document4Identifies a document node
QXmlNodeModelIndex::Element8Identifies an element node
QXmlNodeModelIndex::Namespace16Identifies a namespace node
QXmlNodeModelIndex::ProcessingInstruction32Identifies a processing instruction.

Note that the optional XML declaration at very beginning of the XML document is not a processing instruction

See also QAbstractXmlNodeModel::kind().

Member Function Documentation

QXmlNodeModelIndex::QXmlNodeModelIndex()

Default constructs an instance of QXmlNodeModelIndex.

QXmlNodeModelIndex::QXmlNodeModelIndex(const QXmlNodeModelIndex &other)

Default constructs an instance of QXmlNodeModelIndex.

qint64 QXmlNodeModelIndex::additionalData() const

QUrl QXmlNodeModelIndex::baseUri() const

QXmlNodeModelIndex::DocumentOrder QXmlNodeModelIndex::compareOrder(const QXmlNodeModelIndex &other) const

qint64 QXmlNodeModelIndex::data() const

QUrl QXmlNodeModelIndex::documentUri() const

void *QXmlNodeModelIndex::internalPointer() const

bool QXmlNodeModelIndex::is(const QXmlNodeModelIndex &other) const

bool QXmlNodeModelIndex::isDeepEqual(const QXmlNodeModelIndex &other) const

bool QXmlNodeModelIndex::isNull() const

QExplicitlySharedDataPointer<QAbstractXmlForwardIterator<QXmlNodeModelIndex> > QXmlNodeModelIndex::iterate(const QXmlNodeModelIndex::Axis axis) const

QXmlNodeModelIndex::NodeKind QXmlNodeModelIndex::kind() const

const QAbstractXmlNodeModel *QXmlNodeModelIndex::model() const

QXmlName QXmlNodeModelIndex::name() const

QVector<QXmlName> QXmlNodeModelIndex::namespaceBindings() const

QXmlName::NamespaceCode QXmlNodeModelIndex::namespaceForPrefix(const QXmlName::PrefixCode prefix) const

void QXmlNodeModelIndex::reset()

QXmlNodeModelIndex QXmlNodeModelIndex::root() const

void QXmlNodeModelIndex::sendNamespaces(QAbstractXmlReceiver *const receiver) const

QExplicitlySharedDataPointer<QAbstractXmlForwardIterator<QPatternist::Item> > QXmlNodeModelIndex::sequencedTypedValue() const

QString QXmlNodeModelIndex::stringValue() const

QPatternist::ItemTypePtr QXmlNodeModelIndex::type() const

bool QXmlNodeModelIndex::operator!=(const QXmlNodeModelIndex &other) const

Returns true if other is the same node as this.

bool QXmlNodeModelIndex::operator==(const QXmlNodeModelIndex &other) const

Returns true if this node is the same as other. This operator does not compare values, children, or names of nodes. It compares node identities, i.e., whether two nodes are from the same document and are found at the exact same place.