Commit aa094ee8 authored by Marco Bubke's avatar Marco Bubke
Browse files

Add feedback for overwritten expressions

parent 3ac38c9f
...@@ -141,37 +141,53 @@ void FormEditorGraphicsView::drawForeground(QPainter *painter, const QRectF &/*r ...@@ -141,37 +141,53 @@ void FormEditorGraphicsView::drawForeground(QPainter *painter, const QRectF &/*r
painter->restore(); painter->restore();
if (m_beginXHasExpression != m_feedbackNode.hasBindingProperty("x")) {
painter->setPen(Qt::red);
} else {
if (m_beginX != m_feedbackNode.instanceValue("x")) if (m_beginX != m_feedbackNode.instanceValue("x"))
painter->setPen(changeColor); painter->setPen(changeColor);
else else
painter->setPen(Qt::black); painter->setPen(Qt::black);
}
painter->drawText(QPoint(2.0, 12.0), QString("x:")); painter->drawText(QPoint(2.0, 12.0), QString("x:"));
painter->drawText(QPoint(14.0, 12.0), m_feedbackNode.instanceValue("x").toString()); painter->drawText(QPoint(14.0, 12.0), m_feedbackNode.instanceValue("x").toString());
if (m_beginYHasExpression != m_feedbackNode.hasBindingProperty("y")) {
painter->setPen(Qt::red);
} else {
if (m_beginY != m_feedbackNode.instanceValue("y")) if (m_beginY != m_feedbackNode.instanceValue("y"))
painter->setPen(changeColor); painter->setPen(changeColor);
else else
painter->setPen(Qt::black); painter->setPen(Qt::black);
}
painter->drawText(QPoint(50.0, 12.0), QString("y:")); painter->drawText(QPoint(50.0, 12.0), QString("y:"));
painter->drawText(QPoint(60.0, 12.0), m_feedbackNode.instanceValue("y").toString()); painter->drawText(QPoint(60.0, 12.0), m_feedbackNode.instanceValue("y").toString());
if (m_beginWidthHasExpression != m_feedbackNode.hasBindingProperty("width")) {
painter->setPen(Qt::red);
} else {
if (m_beginWidth != m_feedbackNode.instanceValue("width")) if (m_beginWidth != m_feedbackNode.instanceValue("width"))
painter->setPen(changeColor); painter->setPen(changeColor);
else else
painter->setPen(Qt::black); painter->setPen(Qt::black);
}
painter->drawText(QPoint(2.0, 24.0), QString("w:")); painter->drawText(QPoint(2.0, 24.0), QString("w:"));
painter->drawText(QPoint(14.0, 24.0), m_feedbackNode.instanceValue("width").toString()); painter->drawText(QPoint(14.0, 24.0), m_feedbackNode.instanceValue("width").toString());
if (m_beginHeightHasExpression != m_feedbackNode.hasBindingProperty("height")) {
painter->setPen(Qt::red);
} else {
if (m_beginHeight != m_feedbackNode.instanceValue("height")) if (m_beginHeight != m_feedbackNode.instanceValue("height"))
painter->setPen(changeColor); painter->setPen(changeColor);
else else
painter->setPen(Qt::black); painter->setPen(Qt::black);
}
painter->drawText(QPoint(50.0, 24.0), QString("h:")); painter->drawText(QPoint(50.0, 24.0), QString("h:"));
painter->drawText(QPoint(60.0, 24.0),m_feedbackNode.instanceValue("height").toString()); painter->drawText(QPoint(60.0, 24.0),m_feedbackNode.instanceValue("height").toString());
...@@ -245,6 +261,10 @@ void FormEditorGraphicsView::setFeedbackNode(const QmlItemNode &node) ...@@ -245,6 +261,10 @@ void FormEditorGraphicsView::setFeedbackNode(const QmlItemNode &node)
m_beginRightMargin = m_feedbackNode.instanceValue("anchors.rightMargin"); m_beginRightMargin = m_feedbackNode.instanceValue("anchors.rightMargin");
m_beginTopMargin = m_feedbackNode.instanceValue("anchors.topMargin"); m_beginTopMargin = m_feedbackNode.instanceValue("anchors.topMargin");
m_beginBottomMargin = m_feedbackNode.instanceValue("anchors.bottomMargin"); m_beginBottomMargin = m_feedbackNode.instanceValue("anchors.bottomMargin");
m_beginXHasExpression = m_feedbackNode.hasBindingProperty("x");
m_beginYHasExpression = m_feedbackNode.hasBindingProperty("y");
m_beginWidthHasExpression = m_feedbackNode.hasBindingProperty("width");
m_beginHeightHasExpression = m_feedbackNode.hasBindingProperty("height");
} else { } else {
m_beginX = QVariant(); m_beginX = QVariant();
m_beginY = QVariant(); m_beginY = QVariant();
...@@ -255,6 +275,10 @@ void FormEditorGraphicsView::setFeedbackNode(const QmlItemNode &node) ...@@ -255,6 +275,10 @@ void FormEditorGraphicsView::setFeedbackNode(const QmlItemNode &node)
m_beginRightMargin = QVariant(); m_beginRightMargin = QVariant();
m_beginTopMargin = QVariant(); m_beginTopMargin = QVariant();
m_beginBottomMargin = QVariant(); m_beginBottomMargin = QVariant();
m_beginXHasExpression = false;
m_beginYHasExpression = false;
m_beginWidthHasExpression = false;
m_beginHeightHasExpression = false;
} }
} }
......
...@@ -60,6 +60,10 @@ private: ...@@ -60,6 +60,10 @@ private:
QVariant m_beginRightMargin; QVariant m_beginRightMargin;
QVariant m_beginTopMargin; QVariant m_beginTopMargin;
QVariant m_beginBottomMargin; QVariant m_beginBottomMargin;
bool m_beginXHasExpression;
bool m_beginYHasExpression;
bool m_beginWidthHasExpression;
bool m_beginHeightHasExpression;
}; };
} // namespace QmlDesigner } // namespace QmlDesigner
......
...@@ -65,6 +65,7 @@ public: ...@@ -65,6 +65,7 @@ public:
QVariant instanceValue(const QString &name) const; QVariant instanceValue(const QString &name) const;
bool hasProperty(const QString &name) const; bool hasProperty(const QString &name) const;
bool hasBindingProperty(const QString &name) const;
bool propertyAffectedByCurrentState(const QString &name) const; bool propertyAffectedByCurrentState(const QString &name) const;
QVariant modelValue(const QString &name) const; QVariant modelValue(const QString &name) const;
bool isInBaseState() const; bool isInBaseState() const;
......
...@@ -102,9 +102,29 @@ bool QmlObjectNode::hasProperty(const QString &name) const ...@@ -102,9 +102,29 @@ bool QmlObjectNode::hasProperty(const QString &name) const
if (!isValid()) if (!isValid())
throw new InvalidModelNodeException(__LINE__, __FUNCTION__, __FILE__); throw new InvalidModelNodeException(__LINE__, __FUNCTION__, __FILE__);
if (currentState().hasPropertyChanges(modelNode())) {
QmlPropertyChanges propertyChanges = currentState().propertyChanges(modelNode());
if (propertyChanges.modelNode().hasProperty(name))
return true;
}
return modelNode().hasProperty(name); return modelNode().hasProperty(name);
} }
bool QmlObjectNode::hasBindingProperty(const QString &name) const
{
if (!isValid())
throw new InvalidModelNodeException(__LINE__, __FUNCTION__, __FILE__);
if (currentState().hasPropertyChanges(modelNode())) {
QmlPropertyChanges propertyChanges = currentState().propertyChanges(modelNode());
if (propertyChanges.modelNode().hasBindingProperty(name))
return true;
}
return modelNode().hasBindingProperty(name);
}
NodeAbstractProperty QmlObjectNode::nodeAbstractProperty(const QString &name) const NodeAbstractProperty QmlObjectNode::nodeAbstractProperty(const QString &name) const
{ {
return modelNode().nodeAbstractProperty(name); return modelNode().nodeAbstractProperty(name);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment