| 
									
										
										
										
											2012-10-02 09:12:39 +02:00
										 |  |  | /****************************************************************************
 | 
					
						
							| 
									
										
										
										
											2011-06-09 15:50:48 +02:00
										 |  |  | ** | 
					
						
							| 
									
										
										
										
											2016-01-15 14:59:14 +01:00
										 |  |  | ** Copyright (C) 2016 The Qt Company Ltd. | 
					
						
							|  |  |  | ** Contact: https://www.qt.io/licensing/
 | 
					
						
							| 
									
										
										
										
											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 | 
					
						
							| 
									
										
										
										
											2016-01-15 14:59:14 +01:00
										 |  |  | ** a written agreement between you and The Qt Company. For licensing terms | 
					
						
							|  |  |  | ** and conditions see https://www.qt.io/terms-conditions. For further
 | 
					
						
							|  |  |  | ** information use the contact form at https://www.qt.io/contact-us.
 | 
					
						
							| 
									
										
										
										
											2011-06-09 15:50:48 +02:00
										 |  |  | ** | 
					
						
							| 
									
										
										
										
											2015-09-18 11:34:48 +02:00
										 |  |  | ** GNU General Public License Usage | 
					
						
							|  |  |  | ** Alternatively, this file may be used under the terms of the GNU | 
					
						
							| 
									
										
										
										
											2016-01-15 14:59:14 +01:00
										 |  |  | ** General Public License version 3 as published by the Free Software | 
					
						
							|  |  |  | ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT | 
					
						
							|  |  |  | ** included in the packaging of this file. Please review the following | 
					
						
							|  |  |  | ** information to ensure the GNU General Public License requirements will | 
					
						
							|  |  |  | ** be met: https://www.gnu.org/licenses/gpl-3.0.html.
 | 
					
						
							| 
									
										
										
										
											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 "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"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-14 12:06:07 +02:00
										 |  |  | #include <designersupportdelegate.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) { | 
					
						
							| 
									
										
										
										
											2014-06-24 17:20:53 +02:00
										 |  |  |                     if (hasInstanceForObject(item)) { | 
					
						
							|  |  |  |                             if (DesignerSupport::isDirty(item, DesignerSupport::ContentUpdateMask)) | 
					
						
							|  |  |  |                                 m_dirtyInstanceSet.insert(instanceForObject(item)); | 
					
						
							| 
									
										
										
										
											2012-10-10 18:25:43 +02:00
										 |  |  |                     } 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()) { | 
					
						
							| 
									
										
										
										
											2019-07-31 12:31:51 +02:00
										 |  |  |                 nodeInstanceClient()->pixmapChanged(createPixmapChangedCommand(QtHelpers::toList(m_dirtyInstanceSet))); | 
					
						
							| 
									
										
										
										
											2011-06-21 15:05:15 +02:00
										 |  |  |                 m_dirtyInstanceSet.clear(); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-06-24 17:19:04 +02:00
										 |  |  |             resetAllItems(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-06-21 15:05:15 +02:00
										 |  |  |             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()) { | 
					
						
							| 
									
										
										
										
											2014-07-02 14:33:15 +02:00
										 |  |  |         if (hasInstanceForId(container.instanceId())) { | 
					
						
							|  |  |  |             ServerNodeInstance instance = instanceForId(container.instanceId()); | 
					
						
							|  |  |  |             if (instance.isValid()) { | 
					
						
							|  |  |  |                 instanceList.append(instance); | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2011-06-09 15:50:48 +02:00
										 |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     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()) { | 
					
						
							| 
									
										
										
										
											2014-07-02 14:33:15 +02:00
										 |  |  |         if (hasInstanceForId(instanceId)) { | 
					
						
							|  |  |  |             ServerNodeInstance instance = instanceForId(instanceId); | 
					
						
							|  |  |  |             if (instance.isValid()) { | 
					
						
							|  |  |  |                 instanceList.append(instance); | 
					
						
							|  |  |  |                 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
 |