diff options
author | Marco Bubke <marco.bubke@nokia.com> | 2011-07-06 15:48:21 +0200 |
---|---|---|
committer | Marco Bubke <marco.bubke@nokia.com> | 2011-07-06 18:19:28 +0200 |
commit | 765ba3b4b99c289b268907b9fefffad545fdb120 (patch) | |
tree | a304e3ae8904b32edf58516bce08a712632b817c /share/qtcreator | |
parent | a4c4d67772cf243e9f694e78129bf9a24d0304b0 (diff) | |
download | qt-creator-765ba3b4b99c289b268907b9fefffad545fdb120.tar.gz |
QmlDesigner: Prevent item hoping for reparenting
Because of the asynchronous nature of the formeditor the item can be between
to states. This looks like the item is hoping around. To prevent this a token
is sent to the instances and back. For the time frame the painting is disabled.
Change-Id: If7e937cba8171248464ad350bb14438c020b25f9
Reviewed-on: http://codereview.qt.nokia.com/1189
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Alessandro Portale <alessandro.portale@nokia.com>
Diffstat (limited to 'share/qtcreator')
14 files changed, 294 insertions, 5 deletions
diff --git a/share/qtcreator/qml/qmlpuppet/commands/commands.pri b/share/qtcreator/qml/qmlpuppet/commands/commands.pri index c6c9282d1b..5ae623cf3f 100644 --- a/share/qtcreator/qml/qmlpuppet/commands/commands.pri +++ b/share/qtcreator/qml/qmlpuppet/commands/commands.pri @@ -1,6 +1,7 @@ INCLUDEPATH += $$PWD/ HEADERS += $$PWD/synchronizecommand.h +HEADERS += $$PWD/tokencommand.h HEADERS += $$PWD/componentcompletedcommand.h HEADERS += $$PWD/completecomponentcommand.h HEADERS += $$PWD/statepreviewimagechangedcommand.h @@ -24,6 +25,7 @@ HEADERS += $$PWD/changeauxiliarycommand.h SOURCES += $$PWD/synchronizecommand.cpp +SOURCES += $$PWD/tokencommand.cpp SOURCES += $$PWD/componentcompletedcommand.cpp SOURCES += $$PWD/completecomponentcommand.cpp SOURCES += $$PWD/statepreviewimagechangedcommand.cpp diff --git a/share/qtcreator/qml/qmlpuppet/commands/tokencommand.cpp b/share/qtcreator/qml/qmlpuppet/commands/tokencommand.cpp new file mode 100644 index 0000000000..bb8279a971 --- /dev/null +++ b/share/qtcreator/qml/qmlpuppet/commands/tokencommand.cpp @@ -0,0 +1,114 @@ +/************************************************************************** + +** + +** This file is part of Qt Creator + +** + +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). + +** + +** Contact: Nokia Corporation (qt-info@nokia.com) + +** + +** No Commercial Usage + +** + +** This file contains pre-release code and may not be distributed. + +** You may use this file in accordance with the terms and conditions + +** contained in the Technology Preview License Agreement accompanying + +** this package. + +** + +** GNU Lesser General Public License Usage + +** + +** Alternatively, this file may be used under the terms of the GNU Lesser + +** General Public License version 2.1 as published by the Free Software + +** Foundation and appearing in the file LICENSE.LGPL included in the + +** packaging of this file. Please review the following information to + +** ensure the GNU Lesser General Public License version 2.1 requirements + +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. + +** + +** In addition, as a special exception, Nokia gives you certain additional + +** rights. These rights are described in the Nokia Qt LGPL Exception + +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. + +** + +** If you have questions regarding the use of this file, please contact + +** Nokia at qt-info@nokia.com. + +** + +**************************************************************************/ + +#include "tokencommand.h" + +namespace QmlDesigner { + +TokenCommand::TokenCommand() + : m_tokenNumber(-1) +{ +} + +TokenCommand::TokenCommand(const QString &tokenName, qint32 tokenNumber, const QVector<qint32> &instanceIdVector) + : m_tokenName(tokenName), + m_tokenNumber(tokenNumber), + m_instanceIdVector(instanceIdVector) +{ +} + +QString TokenCommand::tokenName() const +{ + return m_tokenName; +} + +qint32 TokenCommand::tokenNumber() const +{ + return m_tokenNumber; +} + +QVector<qint32> TokenCommand::instances() const +{ + return m_instanceIdVector; +} + +QDataStream &operator<<(QDataStream &out, const TokenCommand &command) +{ + out << command.tokenName(); + out << command.tokenNumber(); + out << command.instances(); + return out; +} + +QDataStream &operator>>(QDataStream &in, TokenCommand &command) +{ + in >> command.m_tokenName; + in >> command.m_tokenNumber; + in >> command.m_instanceIdVector; + + return in; +} + + +} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/commands/tokencommand.h b/share/qtcreator/qml/qmlpuppet/commands/tokencommand.h new file mode 100644 index 0000000000..ef4325a8d7 --- /dev/null +++ b/share/qtcreator/qml/qmlpuppet/commands/tokencommand.h @@ -0,0 +1,100 @@ +/************************************************************************** + +** + +** This file is part of Qt Creator + +** + +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). + +** + +** Contact: Nokia Corporation (qt-info@nokia.com) + +** + +** No Commercial Usage + +** + +** This file contains pre-release code and may not be distributed. + +** You may use this file in accordance with the terms and conditions + +** contained in the Technology Preview License Agreement accompanying + +** this package. + +** + +** GNU Lesser General Public License Usage + +** + +** Alternatively, this file may be used under the terms of the GNU Lesser + +** General Public License version 2.1 as published by the Free Software + +** Foundation and appearing in the file LICENSE.LGPL included in the + +** packaging of this file. Please review the following information to + +** ensure the GNU Lesser General Public License version 2.1 requirements + +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. + +** + +** In addition, as a special exception, Nokia gives you certain additional + +** rights. These rights are described in the Nokia Qt LGPL Exception + +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. + +** + +** If you have questions regarding the use of this file, please contact + +** Nokia at qt-info@nokia.com. + +** + +**************************************************************************/ + +#ifndef QMLDESIGNER_TOKENCOMMAND_H +#define QMLDESIGNER_TOKENCOMMAND_H + + +#include <QMetaType> +#include <QVector> + +namespace QmlDesigner { + +class TokenCommand +{ + friend QDataStream &operator>>(QDataStream &in, TokenCommand &command); + +public: + TokenCommand(); + TokenCommand(const QString &tokenName, qint32 tokenNumber, const QVector<qint32> &instances); + + QString tokenName() const; + qint32 tokenNumber() const; + QVector<qint32> instances() const; + +private: + QString m_tokenName; + qint32 m_tokenNumber; + QVector<qint32> m_instanceIdVector; +}; + +QDataStream &operator<<(QDataStream &out, const TokenCommand &command); +QDataStream &operator>>(QDataStream &in, TokenCommand &command); + +} // namespace QmlDesigner + +Q_DECLARE_METATYPE(QmlDesigner::TokenCommand) + + +#endif // QMLDESIGNER_TOKENCOMMAND_H diff --git a/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.cpp b/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.cpp index ad10cdc57c..bdefc54d91 100644 --- a/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.cpp +++ b/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.cpp @@ -57,6 +57,7 @@ #include "changestatecommand.h" #include "completecomponentcommand.h" #include "synchronizecommand.h" +#include "tokencommand.h" #include "informationchangedcommand.h" #include "pixmapchangedcommand.h" @@ -133,6 +134,11 @@ void NodeInstanceClientProxy::componentCompleted(const ComponentCompletedCommand writeCommand(QVariant::fromValue(command)); } +void NodeInstanceClientProxy::token(const TokenCommand &command) +{ + writeCommand(QVariant::fromValue(command)); +} + void NodeInstanceClientProxy::flush() { } @@ -267,6 +273,10 @@ void NodeInstanceClientProxy::changeNodeSource(const ChangeNodeSourceCommand &co { nodeInstanceServer()->changeNodeSource(command); } +void NodeInstanceClientProxy::redirectToken(const TokenCommand &command) +{ + nodeInstanceServer()->token(command); +} void NodeInstanceClientProxy::dispatchCommand(const QVariant &command) { @@ -285,6 +295,7 @@ void NodeInstanceClientProxy::dispatchCommand(const QVariant &command) static const int completeComponentCommandType = QMetaType::type("CompleteComponentCommand"); static const int synchronizeCommandType = QMetaType::type("SynchronizeCommand"); static const int changeNodeSourceCommandType = QMetaType::type("ChangeNodeSourceCommand"); + static const int tokenCommandType = QMetaType::type("TokenCommand"); if (command.userType() == createInstancesCommandType) { createInstances(command.value<CreateInstancesCommand>()); @@ -314,6 +325,8 @@ void NodeInstanceClientProxy::dispatchCommand(const QVariant &command) completeComponent(command.value<CompleteComponentCommand>()); else if (command.userType() == changeNodeSourceCommandType) changeNodeSource(command.value<ChangeNodeSourceCommand>()); + else if (command.userType() == tokenCommandType) + redirectToken(command.value<TokenCommand>()); else if (command.userType() == synchronizeCommandType) { SynchronizeCommand synchronizeCommand = command.value<SynchronizeCommand>(); m_synchronizeId = synchronizeCommand.synchronizeId(); diff --git a/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.h b/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.h index 0ee07bf354..ba429123f0 100644 --- a/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.h +++ b/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.h @@ -75,6 +75,7 @@ public: void childrenChanged(const ChildrenChangedCommand &command); void statePreviewImagesChanged(const StatePreviewImageChangedCommand &command); void componentCompleted(const ComponentCompletedCommand &command); + void token(const TokenCommand &command); void flush(); void synchronizeWithClientProcess(); @@ -101,6 +102,7 @@ protected: void changeState(const ChangeStateCommand &command); void completeComponent(const CompleteComponentCommand &command); void changeNodeSource(const ChangeNodeSourceCommand &command); + void redirectToken(const TokenCommand &command); private slots: void readDataStream(); diff --git a/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceserver.cpp b/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceserver.cpp index 84f7d8fcd2..5acbc7fcf8 100644 --- a/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceserver.cpp +++ b/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceserver.cpp @@ -74,6 +74,7 @@ #include "componentcompletedcommand.h" #include "createscenecommand.h" #include "changenodesourcecommand.h" +#include "tokencommand.h" #include "dummycontextobject.h" @@ -338,6 +339,11 @@ void NodeInstanceServer::changeNodeSource(const ChangeNodeSourceCommand &command startRenderTimer(); } +void NodeInstanceServer::token(const TokenCommand &/*command*/) +{ + +} + void NodeInstanceServer::setupImports(const QVector<AddImportContainer> &containerVector) { foreach (const AddImportContainer &container, containerVector) { diff --git a/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceserver.h b/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceserver.h index bd45ec4849..ea24316fda 100644 --- a/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceserver.h +++ b/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceserver.h @@ -92,6 +92,7 @@ public: void changeState(const ChangeStateCommand &command); void completeComponent(const CompleteComponentCommand &command); void changeNodeSource(const ChangeNodeSourceCommand &command); + void token(const TokenCommand &command); ServerNodeInstance instanceForId(qint32 id) const; bool hasInstanceForId(qint32 id) const; @@ -152,7 +153,6 @@ protected: virtual void collectItemChangesAndSendChangeCommands() = 0; - ValuesChangedCommand createValuesChangedCommand(const QList<ServerNodeInstance> &instanceList) const; ValuesChangedCommand createValuesChangedCommand(const QVector<InstancePropertyPair> &propertyList) const; PixmapChangedCommand createPixmapChangedCommand(const QList<ServerNodeInstance> &instanceList) const; diff --git a/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceclientinterface.h b/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceclientinterface.h index 77bf3355ef..46f45e794e 100644 --- a/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceclientinterface.h +++ b/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceclientinterface.h @@ -43,6 +43,7 @@ class InformationChangedCommand; class ChildrenChangedCommand; class StatePreviewImageChangedCommand; class ComponentCompletedCommand; +class TokenCommand; class NodeInstanceClientInterface { @@ -53,6 +54,7 @@ public: virtual void childrenChanged(const ChildrenChangedCommand &command) = 0; virtual void statePreviewImagesChanged(const StatePreviewImageChangedCommand &command) = 0; virtual void componentCompleted(const ComponentCompletedCommand &command) = 0; + virtual void token(const TokenCommand &command) = 0; virtual void flush() {}; virtual void synchronizeWithClientProcess() {} diff --git a/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceserverinterface.cpp b/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceserverinterface.cpp index ce2bb01042..c047308ab5 100644 --- a/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceserverinterface.cpp +++ b/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceserverinterface.cpp @@ -61,6 +61,7 @@ #include "statepreviewimagechangedcommand.h" #include "componentcompletedcommand.h" #include "synchronizecommand.h" +#include "tokencommand.h" namespace QmlDesigner { @@ -169,6 +170,9 @@ void NodeInstanceServerInterface::registerCommands() qRegisterMetaType<ChangeAuxiliaryCommand>("ChangeAuxiliaryCommand"); qRegisterMetaTypeStreamOperators<ChangeAuxiliaryCommand>("ChangeAuxiliaryCommand"); + + qRegisterMetaType<TokenCommand>("TokenCommand"); + qRegisterMetaTypeStreamOperators<TokenCommand>("TokenCommand"); } } diff --git a/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceserverinterface.h b/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceserverinterface.h index 98d1fe3865..3ba6597460 100644 --- a/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceserverinterface.h +++ b/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceserverinterface.h @@ -55,6 +55,7 @@ class RemovePropertiesCommand; class ChangeStateCommand; class CompleteComponentCommand; class ChangeNodeSourceCommand; +class TokenCommand; class NodeInstanceServerInterface : public QObject { @@ -81,6 +82,7 @@ public: virtual void changeState(const ChangeStateCommand &command) = 0; virtual void completeComponent(const CompleteComponentCommand &command) = 0; virtual void changeNodeSource(const ChangeNodeSourceCommand &command) = 0; + virtual void token(const TokenCommand &command) = 0; static void registerCommands(); }; diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp index 0997e125d0..c0dd079a9f 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp @@ -60,6 +60,7 @@ #include "completecomponentcommand.h" #include "componentcompletedcommand.h" #include "createscenecommand.h" +#include "tokencommand.h" #include "dummycontextobject.h" @@ -72,6 +73,20 @@ Qt5InformationNodeInstanceServer::Qt5InformationNodeInstanceServer(NodeInstanceC { } +void Qt5InformationNodeInstanceServer::sendTokenBack() +{ + foreach (const TokenCommand &command, m_tokenList) + nodeInstanceClient()->token(command); + + m_tokenList.clear(); +} + +void Qt5InformationNodeInstanceServer::token(const TokenCommand &command) +{ + m_tokenList.append(command); + startRenderTimer(); +} + void Qt5InformationNodeInstanceServer::collectItemChangesAndSendChangeCommands() { static bool inFunction = false; @@ -125,6 +140,8 @@ void Qt5InformationNodeInstanceServer::collectItemChangesAndSendChangeCommands() resetAllItems(); clearChangedPropertyList(); + sendTokenBack(); + if (!informationChangedInstanceSet.isEmpty()) nodeInstanceClient()->informationChanged(createAllInformationChangedCommand(informationChangedInstanceSet.toList())); diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.h index e97e2c25d5..7e969428d6 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.h +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.h @@ -34,6 +34,7 @@ #define QMLDESIGNER_QT5INFORMATIONNODEINSTANCESERVER_H #include "qt5nodeinstanceserver.h" +#include "tokencommand.h" namespace QmlDesigner { @@ -47,14 +48,18 @@ public: void clearScene(const ClearSceneCommand &command); void createScene(const CreateSceneCommand &command); void completeComponent(const CompleteComponentCommand &command); + void token(const TokenCommand &command); protected: void collectItemChangesAndSendChangeCommands(); void sendChildrenChangedCommand(const QList<ServerNodeInstance> childList); + void sendTokenBack(); + private: QSet<ServerNodeInstance> m_parentChangedSet; QList<ServerNodeInstance> m_completedComponentList; + QList<TokenCommand> m_tokenList; }; } // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/qmlpuppet/instances/qt4informationnodeinstanceserver.cpp b/share/qtcreator/qml/qmlpuppet/qmlpuppet/instances/qt4informationnodeinstanceserver.cpp index 9c23b88fbb..48ab73adf9 100644 --- a/share/qtcreator/qml/qmlpuppet/qmlpuppet/instances/qt4informationnodeinstanceserver.cpp +++ b/share/qtcreator/qml/qmlpuppet/qmlpuppet/instances/qt4informationnodeinstanceserver.cpp @@ -75,6 +75,8 @@ #include "completecomponentcommand.h" #include "componentcompletedcommand.h" #include "createscenecommand.h" +#include "tokencommand.h" + #include "dummycontextobject.h" @@ -85,6 +87,20 @@ Qt4InformationNodeInstanceServer::Qt4InformationNodeInstanceServer(NodeInstanceC { } +void Qt4InformationNodeInstanceServer::sendTokenBack() +{ + foreach (const TokenCommand &command, m_tokenList) + nodeInstanceClient()->token(command); + + m_tokenList.clear(); +} + +void Qt4InformationNodeInstanceServer::token(const TokenCommand &command) +{ + m_tokenList.append(command); + startRenderTimer(); +} + void Qt4InformationNodeInstanceServer::collectItemChangesAndSendChangeCommands() { static bool inFunction = false; @@ -143,10 +159,7 @@ void Qt4InformationNodeInstanceServer::collectItemChangesAndSendChangeCommands() clearChangedPropertyList(); resetAllItems(); - if (!m_parentChangedSet.isEmpty()) { - sendChildrenChangedCommand(m_parentChangedSet.toList()); - m_parentChangedSet.clear(); - } + sendTokenBack(); if (!informationChangedInstanceSet.isEmpty()) nodeInstanceClient()->informationChanged(createAllInformationChangedCommand(informationChangedInstanceSet.toList())); @@ -154,6 +167,11 @@ void Qt4InformationNodeInstanceServer::collectItemChangesAndSendChangeCommands() if (!propertyChangedList.isEmpty()) nodeInstanceClient()->valuesChanged(createValuesChangedCommand(propertyChangedList)); + if (!m_parentChangedSet.isEmpty()) { + sendChildrenChangedCommand(m_parentChangedSet.toList()); + m_parentChangedSet.clear(); + } + if (adjustSceneRect) { QRectF boundingRect = rootNodeInstance().boundingRect(); if (boundingRect.isValid()) { diff --git a/share/qtcreator/qml/qmlpuppet/qmlpuppet/instances/qt4informationnodeinstanceserver.h b/share/qtcreator/qml/qmlpuppet/qmlpuppet/instances/qt4informationnodeinstanceserver.h index 1390827ff5..04f3064b6d 100644 --- a/share/qtcreator/qml/qmlpuppet/qmlpuppet/instances/qt4informationnodeinstanceserver.h +++ b/share/qtcreator/qml/qmlpuppet/qmlpuppet/instances/qt4informationnodeinstanceserver.h @@ -34,6 +34,7 @@ #define INFORMATIONNODEINSTANCESERVER_H #include "qt4nodeinstanceserver.h" +#include "tokencommand.h" namespace QmlDesigner { @@ -47,14 +48,17 @@ public: void clearScene(const ClearSceneCommand &command); void createScene(const CreateSceneCommand &command); void completeComponent(const CompleteComponentCommand &command); + void token(const TokenCommand &command); protected: void collectItemChangesAndSendChangeCommands(); void sendChildrenChangedCommand(const QList<ServerNodeInstance> childList); + void sendTokenBack(); private: QSet<ServerNodeInstance> m_parentChangedSet; QList<ServerNodeInstance> m_completedComponentList; + QList<TokenCommand> m_tokenList; }; } // namespace QmlDesigner |