本文整理汇总了C++中QXmlNodeModelIndex::additionalData方法的典型用法代码示例。如果您正苦于以下问题:C++ QXmlNodeModelIndex::additionalData方法的具体用法?C++ QXmlNodeModelIndex::additionalData怎么用?C++ QXmlNodeModelIndex::additionalData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QXmlNodeModelIndex
的用法示例。
在下文中一共展示了QXmlNodeModelIndex::additionalData方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
}
示例2: constCorrectness
void tst_QXmlNodeModelIndex::constCorrectness() const
{
const QXmlNodeModelIndex index;
/* All these functions should be const. */
index.internalPointer();
index.data();
index.additionalData();
index.isNull();
index.model();
}
示例3: 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.
}
示例4: 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;
}
}
示例5: 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;
}
示例6: fi
//! [4]
QXmlNodeModelIndex
FileTree::nextFromSimpleAxis(SimpleAxis axis, const QXmlNodeModelIndex &nodeIndex) const
{
const QFileInfo fi(toFileInfo(nodeIndex));
const Type type = Type(nodeIndex.additionalData());
if (type != File && type != Directory) {
Q_ASSERT_X(axis == Parent, Q_FUNC_INFO, "An attribute only has a parent!");
return toNodeIndex(fi, Directory);
}
switch (axis) {
case Parent:
return toNodeIndex(QFileInfo(fi.path()), Directory);
case FirstChild:
{
if (type == File) // A file has no children.
return QXmlNodeModelIndex();
else {
Q_ASSERT(type == Directory);
Q_ASSERT_X(fi.isDir(), Q_FUNC_INFO, "It isn't really a directory!");
const QDir dir(fi.absoluteFilePath());
Q_ASSERT(dir.exists());
const QFileInfoList children(dir.entryInfoList(QStringList(),
m_filterAllowAll,
m_sortFlags));
if (children.isEmpty())
return QXmlNodeModelIndex();
const QFileInfo firstChild(children.first());
return toNodeIndex(firstChild);
}
}
case PreviousSibling:
return nextSibling(nodeIndex, fi, -1);
case NextSibling:
return nextSibling(nodeIndex, fi, 1);
}
Q_ASSERT_X(false, Q_FUNC_INFO, "Don't ever get here!");
return QXmlNodeModelIndex();
}
示例7: toNodeType
//! [1]
QObjectXmlModel::QObjectNodeType QObjectXmlModel::toNodeType(const QXmlNodeModelIndex &n)
{
return QObjectNodeType(n.additionalData() & (15 << 26));
}
示例8: toMetaProperty
QMetaProperty QObjectXmlModel::toMetaProperty(const QXmlNodeModelIndex &n)
{
const int propertyOffset = n.additionalData() & (~QObjectProperty);
const QObject *const qo = asQObject(n);
return qo->metaObject()->property(propertyOffset);
}
示例9: isProperty
bool QObjectXmlModel::isProperty(const QXmlNodeModelIndex n)
{
return n.additionalData() & QObjectProperty;
}
示例10: name
//! [3]
QXmlName FileTree::name(const QXmlNodeModelIndex &node) const
{
return m_names.at(node.additionalData());
}