From 0b010954ad485ca3df986bf39a933df437d30fad Mon Sep 17 00:00:00 2001
From: Lasse Holmstedt <lasse.holmstedt@nokia.com>
Date: Mon, 22 Mar 2010 11:39:14 +0100
Subject: [PATCH] Help for qml inspector (with F1), namespace fixes

---
 .../components/canvasframerate.cpp            |  6 ++-
 .../qmlinspector/components/canvasframerate.h | 14 ++++--
 .../components/expressionquerywidget.cpp      | 14 ++++++
 .../components/expressionquerywidget.h        | 11 ++++-
 .../components/objectpropertiesview.cpp       | 17 +++++++
 .../components/objectpropertiesview.h         |  8 +++-
 .../qmlinspector/components/objecttree.cpp    | 20 ++++++++-
 .../qmlinspector/components/objecttree.h      | 11 ++++-
 .../qmlinspector/components/watchtable.cpp    |  9 +++-
 .../qmlinspector/components/watchtable.h      |  9 +++-
 src/plugins/qmlinspector/inspectorcontext.cpp | 26 ++++++++++-
 src/plugins/qmlinspector/inspectorcontext.h   | 16 ++++++-
 src/plugins/qmlinspector/qmlinspector.cpp     | 44 +++++++++++++------
 src/plugins/qmlinspector/qmlinspector.h       | 31 +++++++------
 .../qmlinspector/qmlinspectorplugin.cpp       |  9 ++--
 15 files changed, 197 insertions(+), 48 deletions(-)

diff --git a/src/plugins/qmlinspector/components/canvasframerate.cpp b/src/plugins/qmlinspector/components/canvasframerate.cpp
index 0cd3cab01bc..d3f6179d8f7 100644
--- a/src/plugins/qmlinspector/components/canvasframerate.cpp
+++ b/src/plugins/qmlinspector/components/canvasframerate.cpp
@@ -48,7 +48,8 @@
 #include <QtGui/qevent.h>
 
 
-QT_BEGIN_NAMESPACE
+namespace Qml {
+namespace Internal {
 
 class QLineGraph : public QWidget
 {
@@ -562,6 +563,7 @@ void CanvasFrameRate::enabledToggled(bool checked)
         static_cast<QDeclarativeDebugClient *>(m_plugin)->setEnabled(checked);
 }
 
-QT_END_NAMESPACE
+}
+}
 
 #include "canvasframerate.moc"
diff --git a/src/plugins/qmlinspector/components/canvasframerate.h b/src/plugins/qmlinspector/components/canvasframerate.h
index b067374e897..d65ebc71e64 100644
--- a/src/plugins/qmlinspector/components/canvasframerate.h
+++ b/src/plugins/qmlinspector/components/canvasframerate.h
@@ -34,15 +34,19 @@
 #include <QtCore/qpointer.h>
 #include <QtGui/qwidget.h>
 
-
 QT_BEGIN_NAMESPACE
-
 class QTabWidget;
 class QSlider;
 class QGroupBox;
 class QLabel;
 class QSpinBox;
 class QPushButton;
+QT_END_NAMESPACE
+
+
+namespace Qml {
+namespace Internal {
+
 
 class CanvasFrameRatePlugin;
 
@@ -57,6 +61,9 @@ public:
     void setSizeHint(const QSize &);
     virtual QSize sizeHint() const;
 
+signals:
+    void contextHelpIdChanged(const QString &helpId);
+
 private slots:
     void clearGraph();
     void newTab();
@@ -74,7 +81,8 @@ private:
     QSize m_sizeHint;
 };
 
-QT_END_NAMESPACE
+} // Internal
+} // Qml
 
 #endif // CANVASFRAMERATE_H
 
diff --git a/src/plugins/qmlinspector/components/expressionquerywidget.cpp b/src/plugins/qmlinspector/components/expressionquerywidget.cpp
index 32cb1b25de9..c57e914952c 100644
--- a/src/plugins/qmlinspector/components/expressionquerywidget.cpp
+++ b/src/plugins/qmlinspector/components/expressionquerywidget.cpp
@@ -28,6 +28,7 @@
 **************************************************************************/
 #include "expressionquerywidget.h"
 #include "qmlinspectorconstants.h"
