本文整理汇总了C++中qmldesigner::ModelNode::nodeListProperty方法的典型用法代码示例。如果您正苦于以下问题:C++ ModelNode::nodeListProperty方法的具体用法?C++ ModelNode::nodeListProperty怎么用?C++ ModelNode::nodeListProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qmldesigner::ModelNode
的用法示例。
在下文中一共展示了ModelNode::nodeListProperty方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addStop
void GradientModel::addStop(qreal position, const QColor &color)
{
if (m_lock)
return;
if (!m_itemNode.isValid() || gradientPropertyName().isEmpty())
return;
if (m_itemNode.modelNode().hasNodeProperty(gradientPropertyName().toUtf8())) {
//QmlDesigner::RewriterTransaction transaction = m_itemNode.modelNode().view()->beginRewriterTransaction();
//### TODO does not work
QmlDesigner::ModelNode gradientNode = m_itemNode.modelNode().nodeProperty(gradientPropertyName().toUtf8()).modelNode();
QmlDesigner::ModelNode gradientStopNode =
m_itemNode.modelNode().view()->createModelNode("QtQuick.GradientStop",
m_itemNode.modelNode().view()->majorQtQuickVersion(), 0);
gradientStopNode.variantProperty("position").setValue(position);
gradientStopNode.variantProperty("color").setValue(color);
gradientNode.nodeListProperty("stops").reparentHere(gradientStopNode);
const QList<QmlDesigner::ModelNode> stopNodes = gradientNode.nodeListProperty("stops").toModelNodeList();
int properPos = 0;
for (int i = 0; i < stopNodes.count(); i++) {
if (QmlDesigner::QmlObjectNode(stopNodes.at(i)).modelValue("position").toReal() < position)
properPos = i + 1;
}
gradientNode.nodeListProperty("stops").slide(stopNodes.count() - 1, properPos);
setupModel();
}
}
示例2: addGradient
void GradientModel::addGradient()
{
if (m_locked)
return;
if (!m_itemNode.isValid() || gradientPropertyName().isEmpty())
return;
if (!m_itemNode.modelNode().hasNodeProperty(gradientPropertyName().toUtf8())) {
QColor color = m_itemNode.instanceValue("color").value<QColor>();
if (!color.isValid())
color = QColor(Qt::white);
QmlDesigner::RewriterTransaction transaction = m_itemNode.modelNode().view()->beginRewriterTransaction(QByteArrayLiteral("GradientModel::addGradient"));
QmlDesigner::ModelNode gradientNode =
m_itemNode.modelNode().view()->createModelNode("QtQuick.Gradient",
m_itemNode.modelNode().view()->majorQtQuickVersion(), 0);
m_itemNode.modelNode().nodeProperty(gradientPropertyName().toUtf8()).reparentHere(gradientNode);
QmlDesigner::ModelNode gradientStopNode =
m_itemNode.modelNode().view()->createModelNode("QtQuick.GradientStop",
m_itemNode.modelNode().view()->majorQtQuickVersion(), 0);
gradientStopNode.variantProperty("position").setValue(0.0);
gradientStopNode.variantProperty("color").setValue(color);
gradientNode.nodeListProperty("stops").reparentHere(gradientStopNode);
gradientStopNode = m_itemNode.modelNode().view()->createModelNode(
"QtQuick.GradientStop",
m_itemNode.modelNode().view()->majorQtQuickVersion(), 0);
gradientStopNode.variantProperty("position").setValue(1.0);
gradientStopNode.variantProperty("color").setValue(QColor(Qt::black));
gradientNode.nodeListProperty("stops").reparentHere(gradientStopNode);
}
setupModel();
emit hasGradientChanged();
}
示例3: getPosition
qreal GradientModel::getPosition(int index) const
{
if (index < rowCount()) {
QmlDesigner::ModelNode gradientNode = m_itemNode.modelNode().nodeProperty(gradientPropertyName().toUtf8()).modelNode();
QmlDesigner::QmlObjectNode stop = gradientNode.nodeListProperty("stops").at(index);
if (stop.isValid())
return stop.modelValue("position").toReal();
}
qWarning() << Q_FUNC_INFO << "invalid position index";
return 0.0;
}
示例4: getColor
QColor GradientModel::getColor(int index) const
{
if (index < rowCount()) {
QmlDesigner::ModelNode gradientNode = m_itemNode.modelNode().nodeProperty(gradientPropertyName().toUtf8()).modelNode();
QmlDesigner::QmlObjectNode stop = gradientNode.nodeListProperty("stops").at(index);
if (stop.isValid())
return stop.modelValue("color").value<QColor>();
}
qWarning() << Q_FUNC_INFO << "invalid color index";
return QColor();
}
示例5: removeStop
void GradientModel::removeStop(int index)
{
if (index < rowCount() - 1 && index != 0) {
QmlDesigner::RewriterTransaction transaction = m_itemNode.modelNode().view()->beginRewriterTransaction(QByteArrayLiteral("GradientModel::removeStop"));
QmlDesigner::ModelNode gradientNode = m_itemNode.modelNode().nodeProperty(gradientPropertyName().toUtf8()).modelNode();
QmlDesigner::QmlObjectNode stop = gradientNode.nodeListProperty("stops").at(index);
if (stop.isValid()) {
stop.destroy();
setupModel();
}
}
qWarning() << Q_FUNC_INFO << "invalid index";
}
示例6: setPosition
void GradientModel::setPosition(int index, qreal positition)
{
if (locked())
return;
if (index < rowCount()) {
QmlDesigner::ModelNode gradientNode = m_itemNode.modelNode().nodeProperty(gradientPropertyName().toUtf8()).modelNode();
QmlDesigner::QmlObjectNode stop = gradientNode.nodeListProperty("stops").at(index);
if (stop.isValid())
stop.setVariantProperty("position", positition);
setupModel();
}
}
示例7: rowCount
int GradientModel::rowCount(const QModelIndex & /*parent*/) const
{
if (m_itemNode.isValid()) {
if (m_itemNode.modelNode().hasNodeProperty(gradientPropertyName().toUtf8())) {
QmlDesigner::ModelNode gradientNode =
m_itemNode.modelNode().nodeProperty(gradientPropertyName().toUtf8()).modelNode();
if (gradientNode.isValid() && gradientNode.hasNodeListProperty("stops"))
return gradientNode.nodeListProperty("stops").toModelNodeList().count();
}
}
return 0;
}
示例8: setColor
void GradientModel::setColor(int index, const QColor &color)
{
if (locked())
return;
if (!m_itemNode.modelNode().isSelected())
return;
if (index < rowCount()) {
QmlDesigner::ModelNode gradientNode = m_itemNode.modelNode().nodeProperty(gradientPropertyName().toUtf8()).modelNode();
QmlDesigner::QmlObjectNode stop = gradientNode.nodeListProperty("stops").at(index);
if (stop.isValid())
stop.setVariantProperty("color", color);
setupModel();
}
}