From f31d299d51ecfc7b31674f319bfd389d03863a80 Mon Sep 17 00:00:00 2001
From: Roberto Raggi <roberto.raggi@nokia.com>
Date: Tue, 29 Jun 2010 16:15:49 +0200
Subject: [PATCH] Observe the QML/JS model manager.

---
 src/plugins/qmljsinspector/qmljsinspector.cpp     | 15 +++++++++++++++
 src/plugins/qmljsinspector/qmljsinspector.h       |  2 ++
 .../qmljsinspector/qmljsinspectorplugin.cpp       |  6 ++++++
 3 files changed, 23 insertions(+)

diff --git a/src/plugins/qmljsinspector/qmljsinspector.cpp b/src/plugins/qmljsinspector/qmljsinspector.cpp
index 7294d0972b0..f62e28e89b8 100644
--- a/src/plugins/qmljsinspector/qmljsinspector.cpp
+++ b/src/plugins/qmljsinspector/qmljsinspector.cpp
@@ -30,6 +30,10 @@
 #include "qmljsinspector.h"
 #include "qmljsclientproxy.h"
 #include "qmljsinspectorcontext.h"
+#include "qmljsdelta.h"
+
+#include <qmljs/qmljsmodelmanagerinterface.h>
+#include <qmljs/qmljsdocument.h>
 
 #include <debugger/debuggerrunner.h>
 #include <debugger/debuggerconstants.h>
@@ -96,6 +100,7 @@
 
 #include <QtNetwork/QHostAddress>
 
+using namespace QmlJS;
 using namespace QmlJS::AST;
 using namespace QmlJSInspector::Internal;
 using namespace Debugger::Internal;
@@ -604,3 +609,13 @@ bool Inspector::addQuotesForData(const QVariant &value) const
     return false;
 }
 
+void Inspector::documentUpdated(QmlJS::Document::Ptr doc)
+{
+    Core::ICore *core = Core::ICore::instance();
+    const int dbgcontext = core->uniqueIDManager()->uniqueIdentifier(Debugger::Constants::C_DEBUGMODE);
+
+    if (! core->hasContext(dbgcontext))
+        return;
+
+    qDebug() << "TODO: compute the delta changes for:" << doc->fileName();
+}
diff --git a/src/plugins/qmljsinspector/qmljsinspector.h b/src/plugins/qmljsinspector/qmljsinspector.h
index 35be72d7655..0b0778b576a 100644
--- a/src/plugins/qmljsinspector/qmljsinspector.h
+++ b/src/plugins/qmljsinspector/qmljsinspector.h
@@ -114,6 +114,8 @@ private slots:
     void disconnectWidgets();
     void disconnected();
 
+    void documentUpdated(QmlJS::Document::Ptr doc);
+
 private:
     Debugger::DebuggerRunControl *createDebuggerRunControl(ProjectExplorer::RunConfiguration *runConfig,
                                                            const QString &executableFile = QString(),
diff --git a/src/plugins/qmljsinspector/qmljsinspectorplugin.cpp b/src/plugins/qmljsinspector/qmljsinspectorplugin.cpp
index 57908d52183..dbff04b33e9 100644
--- a/src/plugins/qmljsinspector/qmljsinspectorplugin.cpp
+++ b/src/plugins/qmljsinspector/qmljsinspectorplugin.cpp
@@ -174,6 +174,12 @@ void InspectorPlugin::extensionsInitialized()
     configBarLayout->addStretch();
 
     uiSwitcher->setToolbar(LANG_QML, configBar);
+
+    if (QmlJS::ModelManagerInterface *m = InspectorPlugin::instance()->modelManager()) {
+        connect(m, SIGNAL(documentUpdated(QmlJS::Document::Ptr)),
+                _inspector, SLOT(documentUpdated(QmlJS::Document::Ptr)));
+    }
+
 }
 
 void InspectorPlugin::activateDebuggerForProject(ProjectExplorer::Project *project, const QString &runMode)
-- 
GitLab