+#include "inspectorcontext.h"
 
 #include <utils/styledbar.h>
 #include <utils/filterlineedit.h>
@@ -54,6 +55,10 @@
 
 #include <QtCore/QDebug>
 
+namespace Qml {
+namespace Internal {
+
+
 ExpressionQueryWidget::ExpressionQueryWidget(Mode mode, QDeclarativeEngineDebug *client, QWidget *parent)
     : QWidget(parent),
       m_mode(mode),
@@ -87,6 +92,7 @@ ExpressionQueryWidget::ExpressionQueryWidget(Mode mode, QDeclarativeEngineDebug
         m_clearButton->setToolTip(tr("Clear Output"));
         m_clearButton->setIcon(QIcon(Core::Constants::ICON_CLEAN_PANE));
         connect(m_clearButton, SIGNAL(clicked()), this, SLOT(clearTextEditor()));
+        connect(m_lineEdit, SIGNAL(textChanged(QString)), SLOT(changeContextHelpId(QString)));
 
         connect(m_lineEdit, SIGNAL(returnPressed()), SLOT(executeExpression()));
         QHBoxLayout *hbox = new QHBoxLayout(bar);
@@ -106,6 +112,11 @@ ExpressionQueryWidget::ExpressionQueryWidget(Mode mode, QDeclarativeEngineDebug
     clear();
 }
 
+void ExpressionQueryWidget::changeContextHelpId(const QString &)
+{
+    emit contextHelpIdChanged(InspectorContext::contextHelpIdForItem(m_lineEdit->text()));
+}
+
 void ExpressionQueryWidget::clearTextEditor()
 {
     m_textEdit->clear();
@@ -339,3 +350,6 @@ bool ExpressionQueryWidget::eventFilter(QObject *obj, QEvent *event)
     }
     return QWidget::eventFilter(obj, event);
 }
+
+} // Internal
+} // Qml
diff --git a/src/plugins/qmlinspector/components/expressionquerywidget.h b/src/plugins/qmlinspector/components/expressionquerywidget.h
index cb1aaa44cb8..50ec058b8ec 100644
--- a/src/plugins/qmlinspector/components/expressionquerywidget.h
+++ b/src/plugins/qmlinspector/components/expressionquerywidget.h
@@ -33,7 +33,6 @@
 
 #include <QtGui/qwidget.h>
 
-
 QT_BEGIN_NAMESPACE
 
 class QGroupBox;
@@ -55,6 +54,9 @@ namespace QmlJSEditor {
     class Highlighter;
 }
 
+namespace Qml {
+namespace Internal {
+
 class ExpressionQueryWidget : public QWidget
 {
     Q_OBJECT
@@ -70,6 +72,9 @@ public:
     void setEngineDebug(QDeclarativeEngineDebug *client);
     void clear();
 
+signals:
+    void contextHelpIdChanged(const QString &contextHelpId);
+
 protected:
     bool eventFilter(QObject *obj, QEvent *event);
 
@@ -81,6 +86,7 @@ private slots:
     void executeExpression();
     void showResult();
     void invokeCompletion();
+    void changeContextHelpId(const QString &text);
 
 private:
     void setFontSettings();
@@ -108,5 +114,8 @@ private:
     QDeclarativeDebugObjectReference m_objectAtLastFocus;
 };
 
+} // Internal
+} // Qml
+
 #endif
 
diff --git a/src/plugins/qmlinspector/components/objectpropertiesview.cpp b/src/plugins/qmlinspector/components/objectpropertiesview.cpp
index 890e0c19fd5..ace3432a825 100644
--- a/src/plugins/qmlinspector/components/objectpropertiesview.cpp
+++ b/src/plugins/qmlinspector/components/objectpropertiesview.cpp
@@ -27,12 +27,15 @@
 **
 **************************************************************************/
 #include "objectpropertiesview.h"
+#include "inspectorcontext.h"
 
 #include <QtCore/QDebug>
 
 #include <QtGui/QTreeWidget>
 #include <QtGui/QLayout>
 #include <QtGui/QHeaderView>
