aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/qmltooling/declarativeobserver/qdeclarativeviewobserver.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/qmltooling/declarativeobserver/qdeclarativeviewobserver.cpp')
-rw-r--r--src/plugins/qmltooling/declarativeobserver/qdeclarativeviewobserver.cpp178
1 files changed, 16 insertions, 162 deletions
diff --git a/src/plugins/qmltooling/declarativeobserver/qdeclarativeviewobserver.cpp b/src/plugins/qmltooling/declarativeobserver/qdeclarativeviewobserver.cpp
index 41346ffafe..bb238310a1 100644
--- a/src/plugins/qmltooling/declarativeobserver/qdeclarativeviewobserver.cpp
+++ b/src/plugins/qmltooling/declarativeobserver/qdeclarativeviewobserver.cpp
@@ -51,7 +51,6 @@
#include "editor/colorpickertool_p.h"
#include "editor/livelayeritem_p.h"
#include "editor/boundingrecthighlighter_p.h"
-#include "editor/subcomponenteditortool_p.h"
#include "editor/qmltoolbar_p.h"
#include <QtDeclarative/QDeclarativeItem>
@@ -138,7 +137,6 @@ QDeclarativeViewObserver::QDeclarativeViewObserver(QDeclarativeView *view,
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
@@ -158,14 +156,6 @@ QDeclarativeViewObserver::QDeclarativeViewObserver(QDeclarativeView *view,
connect(data->colorPickerTool, SIGNAL(selectedColorChanged(QColor)),
this, SLOT(sendColorChanged(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)),
- this, SLOT(sendContextPathUpdated(QStringList)));
-
data->_q_changeToSingleSelectTool();
}
@@ -173,15 +163,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)
@@ -196,7 +177,6 @@ void QDeclarativeViewObserverPrivate::_q_setToolBoxVisible(bool visible)
void QDeclarativeViewObserverPrivate::_q_reloadView()
{
- subcomponentEditorTool->clear();
clearHighlight();
emit q->reloadRequested();
}
@@ -318,10 +298,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;
@@ -331,7 +309,6 @@ bool QDeclarativeViewObserver::mouseReleaseEvent(QMouseEvent *event)
{
if (!data->designModeBehavior)
return false;
- data->subcomponentEditorTool->mouseReleaseEvent(event);
data->cursorPos = event->pos();
data->currentTool->mouseReleaseEvent(event);
@@ -366,11 +343,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;
@@ -435,41 +407,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;
}
@@ -481,16 +423,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);
@@ -500,14 +432,6 @@ void QDeclarativeViewObserver::setDesignModeBehavior(bool value)
sendDesignModeBehavior(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();
@@ -557,7 +481,7 @@ void QDeclarativeViewObserverPrivate::changeTool(Constants::DesignTool tool,
}
}
-void QDeclarativeViewObserverPrivate::setSelectedItemsForTools(QList<QGraphicsItem *> items)
+void QDeclarativeViewObserverPrivate::setSelectedItemsForTools(const QList<QGraphicsItem *> &items)
{
foreach (const QWeakPointer<QGraphicsObject> &obj, currentSelection) {
if (QGraphicsItem *item = obj.data()) {
@@ -570,8 +494,8 @@ void QDeclarativeViewObserverPrivate::setSelectedItemsForTools(QList<QGraphicsIt
}
foreach (QGraphicsItem *item, items) {
- if (item) {
- if (QGraphicsObject *obj = item->toGraphicsObject()) {
+ if (QGraphicsObject *obj = item->toGraphicsObject()) {
+ if (!currentSelection.contains(obj)) {
QObject::connect(obj, SIGNAL(destroyed(QObject*)),
this, SLOT(_q_removeFromSelection(QObject*)));
currentSelection.append(obj);
@@ -582,7 +506,7 @@ void QDeclarativeViewObserverPrivate::setSelectedItemsForTools(QList<QGraphicsIt
currentTool->updateSelectedItems();
}
-void QDeclarativeViewObserverPrivate::setSelectedItems(QList<QGraphicsItem *> items)
+void QDeclarativeViewObserverPrivate::setSelectedItems(const QList<QGraphicsItem *> &items)
{
QList<QWeakPointer<QGraphicsObject> > oldList = currentSelection;
setSelectedItemsForTools(items);
@@ -628,12 +552,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;
@@ -641,8 +560,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();
@@ -654,30 +571,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()
@@ -737,11 +648,6 @@ void QDeclarativeViewObserverPrivate::_q_changeToColorPickerTool()
q->sendCurrentTool(Constants::ColorPickerMode);
}
-void QDeclarativeViewObserverPrivate::_q_changeContextPathIndex(int index)
-{
- subcomponentEditorTool->setContext(index);
-}
-
void QDeclarativeViewObserver::setAnimationSpeed(qreal slowDownFactor)
{
Q_ASSERT(slowDownFactor > 0);
@@ -793,38 +699,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
@@ -834,14 +715,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)
q->sendReloaded();
- }
}
void QDeclarativeViewObserverPrivate::_q_onCurrentObjectsChanged(QList<QObject*> objects)
@@ -849,17 +724,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);
}
}
@@ -942,9 +815,7 @@ void QDeclarativeViewObserver::handleMessage(const QByteArray &message)
for (int i = 0; i < itemCount; ++i) {
int debugId = -1;
ds >> debugId;
- QObject *obj = QDeclarativeDebugService::objectForId(debugId);
-
- if (obj)
+ if (QObject *obj = QDeclarativeDebugService::objectForId(debugId))
selectedObjects << obj;
}
@@ -1038,12 +909,6 @@ void QDeclarativeViewObserver::handleMessage(const QByteArray &message)
}
break;
}
- case ObserverProtocol::SetContextPathIdx: {
- int contextPathIndex;
- ds >> contextPathIndex;
- data->_q_changeContextPathIndex(contextPathIndex);
- break;
- }
case ObserverProtocol::ClearComponentCache: {
data->_q_clearComponentCache();
break;
@@ -1064,7 +929,7 @@ void QDeclarativeViewObserver::sendDesignModeBehavior(bool inDesignMode)
data->debugService->sendMessage(message);
}
-void QDeclarativeViewObserver::sendCurrentObjects(QList<QObject*> objects)
+void QDeclarativeViewObserver::sendCurrentObjects(const QList<QObject*> &objects)
{
QByteArray message;
QDataStream ds(&message, QIODevice::WriteOnly);
@@ -1144,17 +1009,6 @@ void QDeclarativeViewObserver::sendColorChanged(const QColor &color)
data->debugService->sendMessage(message);
}
-void QDeclarativeViewObserver::sendContextPathUpdated(const QStringList &contextPath)
-{
- QByteArray message;
- QDataStream ds(&message, QIODevice::WriteOnly);
-
- ds << ObserverProtocol::ContextPathUpdated
- << contextPath;
-
- data->debugService->sendMessage(message);
-}
-
QString QDeclarativeViewObserver::idStringForObject(QObject *obj) const
{
int id = QDeclarativeDebugService::idForObject(obj);