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


C++ AbstractProperty::isBindingProperty方法代码示例

本文整理汇总了C++中AbstractProperty::isBindingProperty方法的典型用法代码示例。如果您正苦于以下问题:C++ AbstractProperty::isBindingProperty方法的具体用法?C++ AbstractProperty::isBindingProperty怎么用?C++ AbstractProperty::isBindingProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AbstractProperty的用法示例。


在下文中一共展示了AbstractProperty::isBindingProperty方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: if

QmlDesigner::QmlRefactoring::PropertyType ModelToTextMerger::propertyType(const AbstractProperty &property, const QString &textValue)
{
    if (property.isBindingProperty()) {
        QString val = textValue.trimmed();
        if (val.isEmpty())
            return QmlDesigner::QmlRefactoring::ObjectBinding;
        const QChar lastChar = val.at(val.size() - 1);
        if (lastChar == '}' || lastChar == ';')
            return QmlDesigner::QmlRefactoring::ObjectBinding;
        else
            return QmlDesigner::QmlRefactoring::ScriptBinding;
    } else if (property.isNodeListProperty())
        return QmlDesigner::QmlRefactoring::ArrayBinding;
    else if (property.isNodeProperty())
        return QmlDesigner::QmlRefactoring::ObjectBinding;
    else if (property.isVariantProperty())
        return QmlDesigner::QmlRefactoring::ScriptBinding;

    Q_ASSERT(!"cannot convert property type");
    return (QmlDesigner::QmlRefactoring::PropertyType) -1;
}
开发者ID:CNOT,项目名称:julia-studio,代码行数:21,代码来源:modeltotextmerger.cpp

示例2: toQml

QString QmlTextGenerator::toQml(const AbstractProperty &property, int indentDepth) const
{
    if (property.isBindingProperty()) {
        return property.toBindingProperty().expression();
    } else if (property.isNodeProperty()) {
        return toQml(property.toNodeProperty().modelNode(), indentDepth);
    } else if (property.isNodeListProperty()) {
        const QList<ModelNode> nodes = property.toNodeListProperty().toModelNodeList();
        if (property.isDefaultProperty()) {
            QString result;
            for (int i = 0; i < nodes.length(); ++i) {
                if (i > 0)
                    result += QLatin1String("\n\n");
                result += QString(indentDepth, QLatin1Char(' '));
                result += toQml(nodes.at(i), indentDepth);
            }
            return result;
        } else {
            QString result = QLatin1String("[");
            const int arrayContentDepth = indentDepth + 4;
            const QString arrayContentIndentation(arrayContentDepth, QLatin1Char(' '));
            for (int i = 0; i < nodes.length(); ++i) {
                if (i > 0)
                    result += QLatin1Char(',');
                result += QLatin1Char('\n');
                result += arrayContentIndentation;
                result += toQml(nodes.at(i), arrayContentDepth);
            }
            return result + QLatin1Char(']');
        }
    } else if (property.isVariantProperty()) {
        const VariantProperty variantProperty = property.toVariantProperty();
        const QVariant value = variantProperty.value();
        const QString stringValue = value.toString();

        if (property.name() == QLatin1String("id"))
            return stringValue;

          if (false) {
          }
        if (variantProperty.parentModelNode().metaInfo().isValid() &&
            variantProperty.parentModelNode().metaInfo().propertyIsEnumType(variantProperty.name())) {
            return variantProperty.parentModelNode().metaInfo().propertyEnumScope(variantProperty.name()) + '.' + stringValue;
        } else {

            switch (value.type()) {
            case QVariant::Bool:
                if (value.value<bool>())
                    return QLatin1String("true");
                else
                    return QLatin1String("false");

            case QVariant::Color:
                return QString(QLatin1String("\"%1\"")).arg(properColorName(value.value<QColor>()));

            case QVariant::Double:
                return doubleToString(value.toDouble());
            case QVariant::Int:
            case QVariant::LongLong:
            case QVariant::UInt:
            case QVariant::ULongLong:
                return stringValue;

            default:
                return QString(QLatin1String("\"%1\"")).arg(escape(stringValue));
            }
        }
    } else {
        Q_ASSERT("Unknown property type");
        return QString();
    }
}
开发者ID:KDE,项目名称:android-qt-creator,代码行数:72,代码来源:qmltextgenerator.cpp

