diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/graphicalnodeinstance.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/graphicalnodeinstance.h index 28867a60cc0..4aaa414d8f2 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/graphicalnodeinstance.h +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/graphicalnodeinstance.h @@ -11,8 +11,8 @@ namespace Internal { class GraphicalNodeInstance : public ObjectNodeInstance { public: - typedef QSharedPointer Pointer; - typedef QWeakPointer WeakPointer; + typedef QSharedPointer Pointer; + typedef QWeakPointer WeakPointer; ~GraphicalNodeInstance(); diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/instances.pri b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/instances.pri index 60db67d7fdd..2bb894ef1bc 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/instances.pri +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/instances.pri @@ -23,6 +23,7 @@ HEADERS += $$PWD/servernodeinstance.h HEADERS += $$PWD/anchorchangesnodeinstance.h HEADERS += $$PWD/positionernodeinstance.h HEADERS += $$PWD/quickwindownodeinstance.h +HEADERS += $$PWD/layoutnodeinstance.h SOURCES += $$PWD/qt5nodeinstanceserver.cpp SOURCES += $$PWD/graphicalnodeinstance.cpp @@ -47,3 +48,4 @@ SOURCES += $$PWD/servernodeinstance.cpp SOURCES += $$PWD/anchorchangesnodeinstance.cpp SOURCES += $$PWD/positionernodeinstance.cpp SOURCES += $$PWD/quickwindownodeinstance.cpp +SOURCES += $$PWD/layoutnodeinstance.cpp diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/layoutnodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/layoutnodeinstance.cpp new file mode 100644 index 00000000000..ca7071f6925 --- /dev/null +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/layoutnodeinstance.cpp @@ -0,0 +1,94 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of Qt Creator. +** +** 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. +** +** 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ +#include "layoutnodeinstance.h" + +namespace QmlDesigner { +namespace Internal { + +LayoutNodeInstance::LayoutNodeInstance(QQuickItem *item) + : QuickItemNodeInstance(item) +{ +} + +bool LayoutNodeInstance::isLayoutable() const +{ + return true; +} + +bool LayoutNodeInstance::isResizable() const +{ + return true; +} + +void LayoutNodeInstance::setPropertyVariant(const PropertyName &name, const QVariant &value) +{ + if (name == "move" || name == "add" || name == "populate") + return; + + QuickItemNodeInstance::setPropertyVariant(name, value); +} + +void LayoutNodeInstance::setPropertyBinding(const PropertyName &name, const QString &expression) +{ + if (name == "move" || name == "add" || name == "populate") + return; + + QuickItemNodeInstance::setPropertyBinding(name, expression); +} + +LayoutNodeInstance::Pointer LayoutNodeInstance::create(QObject *object) +{ + qDebug() << "layout" << object; + QQuickItem *item = qobject_cast(object); + + Q_ASSERT(item); + + Pointer instance(new LayoutNodeInstance(item)); + + instance->setHasContent(anyItemHasContent(item)); + item->setFlag(QQuickItem::ItemHasContents, true); + + static_cast(item)->classBegin(); + + instance->populateResetHashes(); + + return instance; +} + +void LayoutNodeInstance::refreshLayoutable() +{ + qDebug() << "before"; + if (quickItem()->parent()) + QCoreApplication::postEvent(quickItem(), new QEvent(QEvent::LayoutRequest)); + qDebug() << "refresh"; + +} + +} +} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/layoutnodeinstance.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/layoutnodeinstance.h new file mode 100644 index 00000000000..7a92f83b044 --- /dev/null +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/layoutnodeinstance.h @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of Qt Creator. +** +** 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. +** +** 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef LAYOUTNODEINSTANCE_H +#define LAYOUTNODEINSTANCE_H + +#include "quickitemnodeinstance.h" + +namespace QmlDesigner { +namespace Internal { + +class LayoutNodeInstance : public QuickItemNodeInstance +{ + +public: + typedef QSharedPointer Pointer; + typedef QWeakPointer WeakPointer; + + static Pointer create(QObject *objectToBeWrapped); + + void setPropertyVariant(const PropertyName &name, const QVariant &value) Q_DECL_OVERRIDE; + void setPropertyBinding(const PropertyName &name, const QString &expression) Q_DECL_OVERRIDE; + + bool isLayoutable() const Q_DECL_OVERRIDE; + + bool isResizable() const Q_DECL_OVERRIDE; + + void refreshLayoutable() Q_DECL_OVERRIDE; + +protected: + LayoutNodeInstance(QQuickItem *item); +}; + +} // namespace Internal +} // namespace QmlDesigner + +#endif // LAYOUTNODEINSTANCE_H diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.cpp index 7a8e0e65013..fd9a16b6d20 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.cpp @@ -37,6 +37,7 @@ #include "qmlstatenodeinstance.h" #include "anchorchangesnodeinstance.h" #include "positionernodeinstance.h" +#include "layoutnodeinstance.h" #include "debugoutputcommand.h" #include "quickitemnodeinstance.h" @@ -181,6 +182,8 @@ Internal::ObjectNodeInstance::Pointer ServerNodeInstance::createInstance(QObject instance = Internal::DummyNodeInstance::create(); else if (isSubclassOf(objectToBeWrapped, "QQuickBasePositioner")) instance = Internal::PositionerNodeInstance::create(objectToBeWrapped); + else if (isSubclassOf(objectToBeWrapped, "QQuickLayout")) + instance = Internal::LayoutNodeInstance::create(objectToBeWrapped); else if (isSubclassOf(objectToBeWrapped, "QQuickItem")) instance = Internal::QuickItemNodeInstance::create(objectToBeWrapped); else if (isSubclassOf(objectToBeWrapped, "QQmlComponent"))