From 47db341b672600b2d3a4a1e370ae4b7b7297ce74 Mon Sep 17 00:00:00 2001
From: Olivier Goffart <olivier.goffart@nokia.com>
Date: Tue, 24 Aug 2010 18:06:52 +0200
Subject: [PATCH] qmlobserver: Remove the changed() hack to get new object.

There is now a hook in QDeclarative itself for that.
Needs commit af2b28f9ca07057 of Qt
---
 .../include/qdeclarativedesigndebugserver.h   |  1 -
 .../include/qdeclarativedesignview.h          |  2 -
 .../qdeclarativedesigndebugserver.cpp         | 10 ----
 .../qmljsdebugger/qdeclarativedesignview.cpp  | 55 -------------------
 .../qmljsdebugger/qdeclarativedesignview_p.h  |  7 ---
 .../qmljsinspector/qmljsclientproxy.cpp       |  4 --
 .../qmljsinspector/qmljsdesigndebugclient.cpp |  2 -
 .../qmljsinspector/qmljsdesigndebugclient.h   |  1 -
 8 files changed, 82 deletions(-)

diff --git a/share/qtcreator/qmljsdebugger/include/qdeclarativedesigndebugserver.h b/share/qtcreator/qmljsdebugger/include/qdeclarativedesigndebugserver.h
index 53a554949a6..f93508194ac 100644
--- a/share/qtcreator/qmljsdebugger/include/qdeclarativedesigndebugserver.h
+++ b/share/qtcreator/qmljsdebugger/include/qdeclarativedesigndebugserver.h
@@ -72,7 +72,6 @@ public:
 public Q_SLOTS:
     void selectedColorChanged(const QColor &color);
     void contextPathUpdated(const QStringList &contextPath);
-    void sceneItemCountChanged();
 
 Q_SIGNALS:
     void currentObjectsChanged(const QList<QObject*> &objects);
diff --git a/share/qtcreator/qmljsdebugger/include/qdeclarativedesignview.h b/share/qtcreator/qmljsdebugger/include/qdeclarativedesignview.h
index 543aaada671..8909fda24f8 100644
--- a/share/qtcreator/qmljsdebugger/include/qdeclarativedesignview.h
+++ b/share/qtcreator/qmljsdebugger/include/qdeclarativedesignview.h
@@ -111,8 +111,6 @@ private:
     Q_PRIVATE_SLOT(d_func(), void _q_changeToColorPickerTool())
     Q_PRIVATE_SLOT(d_func(), void _q_changeContextPathIndex(int index))
     Q_PRIVATE_SLOT(d_func(), void _q_clearComponentCache());
-    Q_PRIVATE_SLOT(d_func(), void _q_sceneChanged(const QList<QRectF> &areas));
-    Q_PRIVATE_SLOT(d_func(), void _q_checkSceneItemCount());
 
     inline QDeclarativeDesignViewPrivate *d_func() { return data.data(); }
     QScopedPointer<QDeclarativeDesignViewPrivate> data;
diff --git a/share/qtcreator/qmljsdebugger/qdeclarativedesigndebugserver.cpp b/share/qtcreator/qmljsdebugger/qdeclarativedesigndebugserver.cpp
index 315c529bb90..bf68d432ffc 100644
--- a/share/qtcreator/qmljsdebugger/qdeclarativedesigndebugserver.cpp
+++ b/share/qtcreator/qmljsdebugger/qdeclarativedesigndebugserver.cpp
@@ -211,16 +211,6 @@ void QDeclarativeDesignDebugServer::contextPathUpdated(const QStringList &contex
     sendMessage(message);
 }
 
