From 56392bf5124dfe5d50d1aeda8aeeacc75534cc57 Mon Sep 17 00:00:00 2001
From: Thomas Hartmann <Thomas.Hartmann@nokia.com>
Date: Thu, 25 Feb 2010 15:32:06 +0100
Subject: [PATCH] QmlDesigner.propertyEditor: setting of anchor targets

---
 .../propertyeditor/propertyeditor.pri         |   6 +-
 .../propertyeditor/propertyeditorvalue.h      |   3 +-
 .../propertyeditor/qmlanchorbindingproxy.cpp  | 198 ++++++++++++++++--
 .../propertyeditor/qmlanchorbindingproxy.h    |  58 ++++-
 .../propertyeditor/siblingcombobox.cpp        | 102 +++++++++
 .../propertyeditor/siblingcombobox.h          |  73 +++++++
 6 files changed, 416 insertions(+), 24 deletions(-)
 create mode 100644 src/plugins/qmldesigner/components/propertyeditor/siblingcombobox.cpp
 create mode 100644 src/plugins/qmldesigner/components/propertyeditor/siblingcombobox.h

diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.pri b/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.pri
index 4d0fc95a6f6..462ef87c814 100644
--- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.pri
+++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.pri
@@ -14,7 +14,8 @@ SOURCES += propertyeditor.cpp \
     layoutwidget.cpp \
     filewidget.cpp \
     propertyeditorvalue.cpp \
-    fontwidget.cpp
+    fontwidget.cpp \
+    siblingcombobox.cpp
 HEADERS += propertyeditor.h \
     qmlanchorbindingproxy.h \
     allpropertiesbox.h \
@@ -28,7 +29,8 @@ HEADERS += propertyeditor.h \
     layoutwidget.h \
     filewidget.h \
     propertyeditorvalue.h \
-    fontwidget.h
+    fontwidget.h \
+    siblingcombobox.h
 QT += declarative
 RESOURCES += propertyeditor.qrc
 FORMS += behaviordialog.ui
diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.h b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.h
index ffce1be50e2..b9c544e32d3 100644
--- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.h
+++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.h
@@ -34,6 +34,7 @@
 #include <QmlPropertyMap>
 #include <qml.h>
 #include <modelnode.h>
+#include <qmlitemnode.h>
 #include <rewritertransaction.h>
 
 class PropertyEditorValue;
@@ -76,7 +77,6 @@ private:
     PropertyEditorValue* m_editorValue;
 };
 
-
 class PropertyEditorValue : public QObject
 {
     Q_OBJECT
@@ -150,4 +150,5 @@ QML_DECLARE_TYPE(PropertyEditorValue);
 QML_DECLARE_TYPE(PropertyEditorNodeWrapper);
 QML_DECLARE_TYPE(QmlPropertyMap);
 
+
 #endif // PROPERTYEDITORVALUE_H
diff --git a/src/plugins/qmldesigner/components/propertyeditor/qmlanchorbindingproxy.cpp b/src/plugins/qmldesigner/components/propertyeditor/qmlanchorbindingproxy.cpp
index 4dd11f2c65a..1cdfbd2d03f 100644
--- a/src/plugins/qmldesigner/components/propertyeditor/qmlanchorbindingproxy.cpp
+++ b/src/plugins/qmldesigner/components/propertyeditor/qmlanchorbindingproxy.cpp
@@ -52,6 +52,28 @@ QmlAnchorBindingProxy::~QmlAnchorBindingProxy()
 void QmlAnchorBindingProxy::setup(const QmlItemNode &fxItemNode)
 {
     m_fxItemNode = fxItemNode;
+
+    m_verticalTarget = m_horizontalTarget = m_topTarget = m_bottomTarget = m_leftTarget = m_rightTarget = m_fxItemNode.modelNode().parentProperty().parentModelNode();
+
+    if (topAnchored())
+        m_topTarget = m_fxItemNode.anchors().instanceAnchor(AnchorLine::Top).qmlItemNode();
+
+    if (bottomAnchored())
+        m_bottomTarget = m_fxItemNode.anchors().instanceAnchor(AnchorLine::Bottom).qmlItemNode();
+
+    if (leftAnchored())
+        m_leftTarget = m_fxItemNode.anchors().instanceAnchor(AnchorLine::Left).qmlItemNode();
+
+    if (rightAnchored())
+        m_rightTarget = m_fxItemNode.anchors().instanceAnchor(AnchorLine::Right).qmlItemNode();
+
+    if (verticalCentered())
+        m_verticalTarget = m_fxItemNode.anchors().instanceAnchor(AnchorLine::VerticalCenter).qmlItemNode();
+
+    if (horizontalCentered())
+        m_horizontalTarget = m_fxItemNode.anchors().instanceAnchor(AnchorLine::HorizontalCenter).qmlItemNode();
+
+
     emit parentChanged();
     emit topAnchorChanged();
     emit bottomAnchorChanged();
@@ -60,6 +82,16 @@ void QmlAnchorBindingProxy::setup(const QmlItemNode &fxItemNode)
     emit centeredHChanged();
     emit centeredVChanged();
     emit anchorsChanged();
+
+    if (m_fxItemNode.hasNodeParent()) {
+        emit itemNodeChanged();
+        emit topTargetChanged();
+        emit bottomTargetChanged();
+        emit leftTargetChanged();
+        emit rightTargetChanged();
+        emit verticalTargetChanged();
+        emit horizontalTargetChanged();
+    }
 }
 
 bool QmlAnchorBindingProxy::hasParent()
@@ -93,6 +125,85 @@ bool QmlAnchorBindingProxy::hasAnchors()
 }
 
 
