本文整理汇总了C++中ModelNode::hasProperty方法的典型用法代码示例。如果您正苦于以下问题:C++ ModelNode::hasProperty方法的具体用法?C++ ModelNode::hasProperty怎么用?C++ ModelNode::hasProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModelNode
的用法示例。
在下文中一共展示了ModelNode::hasProperty方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setupGradient
void GradientLineQmlAdaptor::setupGradient()
{
if (!active())
return;
ModelNode modelNode = m_itemNode.modelNode();
QLinearGradient newGradient;
QVector<QGradientStop> stops;
if (!modelNode.isValid())
return;
if (modelNode.hasBindingProperty(gradientName()))
return;
if (modelNode.hasProperty(gradientName())) { //gradient exists
ModelNode gradientNode = modelNode.nodeProperty(gradientName()).modelNode();
QList<ModelNode> stopList = gradientNode.nodeListProperty("stops").toModelNodeList();
foreach (const ModelNode &stopNode, stopList) {
QmlObjectNode stopObjectNode = stopNode;
if (stopObjectNode.isValid()) {
qreal position = stopObjectNode.modelValue("position").toReal();
QColor color = stopObjectNode.modelValue("color").value<QColor>();
stops.append( QPair<qreal, QColor>(position, color));
}
}
示例2: resolveBinding
static ModelNode resolveBinding(const QString &binding, ModelNode currentNode, AbstractView* view)
{
int i = 0;
QString element = binding.split(QLatin1Char('.')).at(0);
while (!element.isEmpty())
{
if (element == "parent") {
if (currentNode.hasParentProperty())
currentNode = currentNode.parentProperty().toNodeAbstractProperty().parentModelNode();
else
return ModelNode(); //binding not valid
} else if (currentNode.hasProperty(element)) {
if (currentNode.property(element).isNodeProperty()) {
currentNode = currentNode.nodeProperty(element).modelNode();
} else {
currentNode = view->modelNodeForId(element); //id
if (!currentNode.isValid())
return ModelNode(); //binding not valid
}
} else {
currentNode = view->modelNodeForId(element); //id
}
i++;
if (i < binding.split(QLatin1Char('.')).count())
element = binding.split(QLatin1Char('.')).at(i);
else
element.clear();
}
return currentNode;
}
示例3: inspectPropertyEditor
static void inspectPropertyEditor(ModelNode node, QWidget* propWidget)
{
if (!propWidget)
return;
QStackedWidget * stackedWidget = qobject_cast<QStackedWidget *> (propWidget);
QVERIFY(stackedWidget);
QDeclarativeView *view = qobject_cast<QDeclarativeView*>(stackedWidget->currentWidget());
QVERIFY(view);
QLineEdit * idLineEdit = view->findChild<QLineEdit* >("IdLineEdit");
if (!idLineEdit)
return ;
QCOMPARE(idLineEdit->text(), node.id());
if (node.hasProperty("width")) {
QSpinBox * widthSpinBox = view->findChild<QSpinBox* >("WidthSpinBox");
QVERIFY(widthSpinBox);
QCOMPARE(widthSpinBox->value(), node.variantProperty("width").value().toInt());
}
if (node.hasProperty("height")) {
QSpinBox * heightSpinBox = view->findChild<QSpinBox* >("HeightSpinBox");
QVERIFY(heightSpinBox);
QCOMPARE(heightSpinBox->value(), node.variantProperty("height").value().toInt());// this can be dangerous
}
if (node.hasProperty("x")) {
QSpinBox * xSpinBox = view->findChild<QSpinBox* >("XSpinBox");
QVERIFY(xSpinBox);
QCOMPARE(xSpinBox->value(), node.variantProperty("x").value().toInt()); // this can be dangerous
}
if (node.hasProperty("y")) {
QSpinBox * ySpinBox = view->findChild<QSpinBox* >("YSpinBox");
QVERIFY(ySpinBox);
QCOMPARE(ySpinBox->value(), node.variantProperty("y").value().toInt());
}
}
示例4: data
QVariant StatesEditorModel::data(const QModelIndex &index, int role) const
{
if (index.parent().isValid() || index.column() != 0 || m_statesEditorView.isNull() || !m_statesEditorView->hasModelNodeForInternalId(index.internalId()))
return QVariant();
ModelNode stateNode;
if (index.internalId() > 0)
stateNode = m_statesEditorView->modelNodeForInternalId(index.internalId());
switch (role) {
case StateNameRole: {
if (index.row() == 0) {
return QString(tr("base state", "Implicit default state"));
} else {
if (stateNode.hasVariantProperty("name"))
return stateNode.variantProperty("name").value();
else
return QVariant();
}
}
case StateImageSourceRole: {
static int randomNumber = 0;
randomNumber++;
if (index.row() == 0)
return QString("image://qmldesigner_stateseditor/baseState-%1").arg(randomNumber);
else
return QString("image://qmldesigner_stateseditor/%1-%2").arg(index.internalId()).arg(randomNumber);
}
case InternalNodeId: return index.internalId();
case HasWhenCondition: return stateNode.isValid() && stateNode.hasProperty("when");
case WhenConditionString: {
if (stateNode.isValid() && stateNode.hasBindingProperty("when"))
return stateNode.bindingProperty("when").expression();
else
return QString();
}
}
return QVariant();
}
示例5: setup
void BehaviorDialog::setup(const ModelNode &node, const QString propertyName)
{
m_modelNode = node;
m_ui->duration->setValue(100);
m_ui->velocity->setValue(2);
m_ui->spring->setValue(2);
m_ui->damping->setValue(2);
m_ui->stackedWidget->setCurrentIndex(0);
m_ui->curve->setCurrentIndex(0);
if (m_modelNode.isValid()) {
m_propertyName = propertyName;
m_ui->id->setText(m_modelNode.id());
m_ui->type->setText(m_modelNode.simplifiedTypeName());
m_ui->propertyName->setText(propertyName);
if (m_modelNode.hasProperty(m_propertyName) && m_modelNode.property(m_propertyName).isNodeProperty()) {
NodeProperty nodeProperty(m_modelNode.nodeProperty(m_propertyName));
if (nodeProperty.modelNode().type() == "Qt/SpringFollow") {
ModelNode springFollow = nodeProperty.modelNode();
m_ui->curve->setCurrentIndex(1);
m_ui->stackedWidget->setCurrentIndex(1);
if (springFollow.hasProperty("velocity") && springFollow.property("velocity").isVariantProperty())
m_ui->velocity->setValue(springFollow.variantProperty("velocity").value().toDouble());
if (springFollow.hasProperty("spring") && springFollow.property("spring").isVariantProperty())
m_ui->spring->setValue(springFollow.variantProperty("spring").value().toDouble());
if (springFollow.hasProperty("damping") && springFollow.property("damping").isVariantProperty())
m_ui->damping->setValue(springFollow.variantProperty("damping").value().toDouble());
if (springFollow.hasProperty("source") && springFollow.property("source").isVariantProperty())
m_ui->source->setText(springFollow.variantProperty("source").value().toString());
} else if (nodeProperty.modelNode().type() == "Qt/Behavior") {
if (nodeProperty.modelNode().hasProperty("animation") &&
nodeProperty.modelNode().property("animation").isNodeProperty() &&
nodeProperty.modelNode().nodeProperty("animation").modelNode().type() == "Qt/NumberAnimation") {
m_ui->curve->setCurrentIndex(0);
ModelNode animation = nodeProperty.modelNode().nodeProperty("animation").modelNode();
if (animation.hasProperty("duration") && animation.property("duration").isVariantProperty())
m_ui->duration->setValue(animation.variantProperty("duration").value().toInt());
if (animation.hasProperty("easing") && animation.property("easing").isVariantProperty()) {
QStringList easingItems;
for (int i = 0; i < m_ui->curve->count(); i++)
easingItems.append(m_ui->curve->itemText(i));
m_ui->curve->setCurrentIndex(easingItems.indexOf(animation.variantProperty("easing").value().toString()));
}
}
}
}
}
}
示例6: toogleExportAlias
void PropertyEditorContextObject::toogleExportAlias()
{
if (!m_model || !m_model->rewriterView())
return;
/* Ideally we should not missuse the rewriterView
* If we add more code here we have to forward the property editor view */
RewriterView *rewriterView = m_model->rewriterView();
if (rewriterView->selectedModelNodes().isEmpty())
return;
const ModelNode selectedNode = rewriterView->selectedModelNodes().constFirst();
if (QmlObjectNode::isValidQmlObjectNode(selectedNode)) {
QmlObjectNode objectNode(selectedNode);
PropertyName modelNodeId = selectedNode.id().toUtf8();
ModelNode rootModelNode = rewriterView->rootModelNode();
try {
RewriterTransaction transaction =
rewriterView->beginRewriterTransaction(QByteArrayLiteral("PropertyEditorContextObject:toogleExportAlias"));
if (!objectNode.isAliasExported())
objectNode.ensureAliasExport();
else
if (rootModelNode.hasProperty(modelNodeId))
rootModelNode.removeProperty(modelNodeId);
transaction.commit();
} catch (RewritingException &exception) { //better safe than sorry! There always might be cases where we fail
exception.showException();
}
}
}