-void QDeclarativeDesignDebugServer::sceneItemCountChanged()
-{
-    QByteArray message;
-    QDataStream ds(&message, QIODevice::WriteOnly);
-
-    ds << QByteArray("SCENE_ITEM_COUNT_CHANGED");
-
-    sendMessage(message);
-}
-
 QString QDeclarativeDesignDebugServer::idStringForObject(QObject *obj) const
 {
     int id = idForObject(obj);
diff --git a/share/qtcreator/qmljsdebugger/qdeclarativedesignview.cpp b/share/qtcreator/qmljsdebugger/qdeclarativedesignview.cpp
index 704711f9da8..a086b984fe2 100644
--- a/share/qtcreator/qmljsdebugger/qdeclarativedesignview.cpp
+++ b/share/qtcreator/qmljsdebugger/qdeclarativedesignview.cpp
@@ -66,8 +66,6 @@ QDeclarativeDesignViewPrivate::QDeclarativeDesignViewPrivate(QDeclarativeDesignV
     jsDebuggerAgent(0),
     toolbar(0)
 {
-    sceneChangedTimer.setInterval(SceneChangeUpdateInterval);
-    sceneChangedTimer.setSingleShot(true);
 }
 
 QDeclarativeDesignViewPrivate::~QDeclarativeDesignViewPrivate()
@@ -85,7 +83,6 @@ QDeclarativeDesignView::QDeclarativeDesignView(QWidget *parent) :
     data->subcomponentEditorTool = new SubcomponentEditorTool(this);
     data->currentTool = data->selectionTool;
 
-    connect(scene(), SIGNAL(changed(QList<QRectF>)), SLOT(_q_sceneChanged(QList<QRectF>)));
     setMouseTracking(true);
 
     connect(qmlDesignDebugServer(), SIGNAL(designModeBehaviorChanged(bool)), SLOT(setDesignModeBehavior(bool)));
@@ -114,8 +111,6 @@ QDeclarativeDesignView::QDeclarativeDesignView(QWidget *parent) :
     connect(data->subcomponentEditorTool, SIGNAL(contextPopped()), SIGNAL(inspectorContextPopped()));
     connect(data->subcomponentEditorTool, SIGNAL(contextPathChanged(QStringList)), qmlDesignDebugServer(), SLOT(contextPathUpdated(QStringList)));
 
-    connect(&(data->sceneChangedTimer), SIGNAL(timeout()), SLOT(_q_checkSceneItemCount()));
-
     data->createToolbar();
 
     data->_q_changeToSingleSelectTool();
@@ -535,55 +530,6 @@ void QDeclarativeDesignViewPrivate::_q_changeContextPathIndex(int index)
     subcomponentEditorTool->setContext(index);
 }
 
-void QDeclarativeDesignViewPrivate::_q_sceneChanged(const QList<QRectF> & /*areas*/)
-{
-    if (designModeBehavior)
-        return;
-
-    if (!sceneChangedTimer.isActive())
-        sceneChangedTimer.start();
-}
-
-void QDeclarativeDesignViewPrivate::_q_checkSceneItemCount()
-{
-    bool hasNewItems = hasNewGraphicsObjects(q->rootObject());
-
-    if (hasNewItems) {
-        qmlDesignDebugServer()->sceneItemCountChanged();
-    }
-}
-
-static bool hasNewGraphicsObjectsRecur(QGraphicsObject *object,
-                                  QSet<QGraphicsObject *> &newItems,
-                                  const QSet<QGraphicsObject *> &previousItems)
-{
-    bool hasNew = false;
-
-    newItems << object;
-
-    foreach(QGraphicsItem *item, object->childItems()) {
-        QGraphicsObject *gfxObject = item->toGraphicsObject();
-        if (gfxObject) {
-            newItems << gfxObject;
-
-            hasNew = hasNewGraphicsObjectsRecur(gfxObject, newItems, previousItems) || hasNew;
-            if (!previousItems.contains(gfxObject))
-                hasNew = true;
-        }
-    }
-
-    return hasNew;
-}
-
-bool QDeclarativeDesignViewPrivate::hasNewGraphicsObjects(QGraphicsObject *object)
-{
-    QSet<QGraphicsObject *> newItems;
-    bool ret = hasNewGraphicsObjectsRecur(object, newItems, sceneGraphicsObjects);
-    sceneGraphicsObjects = newItems;
-
-    return ret;
-}
-
 void QDeclarativeDesignView::changeAnimationSpeed(qreal slowdownFactor)
 {
     data->slowdownFactor = slowdownFactor;
@@ -674,7 +620,6 @@ void QDeclarativeDesignViewPrivate::_q_onStatusChanged(QDeclarativeView::Status
 {
     if (status == QDeclarativeView::Ready) {
         if (q->rootObject()) {
-            hasNewGraphicsObjects(q->rootObject());
             if (subcomponentEditorTool->contextIndex() != -1)
                 subcomponentEditorTool->clear();
             subcomponentEditorTool->pushContext(q->rootObject());
diff --git a/share/qtcreator/qmljsdebugger/qdeclarativedesignview_p.h b/share/qtcreator/qmljsdebugger/qdeclarativedesignview_p.h
index d83f46aca9c..0c79810ceec 100644
--- a/share/qtcreator/qmljsdebugger/qdeclarativedesignview_p.h
+++ b/share/qtcreator/qmljsdebugger/qdeclarativedesignview_p.h
@@ -87,8 +87,6 @@ public:
     JSDebuggerAgent *jsDebuggerAgent;
 
     QmlToolbar *toolbar;
-    QTimer sceneChangedTimer;
-    QSet<QGraphicsObject *> sceneGraphicsObjects;
 
     void clearEditorItems();
     void createToolbar();
@@ -100,8 +98,6 @@ public:
     QList<QGraphicsItem*> selectableItems(const QPointF &scenePos) const;
     QList<QGraphicsItem*> selectableItems(const QRectF &sceneRect, Qt::ItemSelectionMode selectionMode) const;
 
-    bool hasNewGraphicsObjects(QGraphicsObject *object);
-
     void setSelectedItemsForTools(QList<QGraphicsItem *> items);
     void setSelectedItems(QList<QGraphicsItem *> items);
     QList<QGraphicsItem *> selectedItems();
@@ -132,9 +128,6 @@ public:
     void _q_changeToColorPickerTool();
     void _q_changeContextPathIndex(int index);
     void _q_clearComponentCache();
-    void _q_sceneChanged(const QList<QRectF> &areas);
-    void _q_changeDebugObjectCount(int objectCount);
-    void _q_checkSceneItemCount();
 
     static QDeclarativeDesignViewPrivate *get(QDeclarativeDesignView *v) { return v->d_func(); }
 };
diff --git a/src/plugins/qmljsinspector/qmljsclientproxy.cpp b/src/plugins/qmljsinspector/qmljsclientproxy.cpp
index 6b5e2581168..2a81edac6e9 100644
--- a/src/plugins/qmljsinspector/qmljsclientproxy.cpp
+++ b/src/plugins/qmljsinspector/qmljsclientproxy.cpp
@@ -85,9 +85,6 @@ void ClientProxy::connectToServer()
         SIGNAL(selectedColorChanged(QColor)));
     connect(m_designClient, SIGNAL(contextPathUpdated(QStringList)),
         SIGNAL(contextPathUpdated(QStringList)));
-  /*  connect(m_designClient, SIGNAL(treeRefreshRequested()),
-        SLOT(refreshObjectTree()));*/
-
     reloadEngines();
 }
 
@@ -454,4 +451,3 @@ void ClientProxy::newObjects()
     if (!m_requestObjectsTimer.isActive())
         m_requestObjectsTimer.start();
 }
-
diff --git a/src/plugins/qmljsinspector/qmljsdesigndebugclient.cpp b/src/plugins/qmljsinspector/qmljsdesigndebugclient.cpp
index 2e2b2332cb3..5bc160b5200 100644
--- a/src/plugins/qmljsinspector/qmljsdesigndebugclient.cpp
+++ b/src/plugins/qmljsinspector/qmljsdesigndebugclient.cpp
@@ -108,8 +108,6 @@ void QmlJSDesignDebugClient::messageReceived(const QByteArray &message)
         QStringList contextPath;
         ds >> contextPath;
         emit contextPathUpdated(contextPath);
-    } else if (type == "SCENE_ITEM_COUNT_CHANGED") {
-        //emit treeRefreshRequested();
     }
 }
 
diff --git a/src/plugins/qmljsinspector/qmljsdesigndebugclient.h b/src/plugins/qmljsinspector/qmljsdesigndebugclient.h
index 9b7458f3f6a..406495844bd 100644
--- a/src/plugins/qmljsinspector/qmljsdesigndebugclient.h
+++ b/src/plugins/qmljsinspector/qmljsdesigndebugclient.h
@@ -89,7 +89,6 @@ signals:
     void designModeBehaviorChanged(bool inDesignMode);
     void reloaded(); // the server has reloaded the document
     void contextPathUpdated(const QStringList &path);
-    void treeRefreshRequested(); // scene has some new items
 
 protected:
     virtual void messageReceived(const QByteArray &);
-- 
GitLab