+namespace Qml {
+namespace Internal {
 
 
 class PropertiesViewItem : public QObject, public QTreeWidgetItem
@@ -81,6 +84,7 @@ ObjectPropertiesView::ObjectPropertiesView(QDeclarativeEngineDebug *client, QWid
             << tr("Name") << tr("Value") << tr("Type"));
     QObject::connect(m_tree, SIGNAL(itemActivated(QTreeWidgetItem *, int)),
                      this, SLOT(itemActivated(QTreeWidgetItem *)));
+    connect(m_tree, SIGNAL(itemSelectionChanged()), SLOT(changeItemSelection()));
 
     m_tree->setColumnCount(3);
     m_tree->header()->setDefaultSectionSize(150);
@@ -88,6 +92,16 @@ ObjectPropertiesView::ObjectPropertiesView(QDeclarativeEngineDebug *client, QWid
     layout->addWidget(m_tree);
 }
 
+void ObjectPropertiesView::changeItemSelection()
+{
+    if (m_tree->selectedItems().isEmpty())
+        return;
+
+    QString item = m_object.className();
+    QString prop = m_tree->selectedItems().first()->text(0);
+    emit contextHelpIdChanged(InspectorContext::contextHelpIdForProperty(item, prop));
+}
+
 void ObjectPropertiesView::setEngineDebug(QDeclarativeEngineDebug *client)
 {
     m_client = client;
@@ -254,4 +268,7 @@ void ObjectPropertiesView::itemActivated(QTreeWidgetItem *i)
         emit activated(m_object, item->property);
 }
 
+}
+}
+
 #include "objectpropertiesview.moc"
diff --git a/src/plugins/qmlinspector/components/objectpropertiesview.h b/src/plugins/qmlinspector/components/objectpropertiesview.h
index 9bf382ae531..8cd3a7decd6 100644
--- a/src/plugins/qmlinspector/components/objectpropertiesview.h
+++ b/src/plugins/qmlinspector/components/objectpropertiesview.h
@@ -41,6 +41,9 @@ class QDeclarativeDebugConnection;
 
 QT_END_NAMESPACE
 
+namespace Qml {
+namespace Internal {
+
 class PropertiesViewItem;
 
 class ObjectPropertiesView : public QWidget
@@ -54,12 +57,14 @@ public:
 
 signals:
     void activated(const QDeclarativeDebugObjectReference &, const QDeclarativeDebugPropertyReference &);
+    void contextHelpIdChanged(const QString &contextHelpId);
 
 public slots:
     void reload(const QDeclarativeDebugObjectReference &);
     void watchCreated(QDeclarativeDebugWatch *);
 
 private slots:
+    void changeItemSelection();
     void queryFinished();
     void watchStateChanged();
     void valueChanged(const QByteArray &name, const QVariant &value);
@@ -78,7 +83,8 @@ private:
     QDeclarativeDebugObjectReference m_object;
 };
 
-
+} // Internal
+} // Qml
 
 
 #endif
diff --git a/src/plugins/qmlinspector/components/objecttree.cpp b/src/plugins/qmlinspector/components/objecttree.cpp
index c65da984b19..e4c187bbf68 100644
--- a/src/plugins/qmlinspector/components/objecttree.cpp
+++ b/src/plugins/qmlinspector/components/objecttree.cpp
@@ -37,8 +37,10 @@
 #include <private/qdeclarativedebug_p.h>
 
 #include "objecttree.h"
+#include "inspectorcontext.h"
 
-//Q_DECLARE_METATYPE(QDeclarativeDebugObjectReference)
+namespace Qml {
+namespace Internal {
 
 ObjectTree::ObjectTree(QDeclarativeEngineDebug *client, QWidget *parent)
     : QTreeWidget(parent),
@@ -54,6 +56,7 @@ ObjectTree::ObjectTree(QDeclarativeEngineDebug *client, QWidget *parent)
             SLOT(currentItemChanged(QTreeWidgetItem *)));
     connect(this, SIGNAL(itemActivated(QTreeWidgetItem *, int)),
             SLOT(activated(QTreeWidgetItem *)));
+    connect(this, SIGNAL(itemSelectionChanged()), SLOT(selectionChanged()));
 }
 
 void ObjectTree::setEngineDebug(QDeclarativeEngineDebug *client)
