Commit a83548f1 authored by Marco Bubke's avatar Marco Bubke Committed by Tim Jenssen
Browse files

QmlDesigner: Direct update of the position



This is maybe harmful shortcut in 99.99% of the cases it should work
better.

Change-Id: Ia162666862498ac331c9f5381cb12753d34758c1
Reviewed-by: default avatarTim Jenssen <tim.jenssen@digia.com>
parent 8dfb05c8
......@@ -122,6 +122,14 @@ bool MoveManipulator::itemsCanReparented() const
return true;
}
void MoveManipulator::setDirectUpdateInNodeInstances(bool directUpdate)
{
foreach (FormEditorItem* item, m_itemList) {
if (item && item->qmlItemNode().isValid())
item->qmlItemNode().nodeInstance().setUpdateTransform(!directUpdate);
}
}
void MoveManipulator::begin(const QPointF &beginPoint)
{
m_isActive = true;
......@@ -159,6 +167,8 @@ void MoveManipulator::begin(const QPointF &beginPoint)
// setOpacityForAllElements(0.62);
setDirectUpdateInNodeInstances(true);
m_rewriterTransaction = m_view->beginRewriterTransaction(QByteArrayLiteral("MoveManipulator::begin"));
}
......@@ -371,6 +381,7 @@ void MoveManipulator::reparentTo(FormEditorItem *newParent)
void MoveManipulator::end()
{
setDirectUpdateInNodeInstances(false);
m_isActive = false;
deleteSnapLines();
clear();
......
......@@ -97,6 +97,8 @@ protected:
void adjustAnchoringOfItem(FormEditorItem *item);
void setDirectUpdateInNodeInstances(bool directUpdate);
private:
Snapper m_snapper;
QPointer<LayerItem> m_layerItem;
......
......@@ -86,6 +86,10 @@ public:
qint32 parentId() const;
qint32 instanceId() const;
void setUpdateTransform(bool updateTransform);
bool updateTransform() const;
void setX(double x);
void setY(double y);
protected:
void setProperty(const PropertyName &name, const QVariant &value);
......
......@@ -136,6 +136,7 @@ public:
NodeInstance activeStateInstance() const;
void updatePosition(const QList<VariantProperty>& propertyList);
void valuesChanged(const ValuesChangedCommand &command);
void pixmapChanged(const PixmapChangedCommand &command);
......
......@@ -41,9 +41,12 @@ namespace QmlDesigner {
class QmlItemNode;
class QmlPropertyChanges;
class MoveManipulator;
class QMLDESIGNERCORE_EXPORT QmlObjectNode : public QmlModelNodeFacade
{
friend class QmlItemNode;
friend class MoveManipulator;
public:
QmlObjectNode();
QmlObjectNode(const ModelNode &modelNode);
......
......@@ -51,7 +51,8 @@ public:
hasContent(false),
isMovable(false),
isResizable(false),
isInLayoutable(false)
isInLayoutable(false),
updateTransform(true)
{}
qint32 parentInstanceId;
......@@ -71,6 +72,7 @@ public:
bool isMovable;
bool isResizable;
bool isInLayoutable;
bool updateTransform;
QHash<PropertyName, QVariant> propertyValues;
......@@ -133,6 +135,36 @@ qint32 NodeInstance::instanceId() const
return -1;
}
void NodeInstance::setUpdateTransform(bool updateTransform)
{
if (d)
d->updateTransform = updateTransform;
}
bool NodeInstance::updateTransform() const
{
if (d)
d->updateTransform || d->transform.isRotating() || d->transform.isScaling();
else
return true;
}
void NodeInstance::setX(double x)
{
if(d && !updateTransform()) {
double dx = x - d->transform.dx();
d->transform.translate(dx, 0.0);
}
}
void NodeInstance::setY(double y)
{
if(d && !updateTransform()) {
double dy = y - d->transform.dy();
d->transform.translate(0.0, dy);
}
}
bool NodeInstance::isValid() const
{
return instanceId() >= 0 && modelNode().isValid();
......@@ -375,7 +407,7 @@ InformationName NodeInstance::setInformationContentItemBoundingRect(const QRectF
InformationName NodeInstance::setInformationTransform(const QTransform &transform)
{
if (d->transform != transform) {
if (updateTransform() && d->transform != transform) {
d->transform = transform;
return Transform;
}
......
......@@ -370,6 +370,7 @@ void NodeInstanceView::signalHandlerPropertiesChanged(const QVector<SignalHandle
void NodeInstanceView::variantPropertiesChanged(const QList<VariantProperty>& propertyList, PropertyChangeFlags /*propertyChange*/)
{
updatePosition(propertyList);
nodeInstanceServer()->changePropertyValues(createChangeValueCommand(propertyList));
}
/*!
......@@ -673,6 +674,26 @@ NodeInstance NodeInstanceView::activeStateInstance() const
return m_activeStateInstance;
}
void NodeInstanceView::updatePosition(const QList<VariantProperty> &propertyList)
{
QMultiHash<ModelNode, InformationName> informationChangeHash;
foreach (const VariantProperty &variantProperty, propertyList) {
if (variantProperty.name() == "x") {
NodeInstance instance = instanceForModelNode(variantProperty.parentModelNode());
instance.setX(variantProperty.value().toDouble());
informationChangeHash.insert(variantProperty.parentModelNode(), Transform);
} else if (variantProperty.name() == "y") {
NodeInstance instance = instanceForModelNode(variantProperty.parentModelNode());
instance.setY(variantProperty.value().toDouble());
informationChangeHash.insert(variantProperty.parentModelNode(), Transform);
}
}
if (!informationChangeHash.isEmpty())
emitInstanceInformationsChange(informationChangeHash);
}
NodeInstanceServerInterface *NodeInstanceView::nodeInstanceServer() const
{
return m_nodeInstanceServer.data();
......
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