本文整理汇总了C++中QXmlNodeModelIndex类的典型用法代码示例。如果您正苦于以下问题:C++ QXmlNodeModelIndex类的具体用法?C++ QXmlNodeModelIndex怎么用?C++ QXmlNodeModelIndex使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QXmlNodeModelIndex类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: typedValue
QVariant QObjectXmlModel::typedValue(const QXmlNodeModelIndex &n) const
{
switch (toNodeType(n))
{
case QObjectProperty:
{
const QVariant &candidate = toMetaProperty(n).read(asQObject(n));
if (isTypeSupported(candidate.type()))
return candidate;
else
return QVariant();
}
case MetaObjectClassName:
return QVariant(static_cast<QMetaObject*>(n.internalPointer())->className());
case MetaObjectSuperClass:
{
const QMetaObject *const superClass = static_cast<QMetaObject*>(n.internalPointer())->superClass();
if (superClass)
return QVariant(superClass->className());
else
return QVariant();
}
case QObjectClassName:
return QVariant(asQObject(n)->metaObject()->className());
default:
return QVariant();
}
}
示例2: internalPointer
void tst_QXmlNodeModelIndex::internalPointer() const
{
/* Check default value. */
{
const QXmlNodeModelIndex index;
QCOMPARE(index.internalPointer(), static_cast<void *>(0));
}
}
示例3: model
void tst_QXmlNodeModelIndex::model() const
{
/* Check default value. */
{
const QXmlNodeModelIndex index;
QCOMPARE(index.model(), static_cast<const QAbstractXmlNodeModel *>(0));
}
}
示例4: additionalData
void tst_QXmlNodeModelIndex::additionalData() const
{
/* Check default value. */
{
const QXmlNodeModelIndex index;
QCOMPARE(index.additionalData(), qint64(0));
}
// TODO check that the return value for data() is qint64.
}
示例5: Q_ASSERT
void QAbstractXmlReceiver::sendFromAxis(const QXmlNodeModelIndex &node)
{
Q_ASSERT(!node.isNull());
const QXmlNodeModelIndex::Iterator::Ptr it(node.iterate(axis));
QXmlNodeModelIndex next(it->next());
while(!next.isNull())
{
sendAsNode(next);
next = it->next();
}
}
示例6: Q_ASSERT
QXmlNodeModelIndex QObjectXmlModel::metaObjectSibling(const int pos, const QXmlNodeModelIndex &n) const
{
Q_ASSERT(pos == 1 || pos == -1);
Q_ASSERT(!n.isNull());
const int indexOf = m_allMetaObjects.indexOf(static_cast<const QMetaObject *>(n.internalPointer())) + pos;
if (indexOf >= 0 && indexOf < m_allMetaObjects.count())
return createIndex(const_cast<QMetaObject *>(m_allMetaObjects.at(indexOf)), MetaObject);
else
return QXmlNodeModelIndex();
}
示例7: QVERIFY
void tst_QXmlNodeModelIndex::isNull() const
{
/* Check default value. */
{
const QXmlNodeModelIndex index;
QVERIFY(index.isNull());
}
/* Test default value on a temporary object. */
{
QVERIFY(QXmlNodeModelIndex().isNull());
}
}
示例8: while
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;
}
示例9: Q_ASSERT_X
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;
}
示例10: typedValue
/*!
Returns the typed value for \a node, which must be either an
attribute or an element. The QVariant returned represents the atomic
value of an attribute or the atomic value contained in an element.
If the QVariant is returned as a default constructed variant,
it means that \a node has no typed value.
*/
QVariant FileTree::typedValue(const QXmlNodeModelIndex &node) const
{
const QFileInfo &fi = toFileInfo(node);
switch (Type(node.additionalData())) {
case Directory:
// deliberate fall through.
case File:
return QString();
case AttributeFileName:
return fi.fileName();
case AttributeFilePath:
return fi.filePath();
case AttributeSize:
return fi.size();
case AttributeMIMEType:
{
/* We don't have any MIME detection code currently, so return
* the most generic one. */
return QLatin1String("application/octet-stream");
}
case AttributeSuffix:
return fi.suffix();
}
Q_ASSERT_X(false, Q_FUNC_INFO, "This line should never be reached.");
return QString();
}
示例11: attribute
/*!
\internal
Treats \a outputItem as a node and calls the appropriate function,
e.g., attribute() or comment(), depending on its
QXmlNodeModelIndex::NodeKind.
This is a helper function that subclasses can use to multiplex
Nodes received via item().
*/
void QAbstractXmlReceiver::sendAsNode(const QPatternist::Item &outputItem)
{
Q_ASSERT(outputItem);
Q_ASSERT(outputItem.isNode());
const QXmlNodeModelIndex asNode = outputItem.asNode();
switch(asNode.kind())
{
case QXmlNodeModelIndex::Attribute:
{
const QString &v = outputItem.stringValue();
attribute(asNode.name(), QStringRef(&v));
return;
}
case QXmlNodeModelIndex::Element:
{
startElement(asNode.name());
/* First the namespaces, then attributes, then the children. */
asNode.sendNamespaces(this);
sendFromAxis<QXmlNodeModelIndex::AxisAttribute>(asNode);
sendFromAxis<QXmlNodeModelIndex::AxisChild>(asNode);
endElement();
return;
}
case QXmlNodeModelIndex::Text:
{
const QString &v = asNode.stringValue();
characters(QStringRef(&v));
return;
}
case QXmlNodeModelIndex::ProcessingInstruction:
{
processingInstruction(asNode.name(), outputItem.stringValue());
return;
}
case QXmlNodeModelIndex::Comment:
{
comment(outputItem.stringValue());
return;
}
case QXmlNodeModelIndex::Document:
{
startDocument();
sendFromAxis<QXmlNodeModelIndex::AxisChild>(asNode);
endDocument();
return;
}
case QXmlNodeModelIndex::Namespace:
Q_ASSERT_X(false, Q_FUNC_INFO, "Not implemented");
}
Q_ASSERT_X(false, Q_FUNC_INFO,
QString::fromLatin1("Unknown node type: %1").arg(asNode.kind()).toUtf8().constData());
}
示例12: Q_ASSERT
QHash<QXmlName, QXmlItem> PullBridge::attributeItems()
{
Q_ASSERT(m_current == StartElement);
QHash<QXmlName, QXmlItem> attributes;
QXmlNodeModelIndex::Iterator::Ptr it = m_index.iterate(QXmlNodeModelIndex::AxisAttribute);
QXmlNodeModelIndex index = it->next();
while (!index.isNull()) {
const Item attribute(index);
attributes.insert(index.name(), QXmlItem(index));
index = it->next();
}
return attributes;
}
示例13: switch
/*!
This function returns QXmlNodeModelIndex::Element if \a node
is a directory or a file, and QXmlNodeModelIndex::Attribute
otherwise.
*/
QXmlNodeModelIndex::NodeKind
FileTree::kind(const QXmlNodeModelIndex &node) const
{
switch (Type(node.additionalData())) {
case Directory:
case File:
return QXmlNodeModelIndex::Element;
default:
return QXmlNodeModelIndex::Attribute;
}
}
示例14: toFileInfo
/*!
Returns the attributes of \a element. The caller guarantees
that \a element is an element in this node model.
*/
QVector<QXmlNodeModelIndex>
FileTree::attributes(const QXmlNodeModelIndex &element) const
{
QVector<QXmlNodeModelIndex> result;
/* Both elements has this attribute. */
const QFileInfo &forElement = toFileInfo(element);
result.append(toNodeIndex(forElement, AttributeFilePath));
result.append(toNodeIndex(forElement, AttributeFileName));
if (Type(element.additionalData() == File)) {
result.append(toNodeIndex(forElement, AttributeSize));
result.append(toNodeIndex(forElement, AttributeSuffix));
//result.append(toNodeIndex(forElement, AttributeMIMEType));
}
else {
Q_ASSERT(element.additionalData() == Directory);
}
return result;
}
示例15: mapToItem
Item AxisStep::mapToItem(const QXmlNodeModelIndex &node,
const DynamicContext::Ptr &context) const
{
Q_ASSERT(!node.isNull());
Q_ASSERT(Item(node).isNode());
Q_ASSERT(Item(node));
Q_UNUSED(context);
if(m_nodeTest->itemMatches(Item(node)))
return Item(node);
else
return Item();
}