@@ -61,6 +64,16 @@ void ObjectTree::setEngineDebug(QDeclarativeEngineDebug *client)
     m_client = client;
 }
 
+void ObjectTree::selectionChanged()
+{
+    if (selectedItems().isEmpty())
+        return;
+
+    QTreeWidgetItem *item = selectedItems().first();
+    if (item)
+        emit contextHelpIdChanged(InspectorContext::contextHelpIdForItem(item->text(0)));
+}
+
 void ObjectTree::reload(int objectDebugId)
 {
     if (!m_client)
@@ -87,6 +100,8 @@ void ObjectTree::setCurrentObject(int debugId)
         scrollToItem(item);
         item->setExpanded(true);
     }
+
+
 }
 
 void ObjectTree::objectFetched()
@@ -218,3 +233,6 @@ void ObjectTree::mousePressEvent(QMouseEvent *me)
         }
     }
 }
+
+}
+}
diff --git a/src/plugins/qmlinspector/components/objecttree.h b/src/plugins/qmlinspector/components/objecttree.h
index fed55390c62..8e800209f53 100644
--- a/src/plugins/qmlinspector/components/objecttree.h
+++ b/src/plugins/qmlinspector/components/objecttree.h
@@ -41,6 +41,11 @@ class QDeclarativeDebugObjectQuery;
 class QDeclarativeDebugContextReference;
 class QDeclarativeDebugConnection;
 
+QT_END_NAMESPACE
+
+namespace Qml {
+namespace Internal {
+
 
 class ObjectTree : public QTreeWidget
 {
@@ -54,6 +59,7 @@ signals:
     void currentObjectChanged(const QDeclarativeDebugObjectReference &);
     void activated(const QDeclarativeDebugObjectReference &);
     void expressionWatchRequested(const QDeclarativeDebugObjectReference &, const QString &);
+    void contextHelpIdChanged(const QString &contextHelpId);
 
 public slots:
     void reload(int objectDebugId);     // set the root object
@@ -66,6 +72,7 @@ private slots:
     void objectFetched();
     void currentItemChanged(QTreeWidgetItem *);
     void activated(QTreeWidgetItem *);
+    void selectionChanged();
 
 private:
     QTreeWidgetItem *findItemByObjectId(int debugId) const;
@@ -78,7 +85,7 @@ private:
     QDeclarativeDebugObjectQuery *m_query;
 };
 
-QT_END_NAMESPACE
-
+} // Internal
+} // Qml
 
 #endif
diff --git a/src/plugins/qmlinspector/components/watchtable.cpp b/src/plugins/qmlinspector/components/watchtable.cpp
index eb710d75524..4712f901998 100644
--- a/src/plugins/qmlinspector/components/watchtable.cpp
+++ b/src/plugins/qmlinspector/components/watchtable.cpp
@@ -36,7 +36,8 @@
 #include <private/qdeclarativedebug_p.h>
 #include <private/qdeclarativemetatype_p.h>
 
-QT_BEGIN_NAMESPACE
+namespace Qml {
+namespace Internal {
 
 const int C_NAME = 0;
 const int C_VALUE = 1;
@@ -166,6 +167,8 @@ QVariant WatchTableModel::data(const QModelIndex &idx, int role) const
 
 bool WatchTableModel::setData ( const QModelIndex & index, const QVariant & value, int role)
 {
+    Q_UNUSED(index);
+    Q_UNUSED(value);
     if (role == Qt::EditRole) {
         return true;
     }
@@ -335,4 +338,6 @@ void WatchTableView::mousePressEvent(QMouseEvent *me)
     }
 }
 
-QT_END_NAMESPACE
+
+} // Internal
+} // Qml
diff --git a/src/plugins/qmlinspector/components/watchtable.h b/src/plugins/qmlinspector/components/watchtable.h
index f62bc11a9d0..e38f89c3e92 100644
--- a/src/plugins/qmlinspector/components/watchtable.h
+++ b/src/plugins/qmlinspector/components/watchtable.h
@@ -45,6 +45,11 @@ class QDeclarativeDebugConnection;
 class QDeclarativeDebugPropertyReference;
 class QDeclarativeDebugObjectReference;
 
+QT_END_NAMESPACE
+
+namespace Qml {
+namespace Internal {
+
 class WatchTableModel : public QAbstractTableModel
 {
     Q_OBJECT
@@ -117,6 +122,7 @@ public:
 
 signals:
     void objectActivated(int objectDebugId);
+    void contextHelpIdChanged(const QString &contextHelpId);
 
 protected:
     void mousePressEvent(QMouseEvent *me);
@@ -130,6 +136,7 @@ private:
 };
 
 
-QT_END_NAMESPACE
+} // Internal
+} // Qml
 
 #endif // WATCHTABLEMODEL_H
diff --git a/src/plugins/qmlinspector/inspectorcontext.cpp b/src/plugins/qmlinspector/inspectorcontext.cpp
index 11a3d263782..c735e44d3f2 100644
--- a/src/plugins/qmlinspector/inspectorcontext.cpp
+++ b/src/plugins/qmlinspector/inspectorcontext.cpp
@@ -30,8 +30,15 @@
 #include "inspectorcontext.h"
 #include "qmlinspectorconstants.h"
 
+#include "components/objectpropertiesview.h"
+#include "components/objecttree.h"
+#include <coreplugin/icore.h>
+
 #include <coreplugin/uniqueidmanager.h>
+
 #include <QWidget>
+#include <QDebug>
+
 
 namespace Qml {
 namespace Internal {
@@ -57,9 +64,26 @@ QWidget *InspectorContext::widget()
     return m_widget;
 }
 
+void InspectorContext::setContextHelpId(const QString &helpId)
+{
+    m_contextHelpId = helpId;
+}
+
 QString InspectorContext::contextHelpId() const
 {
-    return QString();
+    return m_contextHelpId;
+}
+
+QString InspectorContext::contextHelpIdForProperty(const QString &itemName, const QString &propName)
+{
+    // TODO this functionality is not supported yet as we don't have help id's for
+    // properties.
+    return QString("QML.").append(itemName).append(".").append(propName);
+}
+
+QString InspectorContext::contextHelpIdForItem(const QString &itemName)
+{
+    return QString("QML.").append(itemName);
 }
 
 }
diff --git a/src/plugins/qmlinspector/inspectorcontext.h b/src/plugins/qmlinspector/inspectorcontext.h
index a3e626db3b2..e73b3e4f235 100644
--- a/src/plugins/qmlinspector/inspectorcontext.h
+++ b/src/plugins/qmlinspector/inspectorcontext.h
@@ -40,6 +40,8 @@ QT_END_NAMESPACE
 namespace Qml {
 namespace Internal {
 
+class ObjectPropertiesView;
+class ObjectTree;
 class DesignModeWidget;
 
 /**
@@ -47,6 +49,8 @@ class DesignModeWidget;
   */
 class InspectorContext : public Core::IContext
 {
+    Q_OBJECT
+
 public:
     InspectorContext(QWidget *widget);
     ~InspectorContext();
@@ -56,12 +60,20 @@ public:
 
     QString contextHelpId() const;
 
+    static QString contextHelpIdForProperty(const QString &itemName, const QString &propName);
+    static QString contextHelpIdForItem(const QString &itemName);
+
+public slots:
+    void setContextHelpId(const QString &helpId);
+
 private:
     QList<int> m_context;
     QWidget *m_widget;
+    QString m_contextHelpId;
+
 };
 
-}
-}
+} // Internal
+} // Qml
 
 #endif // DESIGNMODECONTEXT_H
diff --git a/src/plugins/qmlinspector/qmlinspector.cpp b/src/plugins/qmlinspector/qmlinspector.cpp
index 1dd60e4bfb0..b208cb42f41 100644
--- a/src/plugins/qmlinspector/qmlinspector.cpp
+++ b/src/plugins/qmlinspector/qmlinspector.cpp
@@ -88,6 +88,7 @@ using namespace Qml;
 
 namespace Qml {
 
+namespace Internal {
 class EngineSpinBox : public QSpinBox
 {
     Q_OBJECT
@@ -111,8 +112,6 @@ private:
     QList<EngineInfo> m_engines;
 };
 
-}
-
 EngineSpinBox::EngineSpinBox(QWidget *parent)
     : QSpinBox(parent)
 {
@@ -157,6 +156,8 @@ int EngineSpinBox::valueFromText(const QString &text) const
     return -1;
 }
 
+} // Internal
+
 
 QmlInspector::QmlInspector(QObject *parent)
   : QObject(parent),