+void QmlAnchorBindingProxy::setTopTarget(const QVariant &target)
+{
+    QmlItemNode newTarget(target.value<ModelNode>());
+
+    if (newTarget == m_topTarget)
+        return;
+
+    m_topTarget = newTarget;
+    calcTopMargin();
+
+    emit topTargetChanged();
+}
+
+
+void QmlAnchorBindingProxy::setBottomTarget(const QVariant &target)
+{
+    QmlItemNode newTarget(target.value<ModelNode>());
+
+    if (newTarget == m_bottomTarget)
+        return;
+
+    m_bottomTarget = newTarget;
+    calcBottomMargin();
+
+    emit bottomTargetChanged();
+}
+
+void QmlAnchorBindingProxy::setLeftTarget(const QVariant &target)
+{
+    QmlItemNode newTarget(target.value<ModelNode>());
+
+    if (newTarget == m_leftTarget)
+        return;
+
+    m_leftTarget = newTarget;
+    calcLeftMargin();
+
+    emit leftTargetChanged();
+}
+
+void QmlAnchorBindingProxy::setRightTarget(const QVariant &target)
+{
+    QmlItemNode newTarget(target.value<ModelNode>());
+
+    if (newTarget == m_rightTarget)
+        return;
+
+    m_rightTarget = newTarget;
+    calcRightMargin();
+
+    emit rightTargetChanged();
+}
+
+void QmlAnchorBindingProxy::setVerticalTarget(const QVariant &target)
+{
+     QmlItemNode newTarget(target.value<ModelNode>());
+
+    if (newTarget == m_verticalTarget)
+        return;
+
+    m_verticalTarget = newTarget;
+    m_fxItemNode.anchors().setAnchor(AnchorLine::VerticalCenter, m_verticalTarget, AnchorLine::VerticalCenter);
+
+    emit verticalTargetChanged();
+}
+
+void QmlAnchorBindingProxy::setHorizontalTarget(const QVariant &target)
+{
+    QmlItemNode newTarget(target.value<ModelNode>());
+
+    if (newTarget == m_horizontalTarget)
+        return;
+
+    m_horizontalTarget = newTarget;
+    m_fxItemNode.anchors().setAnchor(AnchorLine::HorizontalCenter, m_horizontalTarget, AnchorLine::HorizontalCenter);
+
+    emit horizontalTargetChanged();
+}
+
 void QmlAnchorBindingProxy::resetLayout() {
         m_fxItemNode.anchors().removeAnchors();
         m_fxItemNode.anchors().removeMargins();
@@ -115,11 +226,7 @@ void QmlAnchorBindingProxy::setBottomAnchor(bool anchor)
     if (!anchor) {
         removeBottomAnchor();
     } else {
-
-        qreal bottomMargin =  parentBoundingBox().bottom() - transformedBoundingBox().bottom();
-
-        m_fxItemNode.anchors().setAnchor(AnchorLine::Bottom, m_fxItemNode.modelNode().parentProperty().parentModelNode(), AnchorLine::Bottom);
-        m_fxItemNode.anchors().setMargin(AnchorLine::Bottom, bottomMargin);
+        calcBottomMargin();
     }
     emit bottomAnchorChanged();
 
@@ -138,10 +245,7 @@ void QmlAnchorBindingProxy::setLeftAnchor(bool anchor)
     if (!anchor) {
         removeLeftAnchor();
     } else {
-        qreal leftMargin = transformedBoundingBox().left() - parentBoundingBox().left();
-
-        m_fxItemNode.anchors().setAnchor(AnchorLine::Left, m_fxItemNode.modelNode().parentProperty().parentModelNode(), AnchorLine::Left);
-        m_fxItemNode.anchors().setMargin(AnchorLine::Left, leftMargin);
+        calcLeftMargin();
     }
     emit leftAnchorChanged();
     if (hasAnchors() != anchor)
@@ -159,11 +263,7 @@ void QmlAnchorBindingProxy::setRightAnchor(bool anchor)
     if (!anchor) {
         removeRightAnchor();
     } else {
-
-        qreal rightMargin =  parentBoundingBox().right() - transformedBoundingBox().right();
-
-        m_fxItemNode.anchors().setAnchor(AnchorLine::Right, m_fxItemNode.modelNode().parentProperty().parentModelNode(), AnchorLine::Right);
-        m_fxItemNode.anchors().setMargin(AnchorLine::Right, rightMargin);
+        calcRightMargin();
     }
     emit rightAnchorChanged();
     if (hasAnchors() != anchor)
@@ -177,11 +277,73 @@ void QmlAnchorBindingProxy::setRightAnchor(bool anchor)
     return QRect();
 }
 
