Commit 45756697 authored by Marco Bubke's avatar Marco Bubke

QmlDesigner.Instances: adding LayoutNodeInstance

This class wraps a QQuickLayout.

Change-Id: Ib661ccb5bb5deb1acb87b9a4bef8da95cb4e40eb
Reviewed-by: default avatarThomas Hartmann <Thomas.Hartmann@digia.com>
parent ff4457bb
......@@ -11,8 +11,8 @@ namespace Internal {
class GraphicalNodeInstance : public ObjectNodeInstance
{
public:
typedef QSharedPointer<QuickItemNodeInstance> Pointer;
typedef QWeakPointer<QuickItemNodeInstance> WeakPointer;
typedef QSharedPointer<GraphicalNodeInstance> Pointer;
typedef QWeakPointer<GraphicalNodeInstance> WeakPointer;
~GraphicalNodeInstance();
......
......@@ -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
/****************************************************************************
**
** 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<QQuickItem*>(object);
Q_ASSERT(item);
Pointer instance(new LayoutNodeInstance(item));
instance->setHasContent(anyItemHasContent(item));
item->setFlag(QQuickItem::ItemHasContents, true);
static_cast<QQmlParserStatus*>(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
/****************************************************************************
**
** 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<LayoutNodeInstance> Pointer;
typedef QWeakPointer<LayoutNodeInstance> 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
......@@ -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"))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment