2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2011-07-06 15:48:52 +00:00
|
|
|
**
|
2014-01-07 13:27:11 +01:00
|
|
|
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
2012-10-02 09:12:39 +02:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
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
|
|
|
|
** 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-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.
|
2011-07-06 15:48:52 +00:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** 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.
|
|
|
|
**
|
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)
|
|
|
|
: NodeInstanceServer(nodeInstanceClient),
|
|
|
|
m_designerSupport(new DesignerSupport)
|
|
|
|
{
|
|
|
|
addImportString("import QtQuick 2.0\n");
|
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
|
|
|
delete m_designerSupport;
|
|
|
|
m_designerSupport = 0;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
void Qt5NodeInstanceServer::initializeView(const QVector<AddImportContainer> &/*importVector*/)
|
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
|
|
|
QList<ServerNodeInstance> Qt5NodeInstanceServer::setupScene(const CreateSceneCommand &command)
|
|
|
|
{
|
|
|
|
setupFileUrl(command.fileUrl());
|
|
|
|
setupImports(command.imports());
|
2011-07-06 14:43:24 +02:00
|
|
|
setupDummyData(command.fileUrl());
|
2011-06-09 15:50:48 +02:00
|
|
|
|
|
|
|
QList<ServerNodeInstance> instanceList = setupInstances(command);
|
|
|
|
|
2012-09-19 15:57:22 +02:00
|
|
|
quickView()->resize(rootNodeInstance().boundingRect().size().toSize());
|
2011-06-09 15:50:48 +02:00
|
|
|
|
|
|
|
return instanceList;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2012-09-19 15:57:22 +02:00
|
|
|
QList<QQuickItem*> itemList;
|
2011-06-09 15:50:48 +02:00
|
|
|
|
2012-09-19 15:57:22 +02:00
|
|
|
if (quickView()) {
|
2012-10-18 16:51:31 +02:00
|
|
|
itemList.append(quickView()->rootObject());
|
|
|
|
itemList.append(subItems(quickView()->rootObject()));
|
2011-06-09 15:50:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return itemList;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Qt5NodeInstanceServer::refreshBindings()
|
|
|
|
{
|
|
|
|
DesignerSupport::refreshExpressions(context());
|
|
|
|
}
|
|
|
|
|
|
|
|
DesignerSupport *Qt5NodeInstanceServer::designerSupport() const
|
|
|
|
{
|
|
|
|
return m_designerSupport;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Qt5NodeInstanceServer::createScene(const CreateSceneCommand &command)
|
|
|
|
{
|
|
|
|
m_designerSupport = new DesignerSupport;
|
|
|
|
NodeInstanceServer::createScene(command);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Qt5NodeInstanceServer::clearScene(const ClearSceneCommand &command)
|
|
|
|
{
|
|
|
|
delete m_designerSupport;
|
|
|
|
m_designerSupport = 0;
|
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
|