+QRectF QmlAnchorBindingProxy::boundingBox(QmlItemNode node)
+{
+    if (node.isValid())
+        return node.instanceTransform().mapRect(node.instanceBoundingRect());
+
+    return QRect();
+}
+
 QRectF QmlAnchorBindingProxy::transformedBoundingBox()
 {
     return m_fxItemNode.instanceTransform().mapRect(m_fxItemNode.instanceBoundingRect());
 }
 
+void QmlAnchorBindingProxy::calcTopMargin()
+{
+    if (m_topTarget == m_fxItemNode.modelNode().parentProperty().parentModelNode()) {
+        qreal topMargin = transformedBoundingBox().top() - parentBoundingBox().top();
+        m_fxItemNode.anchors().setMargin( AnchorLine::Top, topMargin);
+        m_fxItemNode.anchors().setAnchor(AnchorLine::Top, m_topTarget, AnchorLine::Top);
+    } else {
+        qDebug() << boundingBox(m_fxItemNode).top();
+        qDebug() << boundingBox(m_topTarget).bottom();
+        qreal topMargin = boundingBox(m_fxItemNode).top() - boundingBox(m_topTarget).bottom();
+        m_fxItemNode.anchors().setMargin( AnchorLine::Top, topMargin);
+        m_fxItemNode.anchors().setAnchor(AnchorLine::Top, m_topTarget, AnchorLine::Bottom);
+    }
+}
+
+void QmlAnchorBindingProxy::calcBottomMargin()
+{
+    if (m_bottomTarget == m_fxItemNode.modelNode().parentProperty().parentModelNode()) {
+        qreal bottomMargin =  parentBoundingBox().bottom() - transformedBoundingBox().bottom();
+        m_fxItemNode.anchors().setMargin( AnchorLine::Bottom, bottomMargin);
+        m_fxItemNode.anchors().setAnchor(AnchorLine::Bottom, m_bottomTarget, AnchorLine::Bottom);
+    } else {
+        qreal bottomMargin = boundingBox(m_fxItemNode).bottom() - boundingBox(m_rightTarget).top();
+        m_fxItemNode.anchors().setMargin( AnchorLine::Bottom, bottomMargin);
+        m_fxItemNode.anchors().setAnchor(AnchorLine::Bottom, m_bottomTarget, AnchorLine::Top);
+    }
+}
+
+void QmlAnchorBindingProxy::calcLeftMargin()
+{
+    if (m_leftTarget == m_fxItemNode.modelNode().parentProperty().parentModelNode()) {
+        qreal leftMargin = transformedBoundingBox().left() - parentBoundingBox().left();
+        m_fxItemNode.anchors().setMargin(AnchorLine::Left, leftMargin);
+        m_fxItemNode.anchors().setAnchor(AnchorLine::Left, m_leftTarget, AnchorLine::Left);
+    } else {
+        qreal leftMargin = boundingBox(m_fxItemNode).left() - boundingBox(m_leftTarget).right();
+        m_fxItemNode.anchors().setMargin( AnchorLine::Left, leftMargin);
+        m_fxItemNode.anchors().setAnchor(AnchorLine::Left, m_leftTarget, AnchorLine::Right);
+    }
+}
+
+void QmlAnchorBindingProxy::calcRightMargin()
+{
+    if (m_rightTarget == m_fxItemNode.modelNode().parentProperty().parentModelNode()) {
+        qreal rightMargin = transformedBoundingBox().right() - parentBoundingBox().right();
+        m_fxItemNode.anchors().setMargin( AnchorLine::Right, rightMargin);
+        m_fxItemNode.anchors().setAnchor(AnchorLine::Right, m_rightTarget, AnchorLine::Right);
+    } else {
+        qreal rightMargin = boundingBox(m_rightTarget).left() - boundingBox(m_fxItemNode).right();
+        m_fxItemNode.anchors().setMargin( AnchorLine::Right, rightMargin);
+        m_fxItemNode.anchors().setAnchor(AnchorLine::Right, m_rightTarget, AnchorLine::Left);
+    }
+}
+
 void QmlAnchorBindingProxy::setTopAnchor(bool anchor)
 {
     if (!m_fxItemNode.hasNodeParent())
@@ -193,11 +355,7 @@ void QmlAnchorBindingProxy::setTopAnchor(bool anchor)
     if (!anchor) {
         removeTopAnchor();
     } else {
-
-        qreal topMargin = transformedBoundingBox().top() - parentBoundingBox().top();
-
-        m_fxItemNode.anchors().setAnchor(AnchorLine::Top, m_fxItemNode.modelNode().parentProperty().parentModelNode(), AnchorLine::Top);
-        m_fxItemNode.anchors().setMargin( AnchorLine::Top, topMargin);
+        calcTopMargin();
     }
     emit topAnchorChanged();
     if (hasAnchors() != anchor)
@@ -234,6 +392,7 @@ void QmlAnchorBindingProxy::setVerticalCentered(bool centered)
 
     if (!centered) {
         m_fxItemNode.anchors().removeAnchor(AnchorLine::VerticalCenter);
+        m_fxItemNode.anchors().removeMargin(AnchorLine::VerticalCenter);
     } else {
         m_fxItemNode.anchors().setAnchor(AnchorLine::VerticalCenter, m_fxItemNode.modelNode().parentProperty().parentModelNode(), AnchorLine::VerticalCenter);
     }
@@ -250,6 +409,7 @@ void QmlAnchorBindingProxy::setHorizontalCentered(bool centered)
 
     if (!centered) {
         m_fxItemNode.anchors().removeAnchor(AnchorLine::HorizontalCenter);
+        m_fxItemNode.anchors().removeMargin(AnchorLine::HorizontalCenter);
     } else {
         m_fxItemNode.anchors().setAnchor(AnchorLine::HorizontalCenter, m_fxItemNode.modelNode().parentProperty().parentModelNode(), AnchorLine::HorizontalCenter);
     }
diff --git a/src/plugins/qmldesigner/components/propertyeditor/qmlanchorbindingproxy.h b/src/plugins/qmldesigner/components/propertyeditor/qmlanchorbindingproxy.h
index f0144012289..98d6618ab8d 100644
--- a/src/plugins/qmldesigner/components/propertyeditor/qmlanchorbindingproxy.h
+++ b/src/plugins/qmldesigner/components/propertyeditor/qmlanchorbindingproxy.h
@@ -52,10 +52,19 @@ class QmlAnchorBindingProxy : public QObject
     Q_PROPERTY(bool rightAnchored READ rightAnchored WRITE setRightAnchor NOTIFY rightAnchorChanged)
     Q_PROPERTY(bool hasParent READ hasParent NOTIFY parentChanged);
 
+    Q_PROPERTY(QVariant topTarget READ topTarget WRITE setTopTarget NOTIFY topTargetChanged)
+    Q_PROPERTY(QVariant bottomTarget READ bottomTarget WRITE setBottomTarget NOTIFY bottomTargetChanged)
+    Q_PROPERTY(QVariant leftTarget READ leftTarget WRITE setLeftTarget NOTIFY leftTargetChanged)
+    Q_PROPERTY(QVariant rightTarget READ rightTarget WRITE setRightTarget NOTIFY rightTargetChanged)
+
+    Q_PROPERTY(QVariant verticalTarget READ verticalTarget WRITE setVerticalTarget NOTIFY verticalTargetChanged)
+    Q_PROPERTY(QVariant horizontalTarget READ horizontalTarget WRITE setHorizontalTarget NOTIFY horizontalTargetChanged)
+
     Q_PROPERTY(bool hasAnchors READ hasAnchors NOTIFY anchorsChanged)
 
-    Q_PROPERTY(bool verticalCentered READ verticalCentered WRITE setVerticalCentered NOTIFY centeredVChanged)
     Q_PROPERTY(bool horizontalCentered READ horizontalCentered WRITE setHorizontalCentered NOTIFY centeredHChanged)
+    Q_PROPERTY(bool verticalCentered READ verticalCentered WRITE setVerticalCentered NOTIFY centeredVChanged)
+    Q_PROPERTY(QVariant itemNode READ itemNode NOTIFY itemNodeChanged)
 
 public:
     //only enable if node has parent
@@ -78,8 +87,26 @@ public:
     void removeRightAnchor();
     bool hasAnchors();
 
-    bool verticalCentered();
     bool horizontalCentered();
+    bool verticalCentered();
+    QVariant itemNode() const { return QVariant::fromValue(m_fxItemNode.modelNode()); }
+
+    QVariant topTarget() const { return QVariant::fromValue(m_topTarget.modelNode()); }
+    QVariant bottomTarget() const { return QVariant::fromValue(m_bottomTarget.modelNode()); }
+    QVariant leftTarget() const { return QVariant::fromValue(m_leftTarget.modelNode()); }
+    QVariant rightTarget() const { return QVariant::fromValue(m_rightTarget.modelNode()); }
+
+    QVariant verticalTarget() const { return QVariant::fromValue(m_verticalTarget.modelNode()); }
+    QVariant horizontalTarget() const { return QVariant::fromValue(m_horizontalTarget.modelNode()); }
+
+public:
+    void setTopTarget(const QVariant &target);
+    void setBottomTarget(const QVariant &target);
+    void setLeftTarget(const QVariant &target);
+    void setRightTarget(const QVariant &target);
+    void setVerticalTarget(const QVariant &target);
+    void setHorizontalTarget(const QVariant &target);
+
 
 public slots:
     void resetLayout();
@@ -102,11 +129,38 @@ signals:
     void centeredVChanged();
     void centeredHChanged();
     void anchorsChanged();
+    void itemNodeChanged();
+
+    void topTargetChanged();
+    void bottomTargetChanged();
+    void leftTargetChanged();
+    void rightTargetChanged();
+
+    void verticalTargetChanged();
+    void horizontalTargetChanged();
+
 private:
+
+    void calcTopMargin();
+    void calcBottomMargin();
+    void calcLeftMargin();
+    void calcRightMargin();
+
     QmlItemNode m_fxItemNode;
 
     QRectF parentBoundingBox();
+
+    QRectF boundingBox(QmlItemNode node);
+
     QRectF transformedBoundingBox();
+
+    QmlItemNode m_topTarget;
+    QmlItemNode m_bottomTarget;
+    QmlItemNode m_leftTarget;
+    QmlItemNode m_rightTarget;
+
+    QmlItemNode m_verticalTarget;
+    QmlItemNode m_horizontalTarget;
 };
 
 } // namespace Internal
