2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2011-07-06 15:48:52 +00:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** Copyright (C) 2015 The Qt Company Ltd.
|
|
|
|
** Contact: http://www.qt.io/licensing
|
2011-07-06 15:48:52 +00:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2011-07-06 15:48:52 +00: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
|
2015-01-14 18:07:15 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms and
|
|
|
|
** conditions see http://www.qt.io/terms-conditions. For further information
|
2014-10-01 13:21:18 +02:00
|
|
|
** use the contact form at http://www.qt.io/contact-us.
|
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
|
2014-10-01 13:21:18 +02:00
|
|
|
** General Public License version 2.1 or version 3 as published by the Free
|
|
|
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
|
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
|
|
** following information to ensure the GNU Lesser General Public License
|
|
|
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2011-07-06 15:48:52 +00:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** In addition, as a special exception, The Qt Company gives you certain additional
|
|
|
|
** rights. These rights are described in The Qt Company LGPL Exception
|
2011-07-06 15:48:52 +00:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2011-06-09 15:50:48 +02:00
|
|
|
|
|
|
|
#include "qt5nodeinstanceserver.h"
|
|
|
|
|
|
|
|
|
2012-09-19 15:57:22 +02:00
|
|
|
#include <QQuickItem>
|
|
|
|
#include <QQuickView>
|
2011-06-09 15:50:48 +02:00
|
|
|
|
2011-08-31 18:27:41 +02:00
|
|
|
#include <designersupport.h>
|
2011-06-09 15:50:48 +02:00
|
|
|
#include <addimportcontainer.h>
|
|
|
|
#include <createscenecommand.h>
|
2013-06-06 16:33:04 +02:00
|
|
|
#include <reparentinstancescommand.h>
|
2011-06-09 15:50:48 +02:00
|
|
|
|
|
|
|
namespace QmlDesigner {
|
|
|
|
|
|
|
|
Qt5NodeInstanceServer::Qt5NodeInstanceServer(NodeInstanceClientInterface *nodeInstanceClient)
|
2014-10-16 13:56:47 +02:00
|
|
|
: NodeInstanceServer(nodeInstanceClient)
|
2011-06-09 15:50:48 +02:00
|
|
|
{
|
2012-11-15 11:55:47 +01:00
|
|
|
DesignerSupport::activateDesignerMode();
|
2011-06-09 15:50:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Qt5NodeInstanceServer::~Qt5NodeInstanceServer()
|
|
|
|
{
|
2012-09-19 15:57:22 +02:00
|
|
|
delete quickView();
|
2011-06-09 15:50:48 +02:00
|
|
|
}
|
|
|
|
|
2012-09-19 15:57:22 +02:00
|
|
|
QQuickView *Qt5NodeInstanceServer::quickView() const
|
2011-06-09 15:50:48 +02:00
|
|
|
{
|
2012-09-19 15:57:22 +02:00
|
|
|
return m_quickView.data();
|
2011-06-09 15:50:48 +02:00
|
|
|
}
|
|
|
|
|
2014-09-25 12:57:57 +02:00
|
|
|
void Qt5NodeInstanceServer::initializeView()
|
2011-06-09 15:50:48 +02:00
|
|
|
{
|
2012-09-19 15:57:22 +02:00
|
|
|
Q_ASSERT(!quickView());
|
|
|
|
|
|
|
|
m_quickView = new QQuickView;
|
2012-10-10 17:14:31 +02:00
|
|
|
DesignerSupport::createOpenGLContext(m_quickView.data());
|
2011-06-09 15:50:48 +02:00
|
|
|
}
|
|
|
|
|
2012-09-19 15:57:22 +02:00
|
|
|
QQmlView *Qt5NodeInstanceServer::declarativeView() const
|
2011-06-09 15:50:48 +02:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-09-19 15:57:22 +02:00
|
|
|
QQmlEngine *Qt5NodeInstanceServer::engine() const
|
2011-06-09 15:50:48 +02:00
|
|
|
{
|
2012-09-19 15:57:22 +02:00
|
|
|
if (quickView())
|
|
|
|
return quickView()->engine();
|
2011-06-09 15:50:48 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Qt5NodeInstanceServer::resizeCanvasSizeToRootItemSize()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void Qt5NodeInstanceServer::resetAllItems()
|
|
|
|
{
|
2012-09-19 15:57:22 +02:00
|
|
|
foreach (QQuickItem *item, allItems())
|
2011-06-21 15:05:15 +02:00
|
|
|
DesignerSupport::resetDirty(item);
|
2011-06-09 15:50:48 +02:00
|
|
|
}
|
|
|
|
|
2014-12-09 14:50:13 +01:00
|
|
|
void Qt5NodeInstanceServer::setupScene(const CreateSceneCommand &command)
|
2011-06-09 15:50:48 +02:00
|
|
|
{
|
|
|
|
setupFileUrl(command.fileUrl());
|
2015-02-18 13:32:35 +01:00
|
|
|
setupImports(command.imports(), command.ids());
|
2011-07-06 14:43:24 +02:00
|
|
|
setupDummyData(command.fileUrl());
|
2011-06-09 15:50:48 +02:00
|
|
|
|
2014-12-09 14:50:13 +01:00
|
|
|
setupInstances(command);
|
2012-09-19 15:57:22 +02:00
|
|
|
quickView()->resize(rootNodeInstance().boundingRect().size().toSize());
|
2011-06-09 15:50:48 +02:00
|
|
|
}
|
|
|
|
|
2012-09-19 15:57:22 +02:00
|
|
|
QList<QQuickItem*> subItems(QQuickItem *parentItem)
|
2011-06-09 15:50:48 +02:00
|
|
|
{
|
2012-09-19 15:57:22 +02:00
|
|
|
QList<QQuickItem*> itemList;
|
2011-06-09 15:50:48 +02:00
|
|
|
itemList.append(parentItem->childItems());
|
|
|
|
|
2012-09-19 15:57:22 +02:00
|
|
|
foreach (QQuickItem *childItem, parentItem->childItems())
|
2011-06-09 15:50:48 +02:00
|
|
|
itemList.append(subItems(childItem));
|
|
|
|
|
|
|
|
return itemList;
|
|
|
|
}
|
|
|
|
|
2012-09-19 15:57:22 +02:00
|
|
|
QList<QQuickItem*> Qt5NodeInstanceServer::allItems() const
|
2011-06-09 15:50:48 +02:00
|
|
|
{
|
2014-04-16 12:33:50 +02:00
|
|
|
if (rootNodeInstance().isValid())
|
|
|
|
return rootNodeInstance().allItemsRecursive();
|
2011-06-09 15:50:48 +02:00
|
|
|
|
2014-04-16 12:33:50 +02:00
|
|
|
return QList<QQuickItem*>();
|
2011-06-09 15:50:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void Qt5NodeInstanceServer::refreshBindings()
|
|
|
|
{
|
|
|
|
DesignerSupport::refreshExpressions(context());
|
|
|
|
}
|
|
|
|
|
2014-10-16 13:56:47 +02:00
|
|
|
DesignerSupport *Qt5NodeInstanceServer::designerSupport()
|
2011-06-09 15:50:48 +02:00
|
|
|
{
|
2014-10-16 13:56:47 +02:00
|
|
|
return &m_designerSupport;
|
2011-06-09 15:50:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void Qt5NodeInstanceServer::createScene(const CreateSceneCommand &command)
|
|
|
|
{
|
|
|
|
NodeInstanceServer::createScene(command);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Qt5NodeInstanceServer::clearScene(const ClearSceneCommand &command)
|
|
|
|
{
|
2012-10-11 13:32:27 +02:00
|
|
|
NodeInstanceServer::clearScene(command);
|
2011-06-09 15:50:48 +02:00
|
|
|
}
|
|
|
|
|
2013-06-06 16:33:04 +02:00
|
|
|
void Qt5NodeInstanceServer::reparentInstances(const ReparentInstancesCommand &command)
|
|
|
|
{
|
|
|
|
NodeInstanceServer::reparentInstances(command.reparentInstances());
|
|
|
|
startRenderTimer();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-06-09 15:50:48 +02:00
|
|
|
} // QmlDesigner
|