本文整理汇总了C++中qmldesigner::ModelNode类的典型用法代码示例。如果您正苦于以下问题:C++ ModelNode类的具体用法?C++ ModelNode怎么用?C++ ModelNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ModelNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setScenePos
static inline void setScenePos(const QmlDesigner::ModelNode &modelNode,const QPointF &pos)
{
QmlDesigner::QmlItemNode parentNode = modelNode.parentProperty().parentQmlObjectNode().toQmlItemNode();
if (parentNode.isValid()) {
QPointF localPos = parentNode.instanceSceneTransform().inverted().map(pos);
modelNode.variantProperty(QLatin1String("x")) = localPos.toPoint().x();
modelNode.variantProperty(QLatin1String("y")) = localPos.toPoint().y();
}
}
示例2: fixUrl
static void fixUrl(const QmlDesigner::ModelNode &modelNode, const QmlDesigner::PropertyName &name, QVariant *value)
{
if (modelNode.isValid() && modelNode.metaInfo().isValid()
&& (modelNode.metaInfo().propertyTypeName(name) == "QUrl"
|| modelNode.metaInfo().propertyTypeName(name) == "url")) {
if (!value->isValid())
*value = QString(QLatin1String(""));
}
}
示例3: setScenePos
static inline void setScenePos(const QmlDesigner::ModelNode &modelNode,const QPointF &pos)
{
if (modelNode.hasParentProperty() && QmlDesigner::QmlItemNode::isValidQmlItemNode(modelNode.parentProperty().parentModelNode())) {
QmlDesigner::QmlItemNode parentNode = modelNode.parentProperty().parentQmlObjectNode().toQmlItemNode();
QPointF localPos = parentNode.instanceSceneTransform().inverted().map(pos);
modelNode.variantProperty("x").setValue(localPos.toPoint().x());
modelNode.variantProperty("y").setValue(localPos.toPoint().y());
}
}
示例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: 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;
}
示例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: 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";
}
示例8: 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;
}
示例9: setScenePos
static inline void setScenePos(const QmlDesigner::ModelNode &modelNode,const QPointF &pos)
{
if (modelNode.hasParentProperty() && QmlDesigner::QmlItemNode::isValidQmlItemNode(modelNode.parentProperty().parentModelNode())) {
QmlDesigner::QmlItemNode parentNode = modelNode.parentProperty().parentQmlObjectNode().toQmlItemNode();
if (!parentNode.modelNode().metaInfo().isLayoutable()) {
QPointF localPos = parentNode.instanceSceneTransform().inverted().map(pos);
modelNode.variantProperty("x").setValue(localPos.toPoint().x());
modelNode.variantProperty("y").setValue(localPos.toPoint().y());
} else { //Items in Layouts do not have a position
modelNode.removeProperty("x");
modelNode.removeProperty("y");
}
}
}
示例10: 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();
}
}
示例11: 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();
}
}
示例12: deleteGradient
void GradientModel::deleteGradient()
{
if (!m_itemNode.isValid())
return;
if (!m_itemNode.modelNode().metaInfo().hasProperty(gradientPropertyName().toUtf8()))
return;
QmlDesigner::ModelNode modelNode = m_itemNode.modelNode();
if (m_itemNode.isInBaseState()) {
if (modelNode.hasProperty(gradientPropertyName().toUtf8())) {
QmlDesigner::RewriterTransaction transaction = m_itemNode.modelNode().view()->beginRewriterTransaction();
QmlDesigner::ModelNode gradientNode = modelNode.nodeProperty(gradientPropertyName().toUtf8()).modelNode();
if (QmlDesigner::QmlObjectNode(gradientNode).isValid())
QmlDesigner::QmlObjectNode(gradientNode).destroy();
}
}
}
示例13: 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();
}
示例14: nodeReparented
void TestView::nodeReparented(const QmlDesigner::ModelNode & node, const QmlDesigner::NodeAbstractProperty &newPropertyParent, const QmlDesigner::NodeAbstractProperty & oldPropertyParent, AbstractView::PropertyChangeFlags propertyChange)
{
QmlDesigner::QmlModelView::nodeReparented(node, newPropertyParent, oldPropertyParent, propertyChange);
m_methodCalls += MethodCall("nodeReparented", QStringList() << node.id() << newPropertyParent.name() << oldPropertyParent.name() << serialize(propertyChange));
}
示例15: nodeIdChanged
void TestView::nodeIdChanged(const QmlDesigner::ModelNode &node, const QString& newId, const QString &oldId)
{
QmlDesigner::QmlModelView::nodeIdChanged(node, newId, oldId);
m_methodCalls += MethodCall("nodeIdChanged", QStringList() << node.id() << newId << oldId);
}