aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com>2011-05-24 14:08:09 +0200
committerKai Koehne <kai.koehne@nokia.com>2011-05-25 10:14:36 +0200
commit554b8e996bfa95f0e08dfe4ef94da3ced5e09925 (patch)
treedcdaae18b377439a4c6c9df0e1b32c871d35a077
parent97ca81fc6dfe0247d58a97e24a19b44fbe8f6ad0 (diff)
DeclarativeObserver: Removed the SubcomponentEditorTool
This tool made selecting items in your QML app more complicated than necessary. Now, left-click will always just select the top-most item under the mouse and right-click will allow you to select any of the items below. Also, the highlighted bounding rect now always applies to just one item, instead of also including the children bounding rect. Reviewed-by: Kai Koehne Change-Id: I17b5ab397d951fd68711590469ca6e723a9cb0e6 (backported from Qt 4.8 commit 935472c16fc53ee43e1e680ed0122e6363282a8e) Reviewed-on: http://codereview.qt.nokia.com/89 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Kai Koehne <kai.koehne@nokia.com>
-rw-r--r--share/qtcreator/qml/qmljsdebugger/editor/abstractliveedittool.cpp5
-rw-r--r--share/qtcreator/qml/qmljsdebugger/editor/boundingrecthighlighter.cpp8
-rw-r--r--share/qtcreator/qml/qmljsdebugger/editor/liveselectiontool.cpp4
-rw-r--r--share/qtcreator/qml/qmljsdebugger/editor/subcomponenteditortool.cpp354
-rw-r--r--share/qtcreator/qml/qmljsdebugger/editor/subcomponenteditortool.h115
-rw-r--r--share/qtcreator/qml/qmljsdebugger/include/qdeclarativeobserverservice.h2
-rw-r--r--share/qtcreator/qml/qmljsdebugger/include/qdeclarativeviewobserver.h6
-rw-r--r--share/qtcreator/qml/qmljsdebugger/protocol/observerprotocol.h2
-rw-r--r--share/qtcreator/qml/qmljsdebugger/qdeclarativeobserverservice.cpp21
-rw-r--r--share/qtcreator/qml/qmljsdebugger/qdeclarativeviewobserver.cpp147
-rw-r--r--share/qtcreator/qml/qmljsdebugger/qdeclarativeviewobserver_p.h19
-rw-r--r--share/qtcreator/qml/qmljsdebugger/qmljsdebugger-src.pri2
12 files changed, 17 insertions, 668 deletions
diff --git a/share/qtcreator/qml/qmljsdebugger/editor/abstractliveedittool.cpp b/share/qtcreator/qml/qmljsdebugger/editor/abstractliveedittool.cpp
index c9b52babb0..0cad361bc6 100644
--- a/share/qtcreator/qml/qmljsdebugger/editor/abstractliveedittool.cpp
+++ b/share/qtcreator/qml/qmljsdebugger/editor/abstractliveedittool.cpp
@@ -77,11 +77,6 @@ QList<QGraphicsItem*> AbstractLiveEditTool::items() const
return observer()->selectedItems();
}
-void AbstractLiveEditTool::enterContext(QGraphicsItem *itemToEnter)
-{
- observer()->data->enterContext(itemToEnter);
-}
-
bool AbstractLiveEditTool::topItemIsMovable(const QList<QGraphicsItem*> & itemList)
{
QGraphicsItem *firstSelectableItem = topMovableGraphicsItem(itemList);
diff --git a/share/qtcreator/qml/qmljsdebugger/editor/boundingrecthighlighter.cpp b/share/qtcreator/qml/qmljsdebugger/editor/boundingrecthighlighter.cpp
index b443ed42d1..f174e1826f 100644
--- a/share/qtcreator/qml/qmljsdebugger/editor/boundingrecthighlighter.cpp
+++ b/share/qtcreator/qml/qmljsdebugger/editor/boundingrecthighlighter.cpp
@@ -243,12 +243,10 @@ void BoundingRectHighlighter::highlightAll(bool animate)
return;
}
QGraphicsObject *item = box->highlightedObject.data();
- QRectF itemAndChildRect = item->boundingRect() | item->childrenBoundingRect();
- QPolygonF boundingRectInSceneSpace(item->mapToScene(itemAndChildRect));
- QPolygonF boundingRectInLayerItemSpace = mapFromScene(boundingRectInSceneSpace);
- QRectF bboxRect
- = m_view->adjustToScreenBoundaries(boundingRectInLayerItemSpace.boundingRect());
+ QRectF boundingRectInSceneSpace(item->mapToScene(item->boundingRect()).boundingRect());
+ QRectF boundingRectInLayerItemSpace = mapRectFromScene(boundingRectInSceneSpace);
+ QRectF bboxRect = m_view->adjustToScreenBoundaries(boundingRectInLayerItemSpace);
QRectF edgeRect = bboxRect;
edgeRect.adjust(-1, -1, 1, 1);
diff --git a/share/qtcreator/qml/qmljsdebugger/editor/liveselectiontool.cpp b/share/qtcreator/qml/qmljsdebugger/editor/liveselectiontool.cpp
index 603cf0b6e8..63bb690c51 100644
--- a/share/qtcreator/qml/qmljsdebugger/editor/liveselectiontool.cpp
+++ b/share/qtcreator/qml/qmljsdebugger/editor/liveselectiontool.cpp
@@ -125,9 +125,6 @@ void LiveSelectionTool::mousePressEvent(QMouseEvent *event)
void LiveSelectionTool::createContextMenu(QList<QGraphicsItem*> itemList, QPoint globalPos)
{
- if (!QDeclarativeViewObserverPrivate::get(observer())->mouseInsideContextItem())
- return;
-
QMenu contextMenu;
connect(&contextMenu, SIGNAL(hovered(QAction*)),
this, SLOT(contextMenuElementHovered(QAction*)));
@@ -183,7 +180,6 @@ void LiveSelectionTool::contextMenuElementSelected()
QList<QGraphicsItem*>() << item,
false);
m_singleSelectionManipulator.end(updatePt);
- enterContext(item);
}
}
diff --git a/share/qtcreator/qml/qmljsdebugger/editor/subcomponenteditortool.cpp b/share/qtcreator/qml/qmljsdebugger/editor/subcomponenteditortool.cpp
deleted file mode 100644
index cff6b28c17..0000000000
--- a/share/qtcreator/qml/qmljsdebugger/editor/subcomponenteditortool.cpp
+++ /dev/null
@@ -1,354 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact: Nokia Corporation (info@qt.nokia.com)
-**
-**
-** GNU Lesser General Public License Usage
-**
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** Other Usage
-**
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**************************************************************************/
-
-#include "subcomponenteditortool.h"
-#include "../qdeclarativeviewobserver_p.h"
-#include "subcomponentmasklayeritem.h"
-#include "livelayeritem.h"
-
-#include <QtGui/QGraphicsItem>
-#include <QtGui/QGraphicsObject>
-#include <QtGui/QMouseEvent>
-#include <QtGui/QKeyEvent>
-
-#include <QtCore/QTimer>
-#include <QtCore/QDebug>
-
-namespace QmlJSDebugger {
-
-const qreal MaxOpacity = 0.5f;
-
-SubcomponentEditorTool::SubcomponentEditorTool(QDeclarativeViewObserver *view)
- : AbstractLiveEditTool(view),
- m_animIncrement(0.05f),
- m_animTimer(new QTimer(this))
-{
- QDeclarativeViewObserverPrivate *observerPrivate =
- QDeclarativeViewObserverPrivate::get(view);
- m_mask = new SubcomponentMaskLayerItem(view, observerPrivate->manipulatorLayer);
- connect(m_animTimer, SIGNAL(timeout()), SLOT(animate()));
- m_animTimer->setInterval(20);
-}
-
-SubcomponentEditorTool::~SubcomponentEditorTool()
-{
-
-}
-
-void SubcomponentEditorTool::mousePressEvent(QMouseEvent * /*event*/)
-{
-
-}
-
-void SubcomponentEditorTool::mouseMoveEvent(QMouseEvent * /*event*/)
-{
-
-}
-
-bool SubcomponentEditorTool::containsCursor(const QPoint &mousePos) const
-{
- if (!m_currentContext.size())
- return false;
-
- QPointF scenePos = view()->mapToScene(mousePos);
- QRectF itemRect = m_currentContext.top()->boundingRect()
- | m_currentContext.top()->childrenBoundingRect();
- QRectF polyRect = m_currentContext.top()->mapToScene(itemRect).boundingRect();
-
- return polyRect.contains(scenePos);
-}
-
-void SubcomponentEditorTool::mouseReleaseEvent(QMouseEvent * /*event*/)
-{
-
-}
-
-void SubcomponentEditorTool::mouseDoubleClickEvent(QMouseEvent *event)
-{
- if (event->buttons() & Qt::LeftButton
- && !containsCursor(event->pos())
- && m_currentContext.size() > 1)
- {
- aboutToPopContext();
- }
-}
-
-void SubcomponentEditorTool::hoverMoveEvent(QMouseEvent *event)
-{
- if (!containsCursor(event->pos()) && m_currentContext.size() > 1) {
- QDeclarativeViewObserverPrivate::get(observer())->clearHighlight();
- }
-}
-
-void SubcomponentEditorTool::wheelEvent(QWheelEvent * /*event*/)
-{
-
-}
-
-void SubcomponentEditorTool::keyPressEvent(QKeyEvent * /*event*/)
-{
-
-}
-
-void SubcomponentEditorTool::keyReleaseEvent(QKeyEvent * /*keyEvent*/)
-{
-
-}
-
-void SubcomponentEditorTool::itemsAboutToRemoved(const QList<QGraphicsItem*> &/*itemList*/)
-{
-
-}
-
-void SubcomponentEditorTool::animate()
-{
- if (m_animIncrement > 0) {
- if (m_mask->opacity() + m_animIncrement < MaxOpacity) {
- m_mask->setOpacity(m_mask->opacity() + m_animIncrement);
- } else {
- m_animTimer->stop();
- m_mask->setOpacity(MaxOpacity);
- }
- } else {
- if (m_mask->opacity() + m_animIncrement > 0) {
- m_mask->setOpacity(m_mask->opacity() + m_animIncrement);
- } else {
- m_animTimer->stop();
- m_mask->setOpacity(0);
- popContext();
- emit contextPathChanged(m_path);
- }
- }
-
-}
-
-void SubcomponentEditorTool::clear()
-{
- m_currentContext.clear();
- m_mask->setCurrentItem(0);
- m_animTimer->stop();
- m_mask->hide();
- m_path.clear();
-
- emit contextPathChanged(m_path);
- emit cleared();
-}
-
-void SubcomponentEditorTool::selectedItemsChanged(const QList<QGraphicsItem*> &/*itemList*/)
-{
-
-}
-
-void SubcomponentEditorTool::setCurrentItem(QGraphicsItem* contextItem)
-{
- if (!contextItem)
- return;
-
- QGraphicsObject *gfxObject = contextItem->toGraphicsObject();
- if (!gfxObject)
- return;
-
- //QString parentClassName = gfxObject->metaObject()->className();
- //if (parentClassName.contains(QRegExp("_QMLTYPE_\\d+")))
-
- bool containsSelectableItems = false;
- foreach (QGraphicsItem *item, gfxObject->childItems()) {
- if (item->type() == Constants::EditorItemType
- || item->type() == Constants::ResizeHandleItemType)
- {
- continue;
- }
- containsSelectableItems = true;
- break;
- }
-
- if (containsSelectableItems) {
- m_mask->setCurrentItem(gfxObject);
- m_mask->setOpacity(0);
- m_mask->show();
- m_animIncrement = 0.05f;
- m_animTimer->start();
-
- QDeclarativeViewObserverPrivate::get(observer())->clearHighlight();
- observer()->setSelectedItems(QList<QGraphicsItem*>());
-
- pushContext(gfxObject);
- }
-}
-
-QGraphicsItem *SubcomponentEditorTool::firstChildOfContext(QGraphicsItem *item) const
-{
- if (!item)
- return 0;
-
- if (isDirectChildOfContext(item))
- return item;
-
- QGraphicsItem *parent = item->parentItem();
- while (parent) {
- if (isDirectChildOfContext(parent))
- return parent;
- parent = parent->parentItem();
- }
-
- return 0;
-}
-
-bool SubcomponentEditorTool::isChildOfContext(QGraphicsItem *item) const
-{
- return (firstChildOfContext(item) != 0);
-}
-
-bool SubcomponentEditorTool::isDirectChildOfContext(QGraphicsItem *item) const
-{
- return (item->parentItem() == m_currentContext.top());
-}
-
-bool SubcomponentEditorTool::itemIsChildOfQmlSubComponent(QGraphicsItem *item) const
-{
- if (item->parentItem() && item->parentItem() != m_currentContext.top()) {
- QGraphicsObject *parent = item->parentItem()->toGraphicsObject();
- QString parentClassName = parent->metaObject()->className();
-
- if (parentClassName.contains(QRegExp("_QMLTYPE_\\d+"))) {
- return true;
- } else {
- return itemIsChildOfQmlSubComponent(parent);
- }
- }
-
- return false;
-}
-
-void SubcomponentEditorTool::pushContext(QGraphicsObject *contextItem)
-{
- connect(contextItem, SIGNAL(destroyed(QObject*)), this, SLOT(contextDestroyed(QObject*)));
- connect(contextItem, SIGNAL(xChanged()), this, SLOT(resizeMask()));
- connect(contextItem, SIGNAL(yChanged()), this, SLOT(resizeMask()));
- connect(contextItem, SIGNAL(widthChanged()), this, SLOT(resizeMask()));
- connect(contextItem, SIGNAL(heightChanged()), this, SLOT(resizeMask()));
- connect(contextItem, SIGNAL(rotationChanged()), this, SLOT(resizeMask()));
-
- m_currentContext.push(contextItem);
- QString title = titleForItem(contextItem);
- emit contextPushed(title);
-
- m_path << title;
- emit contextPathChanged(m_path);
-}
-
-void SubcomponentEditorTool::aboutToPopContext()
-{
- if (m_currentContext.size() > 2) {
- popContext();
- emit contextPathChanged(m_path);
- } else {
- m_animIncrement = -0.05f;
- m_animTimer->start();
- }
-}
-
-QGraphicsObject *SubcomponentEditorTool::popContext()
-{
- QGraphicsObject *popped = m_currentContext.pop();
- m_path.removeLast();
-
- emit contextPopped();
-
- disconnect(popped, SIGNAL(xChanged()), this, SLOT(resizeMask()));
- disconnect(popped, SIGNAL(yChanged()), this, SLOT(resizeMask()));
- disconnect(popped, SIGNAL(scaleChanged()), this, SLOT(resizeMask()));
- disconnect(popped, SIGNAL(widthChanged()), this, SLOT(resizeMask()));
- disconnect(popped, SIGNAL(heightChanged()), this, SLOT(resizeMask()));
-
- if (m_currentContext.size() > 1) {
- QGraphicsObject *item = m_currentContext.top();
- m_mask->setCurrentItem(item);
- m_mask->setOpacity(MaxOpacity);
- m_mask->setVisible(true);
- } else {
- m_mask->setVisible(false);
- }
-
- return popped;
-}
-
-void SubcomponentEditorTool::resizeMask()
-{
- QGraphicsObject *item = m_currentContext.top();
- m_mask->setCurrentItem(item);
-}
-
-QGraphicsObject *SubcomponentEditorTool::currentRootItem() const
-{
- return m_currentContext.top();
-}
-
-void SubcomponentEditorTool::contextDestroyed(QObject *contextToDestroy)
-{
- disconnect(contextToDestroy, SIGNAL(destroyed(QObject*)),
- this, SLOT(contextDestroyed(QObject*)));
-
- // pop out the whole context - it might not be safe anymore.
- while (m_currentContext.size() > 1) {
- m_currentContext.pop();
- m_path.removeLast();
- emit contextPopped();
- }
- m_mask->setVisible(false);
-
- emit contextPathChanged(m_path);
-}
-
-QGraphicsObject *SubcomponentEditorTool::setContext(int contextIndex)
-{
- Q_ASSERT(contextIndex >= 0);
-
- // sometimes we have to delete the context while user was still clicking around,
- // so just bail out.
- if (contextIndex >= m_currentContext.size() -1)
- return 0;
-
- while (m_currentContext.size() - 1 > contextIndex) {
- popContext();
- }
- emit contextPathChanged(m_path);
-
- return m_currentContext.top();
-}
-
-int SubcomponentEditorTool::contextIndex() const
-{
- return m_currentContext.size() - 1;
-}
-
-} // namespace QmlJSDebugger
diff --git a/share/qtcreator/qml/qmljsdebugger/editor/subcomponenteditortool.h b/share/qtcreator/qml/qmljsdebugger/editor/subcomponenteditortool.h
deleted file mode 100644
index 785c810b36..0000000000
--- a/share/qtcreator/qml/qmljsdebugger/editor/subcomponenteditortool.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact: Nokia Corporation (info@qt.nokia.com)
-**
-**
-** GNU Lesser General Public License Usage
-**
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** Other Usage
-**
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**************************************************************************/
-
-#ifndef SUBCOMPONENTEDITORTOOL_H
-#define SUBCOMPONENTEDITORTOOL_H
-
-#include "abstractliveedittool.h"
-#include <QtCore/QStack>
-#include <QtCore/QStringList>
-
-QT_FORWARD_DECLARE_CLASS(QGraphicsObject)
-QT_FORWARD_DECLARE_CLASS(QPoint)
-QT_FORWARD_DECLARE_CLASS(QTimer)
-
-namespace QmlJSDebugger {
-
-class SubcomponentMaskLayerItem;
-
-class SubcomponentEditorTool : public AbstractLiveEditTool
-{
- Q_OBJECT
-
-public:
- SubcomponentEditorTool(QDeclarativeViewObserver *view);
- ~SubcomponentEditorTool();
-
- void mousePressEvent(QMouseEvent *event);
- void mouseMoveEvent(QMouseEvent *event);
- void mouseReleaseEvent(QMouseEvent *event);
- void mouseDoubleClickEvent(QMouseEvent *event);
-
- void hoverMoveEvent(QMouseEvent *event);
- void wheelEvent(QWheelEvent *event);
-
- void keyPressEvent(QKeyEvent *event);
- void keyReleaseEvent(QKeyEvent *keyEvent);
- void itemsAboutToRemoved(const QList<QGraphicsItem*> &itemList);
-
- void clear();
-
- bool containsCursor(const QPoint &mousePos) const;
- bool itemIsChildOfQmlSubComponent(QGraphicsItem *item) const;
-
- bool isChildOfContext(QGraphicsItem *item) const;
- bool isDirectChildOfContext(QGraphicsItem *item) const;
- QGraphicsItem *firstChildOfContext(QGraphicsItem *item) const;
-
- void setCurrentItem(QGraphicsItem *contextObject);
-
- void pushContext(QGraphicsObject *contextItem);
-
- QGraphicsObject *currentRootItem() const;
- QGraphicsObject *setContext(int contextIndex);
- int contextIndex() const;
-
-signals:
- void exitContextRequested();
- void cleared();
- void contextPushed(const QString &contextTitle);
- void contextPopped();
- void contextPathChanged(const QStringList &path);
-
-protected:
- void selectedItemsChanged(const QList<QGraphicsItem*> &itemList);
-
-private slots:
- void animate();
- void contextDestroyed(QObject *context);
- void resizeMask();
-
-private:
- QGraphicsObject *popContext();
- void aboutToPopContext();
-
-private:
- QStack<QGraphicsObject *> m_currentContext;
- QStringList m_path;
-
- qreal m_animIncrement;
- SubcomponentMaskLayerItem *m_mask;
- QTimer *m_animTimer;
-};
-
-} // namespace QmlJSDebugger
-
-#endif // SUBCOMPONENTEDITORTOOL_H
diff --git a/share/qtcreator/qml/qmljsdebugger/include/qdeclarativeobserverservice.h b/share/qtcreator/qml/qmljsdebugger/include/qdeclarativeobserverservice.h
index 5d05f621c1..972a362788 100644
--- a/share/qtcreator/qml/qmljsdebugger/include/qdeclarativeobserverservice.h
+++ b/share/qtcreator/qml/qmljsdebugger/include/qdeclarativeobserverservice.h
@@ -67,7 +67,6 @@ public:
public Q_SLOTS:
void selectedColorChanged(const QColor &color);
- void contextPathUpdated(const QStringList &contextPath);
Q_SIGNALS:
void debuggingClientChanged(bool hasDebuggingClient);
@@ -91,7 +90,6 @@ Q_SIGNALS:
void animationSpeedChangeRequested(qreal speedFactor);
void executionPauseChangeRequested(bool paused);
- void contextPathIndexChanged(int contextPathIndex);
void clearComponentCacheRequested();
protected:
diff --git a/share/qtcreator/qml/qmljsdebugger/include/qdeclarativeviewobserver.h b/share/qtcreator/qml/qmljsdebugger/include/qdeclarativeviewobserver.h
index 39e1a46985..2accbfa700 100644
--- a/share/qtcreator/qml/qmljsdebugger/include/qdeclarativeviewobserver.h
+++ b/share/qtcreator/qml/qmljsdebugger/include/qdeclarativeviewobserver.h
@@ -75,8 +75,6 @@ public Q_SLOTS:
void setAnimationSpeed(qreal factor);
void setAnimationPaused(bool paused);
- void setObserverContext(int contextIndex);
-
Q_SIGNALS:
void designModeBehaviorChanged(bool inDesignMode);
void showAppOnTopChanged(bool showAppOnTop);
@@ -90,10 +88,6 @@ Q_SIGNALS:
void animationSpeedChanged(qreal factor);
void animationPausedChanged(bool paused);
- void inspectorContextCleared();
- void inspectorContextPushed(const QString &contextTitle);
- void inspectorContextPopped();
-
protected:
bool eventFilter(QObject *obj, QEvent *event);
diff --git a/share/qtcreator/qml/qmljsdebugger/protocol/observerprotocol.h b/share/qtcreator/qml/qmljsdebugger/protocol/observerprotocol.h
index 6627098c9b..828a3f232c 100644
--- a/share/qtcreator/qml/qmljsdebugger/protocol/observerprotocol.h
+++ b/share/qtcreator/qml/qmljsdebugger/protocol/observerprotocol.h
@@ -52,7 +52,6 @@ public:
ChangeTool = 1,
ClearComponentCache = 2,
ColorChanged = 3,
- ContextPathUpdated = 4,
CreateObject = 5,
CurrentObjectsChanged = 6,
DestroyObject = 7,
@@ -62,7 +61,6 @@ public:
Reloaded = 11,
SetAnimationSpeed = 12,
SetAnimationPaused = 18,
- SetContextPathIdx = 13,
SetCurrentObjects = 14,
SetDesignMode = 15,
ShowAppOnTop = 16,
diff --git a/share/qtcreator/qml/qmljsdebugger/qdeclarativeobserverservice.cpp b/share/qtcreator/qml/qmljsdebugger/qdeclarativeobserverservice.cpp
index 5249329f27..255aa1e407 100644
--- a/share/qtcreator/qml/qmljsdebugger/qdeclarativeobserverservice.cpp
+++ b/share/qtcreator/qml/qmljsdebugger/qdeclarativeobserverservice.cpp
@@ -71,9 +71,7 @@ void QDeclarativeObserverService::messageReceived(const QByteArray &message)
for (int i = 0; i < itemCount; ++i) {
int debugId = -1;
ds >> debugId;
- QObject *obj = objectForId(debugId);
-
- if (obj)
+ if (QObject *obj = objectForId(debugId))
selectedObjects << obj;
}
@@ -170,12 +168,6 @@ void QDeclarativeObserverService::messageReceived(const QByteArray &message)
}
break;
}
- case ObserverProtocol::SetContextPathIdx: {
- int contextPathIndex;
- ds >> contextPathIndex;
- emit contextPathIndexChanged(contextPathIndex);
- break;
- }
case ObserverProtocol::ClearComponentCache: {
emit clearComponentCacheRequested();
break;
@@ -276,17 +268,6 @@ void QDeclarativeObserverService::selectedColorChanged(const QColor &color)
sendMessage(message);
}
-void QDeclarativeObserverService::contextPathUpdated(const QStringList &contextPath)
-{
- QByteArray message;
- QDataStream ds(&message, QIODevice::WriteOnly);
-
- ds << ObserverProtocol::ContextPathUpdated
- << contextPath;
-
- sendMessage(message);
-}
-
QString QDeclarativeObserverService::idStringForObject(QObject *obj) const
{
int id = idForObject(obj);
diff --git a/share/qtcreator/qml/qmljsdebugger/qdeclarativeviewobserver.cpp b/share/qtcreator/qml/qmljsdebugger/qdeclarativeviewobserver.cpp
index 4a13f26317..155185d596 100644
--- a/share/qtcreator/qml/qmljsdebugger/qdeclarativeviewobserver.cpp
+++ b/share/qtcreator/qml/qmljsdebugger/qdeclarativeviewobserver.cpp
@@ -38,7 +38,6 @@
#include "editor/colorpickertool.h"
#include "editor/livelayeritem.h"
#include "editor/boundingrecthighlighter.h"
-#include "editor/subcomponenteditortool.h"
#include "editor/qmltoolbar.h"
#include "qt_private/qdeclarativedebughelper_p.h"
@@ -127,7 +126,6 @@ QDeclarativeViewObserver::QDeclarativeViewObserver(QDeclarativeView *view, QObje
data->zoomTool = new ZoomTool(this);
data->colorPickerTool = new ColorPickerTool(this);
data->boundingRectHighlighter = new BoundingRectHighlighter(this);
- data->subcomponentEditorTool = new SubcomponentEditorTool(this);
data->currentTool = data->selectionTool;
// to capture ChildRemoved event when viewport changes
@@ -178,14 +176,6 @@ QDeclarativeViewObserver::QDeclarativeViewObserver(QDeclarativeView *view, QObje
connect(data->colorPickerTool, SIGNAL(selectedColorChanged(QColor)),
data->debugService, SLOT(selectedColorChanged(QColor)));
- connect(data->subcomponentEditorTool, SIGNAL(cleared()), SIGNAL(inspectorContextCleared()));
- connect(data->subcomponentEditorTool, SIGNAL(contextPushed(QString)),
- SIGNAL(inspectorContextPushed(QString)));
- connect(data->subcomponentEditorTool, SIGNAL(contextPopped()),
- SIGNAL(inspectorContextPopped()));
- connect(data->subcomponentEditorTool, SIGNAL(contextPathChanged(QStringList)),
- data->debugService, SLOT(contextPathUpdated(QStringList)));
-
data->_q_changeToSingleSelectTool();
}
@@ -193,15 +183,6 @@ QDeclarativeViewObserver::~QDeclarativeViewObserver()
{
}
-void QDeclarativeViewObserver::setObserverContext(int contextIndex)
-{
- if (data->subcomponentEditorTool->contextIndex() != contextIndex) {
- QGraphicsObject *object = data->subcomponentEditorTool->setContext(contextIndex);
- if (object)
- setSelectedItems(QList<QGraphicsItem*>() << object);
- }
-}
-
void QDeclarativeViewObserverPrivate::_q_setToolBoxVisible(bool visible)
{
#if !defined(Q_OS_SYMBIAN) && !defined(Q_WS_MAEMO_5) && !defined(Q_WS_SIMULATOR)
@@ -216,7 +197,6 @@ void QDeclarativeViewObserverPrivate::_q_setToolBoxVisible(bool visible)
void QDeclarativeViewObserverPrivate::_q_reloadView()
{
- subcomponentEditorTool->clear();
clearHighlight();
emit q->reloadRequested();
}
@@ -338,10 +318,8 @@ bool QDeclarativeViewObserver::mouseMoveEvent(QMouseEvent *event)
declarativeView()->setToolTip(QString());
}
if (event->buttons()) {
- data->subcomponentEditorTool->mouseMoveEvent(event);
data->currentTool->mouseMoveEvent(event);
} else {
- data->subcomponentEditorTool->hoverMoveEvent(event);
data->currentTool->hoverMoveEvent(event);
}
return true;
@@ -351,7 +329,6 @@ bool QDeclarativeViewObserver::mouseReleaseEvent(QMouseEvent *event)
{
if (!data->designModeBehavior)
return false;
- data->subcomponentEditorTool->mouseReleaseEvent(event);
data->cursorPos = event->pos();
data->currentTool->mouseReleaseEvent(event);
@@ -386,11 +363,6 @@ bool QDeclarativeViewObserver::keyReleaseEvent(QKeyEvent *event)
case Qt::Key_Z:
data->_q_changeToZoomTool();
break;
- case Qt::Key_Enter:
- case Qt::Key_Return:
- if (!data->selectedItems().isEmpty())
- data->subcomponentEditorTool->setCurrentItem(data->selectedItems().first());
- break;
case Qt::Key_Space:
setAnimationPaused(!data->animationPaused);
break;
@@ -576,41 +548,11 @@ void QDeclarativeViewObserverPrivate::_q_removeFromSelection(QObject *obj)
setSelectedItems(items);
}
-QGraphicsItem *QDeclarativeViewObserverPrivate::currentRootItem() const
-{
- return subcomponentEditorTool->currentRootItem();
-}
-
-bool QDeclarativeViewObserver::mouseDoubleClickEvent(QMouseEvent *event)
+bool QDeclarativeViewObserver::mouseDoubleClickEvent(QMouseEvent * /*event*/)
{
if (!data->designModeBehavior)
return false;
- if (data->currentToolMode != Constants::SelectionToolMode
- && data->currentToolMode != Constants::MarqueeSelectionToolMode)
- return true;
-
- QGraphicsItem *itemToEnter = 0;
- QList<QGraphicsItem*> itemList = data->view->items(event->pos());
- data->filterForSelection(itemList);
-
- if (data->selectedItems().isEmpty() && !itemList.isEmpty()) {
- itemToEnter = itemList.first();
- } else if (!data->selectedItems().isEmpty() && !itemList.isEmpty()) {
- itemToEnter = itemList.first();
- }
-
- if (itemToEnter)
- itemToEnter = data->subcomponentEditorTool->firstChildOfContext(itemToEnter);
-
- data->subcomponentEditorTool->setCurrentItem(itemToEnter);
- data->subcomponentEditorTool->mouseDoubleClickEvent(event);
-
- if ((event->buttons() & Qt::LeftButton) && itemToEnter) {
- if (QGraphicsObject *objectToEnter = itemToEnter->toGraphicsObject())
- setSelectedItems(QList<QGraphicsItem*>() << objectToEnter);
- }
-
return true;
}
@@ -622,16 +564,6 @@ bool QDeclarativeViewObserver::wheelEvent(QWheelEvent *event)
return true;
}
-void QDeclarativeViewObserverPrivate::enterContext(QGraphicsItem *itemToEnter)
-{
- QGraphicsItem *itemUnderCurrentContext = itemToEnter;
- if (itemUnderCurrentContext)
- itemUnderCurrentContext = subcomponentEditorTool->firstChildOfContext(itemToEnter);
-
- if (itemUnderCurrentContext)
- subcomponentEditorTool->setCurrentItem(itemToEnter);
-}
-
void QDeclarativeViewObserver::setDesignModeBehavior(bool value)
{
emit designModeBehaviorChanged(value);
@@ -641,14 +573,6 @@ void QDeclarativeViewObserver::setDesignModeBehavior(bool value)
data->debugService->setDesignModeBehavior(value);
data->designModeBehavior = value;
- if (data->subcomponentEditorTool) {
- data->subcomponentEditorTool->clear();
- data->clearHighlight();
- data->setSelectedItems(QList<QGraphicsItem*>());
-
- if (data->view->rootObject())
- data->subcomponentEditorTool->pushContext(data->view->rootObject());
- }
if (!data->designModeBehavior)
data->clearEditorItems();
@@ -769,12 +693,7 @@ void QDeclarativeViewObserverPrivate::clearHighlight()
boundingRectHighlighter->clear();
}
-void QDeclarativeViewObserverPrivate::highlight(QGraphicsObject * item, ContextFlags flags)
-{
- highlight(QList<QGraphicsObject*>() << item, flags);
-}
-
-void QDeclarativeViewObserverPrivate::highlight(QList<QGraphicsObject *> items, ContextFlags flags)
+void QDeclarativeViewObserverPrivate::highlight(const QList<QGraphicsObject *> &items)
{
if (items.isEmpty())
return;
@@ -782,8 +701,6 @@ void QDeclarativeViewObserverPrivate::highlight(QList<QGraphicsObject *> items,
QList<QGraphicsObject*> objectList;
foreach (QGraphicsItem *item, items) {
QGraphicsItem *child = item;
- if (flags & ContextSensitive)
- child = subcomponentEditorTool->firstChildOfContext(item);
if (child) {
QGraphicsObject *childObject = child->toGraphicsObject();
@@ -795,30 +712,24 @@ void QDeclarativeViewObserverPrivate::highlight(QList<QGraphicsObject *> items,
boundingRectHighlighter->highlight(objectList);
}
-bool QDeclarativeViewObserverPrivate::mouseInsideContextItem() const
-{
- return subcomponentEditorTool->containsCursor(cursorPos.toPoint());
-}
-
QList<QGraphicsItem*> QDeclarativeViewObserverPrivate::selectableItems(
const QPointF &scenePos) const
{
QList<QGraphicsItem*> itemlist = view->scene()->items(scenePos);
- return filterForCurrentContext(itemlist);
+ return filterForSelection(itemlist);
}
QList<QGraphicsItem*> QDeclarativeViewObserverPrivate::selectableItems(const QPoint &pos) const
{
QList<QGraphicsItem*> itemlist = view->items(pos);
- return filterForCurrentContext(itemlist);
+ return filterForSelection(itemlist);
}
QList<QGraphicsItem*> QDeclarativeViewObserverPrivate::selectableItems(
const QRectF &sceneRect, Qt::ItemSelectionMode selectionMode) const
{
QList<QGraphicsItem*> itemlist = view->scene()->items(sceneRect, selectionMode);
-
- return filterForCurrentContext(itemlist);
+ return filterForSelection(itemlist);
}
void QDeclarativeViewObserverPrivate::_q_changeToSingleSelectTool()
@@ -878,11 +789,6 @@ void QDeclarativeViewObserverPrivate::_q_changeToColorPickerTool()
debugService->setCurrentTool(Constants::ColorPickerMode);
}
-void QDeclarativeViewObserverPrivate::_q_changeContextPathIndex(int index)
-{
- subcomponentEditorTool->setContext(index);
-}
-
void QDeclarativeViewObserver::setAnimationSpeed(qreal slowDownFactor)
{
Q_ASSERT(slowDownFactor > 0);
@@ -934,38 +840,13 @@ QList<QGraphicsItem*> QDeclarativeViewObserverPrivate::filterForSelection(
QList<QGraphicsItem*> &itemlist) const
{
foreach (QGraphicsItem *item, itemlist) {
- if (isEditorItem(item) || !subcomponentEditorTool->isChildOfContext(item))
+ if (isEditorItem(item))
itemlist.removeOne(item);
}
return itemlist;
}
-QList<QGraphicsItem*> QDeclarativeViewObserverPrivate::filterForCurrentContext(
- QList<QGraphicsItem*> &itemlist) const
-{
- foreach (QGraphicsItem *item, itemlist) {
-
- if (isEditorItem(item) || !subcomponentEditorTool->isDirectChildOfContext(item)) {
-
- // if we're a child, but not directly, replace with the parent that is directly in context.
- if (QGraphicsItem *contextParent = subcomponentEditorTool->firstChildOfContext(item)) {
- if (contextParent != item) {
- if (itemlist.contains(contextParent)) {
- itemlist.removeOne(item);
- } else {
- itemlist.replace(itemlist.indexOf(item), contextParent);
- }
- }
- } else {
- itemlist.removeOne(item);
- }
- }
- }
-
- return itemlist;
-}
-
bool QDeclarativeViewObserverPrivate::isEditorItem(QGraphicsItem *item) const
{
return (item->type() == Constants::EditorItemType
@@ -975,14 +856,8 @@ bool QDeclarativeViewObserverPrivate::isEditorItem(QGraphicsItem *item) const
void QDeclarativeViewObserverPrivate::_q_onStatusChanged(QDeclarativeView::Status status)
{
- if (status == QDeclarativeView::Ready) {
- if (view->rootObject()) {
- if (subcomponentEditorTool->contextIndex() != -1)
- subcomponentEditorTool->clear();
- subcomponentEditorTool->pushContext(view->rootObject());
- }
+ if (status == QDeclarativeView::Ready)
debugService->reloaded();
- }
}
void QDeclarativeViewObserverPrivate::_q_onCurrentObjectsChanged(QList<QObject*> objects)
@@ -990,17 +865,15 @@ void QDeclarativeViewObserverPrivate::_q_onCurrentObjectsChanged(QList<QObject*>
QList<QGraphicsItem*> items;
QList<QGraphicsObject*> gfxObjects;
foreach (QObject *obj, objects) {
- QDeclarativeItem* declarativeItem = qobject_cast<QDeclarativeItem*>(obj);
- if (declarativeItem) {
+ if (QDeclarativeItem *declarativeItem = qobject_cast<QDeclarativeItem*>(obj)) {
items << declarativeItem;
- if (QGraphicsObject *gfxObj = declarativeItem->toGraphicsObject())
- gfxObjects << gfxObj;
+ gfxObjects << declarativeItem;
}
}
if (designModeBehavior) {
setSelectedItemsForTools(items);
clearHighlight();
- highlight(gfxObjects, QDeclarativeViewObserverPrivate::IgnoreContext);
+ highlight(gfxObjects);
}
}
diff --git a/share/qtcreator/qml/qmljsdebugger/qdeclarativeviewobserver_p.h b/share/qtcreator/qml/qmljsdebugger/qdeclarativeviewobserver_p.h
index 4b447c512c..543fd10786 100644
--- a/share/qtcreator/qml/qmljsdebugger/qdeclarativeviewobserver_p.h
+++ b/share/qtcreator/qml/qmljsdebugger/qdeclarativeviewobserver_p.h
@@ -48,7 +48,6 @@ class ZoomTool;
class ColorPickerTool;
class LiveLayerItem;
class BoundingRectHighlighter;
-class SubcomponentEditorTool;
class ToolBox;
class CrumblePath;
class AbstractLiveEditTool;
@@ -57,11 +56,6 @@ class QDeclarativeViewObserverPrivate : public QObject
{
Q_OBJECT
public:
- enum ContextFlags {
- IgnoreContext,
- ContextSensitive
- };
-
QDeclarativeViewObserverPrivate(QDeclarativeViewObserver *);
~QDeclarativeViewObserverPrivate();
@@ -79,7 +73,6 @@ public:
LiveSelectionTool *selectionTool;
ZoomTool *zoomTool;
ColorPickerTool *colorPickerTool;
- SubcomponentEditorTool *subcomponentEditorTool;
LiveLayerItem *manipulatorLayer;
BoundingRectHighlighter *boundingRectHighlighter;
@@ -97,7 +90,6 @@ public:
void clearEditorItems();
void createToolBox();
void changeToSelectTool();
- QList<QGraphicsItem*> filterForCurrentContext(QList<QGraphicsItem*> &itemlist) const;
QList<QGraphicsItem*> filterForSelection(QList<QGraphicsItem*> &itemlist) const;
QList<QGraphicsItem*> selectableItems(const QPoint &pos) const;
@@ -112,16 +104,12 @@ public:
Constants::ToolFlags flags = Constants::NoToolFlags);
void clearHighlight();
- void highlight(QList<QGraphicsObject *> item, ContextFlags flags = ContextSensitive);
- void highlight(QGraphicsObject *item, ContextFlags flags = ContextSensitive);
+ void highlight(const QList<QGraphicsObject *> &item);
+ inline void highlight(QGraphicsObject *item)
+ { highlight(QList<QGraphicsObject*>() << item); }
- bool mouseInsideContextItem() const;
bool isEditorItem(QGraphicsItem *item) const;
- QGraphicsItem *currentRootItem() const;
-
- void enterContext(QGraphicsItem *itemToEnter);
-
public slots:
void _q_setToolBoxVisible(bool visible);
@@ -138,7 +126,6 @@ public slots:
void _q_changeToMarqueeSelectTool();
void _q_changeToZoomTool();
void _q_changeToColorPickerTool();
- void _q_changeContextPathIndex(int index);
void _q_clearComponentCache();
void _q_removeFromSelection(QObject *);
diff --git a/share/qtcreator/qml/qmljsdebugger/qmljsdebugger-src.pri b/share/qtcreator/qml/qmljsdebugger/qmljsdebugger-src.pri
index 12f5af926c..025f758adb 100644
--- a/share/qtcreator/qml/qmljsdebugger/qmljsdebugger-src.pri
+++ b/share/qtcreator/qml/qmljsdebugger/qmljsdebugger-src.pri
@@ -21,7 +21,6 @@ HEADERS += \
$$PWD/editor/liveselectionrectangle.h \
$$PWD/editor/liveselectionindicator.h \
$$PWD/editor/boundingrecthighlighter.h \
- $$PWD/editor/subcomponenteditortool.h \
$$PWD/editor/subcomponentmasklayeritem.h \
$$PWD/editor/zoomtool.h \
$$PWD/editor/colorpickertool.h \
@@ -40,7 +39,6 @@ SOURCES += \
$$PWD/editor/liveselectionrectangle.cpp \
$$PWD/editor/liveselectionindicator.cpp \
$$PWD/editor/boundingrecthighlighter.cpp \
- $$PWD/editor/subcomponenteditortool.cpp \
$$PWD/editor/subcomponentmasklayeritem.cpp \
$$PWD/editor/zoomtool.cpp \
$$PWD/editor/colorpickertool.cpp \