| 
									
										
										
										
											2012-10-02 09:12:39 +02:00
										 |  |  | /****************************************************************************
 | 
					
						
							| 
									
										
										
										
											2011-06-09 15:50:48 +02:00
										 |  |  | ** | 
					
						
							| 
									
										
										
										
											2013-01-28 17:12:19 +01:00
										 |  |  | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). | 
					
						
							| 
									
										
										
										
											2012-10-02 09:12:39 +02:00
										 |  |  | ** Contact: http://www.qt-project.org/legal
 | 
					
						
							| 
									
										
										
										
											2011-06-09 15:50:48 +02:00
										 |  |  | ** | 
					
						
							| 
									
										
										
										
											2012-10-02 09:12:39 +02:00
										 |  |  | ** This file is part of Qt Creator. | 
					
						
							| 
									
										
										
										
											2011-06-09 15:50:48 +02:00
										 |  |  | ** | 
					
						
							| 
									
										
										
										
											2012-10-02 09:12:39 +02:00
										 |  |  | ** Commercial License Usage | 
					
						
							|  |  |  | ** Licensees holding valid commercial Qt licenses may use this file in | 
					
						
							|  |  |  | ** accordance with the commercial license agreement provided with the | 
					
						
							|  |  |  | ** Software or, alternatively, in accordance with the terms contained in | 
					
						
							|  |  |  | ** a written agreement between you and Digia.  For licensing terms and | 
					
						
							|  |  |  | ** conditions see http://qt.digia.com/licensing.  For further information
 | 
					
						
							|  |  |  | ** use the contact form at http://qt.digia.com/contact-us.
 | 
					
						
							| 
									
										
										
										
											2011-06-09 15:50:48 +02:00
										 |  |  | ** | 
					
						
							| 
									
										
										
										
											2011-07-06 15:48:52 +00:00
										 |  |  | ** GNU Lesser General Public License Usage | 
					
						
							| 
									
										
										
										
											2012-10-02 09:12:39 +02:00
										 |  |  | ** 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, Digia gives you certain additional | 
					
						
							|  |  |  | ** rights.  These rights are described in the Digia Qt LGPL Exception | 
					
						
							| 
									
										
										
										
											2011-07-06 15:48:52 +00:00
										 |  |  | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | 
					
						
							| 
									
										
										
										
											2011-06-09 15:50:48 +02:00
										 |  |  | ** | 
					
						
							| 
									
										
										
										
											2012-10-02 09:12:39 +02:00
										 |  |  | ****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2011-06-09 15:50:48 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include "qt5rendernodeinstanceserver.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-09-19 15:57:22 +02:00
										 |  |  | #include <QQuickItem>
 | 
					
						
							| 
									
										
										
										
											2012-10-10 17:14:31 +02:00
										 |  |  | #include <QQuickView>
 | 
					
						
							| 
									
										
										
										
											2011-06-21 15:05:15 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-06-09 15:50:48 +02:00
										 |  |  | #include "servernodeinstance.h"
 | 
					
						
							|  |  |  | #include "childrenchangeeventfilter.h"
 | 
					
						
							|  |  |  | #include "propertyabstractcontainer.h"
 | 
					
						
							|  |  |  | #include "propertybindingcontainer.h"
 | 
					
						
							|  |  |  | #include "propertyvaluecontainer.h"
 | 
					
						
							|  |  |  | #include "instancecontainer.h"
 | 
					
						
							|  |  |  | #include "createinstancescommand.h"
 | 
					
						
							|  |  |  | #include "changefileurlcommand.h"
 | 
					
						
							|  |  |  | #include "clearscenecommand.h"
 | 
					
						
							|  |  |  | #include "reparentinstancescommand.h"
 | 
					
						
							|  |  |  | #include "changevaluescommand.h"
 | 
					
						
							|  |  |  | #include "changebindingscommand.h"
 | 
					
						
							|  |  |  | #include "changeidscommand.h"
 | 
					
						
							|  |  |  | #include "removeinstancescommand.h"
 | 
					
						
							|  |  |  | #include "nodeinstanceclientinterface.h"
 | 
					
						
							|  |  |  | #include "removepropertiescommand.h"
 | 
					
						
							|  |  |  | #include "valueschangedcommand.h"
 | 
					
						
							|  |  |  | #include "informationchangedcommand.h"
 | 
					
						
							|  |  |  | #include "pixmapchangedcommand.h"
 | 
					
						
							|  |  |  | #include "commondefines.h"
 | 
					
						
							|  |  |  | #include "childrenchangeeventfilter.h"
 | 
					
						
							|  |  |  | #include "changestatecommand.h"
 | 
					
						
							|  |  |  | #include "childrenchangedcommand.h"
 | 
					
						
							|  |  |  | #include "completecomponentcommand.h"
 | 
					
						
							|  |  |  | #include "componentcompletedcommand.h"
 | 
					
						
							|  |  |  | #include "createscenecommand.h"
 | 
					
						
							| 
									
										
										
										
											2012-09-25 17:05:00 +02:00
										 |  |  | #include "quickitemnodeinstance.h"
 | 
					
						
							| 
									
										
										
										
											2012-09-19 15:57:22 +02:00
										 |  |  | #include "removesharedmemorycommand.h"
 | 
					
						
							| 
									
										
										
										
											2011-06-09 15:50:48 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include "dummycontextobject.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-08-31 18:27:41 +02:00
										 |  |  | #include <designersupport.h>
 | 
					
						
							| 
									
										
										
										
											2011-06-21 15:05:15 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-06-09 15:50:48 +02:00
										 |  |  | namespace QmlDesigner { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Qt5RenderNodeInstanceServer::Qt5RenderNodeInstanceServer(NodeInstanceClientInterface *nodeInstanceClient) : | 
					
						
							|  |  |  |     Qt5NodeInstanceServer(nodeInstanceClient) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-09-19 15:57:22 +02:00
										 |  |  |     Internal::QuickItemNodeInstance::createEffectItem(true); | 
					
						
							| 
									
										
										
										
											2011-06-09 15:50:48 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void Qt5RenderNodeInstanceServer::collectItemChangesAndSendChangeCommands() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2011-06-21 15:05:15 +02:00
										 |  |  |     static bool inFunction = false; | 
					
						
							|  |  |  |     if (!inFunction) { | 
					
						
							|  |  |  |         inFunction = true; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-16 16:32:54 +02:00
										 |  |  |         DesignerSupport::polishItems(quickView()); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-09-19 15:57:22 +02:00
										 |  |  |         if (quickView() && nodeInstanceClient()->bytesToWrite() < 10000) { | 
					
						
							|  |  |  |             foreach (QQuickItem *item, allItems()) { | 
					
						
							| 
									
										
										
										
											2012-10-10 18:25:43 +02:00
										 |  |  |                 if (item) { | 
					
						
							|  |  |  |                     if (hasInstanceForObject(item) | 
					
						
							|  |  |  |                             && DesignerSupport::isDirty(item, DesignerSupport::ContentUpdateMask)) { | 
					
						
							|  |  |  |                         m_dirtyInstanceSet.insert(instanceForObject(item)); | 
					
						
							|  |  |  |                     } else if (DesignerSupport::isDirty(item, DesignerSupport::AllMask)) { | 
					
						
							|  |  |  |                         ServerNodeInstance ancestorInstance = findNodeInstanceForItem(item->parentItem()); | 
					
						
							|  |  |  |                         if (ancestorInstance.isValid()) | 
					
						
							|  |  |  |                             m_dirtyInstanceSet.insert(ancestorInstance); | 
					
						
							|  |  |  |                     } | 
					
						
							| 
									
										
										
										
											2012-10-15 12:49:01 +02:00
										 |  |  |                     DesignerSupport::updateDirtyNode(item); | 
					
						
							| 
									
										
										
										
											2011-06-21 15:05:15 +02:00
										 |  |  |                 } | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             clearChangedPropertyList(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-08-31 18:22:26 +02:00
										 |  |  |             if (!m_dirtyInstanceSet.isEmpty()) { | 
					
						
							| 
									
										
										
										
											2011-06-21 15:05:15 +02:00
										 |  |  |                 nodeInstanceClient()->pixmapChanged(createPixmapChangedCommand(m_dirtyInstanceSet.toList())); | 
					
						
							|  |  |  |                 m_dirtyInstanceSet.clear(); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             slowDownRenderTimer(); | 
					
						
							|  |  |  |             nodeInstanceClient()->flush(); | 
					
						
							|  |  |  |             nodeInstanceClient()->synchronizeWithClientProcess(); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         inFunction = false; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2011-06-09 15:50:48 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-10 18:25:43 +02:00
										 |  |  | ServerNodeInstance Qt5RenderNodeInstanceServer::findNodeInstanceForItem(QQuickItem *item) const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (item) { | 
					
						
							|  |  |  |         if (hasInstanceForObject(item)) | 
					
						
							|  |  |  |             return instanceForObject(item); | 
					
						
							|  |  |  |         else if (item->parentItem()) | 
					
						
							|  |  |  |             return findNodeInstanceForItem(item->parentItem()); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return ServerNodeInstance(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-06-21 15:05:15 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-06-09 15:50:48 +02:00
										 |  |  | void Qt5RenderNodeInstanceServer::createScene(const CreateSceneCommand &command) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2011-08-29 20:51:43 +02:00
										 |  |  |     Qt5NodeInstanceServer::createScene(command); | 
					
						
							| 
									
										
										
										
											2011-06-09 15:50:48 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     QList<ServerNodeInstance> instanceList; | 
					
						
							|  |  |  |     foreach (const InstanceContainer &container, command.instances()) { | 
					
						
							|  |  |  |         ServerNodeInstance instance = instanceForId(container.instanceId()); | 
					
						
							|  |  |  |         if (instance.isValid()) { | 
					
						
							|  |  |  |             instanceList.append(instance); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     nodeInstanceClient()->pixmapChanged(createPixmapChangedCommand(instanceList)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void Qt5RenderNodeInstanceServer::clearScene(const ClearSceneCommand &command) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2011-08-29 20:51:43 +02:00
										 |  |  |     Qt5NodeInstanceServer::clearScene(command); | 
					
						
							| 
									
										
										
										
											2011-06-09 15:50:48 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     m_dirtyInstanceSet.clear(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void Qt5RenderNodeInstanceServer::completeComponent(const CompleteComponentCommand &command) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2011-08-29 20:51:43 +02:00
										 |  |  |     Qt5NodeInstanceServer::completeComponent(command); | 
					
						
							| 
									
										
										
										
											2011-06-09 15:50:48 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     QList<ServerNodeInstance> instanceList; | 
					
						
							|  |  |  |     foreach (qint32 instanceId, command.instances()) { | 
					
						
							|  |  |  |         ServerNodeInstance instance = instanceForId(instanceId); | 
					
						
							|  |  |  |         if (instance.isValid()) { | 
					
						
							|  |  |  |             instanceList.append(instance); | 
					
						
							| 
									
										
										
										
											2011-08-29 20:51:43 +02:00
										 |  |  |             m_dirtyInstanceSet.insert(instance); | 
					
						
							| 
									
										
										
										
											2011-06-09 15:50:48 +02:00
										 |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     nodeInstanceClient()->pixmapChanged(createPixmapChangedCommand(instanceList)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-09-11 15:11:34 +02:00
										 |  |  | void QmlDesigner::Qt5RenderNodeInstanceServer::removeSharedMemory(const QmlDesigner::RemoveSharedMemoryCommand &command) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (command.typeName() == "Image") | 
					
						
							| 
									
										
										
										
											2012-09-19 15:57:22 +02:00
										 |  |  |         ImageContainer::removeSharedMemorys(command.keyNumbers()); | 
					
						
							| 
									
										
										
										
											2012-09-11 15:11:34 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-06-09 15:50:48 +02:00
										 |  |  | } // namespace QmlDesigner
 |