diff --git a/src/plugins/qmldesigner/components/propertyeditor/siblingcombobox.cpp b/src/plugins/qmldesigner/components/propertyeditor/siblingcombobox.cpp
new file mode 100644
index 00000000000..4e6968b8bb9
--- /dev/null
+++ b/src/plugins/qmldesigner/components/propertyeditor/siblingcombobox.cpp
@@ -0,0 +1,102 @@
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** Commercial Usage
+**
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://qt.nokia.com/contact.
+**
+**************************************************************************/
+
+#include "siblingcombobox.h"
+#include <qml.h>
+
+QML_DEFINE_TYPE(Bauhaus,1,0,SiblingComboBox,QmlDesigner::SiblingComboBox)
+
+namespace QmlDesigner {
+
+void SiblingComboBox::setItemNode(const QVariant &itemNode)
+{
+    
+    if (!itemNode.value<ModelNode>().isValid() || !QmlItemNode(itemNode.value<ModelNode>()).hasNodeParent())
+        return;
+    m_itemNode = itemNode.value<ModelNode>();
+    setup();
+    emit itemNodeChanged();
+}
+
+void SiblingComboBox::setSelectedItemNode(const QVariant &itemNode)
+{
+    if (itemNode.value<ModelNode>() == m_selectedItemNode)
+        return;
+    if (!itemNode.value<ModelNode>().isValid())
+        return;
+    m_selectedItemNode = itemNode.value<ModelNode>();
+    setup();
+    emit selectedItemNodeChanged();
+}
+
+void SiblingComboBox::changeSelection(int i)
+{
+    if (i < 0 || m_itemList.at(i) == m_selectedItemNode)
+        return;
+    setSelectedItemNode(QVariant::fromValue(m_itemList.at(i).modelNode()));
+}
+
+void SiblingComboBox::setup()
+{
+    connect(this, SIGNAL(currentIndexChanged (int)), this, SLOT(changeSelection(int)));
+    if (!m_itemNode.isValid())
+        return;
+    m_itemList = m_itemNode.instanceParent().toQmlItemNode().children();
+    m_itemList.removeOne(m_itemNode);
+    
+
+    disconnect(this, SIGNAL(currentIndexChanged (int)), this, SLOT(changeSelection(int)));
+    clear();
+
+    foreach (const QmlItemNode &itemNode, m_itemList) {
+        if (itemNode.isValid())
+            if (itemNode.id().isEmpty())
+                addItem(itemNode.simplfiedTypeName());
+            else
+                addItem(itemNode.id());
+    }
+
+    QmlItemNode parent(m_itemNode.instanceParent().toQmlItemNode());
+    m_itemList.prepend(parent);
+    QString parentString("Parent (");
+
+    if (parent.id().isEmpty())
+        parentString += parent.simplfiedTypeName();
+    else
+        parentString += parent.id();
+    parentString += ")";
+    insertItem(0, parentString);
+
+    setCurrentIndex(m_itemList.indexOf(m_selectedItemNode));
+    connect(this, SIGNAL(currentIndexChanged (int)), this, SLOT(changeSelection(int)));
+
+}
+
+
+} //QmlDesigner
diff --git a/src/plugins/qmldesigner/components/propertyeditor/siblingcombobox.h b/src/plugins/qmldesigner/components/propertyeditor/siblingcombobox.h
new file mode 100644
index 00000000000..36076a7e9c1
--- /dev/null
+++ b/src/plugins/qmldesigner/components/propertyeditor/siblingcombobox.h
@@ -0,0 +1,73 @@
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** Commercial Usage
+**
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://qt.nokia.com/contact.
+**
+**************************************************************************/
+
+#ifndef SIBLINGCOMBOBOX_H
+#define SIBLINGCOMBOBOX_H
+
+#include <QtGui/QComboBox>
+
+#include <qmlitemnode.h>
+
+namespace QmlDesigner {
+
+class SiblingComboBox : public QComboBox
+{
+    Q_OBJECT
+    Q_PROPERTY(QVariant itemNode READ itemNode WRITE setItemNode NOTIFY itemNodeChanged)
+    Q_PROPERTY(QVariant selectedItemNode READ selectedItemNode WRITE setSelectedItemNode NOTIFY selectedItemNodeChanged)
+
+public:
+    SiblingComboBox(QWidget *parent = 0) : QComboBox(parent) {}
+
+    QVariant itemNode() const { return QVariant::fromValue(m_itemNode.modelNode()); }
+    QVariant selectedItemNode() const { return QVariant::fromValue(m_selectedItemNode.modelNode()); }
+
+    void setItemNode(const QVariant &itemNode);
+    void setSelectedItemNode(const QVariant &itemNode);
+
+signals:
+    void selectedItemNodeChanged();
+    void itemNodeChanged();
+
+private slots:
+    void changeSelection(int i);
+
+private:
+    void setup();
+    QmlItemNode m_itemNode;
+    QmlItemNode m_selectedItemNode;
+    QList<QmlItemNode> m_itemList;
+
+
+};
+
+}
+
+#endif //SIBLINGCOMBOBOX_H
+
-- 
GitLab