本文整理汇总了C++中PropertyEditorValue::expression方法的典型用法代码示例。如果您正苦于以下问题:C++ PropertyEditorValue::expression方法的具体用法?C++ PropertyEditorValue::expression怎么用?C++ PropertyEditorValue::expression使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PropertyEditorValue
的用法示例。
在下文中一共展示了PropertyEditorValue::expression方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: changeExpression
void PropertyEditorView::changeExpression(const QString &propertyName)
{
PropertyName name = propertyName.toUtf8();
if (name.isNull())
return;
if (m_locked)
return;
if (!m_selectedNode.isValid())
return;
RewriterTransaction transaction = beginRewriterTransaction(QByteArrayLiteral("PropertyEditorView::changeExpression"));
try {
PropertyName underscoreName(name);
underscoreName.replace('.', '_');
QmlObjectNode qmlObjectNode(m_selectedNode);
PropertyEditorValue *value = m_qmlBackEndForCurrentType->propertyValueForName(underscoreName);
if (!value) {
qWarning() << "PropertyEditor::changeExpression no value for " << underscoreName;
return;
}
if (qmlObjectNode.modelNode().metaInfo().isValid() && qmlObjectNode.modelNode().metaInfo().hasProperty(name)) {
if (qmlObjectNode.modelNode().metaInfo().propertyTypeName(name) == "QColor") {
if (QColor(value->expression().remove('"')).isValid()) {
qmlObjectNode.setVariantProperty(name, QColor(value->expression().remove('"')));
transaction.commit(); //committing in the try block
return;
}
} else if (qmlObjectNode.modelNode().metaInfo().propertyTypeName(name) == "bool") {
if (value->expression().compare("false", Qt::CaseInsensitive) == 0 || value->expression().compare("true", Qt::CaseInsensitive) == 0) {
if (value->expression().compare("true", Qt::CaseInsensitive) == 0)
qmlObjectNode.setVariantProperty(name, true);
else
qmlObjectNode.setVariantProperty(name, false);
transaction.commit(); //committing in the try block
return;
}
} else if (qmlObjectNode.modelNode().metaInfo().propertyTypeName(name) == "int") {
bool ok;
int intValue = value->expression().toInt(&ok);
if (ok) {
qmlObjectNode.setVariantProperty(name, intValue);
transaction.commit(); //committing in the try block
return;
}
} else if (qmlObjectNode.modelNode().metaInfo().propertyTypeName(name) == "qreal") {
bool ok;
qreal realValue = value->expression().toFloat(&ok);
if (ok) {
qmlObjectNode.setVariantProperty(name, realValue);
transaction.commit(); //committing in the try block
return;
}
}
}
if (value->expression().isEmpty())
return;
if (qmlObjectNode.expression(name) != value->expression() || !qmlObjectNode.propertyAffectedByCurrentState(name))
qmlObjectNode.setBindingProperty(name, value->expression());
transaction.commit(); //committing in the try block
}
catch (const RewritingException &e) {
e.showException();
}
}