summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKai Koehne <kai.koehne@nokia.com>2010-09-14 13:39:32 +0200
committerKai Koehne <kai.koehne@nokia.com>2010-09-15 14:18:39 +0200
commit63cae2981b45b8d6c9334d28e0929d8a29f0c1eb (patch)
tree977a54e33cbae7d53bad04a1e952c7f5b342d3b0
parent0fa0d00fcdbb07568cce6bf911c7634893f0c8b6 (diff)
downloadqt-creator-63cae2981b45b8d6c9334d28e0929d8a29f0c1eb.tar.gz
QmlJsDebugger: Replace QDDesignView by QDViewObserver
Don't force users to inherit from QDeclarativeDesignView. Instead we're using now event filters to let a user attach a QDeclarativeViewObserver object to a QDeclarativeDesignView.
-rw-r--r--share/qtcreator/qmljsdebugger/editor/abstractformeditortool.cpp25
-rw-r--r--share/qtcreator/qmljsdebugger/editor/abstractformeditortool.h11
-rw-r--r--share/qtcreator/qmljsdebugger/editor/boundingrecthighlighter.cpp6
-rw-r--r--share/qtcreator/qmljsdebugger/editor/boundingrecthighlighter.h6
-rw-r--r--share/qtcreator/qmljsdebugger/editor/colorpickertool.cpp4
-rw-r--r--share/qtcreator/qmljsdebugger/editor/colorpickertool.h2
-rw-r--r--share/qtcreator/qmljsdebugger/editor/rubberbandselectionmanipulator.cpp8
-rw-r--r--share/qtcreator/qmljsdebugger/editor/rubberbandselectionmanipulator.h6
-rw-r--r--share/qtcreator/qmljsdebugger/editor/selectionindicator.cpp6
-rw-r--r--share/qtcreator/qmljsdebugger/editor/selectionindicator.h6
-rw-r--r--share/qtcreator/qmljsdebugger/editor/selectiontool.cpp34
-rw-r--r--share/qtcreator/qmljsdebugger/editor/selectiontool.h5
-rw-r--r--share/qtcreator/qmljsdebugger/editor/singleselectionmanipulator.cpp10
-rw-r--r--share/qtcreator/qmljsdebugger/editor/singleselectionmanipulator.h6
-rw-r--r--share/qtcreator/qmljsdebugger/editor/subcomponenteditortool.cpp12
-rw-r--r--share/qtcreator/qmljsdebugger/editor/subcomponenteditortool.h2
-rw-r--r--share/qtcreator/qmljsdebugger/editor/subcomponentmasklayeritem.cpp10
-rw-r--r--share/qtcreator/qmljsdebugger/editor/subcomponentmasklayeritem.h6
-rw-r--r--share/qtcreator/qmljsdebugger/editor/zoomtool.cpp6
-rw-r--r--share/qtcreator/qmljsdebugger/editor/zoomtool.h2
-rw-r--r--share/qtcreator/qmljsdebugger/include/qdeclarativeviewobserver.h (renamed from share/qtcreator/qmljsdebugger/include/qdeclarativedesignview.h)42
-rw-r--r--share/qtcreator/qmljsdebugger/qdeclarativeviewobserver.cpp (renamed from share/qtcreator/qmljsdebugger/qdeclarativedesignview.cpp)277
-rw-r--r--share/qtcreator/qmljsdebugger/qdeclarativeviewobserver_p.h (renamed from share/qtcreator/qmljsdebugger/qdeclarativedesignview_p.h)15
-rw-r--r--share/qtcreator/qmljsdebugger/qmljsdebugger-lib.pri6
-rw-r--r--share/qtcreator/templates/qmlapp/qmlapplicationviewer/qmlapplicationviewer.cpp2
-rw-r--r--share/qtcreator/templates/qmlapp/qmlapplicationviewer/qmlapplicationviewer.h4
-rw-r--r--src/plugins/debugger/debuggerrunner.cpp10
-rw-r--r--src/tools/qml/qmlobserver/qmlruntime.cpp29
-rw-r--r--src/tools/qml/qmlobserver/qmlruntime.h5
29 files changed, 314 insertions, 249 deletions
diff --git a/share/qtcreator/qmljsdebugger/editor/abstractformeditortool.cpp b/share/qtcreator/qmljsdebugger/editor/abstractformeditortool.cpp
index ece0b49637..179bda9d7f 100644
--- a/share/qtcreator/qmljsdebugger/editor/abstractformeditortool.cpp
+++ b/share/qtcreator/qmljsdebugger/editor/abstractformeditortool.cpp
@@ -28,8 +28,8 @@
**************************************************************************/
#include "abstractformeditortool.h"
-#include "qdeclarativedesignview.h"
-#include "qdeclarativedesignview_p.h"
+#include "qdeclarativeviewobserver.h"
+#include "qdeclarativeviewobserver_p.h"
#include <QDeclarativeEngine>
@@ -39,8 +39,8 @@
namespace QmlViewer {
-AbstractFormEditorTool::AbstractFormEditorTool(QDeclarativeDesignView *editorView)
- : QObject(editorView), m_view(editorView)
+AbstractFormEditorTool::AbstractFormEditorTool(QDeclarativeViewObserver *editorView)
+ : QObject(editorView), m_observer(editorView)
{
}
@@ -50,9 +50,14 @@ AbstractFormEditorTool::~AbstractFormEditorTool()
}
-QDeclarativeDesignView* AbstractFormEditorTool::view() const
+QDeclarativeViewObserver *AbstractFormEditorTool::observer() const
{
- return m_view;
+ return m_observer;
+}
+
+QDeclarativeView *AbstractFormEditorTool::view() const
+{
+ return m_observer->declarativeView();
}
QGraphicsScene* AbstractFormEditorTool::scene() const
@@ -67,12 +72,12 @@ void AbstractFormEditorTool::updateSelectedItems()
QList<QGraphicsItem*> AbstractFormEditorTool::items() const
{
- return view()->selectedItems();
+ return observer()->selectedItems();
}
void AbstractFormEditorTool::enterContext(QGraphicsItem *itemToEnter)
{
- view()->data->enterContext(itemToEnter);
+ observer()->data->enterContext(itemToEnter);
}
bool AbstractFormEditorTool::topItemIsMovable(const QList<QGraphicsItem*> & itemList)
@@ -92,7 +97,7 @@ bool AbstractFormEditorTool::topItemIsMovable(const QList<QGraphicsItem*> & item
bool AbstractFormEditorTool::topSelectedItemIsMovable(const QList<QGraphicsItem*> &itemList)
{
- QList<QGraphicsItem*> selectedItems = view()->selectedItems();
+ QList<QGraphicsItem*> selectedItems = observer()->selectedItems();
foreach (QGraphicsItem *item, itemList) {
QDeclarativeItem *declarativeItem = toQDeclarativeItem(item);
@@ -178,7 +183,7 @@ QString AbstractFormEditorTool::titleForItem(QGraphicsItem *item)
QDeclarativeItem *declarativeItem = qobject_cast<QDeclarativeItem*>(gfxObject);
if (declarativeItem) {
- objectStringId = QDeclarativeDesignView::idStringForObject(declarativeItem);
+ objectStringId = QDeclarativeViewObserver::idStringForObject(declarativeItem);
}
if (!objectStringId.isEmpty()) {
diff --git a/share/qtcreator/qmljsdebugger/editor/abstractformeditortool.h b/share/qtcreator/qmljsdebugger/editor/abstractformeditortool.h
index 63a3d3eb85..1cecc494bc 100644
--- a/share/qtcreator/qmljsdebugger/editor/abstractformeditortool.h
+++ b/share/qtcreator/qmljsdebugger/editor/abstractformeditortool.h
@@ -42,12 +42,12 @@ class QKeyEvent;
class QGraphicsScene;
class QGraphicsObject;
class QWheelEvent;
+class QDeclarativeView;
QT_END_NAMESPACE
namespace QmlViewer {
-class QDeclarativeDesignView;
-
+class QDeclarativeViewObserver;
class FormEditorView;
@@ -55,7 +55,7 @@ class AbstractFormEditorTool : public QObject
{
Q_OBJECT
public:
- AbstractFormEditorTool(QDeclarativeDesignView* view);
+ AbstractFormEditorTool(QDeclarativeViewObserver* observer);
virtual ~AbstractFormEditorTool();
@@ -92,11 +92,12 @@ public:
protected:
virtual void selectedItemsChanged(const QList<QGraphicsItem*> &objectList) = 0;
- QDeclarativeDesignView *view() const;
+ QDeclarativeViewObserver *observer() const;
+ QDeclarativeView *view() const;
QGraphicsScene* scene() const;
private:
- QDeclarativeDesignView *m_view;
+ QDeclarativeViewObserver *m_observer;
QList<QGraphicsItem*> m_itemList;
};
diff --git a/share/qtcreator/qmljsdebugger/editor/boundingrecthighlighter.cpp b/share/qtcreator/qmljsdebugger/editor/boundingrecthighlighter.cpp
index 43ebea001b..b889e67bc9 100644
--- a/share/qtcreator/qmljsdebugger/editor/boundingrecthighlighter.cpp
+++ b/share/qtcreator/qmljsdebugger/editor/boundingrecthighlighter.cpp
@@ -1,5 +1,5 @@
#include "boundingrecthighlighter.h"
-#include "qdeclarativedesignview.h"
+#include "qdeclarativeviewobserver.h"
#include "qmlviewerconstants.h"
#include <QGraphicsPolygonItem>
@@ -48,8 +48,8 @@ int BoundingBoxPolygonItem::type() const
return Constants::EditorItemType;
}
-BoundingRectHighlighter::BoundingRectHighlighter(QDeclarativeDesignView *view) :
- LayerItem(view->scene()),
+BoundingRectHighlighter::BoundingRectHighlighter(QDeclarativeViewObserver *view) :
+ LayerItem(view->declarativeView()->scene()),
m_view(view),
m_animFrame(0)
{
diff --git a/share/qtcreator/qmljsdebugger/editor/boundingrecthighlighter.h b/share/qtcreator/qmljsdebugger/editor/boundingrecthighlighter.h
index 139b1ac787..16b1c50699 100644
--- a/share/qtcreator/qmljsdebugger/editor/boundingrecthighlighter.h
+++ b/share/qtcreator/qmljsdebugger/editor/boundingrecthighlighter.h
@@ -14,14 +14,14 @@ QT_FORWARD_DECLARE_CLASS(QTimer);
namespace QmlViewer {
-class QDeclarativeDesignView;
+class QDeclarativeViewObserver;
class BoundingBox;
class BoundingRectHighlighter : public LayerItem
{
Q_OBJECT
public:
- explicit BoundingRectHighlighter(QDeclarativeDesignView *view);
+ explicit BoundingRectHighlighter(QDeclarativeViewObserver *view);
~BoundingRectHighlighter();
void clear();
void highlight(QList<QGraphicsObject*> items);
@@ -42,7 +42,7 @@ private:
private:
Q_DISABLE_COPY(BoundingRectHighlighter);
- QDeclarativeDesignView *m_view;
+ QDeclarativeViewObserver *m_view;
QList<BoundingBox* > m_boxes;
QList<BoundingBox* > m_freeBoxes;
QTimer *m_animTimer;
diff --git a/share/qtcreator/qmljsdebugger/editor/colorpickertool.cpp b/share/qtcreator/qmljsdebugger/editor/colorpickertool.cpp
index 5bc349cba9..863ce9b8bc 100644
--- a/share/qtcreator/qmljsdebugger/editor/colorpickertool.cpp
+++ b/share/qtcreator/qmljsdebugger/editor/colorpickertool.cpp
@@ -1,5 +1,5 @@
#include "colorpickertool.h"
-#include "qdeclarativedesignview.h"
+#include "qdeclarativeviewobserver.h"
#include <QMouseEvent>
#include <QKeyEvent>
@@ -11,7 +11,7 @@
namespace QmlViewer {
-ColorPickerTool::ColorPickerTool(QDeclarativeDesignView *view) :
+ColorPickerTool::ColorPickerTool(QDeclarativeViewObserver *view) :
AbstractFormEditorTool(view)
{
m_selectedColor.setRgb(0,0,0);
diff --git a/share/qtcreator/qmljsdebugger/editor/colorpickertool.h b/share/qtcreator/qmljsdebugger/editor/colorpickertool.h
index f762179c41..b9beec58db 100644
--- a/share/qtcreator/qmljsdebugger/editor/colorpickertool.h
+++ b/share/qtcreator/qmljsdebugger/editor/colorpickertool.h
@@ -13,7 +13,7 @@ class ColorPickerTool : public AbstractFormEditorTool
{
Q_OBJECT
public:
- explicit ColorPickerTool(QDeclarativeDesignView *view);
+ explicit ColorPickerTool(QDeclarativeViewObserver *view);
virtual ~ColorPickerTool();
diff --git a/share/qtcreator/qmljsdebugger/editor/rubberbandselectionmanipulator.cpp b/share/qtcreator/qmljsdebugger/editor/rubberbandselectionmanipulator.cpp
index 8f24552890..66843e87ae 100644
--- a/share/qtcreator/qmljsdebugger/editor/rubberbandselectionmanipulator.cpp
+++ b/share/qtcreator/qmljsdebugger/editor/rubberbandselectionmanipulator.cpp
@@ -28,13 +28,13 @@
**************************************************************************/
#include "rubberbandselectionmanipulator.h"
-#include "qdeclarativedesignview_p.h"
+#include "qdeclarativeviewobserver_p.h"
#include <QDebug>
namespace QmlViewer {
-RubberBandSelectionManipulator::RubberBandSelectionManipulator(QGraphicsObject *layerItem, QDeclarativeDesignView *editorView)
+RubberBandSelectionManipulator::RubberBandSelectionManipulator(QGraphicsObject *layerItem, QDeclarativeViewObserver *editorView)
: m_selectionRectangleElement(layerItem),
m_editorView(editorView),
m_beginFormEditorItem(0),
@@ -66,7 +66,7 @@ void RubberBandSelectionManipulator::begin(const QPointF& beginPoint)
m_selectionRectangleElement.setRect(m_beginPoint, m_beginPoint);
m_selectionRectangleElement.show();
m_isActive = true;
- m_beginFormEditorItem = topFormEditorItem(QDeclarativeDesignViewPrivate::get(m_editorView)->selectableItems(beginPoint));
+ m_beginFormEditorItem = topFormEditorItem(QDeclarativeViewObserverPrivate::get(m_editorView)->selectableItems(beginPoint));
m_oldSelectionList = m_editorView->selectedItems();
}
@@ -84,7 +84,7 @@ void RubberBandSelectionManipulator::end()
void RubberBandSelectionManipulator::select(SelectionType selectionType)
{
- QList<QGraphicsItem*> itemList = QDeclarativeDesignViewPrivate::get(m_editorView)->selectableItems(m_selectionRectangleElement.rect(),
+ QList<QGraphicsItem*> itemList = QDeclarativeViewObserverPrivate::get(m_editorView)->selectableItems(m_selectionRectangleElement.rect(),
Qt::IntersectsItemShape);
QList<QGraphicsItem*> newSelectionList;
diff --git a/share/qtcreator/qmljsdebugger/editor/rubberbandselectionmanipulator.h b/share/qtcreator/qmljsdebugger/editor/rubberbandselectionmanipulator.h
index 272d054b65..feacc2d52a 100644
--- a/share/qtcreator/qmljsdebugger/editor/rubberbandselectionmanipulator.h
+++ b/share/qtcreator/qmljsdebugger/editor/rubberbandselectionmanipulator.h
@@ -35,7 +35,7 @@
namespace QmlViewer {
-class QDeclarativeDesignView;
+class QDeclarativeViewObserver;
class RubberBandSelectionManipulator
{
@@ -47,7 +47,7 @@ public:
};
- RubberBandSelectionManipulator(QGraphicsObject *layerItem, QDeclarativeDesignView *editorView);
+ RubberBandSelectionManipulator(QGraphicsObject *layerItem, QDeclarativeViewObserver *editorView);
void setItems(const QList<QGraphicsItem*> &itemList);
@@ -72,7 +72,7 @@ private:
QList<QGraphicsItem*> m_oldSelectionList;
SelectionRectangle m_selectionRectangleElement;
QPointF m_beginPoint;
- QDeclarativeDesignView *m_editorView;
+ QDeclarativeViewObserver *m_editorView;
QGraphicsItem *m_beginFormEditorItem;
bool m_isActive;
};
diff --git a/share/qtcreator/qmljsdebugger/editor/selectionindicator.cpp b/share/qtcreator/qmljsdebugger/editor/selectionindicator.cpp
index 585b54999c..8ebc1d71a9 100644
--- a/share/qtcreator/qmljsdebugger/editor/selectionindicator.cpp
+++ b/share/qtcreator/qmljsdebugger/editor/selectionindicator.cpp
@@ -28,7 +28,7 @@
**************************************************************************/
#include "selectionindicator.h"
-#include "qdeclarativedesignview_p.h"
+#include "qdeclarativeviewobserver_p.h"
#include "qmlviewerconstants.h"
#include <QPen>
@@ -38,7 +38,7 @@
namespace QmlViewer {
-SelectionIndicator::SelectionIndicator(QDeclarativeDesignView *editorView, QGraphicsObject *layerItem)
+SelectionIndicator::SelectionIndicator(QDeclarativeViewObserver *editorView, QGraphicsObject *layerItem)
: m_layerItem(layerItem), m_view(editorView)
{
}
@@ -85,7 +85,7 @@ QPolygonF SelectionIndicator::addBoundingRectToPolygon(QGraphicsItem *item, QPol
}
foreach(QGraphicsItem *child, item->childItems()) {
- if (!QDeclarativeDesignViewPrivate::get(m_view)->isEditorItem(child))
+ if (!QDeclarativeViewObserverPrivate::get(m_view)->isEditorItem(child))
addBoundingRectToPolygon(child, polygon);
}
return polygon;
diff --git a/share/qtcreator/qmljsdebugger/editor/selectionindicator.h b/share/qtcreator/qmljsdebugger/editor/selectionindicator.h
index 9880111c6b..61dfa9af62 100644
--- a/share/qtcreator/qmljsdebugger/editor/selectionindicator.h
+++ b/share/qtcreator/qmljsdebugger/editor/selectionindicator.h
@@ -36,12 +36,12 @@
namespace QmlViewer {
-class QDeclarativeDesignView;
+class QDeclarativeViewObserver;
class SelectionIndicator
{
public:
- SelectionIndicator(QDeclarativeDesignView* editorView, QGraphicsObject *layerItem);
+ SelectionIndicator(QDeclarativeViewObserver* editorView, QGraphicsObject *layerItem);
~SelectionIndicator();
void show();
@@ -57,7 +57,7 @@ private:
private:
QHash<QGraphicsItem*, QGraphicsPolygonItem *> m_indicatorShapeHash;
QWeakPointer<QGraphicsObject> m_layerItem;
- QDeclarativeDesignView *m_view;
+ QDeclarativeViewObserver *m_view;
};
diff --git a/share/qtcreator/qmljsdebugger/editor/selectiontool.cpp b/share/qtcreator/qmljsdebugger/editor/selectiontool.cpp
index dbcadd605b..5e8a01dc1f 100644
--- a/share/qtcreator/qmljsdebugger/editor/selectiontool.cpp
+++ b/share/qtcreator/qmljsdebugger/editor/selectiontool.cpp
@@ -31,7 +31,7 @@
#include "layeritem.h"
//#include "resizehandleitem.h"
-#include "qdeclarativedesignview_p.h"
+#include "qdeclarativeviewobserver_p.h"
#include <QDeclarativeEngine>
@@ -48,12 +48,12 @@
namespace QmlViewer {
-SelectionTool::SelectionTool(QDeclarativeDesignView *editorView)
+SelectionTool::SelectionTool(QDeclarativeViewObserver *editorView)
: AbstractFormEditorTool(editorView),
m_rubberbandSelectionMode(false),
- m_rubberbandSelectionManipulator(QDeclarativeDesignViewPrivate::get(editorView)->manipulatorLayer, editorView),
+ m_rubberbandSelectionManipulator(QDeclarativeViewObserverPrivate::get(editorView)->manipulatorLayer, editorView),
m_singleSelectionManipulator(editorView),
- m_selectionIndicator(editorView, QDeclarativeDesignViewPrivate::get(editorView)->manipulatorLayer),
+ m_selectionIndicator(editorView, QDeclarativeViewObserverPrivate::get(editorView)->manipulatorLayer),
//m_resizeIndicator(editorView->manipulatorLayer()),
m_selectOnlyContentItems(true)
{
@@ -82,7 +82,7 @@ SingleSelectionManipulator::SelectionType SelectionTool::getSelectionType(Qt::Ke
bool SelectionTool::alreadySelected(const QList<QGraphicsItem*> &itemList) const
{
- const QList<QGraphicsItem*> selectedItems = QDeclarativeDesignViewPrivate::get(view())->selectedItems();
+ const QList<QGraphicsItem*> selectedItems = QDeclarativeViewObserverPrivate::get(observer())->selectedItems();
if (selectedItems.isEmpty())
return false;
@@ -98,7 +98,7 @@ bool SelectionTool::alreadySelected(const QList<QGraphicsItem*> &itemList) const
void SelectionTool::mousePressEvent(QMouseEvent *event)
{
- QList<QGraphicsItem*> itemList = QDeclarativeDesignViewPrivate::get(view())->selectableItems(event->pos());
+ QList<QGraphicsItem*> itemList = QDeclarativeViewObserverPrivate::get(observer())->selectableItems(event->pos());
SingleSelectionManipulator::SelectionType selectionType = getSelectionType(event->modifiers());
if (event->buttons() & Qt::LeftButton) {
@@ -109,7 +109,7 @@ void SelectionTool::mousePressEvent(QMouseEvent *event)
} else {
if (itemList.isEmpty()) {
- QDeclarativeDesignViewPrivate::get(view())->setSelectedItems(itemList);
+ QDeclarativeViewObserverPrivate::get(observer())->setSelectedItems(itemList);
return;
}
@@ -130,7 +130,7 @@ void SelectionTool::mousePressEvent(QMouseEvent *event)
m_mousePressTimer.start();
if (itemList.isEmpty()) {
- view()->setSelectedItems(itemList);
+ observer()->setSelectedItems(itemList);
return;
}
@@ -159,7 +159,7 @@ void SelectionTool::mousePressEvent(QMouseEvent *event)
void SelectionTool::createContextMenu(QList<QGraphicsItem*> itemList, QPoint globalPos)
{
- if (!QDeclarativeDesignViewPrivate::get(view())->mouseInsideContextItem())
+ if (!QDeclarativeViewObserverPrivate::get(observer())->mouseInsideContextItem())
return;
QMenu contextMenu;
@@ -177,7 +177,7 @@ void SelectionTool::createContextMenu(QList<QGraphicsItem*> itemList, QPoint glo
QString itemTitle = titleForItem(item);
QAction *elementAction = contextMenu.addAction(itemTitle, this, SLOT(contextMenuElementSelected()));
- if (view()->selectedItems().contains(item)) {
+ if (observer()->selectedItems().contains(item)) {
QFont boldFont = elementAction->font();
boldFont.setBold(true);
elementAction->setFont(boldFont);
@@ -224,7 +224,7 @@ void SelectionTool::contextMenuElementHovered(QAction *action)
int itemListIndex = action->data().toInt();
if (itemListIndex >= 0 && itemListIndex < m_contextMenuItemList.length()) {
QGraphicsObject *item = m_contextMenuItemList.at(itemListIndex)->toGraphicsObject();
- QDeclarativeDesignViewPrivate::get(view())->highlight(item);
+ QDeclarativeViewObserverPrivate::get(observer())->highlight(item);
}
}
@@ -274,16 +274,16 @@ void SelectionTool::hoverMoveEvent(QMouseEvent * event)
// if (topSelectedItemIsMovable(itemList))
// view()->changeTool(Constants::MoveToolMode);
// }
- QList<QGraphicsItem*> selectableItemList = QDeclarativeDesignViewPrivate::get(view())->selectableItems(event->pos());
+ QList<QGraphicsItem*> selectableItemList = QDeclarativeViewObserverPrivate::get(observer())->selectableItems(event->pos());
if (!selectableItemList.isEmpty()) {
QGraphicsObject *item = selectableItemList.first()->toGraphicsObject();
if (item)
- QDeclarativeDesignViewPrivate::get(view())->highlight(item);
+ QDeclarativeViewObserverPrivate::get(observer())->highlight(item);
return;
}
- QDeclarativeDesignViewPrivate::get(view())->clearHighlight();
+ QDeclarativeViewObserverPrivate::get(observer())->clearHighlight();
}
void SelectionTool::mouseReleaseEvent(QMouseEvent *event)
@@ -349,11 +349,11 @@ void SelectionTool::wheelEvent(QWheelEvent *event)
if (event->orientation() == Qt::Horizontal || m_rubberbandSelectionMode)
return;
- QList<QGraphicsItem*> itemList = QDeclarativeDesignViewPrivate::get(view())->selectableItems(event->pos());
+ QList<QGraphicsItem*> itemList = QDeclarativeViewObserverPrivate::get(observer())->selectableItems(event->pos());
int selectedIdx = 0;
- if (!view()->selectedItems().isEmpty()) {
- selectedIdx = itemList.indexOf(view()->selectedItems().first());
+ if (!observer()->selectedItems().isEmpty()) {
+ selectedIdx = itemList.indexOf(observer()->selectedItems().first());
if (selectedIdx >= 0) {
if (event->delta() > 0) {
selectedIdx++;
diff --git a/share/qtcreator/qmljsdebugger/editor/selectiontool.h b/share/qtcreator/qmljsdebugger/editor/selectiontool.h
index 9fa6e8825e..e535786fe4 100644
--- a/share/qtcreator/qmljsdebugger/editor/selectiontool.h
+++ b/share/qtcreator/qmljsdebugger/editor/selectiontool.h
@@ -32,15 +32,14 @@
#include "abstractformeditortool.h"
-#include "movemanipulator.h"
#include "rubberbandselectionmanipulator.h"
#include "singleselectionmanipulator.h"
#include "selectionindicator.h"
-#include "resizeindicator.h"
#include <QHash>
#include <QList>
#include <QTime>
+#include <QAction>
QT_FORWARD_DECLARE_CLASS(QGraphicsItem);
QT_FORWARD_DECLARE_CLASS(QMouseEvent);
@@ -53,7 +52,7 @@ class SelectionTool : public AbstractFormEditorTool
Q_OBJECT
public:
- SelectionTool(QDeclarativeDesignView* editorView);
+ SelectionTool(QDeclarativeViewObserver* editorView);
~SelectionTool();
void mousePressEvent(QMouseEvent *event);
diff --git a/share/qtcreator/qmljsdebugger/editor/singleselectionmanipulator.cpp b/share/qtcreator/qmljsdebugger/editor/singleselectionmanipulator.cpp
index 3c5fed7cca..191252ae8b 100644
--- a/share/qtcreator/qmljsdebugger/editor/singleselectionmanipulator.cpp
+++ b/share/qtcreator/qmljsdebugger/editor/singleselectionmanipulator.cpp
@@ -28,13 +28,13 @@
**************************************************************************/
#include "singleselectionmanipulator.h"
-#include "qdeclarativedesignview.h"
-#include "qdeclarativedesignview_p.h"
+#include "qdeclarativeviewobserver.h"
+#include "qdeclarativeviewobserver_p.h"
#include <QtDebug>
namespace QmlViewer {
-SingleSelectionManipulator::SingleSelectionManipulator(QDeclarativeDesignView *editorView)
+SingleSelectionManipulator::SingleSelectionManipulator(QDeclarativeViewObserver *editorView)
: m_editorView(editorView),
m_isActive(false)
{
@@ -45,7 +45,7 @@ void SingleSelectionManipulator::begin(const QPointF &beginPoint)
{
m_beginPoint = beginPoint;
m_isActive = true;
- m_oldSelectionList = QDeclarativeDesignViewPrivate::get(m_editorView)->selectedItems();
+ m_oldSelectionList = QDeclarativeViewObserverPrivate::get(m_editorView)->selectedItems();
}
void SingleSelectionManipulator::update(const QPointF &/*updatePoint*/)
@@ -116,7 +116,7 @@ void SingleSelectionManipulator::select(SelectionType selectionType, const QList
void SingleSelectionManipulator::select(SelectionType selectionType, bool selectOnlyContentItems)
{
- QList<QGraphicsItem*> itemList = QDeclarativeDesignViewPrivate::get(m_editorView)->selectableItems(m_beginPoint);
+ QList<QGraphicsItem*> itemList = QDeclarativeViewObserverPrivate::get(m_editorView)->selectableItems(m_beginPoint);
select(selectionType, itemList, selectOnlyContentItems);
}
diff --git a/share/qtcreator/qmljsdebugger/editor/singleselectionmanipulator.h b/share/qtcreator/qmljsdebugger/editor/singleselectionmanipulator.h
index 04f339640f..bde990634d 100644
--- a/share/qtcreator/qmljsdebugger/editor/singleselectionmanipulator.h
+++ b/share/qtcreator/qmljsdebugger/editor/singleselectionmanipulator.h
@@ -37,12 +37,12 @@ QT_FORWARD_DECLARE_CLASS(QGraphicsItem);
namespace QmlViewer {
-class QDeclarativeDesignView;
+class QDeclarativeViewObserver;
class SingleSelectionManipulator
{
public:
- SingleSelectionManipulator(QDeclarativeDesignView *editorView);
+ SingleSelectionManipulator(QDeclarativeViewObserver *editorView);
enum SelectionType {
ReplaceSelection,
@@ -67,7 +67,7 @@ public:
private:
QList<QGraphicsItem*> m_oldSelectionList;
QPointF m_beginPoint;
- QDeclarativeDesignView *m_editorView;
+ QDeclarativeViewObserver *m_editorView;
bool m_isActive;
};
diff --git a/share/qtcreator/qmljsdebugger/editor/subcomponenteditortool.cpp b/share/qtcreator/qmljsdebugger/editor/subcomponenteditortool.cpp
index 2bd96c80ef..bdb7e61960 100644
--- a/share/qtcreator/qmljsdebugger/editor/subcomponenteditortool.cpp
+++ b/share/qtcreator/qmljsdebugger/editor/subcomponenteditortool.cpp
@@ -1,5 +1,5 @@
#include "subcomponenteditortool.h"
-#include "qdeclarativedesignview_p.h"
+#include "qdeclarativeviewobserver_p.h"
#include "subcomponentmasklayeritem.h"
#include "layeritem.h"
@@ -16,12 +16,12 @@ namespace QmlViewer {
const qreal MaxOpacity = 0.5f;
-SubcomponentEditorTool::SubcomponentEditorTool(QDeclarativeDesignView *view)
+SubcomponentEditorTool::SubcomponentEditorTool(QDeclarativeViewObserver *view)
: AbstractFormEditorTool(view),
m_animIncrement(0.05f),
m_animTimer(new QTimer(this))
{
- m_mask = new SubcomponentMaskLayerItem(view, QDeclarativeDesignViewPrivate::get(view)->manipulatorLayer);
+ m_mask = new SubcomponentMaskLayerItem(view, QDeclarativeViewObserverPrivate::get(view)->manipulatorLayer);
connect(m_animTimer, SIGNAL(timeout()), SLOT(animate()));
m_animTimer->setInterval(20);
}
@@ -71,7 +71,7 @@ void SubcomponentEditorTool::mouseDoubleClickEvent(QMouseEvent *event)
void SubcomponentEditorTool::hoverMoveEvent(QMouseEvent *event)
{
if (!containsCursor(event->pos()) && m_currentContext.size() > 1) {
- QDeclarativeDesignViewPrivate::get(view())->clearHighlight();
+ QDeclarativeViewObserverPrivate::get(observer())->clearHighlight();
}
}
@@ -164,8 +164,8 @@ void SubcomponentEditorTool::setCurrentItem(QGraphicsItem* contextItem)
m_animIncrement = 0.05f;
m_animTimer->start();
- QDeclarativeDesignViewPrivate::get(view())->clearHighlight();
- view()->setSelectedItems(QList<QGraphicsItem*>());
+ QDeclarativeViewObserverPrivate::get(observer())->clearHighlight();
+ observer()->setSelectedItems(QList<QGraphicsItem*>());
pushContext(gfxObject);
}
diff --git a/share/qtcreator/qmljsdebugger/editor/subcomponenteditortool.h b/share/qtcreator/qmljsdebugger/editor/subcomponenteditortool.h
index d54b6a71dc..c8196ed8e5 100644
--- a/share/qtcreator/qmljsdebugger/editor/subcomponenteditortool.h
+++ b/share/qtcreator/qmljsdebugger/editor/subcomponenteditortool.h
@@ -18,7 +18,7 @@ class SubcomponentEditorTool : public AbstractFormEditorTool
Q_OBJECT
public:
- SubcomponentEditorTool(QDeclarativeDesignView *view);
+ SubcomponentEditorTool(QDeclarativeViewObserver *view);
~SubcomponentEditorTool();
void mousePressEvent(QMouseEvent *event);
diff --git a/share/qtcreator/qmljsdebugger/editor/subcomponentmasklayeritem.cpp b/share/qtcreator/qmljsdebugger/editor/subcomponentmasklayeritem.cpp
index ce1b437131..4e6e911163 100644
--- a/share/qtcreator/qmljsdebugger/editor/subcomponentmasklayeritem.cpp
+++ b/share/qtcreator/qmljsdebugger/editor/subcomponentmasklayeritem.cpp
@@ -1,13 +1,13 @@
#include "subcomponentmasklayeritem.h"
#include "qmlviewerconstants.h"
-#include "qdeclarativedesignview.h"
+#include "qdeclarativeviewobserver.h"
#include <QPolygonF>
namespace QmlViewer {
-SubcomponentMaskLayerItem::SubcomponentMaskLayerItem(QDeclarativeDesignView *view, QGraphicsItem *parentItem) :
+SubcomponentMaskLayerItem::SubcomponentMaskLayerItem(QDeclarativeViewObserver *observer, QGraphicsItem *parentItem) :
QGraphicsPolygonItem(parentItem),
- m_view(view),
+ m_observer(observer),
m_currentItem(0),
m_borderRect(new QGraphicsRectItem(this))
{
@@ -51,8 +51,8 @@ void SubcomponentMaskLayerItem::setCurrentItem(QGraphicsItem *item)
if (!m_currentItem)
return;
- QPolygonF viewPoly(QRectF(m_view->rect()));
- viewPoly = m_view->mapToScene(viewPoly.toPolygon());
+ QPolygonF viewPoly(QRectF(m_observer->declarativeView()->rect()));
+ viewPoly = m_observer->declarativeView()->mapToScene(viewPoly.toPolygon());
QRectF itemRect = item->boundingRect() | item->childrenBoundingRect();
QPolygonF itemPoly(itemRect);
diff --git a/share/qtcreator/qmljsdebugger/editor/subcomponentmasklayeritem.h b/share/qtcreator/qmljsdebugger/editor/subcomponentmasklayeritem.h
index 9a64636461..598cd16195 100644
--- a/share/qtcreator/qmljsdebugger/editor/subcomponentmasklayeritem.h
+++ b/share/qtcreator/qmljsdebugger/editor/subcomponentmasklayeritem.h
@@ -5,12 +5,12 @@
namespace QmlViewer {
-class QDeclarativeDesignView;
+class QDeclarativeViewObserver;
class SubcomponentMaskLayerItem : public QGraphicsPolygonItem
{
public:
- explicit SubcomponentMaskLayerItem(QDeclarativeDesignView *view, QGraphicsItem *parentItem = 0);
+ explicit SubcomponentMaskLayerItem(QDeclarativeViewObserver *observer, QGraphicsItem *parentItem = 0);
int type() const;
void setCurrentItem(QGraphicsItem *item);
void setBoundingBox(const QRectF &boundingBox);
@@ -18,7 +18,7 @@ public:
QRectF itemRect() const;
private:
- QDeclarativeDesignView *m_view;
+ QDeclarativeViewObserver *m_observer;
QGraphicsItem *m_currentItem;
QGraphicsRectItem *m_borderRect;
QRectF m_itemPolyRect;
diff --git a/share/qtcreator/qmljsdebugger/editor/zoomtool.cpp b/share/qtcreator/qmljsdebugger/editor/zoomtool.cpp
index 05937eafc2..7a946cf9e8 100644
--- a/share/qtcreator/qmljsdebugger/editor/zoomtool.cpp
+++ b/share/qtcreator/qmljsdebugger/editor/zoomtool.cpp
@@ -1,5 +1,5 @@
#include "zoomtool.h"
-#include "qdeclarativedesignview_p.h"
+#include "qdeclarativeviewobserver_p.h"
#include <QMouseEvent>
#include <QWheelEvent>
@@ -12,9 +12,9 @@
namespace QmlViewer {
-ZoomTool::ZoomTool(QDeclarativeDesignView *view) :
+ZoomTool::ZoomTool(QDeclarativeViewObserver *view) :
AbstractFormEditorTool(view),
- m_rubberbandManipulator(reinterpret_cast<QGraphicsObject *>(QDeclarativeDesignViewPrivate::get(view)->manipulatorLayer), view),
+ m_rubberbandManipulator(reinterpret_cast<QGraphicsObject *>(QDeclarativeViewObserverPrivate::get(view)->manipulatorLayer), view),
m_smoothZoomMultiplier(0.05f),
m_currentScale(1.0f)
{
diff --git a/share/qtcreator/qmljsdebugger/editor/zoomtool.h b/share/qtcreator/qmljsdebugger/editor/zoomtool.h
index f3774efa11..31159a1b6d 100644
--- a/share/qtcreator/qmljsdebugger/editor/zoomtool.h
+++ b/share/qtcreator/qmljsdebugger/editor/zoomtool.h
@@ -17,7 +17,7 @@ public:
ZoomOut
};
- explicit ZoomTool(QDeclarativeDesignView *view);
+ explicit ZoomTool(QDeclarativeViewObserver *view);
virtual ~ZoomTool();
diff --git a/share/qtcreator/qmljsdebugger/include/qdeclarativedesignview.h b/share/qtcreator/qmljsdebugger/include/qdeclarativeviewobserver.h
index f06002dcd2..b6ec2d0e8b 100644
--- a/share/qtcreator/qmljsdebugger/include/qdeclarativedesignview.h
+++ b/share/qtcreator/qmljsdebugger/include/qdeclarativeviewobserver.h
@@ -27,8 +27,8 @@
**
**************************************************************************/
-#ifndef QDECLARATIVEDESIGNVIEW_H
-#define QDECLARATIVEDESIGNVIEW_H
+#ifndef QDECLARATIVEVIEWOBSERVER_H
+#define QDECLARATIVEVIEWOBSERVER_H
#include "qmljsdebugger_global.h"
#include "qmlviewerconstants.h"
@@ -42,19 +42,21 @@ QT_FORWARD_DECLARE_CLASS(QToolBar);
namespace QmlViewer {
class CrumblePath;
-class QDeclarativeDesignViewPrivate;
+class QDeclarativeViewObserverPrivate;
-class QMLJSDEBUGGER_EXPORT QDeclarativeDesignView : public QDeclarativeView
+class QMLJSDEBUGGER_EXPORT QDeclarativeViewObserver : public QObject
{
Q_OBJECT
public:
- explicit QDeclarativeDesignView(QWidget *parent = 0);
- ~QDeclarativeDesignView();
+ explicit QDeclarativeViewObserver(QDeclarativeView *view, QObject *parent = 0);
+ ~QDeclarativeViewObserver();
void setSelectedItems(QList<QGraphicsItem *> items);
QList<QGraphicsItem *> selectedItems();
+ QDeclarativeView *declarativeView();
+
QToolBar *toolbar() const;
static QString idStringForObject(QObject *obj);
QRectF adjustToScreenBoundaries(const QRectF &boundingRectInSceneSpace);
@@ -87,19 +89,21 @@ Q_SIGNALS:
void inspectorContextPopped();
protected:
- void leaveEvent(QEvent *);
- void mousePressEvent(QMouseEvent *event);
- void mouseMoveEvent(QMouseEvent *event);
- void mouseReleaseEvent(QMouseEvent *event);
- void keyPressEvent(QKeyEvent *event);
- void keyReleaseEvent(QKeyEvent *keyEvent);
- void mouseDoubleClickEvent(QMouseEvent *event);
- void wheelEvent(QWheelEvent *event);
+ bool eventFilter(QObject *obj, QEvent *event);
+
+ bool leaveEvent(QEvent *);
+ bool mousePressEvent(QMouseEvent *event);
+ bool mouseMoveEvent(QMouseEvent *event);
+ bool mouseReleaseEvent(QMouseEvent *event);
+ bool keyPressEvent(QKeyEvent *event);
+ bool keyReleaseEvent(QKeyEvent *keyEvent);
+ bool mouseDoubleClickEvent(QMouseEvent *event);
+ bool wheelEvent(QWheelEvent *event);
void setSelectedItemsForTools(QList<QGraphicsItem *> items);
private:
- Q_DISABLE_COPY(QDeclarativeDesignView)
+ Q_DISABLE_COPY(QDeclarativeViewObserver)
Q_PRIVATE_SLOT(d_func(), void _q_reloadView())
Q_PRIVATE_SLOT(d_func(), void _q_onStatusChanged(QDeclarativeView::Status))
Q_PRIVATE_SLOT(d_func(), void _q_onCurrentObjectsChanged(QList<QObject*>))
@@ -113,13 +117,13 @@ private:
Q_PRIVATE_SLOT(d_func(), void _q_changeContextPathIndex(int index))
Q_PRIVATE_SLOT(d_func(), void _q_clearComponentCache());
- inline QDeclarativeDesignViewPrivate *d_func() { return data.data(); }
- QScopedPointer<QDeclarativeDesignViewPrivate> data;
- friend class QDeclarativeDesignViewPrivate;
+ inline QDeclarativeViewObserverPrivate *d_func() { return data.data(); }
+ QScopedPointer<QDeclarativeViewObserverPrivate> data;
+ friend class QDeclarativeViewObserverPrivate;
friend class AbstractFormEditorTool;
};
} //namespace QmlViewer
-#endif // QDECLARATIVEDESIGNVIEW_H
+#endif // QDECLARATIVEVIEWOBSERVER_H
diff --git a/share/qtcreator/qmljsdebugger/qdeclarativedesignview.cpp b/share/qtcreator/qmljsdebugger/qdeclarativeviewobserver.cpp
index f9e2a806de..d94de934b7 100644
--- a/share/qtcreator/qmljsdebugger/qdeclarativedesignview.cpp
+++ b/share/qtcreator/qmljsdebugger/qdeclarativeviewobserver.cpp
@@ -27,8 +27,8 @@
**
**************************************************************************/
-#include "qdeclarativedesignview.h"
-#include "qdeclarativedesignview_p.h"
+#include "qdeclarativeviewobserver.h"
+#include "qdeclarativeviewobserver_p.h"
#include "qdeclarativedesigndebugserver.h"
#include "selectiontool.h"
#include "zoomtool.h"
@@ -56,7 +56,7 @@ namespace QmlViewer {
const int SceneChangeUpdateInterval = 5000;
-QDeclarativeDesignViewPrivate::QDeclarativeDesignViewPrivate(QDeclarativeDesignView *q) :
+QDeclarativeViewObserverPrivate::QDeclarativeViewObserverPrivate(QDeclarativeViewObserver *q) :
q(q),
designModeBehavior(false),
executionPaused(false),
@@ -66,14 +66,15 @@ QDeclarativeDesignViewPrivate::QDeclarativeDesignViewPrivate(QDeclarativeDesignV
{
}
-QDeclarativeDesignViewPrivate::~QDeclarativeDesignViewPrivate()
+QDeclarativeViewObserverPrivate::~QDeclarativeViewObserverPrivate()
{
}
-QDeclarativeDesignView::QDeclarativeDesignView(QWidget *parent) :
- QDeclarativeView(parent), data(new QDeclarativeDesignViewPrivate(this))
+QDeclarativeViewObserver::QDeclarativeViewObserver(QDeclarativeView *view, QObject *parent) :
+ QObject(parent), data(new QDeclarativeViewObserverPrivate(this))
{
- data->manipulatorLayer = new LayerItem(scene());
+ data->view = view;
+ data->manipulatorLayer = new LayerItem(view->scene());
data->selectionTool = new SelectionTool(this);
data->zoomTool = new ZoomTool(this);
data->colorPickerTool = new ColorPickerTool(this);
@@ -81,7 +82,8 @@ QDeclarativeDesignView::QDeclarativeDesignView(QWidget *parent) :
data->subcomponentEditorTool = new SubcomponentEditorTool(this);
data->currentTool = data->selectionTool;
- setMouseTracking(true);
+ data->view->setMouseTracking(true);
+ data->view->viewport()->installEventFilter(this);
data->debugServer = QDeclarativeDesignDebugServer::instance();
connect(data->debugServer, SIGNAL(designModeBehaviorChanged(bool)), SLOT(setDesignModeBehavior(bool)));
@@ -102,7 +104,7 @@ QDeclarativeDesignView::QDeclarativeDesignView(QWidget *parent) :
SLOT(_q_reparentQmlObject(QObject *, QObject *)));
connect(data->debugServer, SIGNAL(contextPathIndexChanged(int)), SLOT(_q_changeContextPathIndex(int)));
connect(data->debugServer, SIGNAL(clearComponentCacheRequested()), SLOT(_q_clearComponentCache()));
- connect(this, SIGNAL(statusChanged(QDeclarativeView::Status)), SLOT(_q_onStatusChanged(QDeclarativeView::Status)));
+ connect(data->view, SIGNAL(statusChanged(QDeclarativeView::Status)), SLOT(_q_onStatusChanged(QDeclarativeView::Status)));
connect(data->colorPickerTool, SIGNAL(selectedColorChanged(QColor)), SIGNAL(selectedColorChanged(QColor)));
connect(data->colorPickerTool, SIGNAL(selectedColorChanged(QColor)),
@@ -121,11 +123,11 @@ QDeclarativeDesignView::QDeclarativeDesignView(QWidget *parent) :
setDebugMode(true);
}
-QDeclarativeDesignView::~QDeclarativeDesignView()
+QDeclarativeViewObserver::~QDeclarativeViewObserver()
{
}
-void QDeclarativeDesignView::setInspectorContext(int contextIndex)
+void QDeclarativeViewObserver::setInspectorContext(int contextIndex)
{
if (data->subcomponentEditorTool->contextIndex() != contextIndex) {
QGraphicsObject *object = data->subcomponentEditorTool->setContext(contextIndex);
@@ -134,52 +136,101 @@ void QDeclarativeDesignView::setInspectorContext(int contextIndex)
}
}
-void QDeclarativeDesignViewPrivate::_q_reloadView()
+void QDeclarativeViewObserverPrivate::_q_reloadView()
{
subcomponentEditorTool->clear();
clearHighlight();
emit q->reloadRequested();
}
-void QDeclarativeDesignViewPrivate::clearEditorItems()
+void QDeclarativeViewObserverPrivate::clearEditorItems()
{
clearHighlight();
setSelectedItems(QList<QGraphicsItem*>());
}
-void QDeclarativeDesignView::leaveEvent(QEvent *event)
+bool QDeclarativeViewObserver::eventFilter(QObject *obj, QEvent *event)
+ {
+ switch (event->type()) {
+ case QEvent::Leave: {
+ if (leaveEvent(event))
+ return true;
+ break;
+ }
+ case QEvent::MouseButtonPress: {
+ if (mousePressEvent(static_cast<QMouseEvent*>(event)))
+ return true;
+ break;
+ }
+ case QEvent::MouseMove: {
+ if (mouseMoveEvent(static_cast<QMouseEvent*>(event)))
+ return true;
+ break;
+ }
+ case QEvent::MouseButtonRelease: {
+ if (mouseReleaseEvent(static_cast<QMouseEvent*>(event)))
+ return true;
+ break;
+ }
+ case QEvent::KeyPress: {
+ if (keyPressEvent(static_cast<QKeyEvent*>(event)))
+ return true;
+ break;
+ }
+ case QEvent::KeyRelease: {
+ if (keyReleaseEvent(static_cast<QKeyEvent*>(event)))
+ return true;
+ break;
+ }
+ case QEvent::MouseButtonDblClick: {
+ if (mouseDoubleClickEvent(static_cast<QMouseEvent*>(event)))
+ return true;
+ break;
+ }
+ case QEvent::Wheel: {
+ if (wheelEvent(static_cast<QWheelEvent*>(event)))
+ return true;
+ break;
+ }
+ default: {
+ break;
+ }
+ } //switch
+
+ // standard event processing
+ return QObject::eventFilter(obj, event);
+}
+
+bool QDeclarativeViewObserver::leaveEvent(QEvent * /*event*/)
{
- if (!data->designModeBehavior) {
- QDeclarativeView::leaveEvent(event);
- return;
- }
+ if (!data->designModeBehavior)
+ return false;
data->clearHighlight();
+ return true;
}
-void QDeclarativeDesignView::mousePressEvent(QMouseEvent *event)
+bool QDeclarativeViewObserver::mousePressEvent(QMouseEvent *event)
{
- if (!data->designModeBehavior) {
- QDeclarativeView::mousePressEvent(event);
- return;
- }
+ if (!data->designModeBehavior)
+ return false;
data->cursorPos = event->pos();
data->currentTool->mousePressEvent(event);
+ return true;
}
-void QDeclarativeDesignView::mouseMoveEvent(QMouseEvent *event)
+bool QDeclarativeViewObserver::mouseMoveEvent(QMouseEvent *event)
{
if (!data->designModeBehavior) {
data->clearEditorItems();
- QDeclarativeView::mouseMoveEvent(event);
- return;
+ return false;
}
data->cursorPos = event->pos();
QList<QGraphicsItem*> selItems = data->selectableItems(event->pos());
if (!selItems.isEmpty()) {
- setToolTip(AbstractFormEditorTool::titleForItem(selItems.first()));
+ declarativeView()->setToolTip(AbstractFormEditorTool::titleForItem(selItems.first()));
} else {
- setToolTip(QString());
+ declarativeView()->setToolTip(QString());
}
if (event->buttons()) {
data->subcomponentEditorTool->mouseMoveEvent(event);
@@ -188,36 +239,35 @@ void QDeclarativeDesignView::mouseMoveEvent(QMouseEvent *event)
data->subcomponentEditorTool->hoverMoveEvent(event);
data->currentTool->hoverMoveEvent(event);
}
+ return true;
}
-void QDeclarativeDesignView::mouseReleaseEvent(QMouseEvent *event)
+bool QDeclarativeViewObserver::mouseReleaseEvent(QMouseEvent *event)
{
- if (!data->designModeBehavior) {
- QDeclarativeView::mouseReleaseEvent(event);
- return;
- }
+ if (!data->designModeBehavior)
+ return false;
data->subcomponentEditorTool->mouseReleaseEvent(event);
data->cursorPos = event->pos();
data->currentTool->mouseReleaseEvent(event);
data->debugServer->setCurrentObjects(AbstractFormEditorTool::toObjectList(selectedItems()));
+ return true;
}
-void QDeclarativeDesignView::keyPressEvent(QKeyEvent *event)
+bool QDeclarativeViewObserver::keyPressEvent(QKeyEvent *event)
{
if (!data->designModeBehavior) {
- QDeclarativeView::keyPressEvent(event);
- return;
+ return false;
}
data->currentTool->keyPressEvent(event);
+ return true;
}
-void QDeclarativeDesignView::keyReleaseEvent(QKeyEvent *event)
+bool QDeclarativeViewObserver::keyReleaseEvent(QKeyEvent *event)
{
if (!data->designModeBehavior) {
- QDeclarativeView::keyReleaseEvent(event);
- return;
+ return false;
}
switch(event->key()) {
@@ -251,9 +301,10 @@ void QDeclarativeDesignView::keyReleaseEvent(QKeyEvent *event)
}
data->currentTool->keyReleaseEvent(event);
+ return true;
}
-void QDeclarativeDesignViewPrivate::_q_createQmlObject(const QString &qml, QObject *parent, const QStringList &importList, const QString &filename)
+void QDeclarativeViewObserverPrivate::_q_createQmlObject(const QString &qml, QObject *parent, const QStringList &importList, const QString &filename)
{
if (!parent)
return;
@@ -263,8 +314,8 @@ void QDeclarativeDesignViewPrivate::_q_createQmlObject(const QString &qml, QObje
imports += s + "\n";
}
- QDeclarativeContext *parentContext = q->engine()->contextForObject(parent);
- QDeclarativeComponent component(q->engine(), q);
+ QDeclarativeContext *parentContext = view->engine()->contextForObject(parent);
+ QDeclarativeComponent component(view->engine(), q);
QByteArray constructedQml = QString(imports + qml).toLatin1();
component.setData(constructedQml, filename);
@@ -279,7 +330,7 @@ void QDeclarativeDesignViewPrivate::_q_createQmlObject(const QString &qml, QObje
}
}
-void QDeclarativeDesignViewPrivate::_q_reparentQmlObject(QObject *object, QObject *newParent)
+void QDeclarativeViewObserverPrivate::_q_reparentQmlObject(QObject *object, QObject *newParent)
{
if (!newParent)
return;
@@ -292,31 +343,27 @@ void QDeclarativeDesignViewPrivate::_q_reparentQmlObject(QObject *object, QObjec
}
}
-void QDeclarativeDesignViewPrivate::_q_clearComponentCache()
+void QDeclarativeViewObserverPrivate::_q_clearComponentCache()
{
- q->engine()->clearComponentCache();
+ view->engine()->clearComponentCache();
}
-QGraphicsItem *QDeclarativeDesignViewPrivate::currentRootItem() const
+QGraphicsItem *QDeclarativeViewObserverPrivate::currentRootItem() const
{
return subcomponentEditorTool->currentRootItem();
}
-void QDeclarativeDesignView::mouseDoubleClickEvent(QMouseEvent *event)
+bool QDeclarativeViewObserver::mouseDoubleClickEvent(QMouseEvent *event)
{
- if (!data->designModeBehavior) {
- QDeclarativeView::mouseDoubleClickEvent(event);
- return;
- }
+ if (!data->designModeBehavior)
+ return false;
if (data->currentToolMode != Constants::SelectionToolMode
- && data->currentToolMode != Constants::MarqueeSelectionToolMode)
- {
- return;
- }
+ && data->currentToolMode != Constants::MarqueeSelectionToolMode)
+ return true;
QGraphicsItem *itemToEnter = 0;
- QList<QGraphicsItem*> itemList = items(event->pos());
+ QList<QGraphicsItem*> itemList = data->view->items(event->pos());
data->filterForSelection(itemList);
if (data->selectedItems().isEmpty() && !itemList.isEmpty()) {
@@ -337,18 +384,18 @@ void QDeclarativeDesignView::mouseDoubleClickEvent(QMouseEvent *event)
data->debugServer->setCurrentObjects(QList<QObject*>() << objectToEnter);
}
+ return true;
}
-void QDeclarativeDesignView::wheelEvent(QWheelEvent *event)
+bool QDeclarativeViewObserver::wheelEvent(QWheelEvent *event)
{
- if (!data->designModeBehavior) {
- QDeclarativeView::wheelEvent(event);
- return;
- }
+ if (!data->designModeBehavior)
+ return false;
data->currentTool->wheelEvent(event);
+ return true;
}
-void QDeclarativeDesignViewPrivate::enterContext(QGraphicsItem *itemToEnter)
+void QDeclarativeViewObserverPrivate::enterContext(QGraphicsItem *itemToEnter)
{
QGraphicsItem *itemUnderCurrentContext = itemToEnter;
if (itemUnderCurrentContext)
@@ -358,7 +405,7 @@ void QDeclarativeDesignViewPrivate::enterContext(QGraphicsItem *itemToEnter)
subcomponentEditorTool->setCurrentItem(itemToEnter);
}
-void QDeclarativeDesignView::setDesignModeBehavior(bool value)
+void QDeclarativeViewObserver::setDesignModeBehavior(bool value)
{
emit designModeBehaviorChanged(value);
@@ -371,20 +418,20 @@ void QDeclarativeDesignView::setDesignModeBehavior(bool value)
data->clearHighlight();
data->setSelectedItems(QList<QGraphicsItem*>());
- if (rootObject())
- data->subcomponentEditorTool->pushContext(rootObject());
+ if (data->view->rootObject())
+ data->subcomponentEditorTool->pushContext(data->view->rootObject());
}
if (!data->designModeBehavior)
data->clearEditorItems();
}
-bool QDeclarativeDesignView::designModeBehavior()
+bool QDeclarativeViewObserver::designModeBehavior()
{
return data->designModeBehavior;
}
-void QDeclarativeDesignViewPrivate::changeTool(Constants::DesignTool tool, Constants::ToolFlags /*flags*/)
+void QDeclarativeViewObserverPrivate::changeTool(Constants::DesignTool tool, Constants::ToolFlags /*flags*/)
{
switch(tool) {
case Constants::SelectionToolMode:
@@ -397,7 +444,7 @@ void QDeclarativeDesignViewPrivate::changeTool(Constants::DesignTool tool, Const
}
}
-void QDeclarativeDesignViewPrivate::setSelectedItemsForTools(QList<QGraphicsItem *> items)
+void QDeclarativeViewObserverPrivate::setSelectedItemsForTools(QList<QGraphicsItem *> items)
{
currentSelection.clear();
foreach(QGraphicsItem *item, items) {
@@ -410,13 +457,13 @@ void QDeclarativeDesignViewPrivate::setSelectedItemsForTools(QList<QGraphicsItem
currentTool->updateSelectedItems();
}
-void QDeclarativeDesignViewPrivate::setSelectedItems(QList<QGraphicsItem *> items)
+void QDeclarativeViewObserverPrivate::setSelectedItems(QList<QGraphicsItem *> items)
{
setSelectedItemsForTools(items);
debugServer->setCurrentObjects(AbstractFormEditorTool::toObjectList(items));
}
-QList<QGraphicsItem *> QDeclarativeDesignViewPrivate::selectedItems()
+QList<QGraphicsItem *> QDeclarativeViewObserverPrivate::selectedItems()
{
QList<QGraphicsItem *> selection;
foreach(const QWeakPointer<QGraphicsObject> &selectedObject, currentSelection) {
@@ -430,27 +477,32 @@ QList<QGraphicsItem *> QDeclarativeDesignViewPrivate::selectedItems()
return selection;
}
-void QDeclarativeDesignView::setSelectedItems(QList<QGraphicsItem *> items)
+void QDeclarativeViewObserver::setSelectedItems(QList<QGraphicsItem *> items)
{
data->setSelectedItems(items);
}
-QList<QGraphicsItem *> QDeclarativeDesignView::selectedItems()
+QList<QGraphicsItem *> QDeclarativeViewObserver::selectedItems()
{
return data->selectedItems();
}
-void QDeclarativeDesignViewPrivate::clearHighlight()
+QDeclarativeView *QDeclarativeViewObserver::declarativeView()
+{
+ return data->view;
+}
+
+void QDeclarativeViewObserverPrivate::clearHighlight()
{
boundingRectHighlighter->clear();
}
-void QDeclarativeDesignViewPrivate::highlight(QGraphicsObject * item, ContextFlags flags)
+void QDeclarativeViewObserverPrivate::highlight(QGraphicsObject * item, ContextFlags flags)
{
highlight(QList<QGraphicsObject*>() << item, flags);
}
-void QDeclarativeDesignViewPrivate::highlight(QList<QGraphicsObject *> items, ContextFlags flags)
+void QDeclarativeViewObserverPrivate::highlight(QList<QGraphicsObject *> items, ContextFlags flags)
{
if (items.isEmpty())
return;
@@ -471,31 +523,31 @@ void QDeclarativeDesignViewPrivate::highlight(QList<QGraphicsObject *> items, Co
boundingRectHighlighter->highlight(objectList);
}
-bool QDeclarativeDesignViewPrivate::mouseInsideContextItem() const
+bool QDeclarativeViewObserverPrivate::mouseInsideContextItem() const
{
return subcomponentEditorTool->containsCursor(cursorPos.toPoint());
}
-QList<QGraphicsItem*> QDeclarativeDesignViewPrivate::selectableItems(const QPointF &scenePos) const
+QList<QGraphicsItem*> QDeclarativeViewObserverPrivate::selectableItems(const QPointF &scenePos) const
{
- QList<QGraphicsItem*> itemlist = q->scene()->items(scenePos);
+ QList<QGraphicsItem*> itemlist = view->scene()->items(scenePos);
return filterForCurrentContext(itemlist);
}
-QList<QGraphicsItem*> QDeclarativeDesignViewPrivate::selectableItems(const QPoint &pos) const
+QList<QGraphicsItem*> QDeclarativeViewObserverPrivate::selectableItems(const QPoint &pos) const
{
- QList<QGraphicsItem*> itemlist = q->items(pos);
+ QList<QGraphicsItem*> itemlist = view->items(pos);
return filterForCurrentContext(itemlist);
}
-QList<QGraphicsItem*> QDeclarativeDesignViewPrivate::selectableItems(const QRectF &sceneRect, Qt::ItemSelectionMode selectionMode) const
+QList<QGraphicsItem*> QDeclarativeViewObserverPrivate::selectableItems(const QRectF &sceneRect, Qt::ItemSelectionMode selectionMode) const
{
- QList<QGraphicsItem*> itemlist = q->scene()->items(sceneRect, selectionMode);
+ QList<QGraphicsItem*> itemlist = view->scene()->items(sceneRect, selectionMode);
return filterForCurrentContext(itemlist);
}
-void QDeclarativeDesignViewPrivate::_q_changeToSingleSelectTool()
+void QDeclarativeViewObserverPrivate::_q_changeToSingleSelectTool()
{
currentToolMode = Constants::SelectionToolMode;
selectionTool->setRubberbandSelectionMode(false);
@@ -506,7 +558,7 @@ void QDeclarativeDesignViewPrivate::_q_changeToSingleSelectTool()
debugServer->setCurrentTool(Constants::SelectionToolMode);
}
-void QDeclarativeDesignViewPrivate::changeToSelectTool()
+void QDeclarativeViewObserverPrivate::changeToSelectTool()
{
if (currentTool == selectionTool)
return;
@@ -517,7 +569,7 @@ void QDeclarativeDesignViewPrivate::changeToSelectTool()
currentTool->updateSelectedItems();
}
-void QDeclarativeDesignViewPrivate::_q_changeToMarqueeSelectTool()
+void QDeclarativeViewObserverPrivate::_q_changeToMarqueeSelectTool()
{
changeToSelectTool();
currentToolMode = Constants::MarqueeSelectionToolMode;
@@ -527,7 +579,7 @@ void QDeclarativeDesignViewPrivate::_q_changeToMarqueeSelectTool()
debugServer->setCurrentTool(Constants::MarqueeSelectionToolMode);
}
-void QDeclarativeDesignViewPrivate::_q_changeToZoomTool()
+void QDeclarativeViewObserverPrivate::_q_changeToZoomTool()
{
currentToolMode = Constants::ZoomMode;
currentTool->clear();
@@ -538,7 +590,7 @@ void QDeclarativeDesignViewPrivate::_q_changeToZoomTool()
debugServer->setCurrentTool(Constants::ZoomMode);
}
-void QDeclarativeDesignViewPrivate::_q_changeToColorPickerTool()
+void QDeclarativeViewObserverPrivate::_q_changeToColorPickerTool()
{
if (currentTool == colorPickerTool)
return;
@@ -552,12 +604,12 @@ void QDeclarativeDesignViewPrivate::_q_changeToColorPickerTool()
debugServer->setCurrentTool(Constants::ColorPickerMode);
}
-void QDeclarativeDesignViewPrivate::_q_changeContextPathIndex(int index)
+void QDeclarativeViewObserverPrivate::_q_changeContextPathIndex(int index)
{
subcomponentEditorTool->setContext(index);
}
-void QDeclarativeDesignView::changeAnimationSpeed(qreal slowdownFactor)
+void QDeclarativeViewObserver::changeAnimationSpeed(qreal slowdownFactor)
{
data->slowdownFactor = slowdownFactor;
@@ -568,7 +620,7 @@ void QDeclarativeDesignView::changeAnimationSpeed(qreal slowdownFactor)
}
}
-void QDeclarativeDesignView::continueExecution(qreal slowdownFactor)
+void QDeclarativeViewObserver::continueExecution(qreal slowdownFactor)
{
Q_ASSERT(slowdownFactor > 0);
@@ -585,7 +637,7 @@ void QDeclarativeDesignView::continueExecution(qreal slowdownFactor)
data->debugServer->setAnimationSpeed(data->slowdownFactor);
}
-void QDeclarativeDesignView::pauseExecution()
+void QDeclarativeViewObserver::pauseExecution()
{
QUnifiedTimer *timer = QUnifiedTimer::instance();
timer->setSlowdownFactor(0);
@@ -596,13 +648,13 @@ void QDeclarativeDesignView::pauseExecution()
data->debugServer->setAnimationSpeed(0);
}
-void QDeclarativeDesignViewPrivate::_q_applyChangesFromClient()
+void QDeclarativeViewObserverPrivate::_q_applyChangesFromClient()
{
}
-QList<QGraphicsItem*> QDeclarativeDesignViewPrivate::filterForSelection(QList<QGraphicsItem*> &itemlist) const
+QList<QGraphicsItem*> QDeclarativeViewObserverPrivate::filterForSelection(QList<QGraphicsItem*> &itemlist) const
{
foreach(QGraphicsItem *item, itemlist) {
if (isEditorItem(item) || !subcomponentEditorTool->isChildOfContext(item))
@@ -612,7 +664,7 @@ QList<QGraphicsItem*> QDeclarativeDesignViewPrivate::filterForSelection(QList<QG
return itemlist;
}
-QList<QGraphicsItem*> QDeclarativeDesignViewPrivate::filterForCurrentContext(QList<QGraphicsItem*> &itemlist) const
+QList<QGraphicsItem*> QDeclarativeViewObserverPrivate::filterForCurrentContext(QList<QGraphicsItem*> &itemlist) const
{
foreach(QGraphicsItem *item, itemlist) {
@@ -636,20 +688,20 @@ QList<QGraphicsItem*> QDeclarativeDesignViewPrivate::filterForCurrentContext(QLi
return itemlist;
}
-bool QDeclarativeDesignViewPrivate::isEditorItem(QGraphicsItem *item) const
+bool QDeclarativeViewObserverPrivate::isEditorItem(QGraphicsItem *item) const
{
return (item->type() == Constants::EditorItemType
|| item->type() == Constants::ResizeHandleItemType
|| item->data(Constants::EditorItemDataKey).toBool());
}
-void QDeclarativeDesignViewPrivate::_q_onStatusChanged(QDeclarativeView::Status status)
+void QDeclarativeViewObserverPrivate::_q_onStatusChanged(QDeclarativeView::Status status)
{
if (status == QDeclarativeView::Ready) {
- if (q->rootObject()) {
+ if (view->rootObject()) {
if (subcomponentEditorTool->contextIndex() != -1)
subcomponentEditorTool->clear();
- subcomponentEditorTool->pushContext(q->rootObject());
+ subcomponentEditorTool->pushContext(view->rootObject());
emit q->executionStarted(1.0f);
}
@@ -657,7 +709,7 @@ void QDeclarativeDesignViewPrivate::_q_onStatusChanged(QDeclarativeView::Status
}
}
-void QDeclarativeDesignViewPrivate::_q_onCurrentObjectsChanged(QList<QObject*> objects)
+void QDeclarativeViewObserverPrivate::_q_onCurrentObjectsChanged(QList<QObject*> objects)
{
QList<QGraphicsItem*> items;
QList<QGraphicsObject*> gfxObjects;
@@ -672,16 +724,16 @@ void QDeclarativeDesignViewPrivate::_q_onCurrentObjectsChanged(QList<QObject*> o
}
setSelectedItemsForTools(items);
clearHighlight();
- highlight(gfxObjects, QDeclarativeDesignViewPrivate::IgnoreContext);
+ highlight(gfxObjects, QDeclarativeViewObserverPrivate::IgnoreContext);
}
-QString QDeclarativeDesignView::idStringForObject(QObject *obj)
+QString QDeclarativeViewObserver::idStringForObject(QObject *obj)
{
return QDeclarativeDesignDebugServer::instance()->idStringForObject(obj);
}
// adjusts bounding boxes on edges of screen to be visible
-QRectF QDeclarativeDesignView::adjustToScreenBoundaries(const QRectF &boundingRectInSceneSpace)
+QRectF QDeclarativeViewObserver::adjustToScreenBoundaries(const QRectF &boundingRectInSceneSpace)
{
int marginFromEdge = 1;
QRectF boundingRect(boundingRectInSceneSpace);
@@ -689,29 +741,30 @@ QRectF QDeclarativeDesignView::adjustToScreenBoundaries(const QRectF &boundingRe
boundingRect.setLeft(marginFromEdge);
}
- if (boundingRect.right() >= rect().right() ) {
- boundingRect.setRight(rect().right() - marginFromEdge);
+ QRect rect = data->view->rect();
+ if (boundingRect.right() >= rect.right() ) {
+ boundingRect.setRight(rect.right() - marginFromEdge);
}
if (qAbs(boundingRect.top()) - 1 < 2) {
boundingRect.setTop(marginFromEdge);
}
- if (boundingRect.bottom() >= rect().bottom() ) {
- boundingRect.setBottom(rect().bottom() - marginFromEdge);
+ if (boundingRect.bottom() >= rect.bottom() ) {
+ boundingRect.setBottom(rect.bottom() - marginFromEdge);
}
return boundingRect;
}
-QToolBar *QDeclarativeDesignView::toolbar() const
+QToolBar *QDeclarativeViewObserver::toolbar() const
{
return data->toolbar;
}
-void QDeclarativeDesignViewPrivate::createToolbar()
+void QDeclarativeViewObserverPrivate::createToolbar()
{
- toolbar = new QmlToolbar(q);
+ toolbar = new QmlToolbar(q->declarativeView());
QObject::connect(q, SIGNAL(selectedColorChanged(QColor)), toolbar, SLOT(setColorBoxColor(QColor)));
QObject::connect(q, SIGNAL(designModeBehaviorChanged(bool)), toolbar, SLOT(setDesignModeBehavior(bool)));
@@ -740,12 +793,12 @@ void QDeclarativeDesignViewPrivate::createToolbar()
QObject::connect(q, SIGNAL(marqueeSelectToolActivated()), toolbar, SLOT(activateMarqueeSelectTool()));
}
-void QDeclarativeDesignView::setDebugMode(bool isDebugMode)
+void QDeclarativeViewObserver::setDebugMode(bool isDebugMode)
{
if (isDebugMode && !data->jsDebuggerAgent)
- data->jsDebuggerAgent = new JSDebuggerAgent(QDeclarativeEnginePrivate::getScriptEngine(engine()));
+ data->jsDebuggerAgent = new JSDebuggerAgent(QDeclarativeEnginePrivate::getScriptEngine(data->view->engine()));
}
} //namespace QmlViewer
-#include <moc_qdeclarativedesignview.cpp>
+#include <moc_qdeclarativeviewobserver.cpp>
diff --git a/share/qtcreator/qmljsdebugger/qdeclarativedesignview_p.h b/share/qtcreator/qmljsdebugger/qdeclarativeviewobserver_p.h
index e5a63d9982..85e28b94c2 100644
--- a/share/qtcreator/qmljsdebugger/qdeclarativedesignview_p.h
+++ b/share/qtcreator/qmljsdebugger/qdeclarativeviewobserver_p.h
@@ -34,14 +34,14 @@
#include <QPointF>
#include <QTimer>
-#include "qdeclarativedesignview.h"
+#include "qdeclarativeviewobserver.h"
#include "qdeclarativedesigndebugserver.h"
QT_FORWARD_DECLARE_CLASS(JSDebuggerAgent)
namespace QmlViewer {
-class QDeclarativeDesignView;
+class QDeclarativeViewObserver;
class SelectionTool;
class ZoomTool;
class ColorPickerTool;
@@ -52,7 +52,7 @@ class QmlToolbar;
class CrumblePath;
class AbstractFormEditorTool;
-class QDeclarativeDesignViewPrivate
+class QDeclarativeViewObserverPrivate
{
public:
@@ -62,10 +62,11 @@ public:
ContextSensitive
};
- QDeclarativeDesignViewPrivate(QDeclarativeDesignView *);
- ~QDeclarativeDesignViewPrivate();
+ QDeclarativeViewObserverPrivate(QDeclarativeViewObserver *);
+ ~QDeclarativeViewObserverPrivate();
- QDeclarativeDesignView *q;
+ QDeclarativeView *view;
+ QDeclarativeViewObserver *q;
QDeclarativeDesignDebugServer *debugServer;
QPointF cursorPos;
@@ -134,7 +135,7 @@ public:
void _q_changeContextPathIndex(int index);
void _q_clearComponentCache();
- static QDeclarativeDesignViewPrivate *get(QDeclarativeDesignView *v) { return v->d_func(); }
+ static QDeclarativeViewObserverPrivate *get(QDeclarativeViewObserver *v) { return v->d_func(); }
};
} // namespace QmlViewer
diff --git a/share/qtcreator/qmljsdebugger/qmljsdebugger-lib.pri b/share/qtcreator/qmljsdebugger/qmljsdebugger-lib.pri
index 7421f0e9ec..288b3f3542 100644
--- a/share/qtcreator/qmljsdebugger/qmljsdebugger-lib.pri
+++ b/share/qtcreator/qmljsdebugger/qmljsdebugger-lib.pri
@@ -17,15 +17,15 @@ include($$PWD/editor/editor.pri)
## Input
HEADERS += \
include/jsdebuggeragent.h \
- include/qdeclarativedesignview.h \
+ include/qdeclarativeviewobserver.h \
include/qdeclarativedesigndebugserver.h \
include/qmlviewerconstants.h \
include/qmljsdebugger_global.h \
- qdeclarativedesignview_p.h
+ qdeclarativeviewobserver_p.h
SOURCES += \
jsdebuggeragent.cpp \
- qdeclarativedesignview.cpp \
+ qdeclarativeviewobserver.cpp \
qdeclarativedesigndebugserver.cpp
OTHER_FILES += qmljsdebugger.pri
diff --git a/share/qtcreator/templates/qmlapp/qmlapplicationviewer/qmlapplicationviewer.cpp b/share/qtcreator/templates/qmlapp/qmlapplicationviewer/qmlapplicationviewer.cpp
index 9af81c9a85..3a85473788 100644
--- a/share/qtcreator/templates/qmlapp/qmlapplicationviewer/qmlapplicationviewer.cpp
+++ b/share/qtcreator/templates/qmlapp/qmlapplicationviewer/qmlapplicationviewer.cpp
@@ -42,7 +42,7 @@ QString QmlApplicationViewerPrivate::adjustPath(const QString &path)
QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) :
#ifdef QMLINSPECTOR
- QmlViewer::QDeclarativeDesignView(parent)
+ QmlViewer::QDeclarativeViewObserver(parent)
#else
QDeclarativeView(parent)
#endif
diff --git a/share/qtcreator/templates/qmlapp/qmlapplicationviewer/qmlapplicationviewer.h b/share/qtcreator/templates/qmlapp/qmlapplicationviewer/qmlapplicationviewer.h
index 4327a825ee..1ad160b357 100644
--- a/share/qtcreator/templates/qmlapp/qmlapplicationviewer/qmlapplicationviewer.h
+++ b/share/qtcreator/templates/qmlapp/qmlapplicationviewer/qmlapplicationviewer.h
@@ -2,8 +2,8 @@
#define QMLAPPLICATIONVIEWER_H
#ifdef QMLINSPECTOR
-#include <qdeclarativedesignview.h>
-class QmlApplicationViewer : public QmlViewer::QDeclarativeDesignView
+#include <qdeclarativeviewobserver.h>
+class QmlApplicationViewer : public QmlViewer::QDeclarativeViewObserver
#else // QMLINSPECTOR
#include <QtDeclarative/QDeclarativeView>
class QmlApplicationViewer : public QDeclarativeView
diff --git a/src/plugins/debugger/debuggerrunner.cpp b/src/plugins/debugger/debuggerrunner.cpp
index fbebb43aae..d22b393b02 100644
--- a/src/plugins/debugger/debuggerrunner.cpp
+++ b/src/plugins/debugger/debuggerrunner.cpp
@@ -307,11 +307,11 @@ static DebuggerEngineType engineForToolChain(int toolChainType)
// unless the toolchain provides a hint.
DebuggerEngineType DebuggerRunControl::engineForExecutable(const QString &executable)
{
- if (executable.endsWith(_("qmlviewer"))) {
+ /*if (executable.endsWith(_("qmlviewer"))) {
if (d->m_enabledEngines & QmlEngineType)
return QmlEngineType;
d->m_errorMessage = msgEngineNotAvailable("Qml Engine");
- }
+ }*/
if (executable.endsWith(_(".js"))) {
if (d->m_enabledEngines & ScriptEngineType)
@@ -380,13 +380,13 @@ void DebuggerRunControl::createEngine(const DebuggerStartParameters &startParams
// Figure out engine according to toolchain, executable, attach or default.
DebuggerEngineType engineType = NoEngineType;
DebuggerLanguages activeLangs = DebuggerPlugin::instance()->activeLanguages();
- bool isQmlExecutable = sp.executable.endsWith(_("qmlviewer")) || sp.executable.endsWith(_("qmlobserver"));
+ /*bool isQmlExecutable = sp.executable.endsWith(_("qmlviewer")) || sp.executable.endsWith(_("qmlobserver"));
#ifdef Q_OS_MAC
isQmlExecutable = sp.executable.endsWith(_("QMLViewer.app")) || sp.executable.endsWith(_("QMLObserver.app"));
#endif
- if (isQmlExecutable)
+ if (isQmlExecutable && sp.startMode != AttachCore)
engineType = QmlEngineType;
- else if (sp.executable.endsWith(_(".js")))
+ else */if (sp.executable.endsWith(_(".js")))
engineType = ScriptEngineType;
else if (sp.executable.endsWith(_(".py")))
engineType = PdbEngineType;
diff --git a/src/tools/qml/qmlobserver/qmlruntime.cpp b/src/tools/qml/qmlobserver/qmlruntime.cpp
index 6e5bdcf335..fbbeda6efe 100644
--- a/src/tools/qml/qmlobserver/qmlruntime.cpp
+++ b/src/tools/qml/qmlobserver/qmlruntime.cpp
@@ -54,7 +54,7 @@
# include "ui_recopts.h"
#endif
-#include <qdeclarativedesignview.h>
+#include <qdeclarativeviewobserver.h>
#include <qdeclarativedesigndebugserver.h>
#include <utils/crumblepath.h>
@@ -613,13 +613,14 @@ QDeclarativeViewer::QDeclarativeViewer(QWidget *parent, Qt::WindowFlags flags)
recdlg->warning->hide();
}
- canvas = new QmlViewer::QDeclarativeDesignView(this);
+ canvas = new QDeclarativeView(this);
+ observer = new QmlViewer::QDeclarativeViewObserver(canvas, this);
if (!(flags & Qt::FramelessWindowHint)) {
m_crumblePathWidget = new Utils::CrumblePath(canvas);
#ifndef Q_WS_MAC
m_crumblePathWidget->setStyleSheet("QWidget { border-bottom: 1px solid black; }");
#endif
- m_crumblePathWidget->setVisible(canvas->designModeBehavior());
+ m_crumblePathWidget->setVisible(observer->designModeBehavior());
// CrumblePath is not in a layout, so that it overlays the central widget
// The event filter ensures that its width stays in sync nevertheless
@@ -641,15 +642,15 @@ QDeclarativeViewer::QDeclarativeViewer(QWidget *parent, Qt::WindowFlags flags)
canvas->setFocus();
- QObject::connect(canvas, SIGNAL(reloadRequested()), this, SLOT(reload()));
+ QObject::connect(observer, SIGNAL(reloadRequested()), this, SLOT(reload()));
QObject::connect(canvas, SIGNAL(sceneResized(QSize)), this, SLOT(sceneResized(QSize)));
QObject::connect(canvas, SIGNAL(statusChanged(QDeclarativeView::Status)), this, SLOT(statusChanged()));
if (m_crumblePathWidget) {
- QObject::connect(canvas, SIGNAL(inspectorContextCleared()), m_crumblePathWidget, SLOT(clear()));
- QObject::connect(canvas, SIGNAL(inspectorContextPushed(QString)), m_crumblePathWidget, SLOT(pushElement(QString)));
- QObject::connect(canvas, SIGNAL(inspectorContextPopped()), m_crumblePathWidget, SLOT(popElement()));
- QObject::connect(m_crumblePathWidget, SIGNAL(elementClicked(int)), canvas, SLOT(setInspectorContext(int)));
- QObject::connect(canvas, SIGNAL(designModeBehaviorChanged(bool)), m_crumblePathWidget, SLOT(setVisible(bool)));
+ QObject::connect(observer, SIGNAL(inspectorContextCleared()), m_crumblePathWidget, SLOT(clear()));
+ QObject::connect(observer, SIGNAL(inspectorContextPushed(QString)), m_crumblePathWidget, SLOT(pushElement(QString)));
+ QObject::connect(observer, SIGNAL(inspectorContextPopped()), m_crumblePathWidget, SLOT(popElement()));
+ QObject::connect(m_crumblePathWidget, SIGNAL(elementClicked(int)), observer, SLOT(setInspectorContext(int)));
+ QObject::connect(observer, SIGNAL(designModeBehaviorChanged(bool)), m_crumblePathWidget, SLOT(setVisible(bool)));
}
QObject::connect(canvas->engine(), SIGNAL(quit()), QCoreApplication::instance (), SLOT(quit()));
@@ -691,12 +692,12 @@ void QDeclarativeViewer::setDesignModeBehavior(bool value)
{
if (designModeBehaviorAction)
designModeBehaviorAction->setChecked(value);
- canvas->setDesignModeBehavior(value);
+ observer->setDesignModeBehavior(value);
}
void QDeclarativeViewer::setDebugMode(bool on)
{
- canvas->setDebugMode(on);
+ observer->setDebugMode(on);
}
void QDeclarativeViewer::enableExperimentalGestures()
@@ -792,10 +793,10 @@ void QDeclarativeViewer::createMenu()
designModeBehaviorAction = new QAction(tr("&Observer Mode"), this);
designModeBehaviorAction->setShortcut(QKeySequence("Ctrl+D"));
designModeBehaviorAction->setCheckable(true);
- designModeBehaviorAction->setChecked(canvas->designModeBehavior());
+ designModeBehaviorAction->setChecked(observer->designModeBehavior());
designModeBehaviorAction->setEnabled(QDeclarativeDesignDebugServer::hasDebuggingClient());
connect(designModeBehaviorAction, SIGNAL(triggered(bool)), this, SLOT(setDesignModeBehavior(bool)));
- connect(canvas, SIGNAL(designModeBehaviorChanged(bool)), designModeBehaviorAction, SLOT(setChecked(bool)));
+ connect(observer, SIGNAL(designModeBehaviorChanged(bool)), designModeBehaviorAction, SLOT(setChecked(bool)));
connect(QDeclarativeDesignDebugServer::instance(), SIGNAL(debuggingClientChanged(bool)), designModeBehaviorAction, SLOT(setEnabled(bool)));
QAction *proxyAction = new QAction(tr("HTTP &Proxy..."), this);
@@ -1060,7 +1061,7 @@ void QDeclarativeViewer::addPluginPath(const QString& plugin)
void QDeclarativeViewer::reload()
{
- canvas->setDesignModeBehavior(false);
+ observer->setDesignModeBehavior(false);
open(currentFileOrUrl);
}
diff --git a/src/tools/qml/qmlobserver/qmlruntime.h b/src/tools/qml/qmlobserver/qmlruntime.h
index 2c6c5eefbd..1160d91eb5 100644
--- a/src/tools/qml/qmlobserver/qmlruntime.h
+++ b/src/tools/qml/qmlobserver/qmlruntime.h
@@ -50,7 +50,7 @@
#include "loggerwidget.h"
namespace QmlViewer {
- class QDeclarativeDesignView;
+ class QDeclarativeViewObserver;
}
namespace Utils {
class CrumblePath;
@@ -167,7 +167,8 @@ private:
LoggerWidget *loggerWindow;
- QmlViewer::QDeclarativeDesignView *canvas;
+ QDeclarativeView *canvas;
+ QmlViewer::QDeclarativeViewObserver *observer;
QSize initialSize;
QString currentFileOrUrl;
QTimer recordTimer;