Home · All Classes · Main Classes · Grouped Classes · Modules · Functions

QXmlNodeModelIndex Class Reference
[QtXmlPatterns module]

The QXmlNodeModelIndex class is used to represent a node in a node model. More...

 #include <QXmlNodeModelIndex>

Note: All the functions in this class are reentrant.

This class was introduced in Qt 4.4.

Public Types

Public Functions

Related Non-Members


Detailed Description

The QXmlNodeModelIndex class is used to represent a node in a node model.

QXmlNodeModelIndex is used as an index into QAbstractXmlNodeModel. It contains two things:

QXmlNodeModelIndex is intentionally a simple class. For instance it doesn't have a function for getting a node's name or the list of its attributes. Therefore, QXmlNodeModelIndex is primarily useful if you are using your own node model, but falls short if you to some degree want to spectate the nodes as ordinary XML nodes. Typically the best way to achieve the latter is to either send the result out to a QAbstractXmlReceiver or to put more of the logic inside the query.

For instance, let's say you want to populate a list widget with the values of a set of attributes. Instead of letting the query return a set of elements and then iterate over the their attributes and extract the string values, let the query do all this directly and then evaluate it using QXmlQuery::evaluateTo() and pass a pointer to QStringList.

QXmlNodeModelIndex does not impose restrictions on what data QXmlNodeModelIndex should contain, that is entirely up to the associated QAbstractXmlNodeModel.

Conceptually, QXmlNodeModelIndex can be seen as being one of the two types of items in XQuery: namely nodes. When the XQuery engine handles nodes, it uses QXmlNodeModelIndex in order to delegate the actual functionality to the associated QAbstractXmlNodeModel.

Since QXmlNodeModelIndex is dependent on a particular QAbstractXmlNodeModel subclass, there is no way to create instances, except for via QAbstractXmlNodeModel::createIndex(). Since that function is protected, it can probably be good to create a function that creates node indexes from arguments that fits the particular node model.

A default constructed node index null, and isNull() will return true.

QXmlNodeModelIndex and QAbstractXmlNodeModel follows the same design pattern that QModelIndex QAbstractItemModel do.


Member Type Documentation

enum QXmlNodeModelIndex::DocumentOrder

Identifies what specific node comparison operator that should be used.

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

typedef QXmlNodeModelIndex::List

Typedef for QList<QXmlNodeModelIndex>.

enum QXmlNodeModelIndex::NodeKind

Identifies the kind of a 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. Not 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 constructor. Creates an item that is null.

See also isNull().

QXmlNodeModelIndex::QXmlNodeModelIndex ( const QXmlNodeModelIndex & other )

Standard copy constructor. Creates a QXmlNodeModelIndex instance that is a copy of other.

qint64 QXmlNodeModelIndex::additionalData () const

Returns the second data section that this node index carries.

See also data().

qint64 QXmlNodeModelIndex::data () const

Returns the first data section that this node index carries.

See also additionalData().

void * QXmlNodeModelIndex::internalPointer () const

Returns the first data section typed as a void * pointer.

See also additionalData().

bool QXmlNodeModelIndex::isNull () const

Returns true if this QXmlNodeModelIndex is a default constructed value, otherwise false.

A null QXmlNodeModelIndex instance doesn't represent any node and cannot be used in conjunction with QAbstractXmlNodeModel.

const QAbstractXmlNodeModel * QXmlNodeModelIndex::model () const

Returns the QAbstractXmlNodeModel that this node index belongs to. QXmlNodeModelIndex does not own QAbstractXmlNodeModel nor keep track of its lifetime, so this pointer will dangle whenthe QAbstractXmlNodeModel is deallocated.

There is no setter for this, QXmlNodeModelIndex instances are created with QAbstractXmlNodeModel::createIndex().

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.

In other words, this operator does not compare values, children or names of nodes, it tells whether two nodes have the same node identity. That is, whether they are from the same document and can be found at the exact same place.


Related Non-Members

uint qHash ( const QXmlNodeModelIndex & index )

This is an overloaded member function, provided for convenience.

Computes a hash key from the QXmlNodeModelIndex index, and returns it.

The hash is computed on QXmlNodeModelIndex::data(), QXmlNodeModelIndex::additionalData(), and QXmlNodeModelIndex::model(). This means the hash key can be used for node indexes from different node models.


Copyright © 2008 Trolltech Trademarks
Qt 4.4.0