示例3: toQml

QString QmlTextGenerator::toQml(const AbstractProperty &property, int indentDepth) const
{
    if (property.isBindingProperty()) {
        return property.toBindingProperty().expression();
    } else if (property.isSignalHandlerProperty()) {
        return property.toSignalHandlerProperty().source();
    } else if (property.isNodeProperty()) {
        return toQml(property.toNodeProperty().modelNode(), indentDepth);
    } else if (property.isNodeListProperty()) {
        const QList<ModelNode> nodes = property.toNodeListProperty().toModelNodeList();
        if (property.isDefaultProperty()) {
            QString result;
            for (int i = 0; i < nodes.length(); ++i) {
                if (i > 0)
                    result += QLatin1String("\n\n");
                result += QString(indentDepth, QLatin1Char(' '));
                result += toQml(nodes.at(i), indentDepth);
            }
            return result;
        } else {
            QString result = QLatin1String("[");
            const int arrayContentDepth = indentDepth + 4;
            const QString arrayContentIndentation(arrayContentDepth, QLatin1Char(' '));
            for (int i = 0; i < nodes.length(); ++i) {
                if (i > 0)
                    result += QLatin1Char(',');
                result += QLatin1Char('\n');
                result += arrayContentIndentation;
                result += toQml(nodes.at(i), arrayContentDepth);
            }
            return result + QLatin1Char(']');
        }
    } else if (property.isVariantProperty()) {
        const VariantProperty variantProperty = property.toVariantProperty();
        const QVariant value = variantProperty.value();
        const QString stringValue = value.toString();

        if (property.name() == "id")
            return stringValue;

        if (variantProperty.parentModelNode().metaInfo().isValid()
                && variantProperty.parentModelNode().metaInfo().propertyIsEnumType(variantProperty.name())) {
            return variantProperty.parentModelNode().metaInfo().propertyEnumScope(variantProperty.name())
                    + QLatin1String(".") + stringValue;
            //Enums do not work with alias properties. This is a workaround.
        } else if (variantProperty.parentModelNode().metaInfo().isValid()
                   //Enums are not strings
                   && variantProperty.parentModelNode().metaInfo().propertyTypeName(variantProperty.name())
                   != ("string")
                   && variantProperty.parentModelNode().metaInfo().propertyTypeName(variantProperty.name())
                   != ("QString")
                   //We check if the value of the property is one of the known Qt Quick enums.
                   && NodeMetaInfo::qtQuickEnumsWithoutScope().contains(stringValue)
                   ) {
            return NodeMetaInfo::qtQuickEnumScopeForEnumString(stringValue) + QLatin1String(".") + stringValue;
        } else {

            switch (value.type()) {
            case QVariant::Bool:
                if (value.value<bool>())
                    return QLatin1String("true");
                else
                    return QLatin1String("false");

            case QVariant::Color:
                return QString(QLatin1String("\"%1\"")).arg(properColorName(value.value<QColor>()));

            case QVariant::Double:
                return doubleToString(value.toDouble());
            case QVariant::Int:
            case QVariant::LongLong:
            case QVariant::UInt:
            case QVariant::ULongLong:
                return stringValue;

            default:
                return QString(QLatin1String("\"%1\"")).arg(escape(stringValue));
            }
        }
    } else {
        Q_ASSERT("Unknown property type");
        return QString();
    }
}
开发者ID:kaltsi,项目名称:sailfish-qtcreator,代码行数:84,代码来源:qmltextgenerator.cpp


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