@@ -169,15 +170,13 @@ QmlInspector::QmlInspector(QObject *parent)
     m_propertyWatcherDock(0),
     m_inspectorOutputDock(0)
 {
-    m_watchTableModel = new WatchTableModel(0, this);
-
-    m_objectTreeWidget = new ObjectTree;
-    m_propertiesWidget = new ObjectPropertiesView;
-    m_watchTableView = new WatchTableView(m_watchTableModel);
-    m_frameRateWidget = new CanvasFrameRate;
-    m_expressionWidget = new ExpressionQueryWidget(ExpressionQueryWidget::SeparateEntryMode);
-    m_context = new Internal::InspectorContext(m_expressionWidget);
-    m_expressionWidget->createCommands(m_context);
+    m_watchTableModel = new Internal::WatchTableModel(0, this);
+
+    m_objectTreeWidget = new Internal::ObjectTree;
+    m_propertiesWidget = new Internal::ObjectPropertiesView;
+    m_watchTableView = new Internal::WatchTableView(m_watchTableModel);
+    m_frameRateWidget = new Internal::CanvasFrameRate;
+    m_expressionWidget = new Internal::ExpressionQueryWidget(Internal::ExpressionQueryWidget::SeparateEntryMode);
 }
 
 bool QmlInspector::connectToViewer()
@@ -300,7 +299,7 @@ void QmlInspector::connectionError()
 void QmlInspector::createDockWidgets()
 {
 
-    m_engineSpinBox = new EngineSpinBox;
+    m_engineSpinBox = new Internal::EngineSpinBox;
     m_engineSpinBox->setEnabled(false);
     connect(m_engineSpinBox, SIGNAL(valueChanged(int)),
             SLOT(queryEngineContext(int)));
@@ -324,7 +323,7 @@ void QmlInspector::createDockWidgets()
     treeWindowLayout->addWidget(m_objectTreeWidget);
 
     m_watchTableView->setModel(m_watchTableModel);
-    WatchTableHeaderView *header = new WatchTableHeaderView(m_watchTableModel);
+    Internal::WatchTableHeaderView *header = new Internal::WatchTableHeaderView(m_watchTableModel);
     m_watchTableView->setHorizontalHeader(header);
 
     connect(m_objectTreeWidget, SIGNAL(activated(QDeclarativeDebugObjectReference)),
@@ -387,6 +386,23 @@ void QmlInspector::createDockWidgets()
 
     m_dockWidgets << m_objectTreeDock << m_frameRateDock << m_propertyWatcherDock << m_inspectorOutputDock;
 
+    m_context = new Internal::InspectorContext(m_objectTreeDock);
+    m_propWatcherContext = new Internal::InspectorContext(m_propertyWatcherDock);
+
+    Core::ICore *core = Core::ICore::instance();
+    core->addContextObject(m_propWatcherContext);
+    core->addContextObject(m_context);
+
+    m_expressionWidget->createCommands(m_context);
+
+    connect(m_objectTreeWidget, SIGNAL(contextHelpIdChanged(QString)), m_context,
+            SLOT(setContextHelpId(QString)));
+    connect(m_watchTableView, SIGNAL(contextHelpIdChanged(QString)), m_propWatcherContext,
+            SLOT(setContextHelpId(QString)));
+    connect(m_propertiesWidget, SIGNAL(contextHelpIdChanged(QString)), m_propWatcherContext,
+            SLOT(setContextHelpId(QString)));
+    connect(m_expressionWidget, SIGNAL(contextHelpIdChanged(QString)), m_propWatcherContext,
+            SLOT(setContextHelpId(QString)));
 }
 
 void QmlInspector::setSimpleDockWidgetArrangement()
@@ -507,4 +523,6 @@ void QmlInspector::treeObjectActivated(const QDeclarativeDebugObjectReference &o
     }
 }
 
+} // Qml
+
 #include "qmlinspector.moc"
