summaryrefslogtreecommitdiff
path: root/src/plugins/qmldesigner/components/propertyeditor
diff options
context:
space:
mode:
authorThomas Hartmann <Thomas.Hartmann@digia.com>2014-05-19 16:15:06 +0200
committerThomas Hartmann <Thomas.Hartmann@digia.com>2014-05-20 10:56:48 +0200
commit4390a0f11fa3b05532d9817728ad447b42545bd5 (patch)
treed20a80d33e462ce9d7e7cddf6f420606f954d371 /src/plugins/qmldesigner/components/propertyeditor
parent41ac37dd01afcd1e63c871fd64c83ac2547c470e (diff)
downloadqt-creator-4390a0f11fa3b05532d9817728ad447b42545bd5.tar.gz
QmlDesigner.PropertyEditor: Adding QmlModelNodeProxy
We currently use the QmlAnchorBindingProxy in cases that are not related to anchors. Instead this patch adds a separate object for ModelNode that we can use instead. This also adds a proper selectionChanged() signal. Change-Id: Idbcff3a8efcb3343c9d9b379f1d35ab30b02dc50 Reviewed-by: Marco Bubke <marco.bubke@digia.com>
Diffstat (limited to 'src/plugins/qmldesigner/components/propertyeditor')
-rw-r--r--src/plugins/qmldesigner/components/propertyeditor/propertyeditor.pri6
-rw-r--r--src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.cpp12
-rw-r--r--src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.h2
-rw-r--r--src/plugins/qmldesigner/components/propertyeditor/qmlmodelnodeproxy.cpp54
-rw-r--r--src/plugins/qmldesigner/components/propertyeditor/qmlmodelnodeproxy.h61
5 files changed, 131 insertions, 4 deletions
diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.pri b/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.pri
index 0e0e163529..5336225b11 100644
--- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.pri
+++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.pri
@@ -10,7 +10,8 @@ SOURCES += propertyeditorview.cpp \
propertyeditorqmlbackend.cpp \
propertyeditorwidget.cpp \
fileresourcesmodel.cpp \
- components/propertyeditor/gradientmodel.cpp
+ gradientmodel.cpp \
+ qmlmodelnodeproxy.cpp
HEADERS += propertyeditorview.h \
qmlanchorbindingproxy.h \
@@ -22,7 +23,8 @@ HEADERS += propertyeditorview.h \
propertyeditorqmlbackend.h \
propertyeditorwidget.h \
fileresourcesmodel.h \
- components/propertyeditor/gradientmodel.h
+ gradientmodel.h \
+ qmlmodelnodeproxy.h
QT += qml quick
diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.cpp b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.cpp
index 13eba67e89..e985d03870 100644
--- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.cpp
+++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.cpp
@@ -240,13 +240,20 @@ void PropertyEditorQmlBackend::setup(const QmlObjectNode &qmlObjectNode, const Q
QObject::connect(valueObject, SIGNAL(valueChanged(QString,QVariant)), &m_backendValuesPropertyMap, SIGNAL(valueChanged(QString,QVariant)));
m_backendValuesPropertyMap.insert("id", QVariant::fromValue(valueObject));
- // anchors
- m_backendAnchorBinding.setup(QmlItemNode(qmlObjectNode.modelNode()));
+ QmlItemNode itemNode(qmlObjectNode.modelNode());
+ // anchors
+ m_backendAnchorBinding.setup(qmlObjectNode.modelNode());
context()->setContextProperty("anchorBackend", &m_backendAnchorBinding);
+
context()->setContextProperty("transaction", m_propertyEditorTransaction.data());
+
+ // model node
+ m_backendModelNode.setup(qmlObjectNode.modelNode());
+ context()->setContextProperty("modelNodeBackend", &m_backendModelNode);
+
contextObject()->setSpecificsUrl(qmlSpecificsFile);
contextObject()->setStateName(stateName);
@@ -302,6 +309,7 @@ void PropertyEditorQmlBackend::initialSetup(const TypeName &typeName, const QUrl
m_backendValuesPropertyMap.insert("id", QVariant::fromValue(valueObject));
context()->setContextProperty("anchorBackend", &m_backendAnchorBinding);
+ context()->setContextProperty("modelNodeBackend", &m_backendModelNode);
context()->setContextProperty("transaction", m_propertyEditorTransaction.data());
contextObject()->setSpecificsUrl(qmlSpecificsFile);
diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.h b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.h
index 959a0333ca..cccbce7eab 100644
--- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.h
+++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.h
@@ -34,6 +34,7 @@
#include "designerpropertymap.h"
#include "propertyeditorvalue.h"
#include "propertyeditorcontextobject.h"
+#include "qmlmodelnodeproxy.h"
#include "quick2propertyeditorview.h"
#include <nodemetainfo.h>
@@ -88,6 +89,7 @@ private:
private:
Quick2PropertyEditorView *m_view;
Internal::QmlAnchorBindingProxy m_backendAnchorBinding;
+ QmlModelNodeProxy m_backendModelNode;
DesignerPropertyMap m_backendValuesPropertyMap;
QScopedPointer<PropertyEditorTransaction> m_propertyEditorTransaction;
QScopedPointer<PropertyEditorValue> m_dummyPropertyEditorValue;
diff --git a/src/plugins/qmldesigner/components/propertyeditor/qmlmodelnodeproxy.cpp b/src/plugins/qmldesigner/components/propertyeditor/qmlmodelnodeproxy.cpp
new file mode 100644
index 0000000000..d18e5b1f83
--- /dev/null
+++ b/src/plugins/qmldesigner/components/propertyeditor/qmlmodelnodeproxy.cpp
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 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 "qmlmodelnodeproxy.h"
+
+#include <QtQml>
+
+namespace QmlDesigner {
+
+QmlModelNodeProxy::QmlModelNodeProxy(QObject *parent) :
+ QObject(parent)
+{
+}
+
+void QmlModelNodeProxy::setup(const QmlItemNode &itemNode)
+{
+ qDebug() << "QmlModelNodeProxy::setup";
+ m_qmlItemNode = itemNode;
+
+ emit selectionChanged();
+}
+
+void QmlModelNodeProxy::registerDeclarativeType()
+{
+ qmlRegisterType<QmlModelNodeProxy>("HelperWidgets",2,0,"ModelNodeProxy");
+}
+
+}
diff --git a/src/plugins/qmldesigner/components/propertyeditor/qmlmodelnodeproxy.h b/src/plugins/qmldesigner/components/propertyeditor/qmlmodelnodeproxy.h
new file mode 100644
index 0000000000..516477fcfe
--- /dev/null
+++ b/src/plugins/qmldesigner/components/propertyeditor/qmlmodelnodeproxy.h
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 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 QMLMODELNODEPROXY_H
+#define QMLMODELNODEPROXY_H
+
+#include <qmlitemnode.h>
+
+#include <QObject>
+
+namespace QmlDesigner {
+
+class QmlModelNodeProxy : public QObject
+{
+ Q_OBJECT
+
+public:
+ explicit QmlModelNodeProxy(QObject *parent = 0);
+
+ void setup(const QmlItemNode &itemNode);
+
+ static void registerDeclarativeType();
+
+signals:
+ void selectionChanged();
+
+public slots:
+
+private:
+ QmlItemNode m_qmlItemNode;
+};
+
+} //QmlDesigner
+
+#endif // QMLMODELNODEPROXY_H