当前位置: 首页>>代码示例>>C++>>正文


C++ QXmlNodeModelIndex::additionalData方法代码示例

本文整理汇总了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();
}
开发者ID:PNIDigitalMedia,项目名称:emscripten-qt,代码行数:36,代码来源:filetree.cpp

示例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();
}
开发者ID:mpvader,项目名称:qt,代码行数:10,代码来源:tst_qxmlnodemodelindex.cpp

示例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.
}
开发者ID:mpvader,项目名称:qt,代码行数:10,代码来源:tst_qxmlnodemodelindex.cpp

示例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;
    }
}
开发者ID:PNIDigitalMedia,项目名称:emscripten-qt,代码行数:16,代码来源:filetree.cpp

示例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;
}
开发者ID:PNIDigitalMedia,项目名称:emscripten-qt,代码行数:25,代码来源:filetree.cpp

示例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();
}
开发者ID:PNIDigitalMedia,项目名称:emscripten-qt,代码行数:46,代码来源:filetree.cpp

示例7: toNodeType

//! [1]
QObjectXmlModel::QObjectNodeType QObjectXmlModel::toNodeType(const QXmlNodeModelIndex &n)
{
    return QObjectNodeType(n.additionalData() & (15 << 26));
}
开发者ID:eagafonov,项目名称:qtmoko,代码行数:5,代码来源:qobjectxmlmodel.cpp

示例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);
}
开发者ID:eagafonov,项目名称:qtmoko,代码行数:6,代码来源:qobjectxmlmodel.cpp

示例9: isProperty

bool QObjectXmlModel::isProperty(const QXmlNodeModelIndex n)
{
    return n.additionalData() & QObjectProperty;
}
开发者ID:eagafonov,项目名称:qtmoko,代码行数:4,代码来源:qobjectxmlmodel.cpp

示例10: name

//! [3]
QXmlName FileTree::name(const QXmlNodeModelIndex &node) const
{
    return m_names.at(node.additionalData());
}
开发者ID:PNIDigitalMedia,项目名称:emscripten-qt,代码行数:5,代码来源:filetree.cpp


注:本文中的QXmlNodeModelIndex::additionalData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。