diff --git a/src/plugins/qmlinspector/qmlinspector.h b/src/plugins/qmlinspector/qmlinspector.h
index eb23666c59b..3b6270eda34 100644
--- a/src/plugins/qmlinspector/qmlinspector.h
+++ b/src/plugins/qmlinspector/qmlinspector.h
@@ -48,24 +48,26 @@ class QDeclarativeDebugConnection;
 class QDeclarativeDebugEnginesQuery;
 class QDeclarativeDebugRootContextQuery;
 class QDeclarativeDebugObjectReference;
-class ObjectTree;
-class WatchTableModel;
-class WatchTableView;
-class CanvasFrameRate;
 QT_END_NAMESPACE
 
-class ObjectPropertiesView;
-class ExpressionQueryWidget;
+
 
 namespace Core {
     class IContext;
 }
 
 namespace Qml {
-    class EngineSpinBox;
 
     namespace Internal {
+        class EngineSpinBox;
         class InspectorContext;
+        class ObjectTree;
+        class ObjectPropertiesView;
+        class WatchTableModel;
+        class WatchTableView;
+        class CanvasFrameRate;
+        class ExpressionQueryWidget;
+        class EngineSpinBox;
     }
 
 class QMLINSPECTOR_EXPORT QmlInspector : public QObject
@@ -104,14 +106,14 @@ private:
     QDeclarativeDebugEnginesQuery *m_engineQuery;
     QDeclarativeDebugRootContextQuery *m_contextQuery;
 
-    ObjectTree *m_objectTreeWidget;
-    ObjectPropertiesView *m_propertiesWidget;
-    WatchTableModel *m_watchTableModel;
-    WatchTableView *m_watchTableView;
-    CanvasFrameRate *m_frameRateWidget;
-    ExpressionQueryWidget *m_expressionWidget;
+    Internal::ObjectTree *m_objectTreeWidget;
+    Internal::ObjectPropertiesView *m_propertiesWidget;
+    Internal::WatchTableModel *m_watchTableModel;
+    Internal::WatchTableView *m_watchTableView;
+    Internal::CanvasFrameRate *m_frameRateWidget;
+    Internal::ExpressionQueryWidget *m_expressionWidget;
 
-    EngineSpinBox *m_engineSpinBox;
+    Internal::EngineSpinBox *m_engineSpinBox;
 
     QDockWidget *m_objectTreeDock;
     QDockWidget *m_frameRateDock;
@@ -120,6 +122,7 @@ private:
     QList<QDockWidget*> m_dockWidgets;
 
     Internal::InspectorContext *m_context;
+    Internal::InspectorContext *m_propWatcherContext;
 
 };
 
diff --git a/src/plugins/qmlinspector/qmlinspectorplugin.cpp b/src/plugins/qmlinspector/qmlinspectorplugin.cpp
index a80fa499b07..02bab91ae6d 100644
--- a/src/plugins/qmlinspector/qmlinspectorplugin.cpp
+++ b/src/plugins/qmlinspector/qmlinspectorplugin.cpp
@@ -97,19 +97,18 @@ bool QmlInspectorPlugin::initialize(const QStringList &arguments, QString *error
 {
     Q_UNUSED(arguments);
     Q_UNUSED(errorString);
-
+    Core::ICore *core = Core::ICore::instance();
     connect(Core::ModeManager::instance(), SIGNAL(currentModeChanged(Core::IMode*)),
             SLOT(prepareDebugger(Core::IMode*)));
 
     ExtensionSystem::PluginManager *pluginManager = ExtensionSystem::PluginManager::instance();
     Debugger::DebuggerUISwitcher *uiSwitcher = pluginManager->getObject<Debugger::DebuggerUISwitcher>();
 
+    uiSwitcher->addLanguage(Qml::Constants::LANG_QML,
+                            QList<int>() << core->uniqueIDManager()->uniqueIdentifier(Constants::C_INSPECTOR));
     m_inspector = new QmlInspector;
-    addObject(m_inspector);
-    Core::ICore::instance()->addContextObject(m_inspector->context());
-    uiSwitcher->addLanguage(Qml::Constants::LANG_QML, m_inspector->context()->context());
     m_inspector->createDockWidgets();
-
+    addObject(m_inspector);
 
     connect(m_connectionTimer, SIGNAL(timeout()), SLOT(pollInspector()));
 
-- 
GitLab