aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.cpp')
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.cpp580
1 files changed, 66 insertions, 514 deletions
diff --git a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.cpp b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.cpp
index 19bfdaa3b5..be0422d963 100644
--- a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.cpp
+++ b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.cpp
@@ -39,84 +39,28 @@
**
****************************************************************************/
-#include "QtDeclarative/private/qdeclarativeinspectorservice_p.h"
-#include "QtDeclarative/private/qdeclarativedebughelper_p.h"
-
#include "qdeclarativeviewinspector_p.h"
#include "qdeclarativeviewinspector_p_p.h"
-#include "qdeclarativeinspectorprotocol.h"
#include "editor/liveselectiontool_p.h"
#include "editor/zoomtool_p.h"
#include "editor/colorpickertool_p.h"
#include "editor/livelayeritem_p.h"
#include "editor/boundingrecthighlighter_p.h"
-#include "editor/qmltoolbar_p.h"
#include <QtDeclarative/QDeclarativeItem>
#include <QtDeclarative/QDeclarativeEngine>
#include <QtDeclarative/QDeclarativeContext>
#include <QtDeclarative/QDeclarativeExpression>
#include <QtGui/QWidget>
-#include <QtGui/QVBoxLayout>
#include <QtGui/QMouseEvent>
#include <QtGui/QGraphicsObject>
#include <QtGui/QApplication>
-#include <QtCore/QSettings>
-
-static inline void initEditorResource() { Q_INIT_RESOURCE(editor); }
QT_BEGIN_NAMESPACE
-const char * const KEY_TOOLBOX_GEOMETRY = "toolBox/geometry";
-
-const int SceneChangeUpdateInterval = 5000;
-
-
-class ToolBox : public QWidget
-{
- Q_OBJECT
-
-public:
- ToolBox(QWidget *parent = 0);
- ~ToolBox();
-
- QmlToolBar *toolBar() const { return m_toolBar; }
-
-private:
- QSettings m_settings;
- QmlToolBar *m_toolBar;
-};
-
-ToolBox::ToolBox(QWidget *parent)
- : QWidget(parent, Qt::Tool)
- , m_settings(QLatin1String("Nokia"), QLatin1String("QmlInspector"), this)
- , m_toolBar(new QmlToolBar)
-{
- setWindowFlags((windowFlags() & ~Qt::WindowCloseButtonHint) | Qt::CustomizeWindowHint);
- setWindowTitle(tr("Qt Quick Toolbox"));
-
- QVBoxLayout *verticalLayout = new QVBoxLayout;
- verticalLayout->setMargin(0);
- verticalLayout->addWidget(m_toolBar);
- setLayout(verticalLayout);
-
- restoreGeometry(m_settings.value(QLatin1String(KEY_TOOLBOX_GEOMETRY)).toByteArray());
-}
-
-ToolBox::~ToolBox()
-{
- m_settings.setValue(QLatin1String(KEY_TOOLBOX_GEOMETRY), saveGeometry());
-}
-
-
QDeclarativeViewInspectorPrivate::QDeclarativeViewInspectorPrivate(QDeclarativeViewInspector *q) :
- q(q),
- designModeBehavior(false),
- showAppOnTop(false),
- animationPaused(false),
- slowDownFactor(1.0f),
- toolBox(0)
+ q(q)
{
}
@@ -126,11 +70,9 @@ QDeclarativeViewInspectorPrivate::~QDeclarativeViewInspectorPrivate()
QDeclarativeViewInspector::QDeclarativeViewInspector(QDeclarativeView *view,
QObject *parent) :
- QObject(parent),
+ AbstractViewInspector(parent),
data(new QDeclarativeViewInspectorPrivate(this))
{
- initEditorResource();
-
data->view = view;
data->manipulatorLayer = new LiveLayerItem(view->scene());
data->selectionTool = new LiveSelectionTool(this);
@@ -144,10 +86,6 @@ QDeclarativeViewInspector::QDeclarativeViewInspector(QDeclarativeView *view,
data->setViewport(data->view->viewport());
- data->debugService = QDeclarativeInspectorService::instance();
- connect(data->debugService, SIGNAL(gotMessage(QByteArray)),
- this, SLOT(handleMessage(QByteArray)));
-
connect(data->view, SIGNAL(statusChanged(QDeclarativeView::Status)),
data.data(), SLOT(_q_onStatusChanged(QDeclarativeView::Status)));
@@ -156,29 +94,57 @@ QDeclarativeViewInspector::QDeclarativeViewInspector(QDeclarativeView *view,
connect(data->colorPickerTool, SIGNAL(selectedColorChanged(QColor)),
this, SLOT(sendColorChanged(QColor)));
- data->_q_changeToSingleSelectTool();
+ changeTool(InspectorProtocol::SelectTool);
}
QDeclarativeViewInspector::~QDeclarativeViewInspector()
{
}
-void QDeclarativeViewInspectorPrivate::_q_setToolBoxVisible(bool visible)
+void QDeclarativeViewInspector::changeCurrentObjects(const QList<QObject*> &objects)
{
-#if !defined(Q_OS_SYMBIAN) && !defined(Q_WS_MAEMO_5) && !defined(Q_WS_SIMULATOR)
- if (!toolBox && visible)
- createToolBox();
- if (toolBox)
- toolBox->setVisible(visible);
-#else
- Q_UNUSED(visible)
-#endif
+ QList<QGraphicsItem*> items;
+ QList<QGraphicsObject*> gfxObjects;
+ foreach (QObject *obj, objects) {
+ if (QDeclarativeItem *declarativeItem = qobject_cast<QDeclarativeItem*>(obj)) {
+ items << declarativeItem;
+ gfxObjects << declarativeItem;
+ }
+ }
+ if (designModeBehavior()) {
+ data->setSelectedItemsForTools(items);
+ data->clearHighlight();
+ data->highlight(gfxObjects);
+ }
}
-void QDeclarativeViewInspectorPrivate::_q_reloadView()
+void QDeclarativeViewInspector::reloadView()
{
- clearHighlight();
- emit q->reloadRequested();
+ data->clearHighlight();
+ emit reloadRequested();
+}
+
+void QDeclarativeViewInspector::changeTool(InspectorProtocol::Tool tool)
+{
+ switch (tool) {
+ case InspectorProtocol::ColorPickerTool:
+ data->changeToColorPickerTool();
+ break;
+ case InspectorProtocol::SelectMarqueeTool:
+ data->changeToMarqueeSelectTool();
+ break;
+ case InspectorProtocol::SelectTool:
+ data->changeToSingleSelectTool();
+ break;
+ case InspectorProtocol::ZoomTool:
+ data->changeToZoomTool();
+ break;
+ }
+}
+
+QDeclarativeEngine *QDeclarativeViewInspector::declarativeEngine() const
+{
+ return data->view->engine();
}
void QDeclarativeViewInspectorPrivate::setViewport(QWidget *widget)
@@ -268,7 +234,7 @@ bool QDeclarativeViewInspector::eventFilter(QObject *obj, QEvent *event)
bool QDeclarativeViewInspector::leaveEvent(QEvent * /*event*/)
{
- if (!data->designModeBehavior)
+ if (!designModeBehavior())
return false;
data->clearHighlight();
return true;
@@ -276,7 +242,7 @@ bool QDeclarativeViewInspector::leaveEvent(QEvent * /*event*/)
bool QDeclarativeViewInspector::mousePressEvent(QMouseEvent *event)
{
- if (!data->designModeBehavior)
+ if (!designModeBehavior())
return false;
data->cursorPos = event->pos();
data->currentTool->mousePressEvent(event);
@@ -285,7 +251,7 @@ bool QDeclarativeViewInspector::mousePressEvent(QMouseEvent *event)
bool QDeclarativeViewInspector::mouseMoveEvent(QMouseEvent *event)
{
- if (!data->designModeBehavior) {
+ if (!designModeBehavior()) {
data->clearEditorItems();
return false;
}
@@ -307,7 +273,7 @@ bool QDeclarativeViewInspector::mouseMoveEvent(QMouseEvent *event)
bool QDeclarativeViewInspector::mouseReleaseEvent(QMouseEvent *event)
{
- if (!data->designModeBehavior)
+ if (!designModeBehavior())
return false;
data->cursorPos = event->pos();
@@ -317,7 +283,7 @@ bool QDeclarativeViewInspector::mouseReleaseEvent(QMouseEvent *event)
bool QDeclarativeViewInspector::keyPressEvent(QKeyEvent *event)
{
- if (!data->designModeBehavior)
+ if (!designModeBehavior())
return false;
data->currentTool->keyPressEvent(event);
@@ -326,25 +292,25 @@ bool QDeclarativeViewInspector::keyPressEvent(QKeyEvent *event)
bool QDeclarativeViewInspector::keyReleaseEvent(QKeyEvent *event)
{
- if (!data->designModeBehavior)
+ if (!designModeBehavior())
return false;
switch (event->key()) {
case Qt::Key_V:
- data->_q_changeToSingleSelectTool();
+ changeTool(InspectorProtocol::SelectTool);
break;
// disabled because multiselection does not do anything useful without design mode
// case Qt::Key_M:
-// data->_q_changeToMarqueeSelectTool();
+// changeTool(InspectorProtocol::SelectMarqueeTool);
// break;
case Qt::Key_I:
- data->_q_changeToColorPickerTool();
+ changeTool(InspectorProtocol::ColorPickerTool);
break;
case Qt::Key_Z:
- data->_q_changeToZoomTool();
+ changeTool(InspectorProtocol::ZoomTool);
break;
case Qt::Key_Space:
- setAnimationPaused(!data->animationPaused);
+ setAnimationPaused(!animationPaused());
break;
default:
break;
@@ -354,35 +320,7 @@ bool QDeclarativeViewInspector::keyReleaseEvent(QKeyEvent *event)
return true;
}
-void QDeclarativeViewInspectorPrivate::_q_createQmlObject(const QString &qml, QObject *parent,
- const QStringList &importList,
- const QString &filename)
-{
- if (!parent)
- return;
-
- QString imports;
- foreach (const QString &s, importList) {
- imports += s;
- imports += QLatin1Char('\n');
- }
-
- QDeclarativeContext *parentContext = view->engine()->contextForObject(parent);
- QDeclarativeComponent component(view->engine(), q);
- QByteArray constructedQml = QString(imports + qml).toLatin1();
-
- component.setData(constructedQml, QUrl::fromLocalFile(filename));
- QObject *newObject = component.create(parentContext);
- if (newObject) {
- newObject->setParent(parent);
- QDeclarativeItem *parentItem = qobject_cast<QDeclarativeItem*>(parent);
- QDeclarativeItem *newItem = qobject_cast<QDeclarativeItem*>(newObject);
- if (parentItem && newItem)
- newItem->setParentItem(parentItem);
- }
-}
-
-void QDeclarativeViewInspectorPrivate::_q_reparentQmlObject(QObject *object, QObject *newParent)
+void QDeclarativeViewInspector::reparentQmlObject(QObject *object, QObject *newParent)
{
if (!newParent)
return;
@@ -394,11 +332,6 @@ void QDeclarativeViewInspectorPrivate::_q_reparentQmlObject(QObject *object, QOb
item->setParentItem(newParentItem);
}
-void QDeclarativeViewInspectorPrivate::_q_clearComponentCache()
-{
- view->engine()->clearComponentCache();
-}
-
void QDeclarativeViewInspectorPrivate::_q_removeFromSelection(QObject *obj)
{
QList<QGraphicsItem*> items = selectedItems();
@@ -409,7 +342,7 @@ void QDeclarativeViewInspectorPrivate::_q_removeFromSelection(QObject *obj)
bool QDeclarativeViewInspector::mouseDoubleClickEvent(QMouseEvent * /*event*/)
{
- if (!data->designModeBehavior)
+ if (!designModeBehavior())
return false;
return true;
@@ -417,70 +350,12 @@ bool QDeclarativeViewInspector::mouseDoubleClickEvent(QMouseEvent * /*event*/)
bool QDeclarativeViewInspector::wheelEvent(QWheelEvent *event)
{
- if (!data->designModeBehavior)
+ if (!designModeBehavior())
return false;
data->currentTool->wheelEvent(event);
return true;
}
-void QDeclarativeViewInspector::setDesignModeBehavior(bool value)
-{
- emit designModeBehaviorChanged(value);
-
- if (data->toolBox)
- data->toolBox->toolBar()->setDesignModeBehavior(value);
- sendDesignModeBehavior(value);
-
- data->designModeBehavior = value;
-
- if (!data->designModeBehavior)
- data->clearEditorItems();
-}
-
-bool QDeclarativeViewInspector::designModeBehavior()
-{
- return data->designModeBehavior;
-}
-
-bool QDeclarativeViewInspector::showAppOnTop() const
-{
- return data->showAppOnTop;
-}
-
-void QDeclarativeViewInspector::setShowAppOnTop(bool appOnTop)
-{
- if (data->view) {
- QWidget *window = data->view->window();
- Qt::WindowFlags flags = window->windowFlags();
- if (appOnTop)
- flags |= Qt::WindowStaysOnTopHint;
- else
- flags &= ~Qt::WindowStaysOnTopHint;
-
- window->setWindowFlags(flags);
- window->show();
- }
-
- data->showAppOnTop = appOnTop;
- sendShowAppOnTop(appOnTop);
-
- emit showAppOnTopChanged(appOnTop);
-}
-
-void QDeclarativeViewInspectorPrivate::changeTool(Constants::DesignTool tool,
- Constants::ToolFlags /*flags*/)
-{
- switch (tool) {
- case Constants::SelectionToolMode:
- _q_changeToSingleSelectTool();
- break;
- case Constants::NoTool:
- default:
- currentTool = 0;
- break;
- }
-}
-
void QDeclarativeViewInspectorPrivate::setSelectedItemsForTools(const QList<QGraphicsItem *> &items)
{
foreach (const QWeakPointer<QGraphicsObject> &obj, currentSelection) {
@@ -542,7 +417,7 @@ QList<QGraphicsItem *> QDeclarativeViewInspector::selectedItems() const
return data->selectedItems();
}
-QDeclarativeView *QDeclarativeViewInspector::declarativeView()
+QDeclarativeView *QDeclarativeViewInspector::declarativeView() const
{
return data->view;
}
@@ -591,7 +466,7 @@ QList<QGraphicsItem*> QDeclarativeViewInspectorPrivate::selectableItems(
return filterForSelection(itemlist);
}
-void QDeclarativeViewInspectorPrivate::_q_changeToSingleSelectTool()
+void QDeclarativeViewInspectorPrivate::changeToSingleSelectTool()
{
currentToolMode = Constants::SelectionToolMode;
selectionTool->setRubberbandSelectionMode(false);
@@ -613,7 +488,7 @@ void QDeclarativeViewInspectorPrivate::changeToSelectTool()
currentTool->updateSelectedItems();
}
-void QDeclarativeViewInspectorPrivate::_q_changeToMarqueeSelectTool()
+void QDeclarativeViewInspectorPrivate::changeToMarqueeSelectTool()
{
changeToSelectTool();
currentToolMode = Constants::MarqueeSelectionToolMode;
@@ -623,7 +498,7 @@ void QDeclarativeViewInspectorPrivate::_q_changeToMarqueeSelectTool()
q->sendCurrentTool(Constants::MarqueeSelectionToolMode);
}
-void QDeclarativeViewInspectorPrivate::_q_changeToZoomTool()
+void QDeclarativeViewInspectorPrivate::changeToZoomTool()
{
currentToolMode = Constants::ZoomMode;
currentTool->clear();
@@ -634,7 +509,7 @@ void QDeclarativeViewInspectorPrivate::_q_changeToZoomTool()
q->sendCurrentTool(Constants::ZoomMode);
}
-void QDeclarativeViewInspectorPrivate::_q_changeToColorPickerTool()
+void QDeclarativeViewInspectorPrivate::changeToColorPickerTool()
{
if (currentTool == colorPickerTool)
return;
@@ -648,53 +523,14 @@ void QDeclarativeViewInspectorPrivate::_q_changeToColorPickerTool()
q->sendCurrentTool(Constants::ColorPickerMode);
}
-void QDeclarativeViewInspector::setAnimationSpeed(qreal slowDownFactor)
-{
- Q_ASSERT(slowDownFactor > 0);
- if (data->slowDownFactor == slowDownFactor)
- return;
-
- animationSpeedChangeRequested(slowDownFactor);
- sendAnimationSpeed(slowDownFactor);
-}
-
-void QDeclarativeViewInspector::setAnimationPaused(bool paused)
-{
- if (data->animationPaused == paused)
- return;
-
- animationPausedChangeRequested(paused);
- sendAnimationPaused(paused);
-}
-
-void QDeclarativeViewInspector::animationSpeedChangeRequested(qreal factor)
-{
- if (data->slowDownFactor != factor) {
- data->slowDownFactor = factor;
- emit animationSpeedChanged(factor);
- }
-
- const float effectiveFactor = data->animationPaused ? 0 : factor;
- QDeclarativeDebugHelper::setAnimationSlowDownFactor(effectiveFactor);
-}
-void QDeclarativeViewInspector::animationPausedChangeRequested(bool paused)
-{
- if (data->animationPaused != paused) {
- data->animationPaused = paused;
- emit animationPausedChanged(paused);
- }
-
- const float effectiveFactor = paused ? 0 : data->slowDownFactor;
- QDeclarativeDebugHelper::setAnimationSlowDownFactor(effectiveFactor);
-}
-
-
-void QDeclarativeViewInspectorPrivate::_q_applyChangesFromClient()
+static bool isEditorItem(QGraphicsItem *item)
{
+ return (item->type() == Constants::EditorItemType
+ || item->type() == Constants::ResizeHandleItemType
+ || item->data(Constants::EditorItemDataKey).toBool());
}
-
QList<QGraphicsItem*> QDeclarativeViewInspectorPrivate::filterForSelection(
QList<QGraphicsItem*> &itemlist) const
{
@@ -706,36 +542,12 @@ QList<QGraphicsItem*> QDeclarativeViewInspectorPrivate::filterForSelection(
return itemlist;
}
-bool QDeclarativeViewInspectorPrivate::isEditorItem(QGraphicsItem *item) const
-{
- return (item->type() == Constants::EditorItemType
- || item->type() == Constants::ResizeHandleItemType
- || item->data(Constants::EditorItemDataKey).toBool());
-}
-
void QDeclarativeViewInspectorPrivate::_q_onStatusChanged(QDeclarativeView::Status status)
{
if (status == QDeclarativeView::Ready)
q->sendReloaded();
}
-void QDeclarativeViewInspectorPrivate::_q_onCurrentObjectsChanged(QList<QObject*> objects)
-{
- QList<QGraphicsItem*> items;
- QList<QGraphicsObject*> gfxObjects;
- foreach (QObject *obj, objects) {
- if (QDeclarativeItem *declarativeItem = qobject_cast<QDeclarativeItem*>(obj)) {
- items << declarativeItem;
- gfxObjects << declarativeItem;
- }
- }
- if (designModeBehavior) {
- setSelectedItemsForTools(items);
- clearHighlight();
- highlight(gfxObjects);
- }
-}
-
// adjusts bounding boxes on edges of screen to be visible
QRectF QDeclarativeViewInspector::adjustToScreenBoundaries(const QRectF &boundingRectInSceneSpace)
{
@@ -758,264 +570,4 @@ QRectF QDeclarativeViewInspector::adjustToScreenBoundaries(const QRectF &boundin
return boundingRect;
}
-void QDeclarativeViewInspectorPrivate::createToolBox()
-{
- toolBox = new ToolBox(q->declarativeView());
-
- QmlToolBar *toolBar = toolBox->toolBar();
-
- QObject::connect(q, SIGNAL(selectedColorChanged(QColor)),
- toolBar, SLOT(setColorBoxColor(QColor)));
-
- QObject::connect(q, SIGNAL(designModeBehaviorChanged(bool)),
- toolBar, SLOT(setDesignModeBehavior(bool)));
-
- QObject::connect(toolBar, SIGNAL(designModeBehaviorChanged(bool)),
- q, SLOT(setDesignModeBehavior(bool)));
- QObject::connect(toolBar, SIGNAL(animationSpeedChanged(qreal)), q, SLOT(setAnimationSpeed(qreal)));
- QObject::connect(toolBar, SIGNAL(animationPausedChanged(bool)), q, SLOT(setAnimationPaused(bool)));
- QObject::connect(toolBar, SIGNAL(colorPickerSelected()), this, SLOT(_q_changeToColorPickerTool()));
- QObject::connect(toolBar, SIGNAL(zoomToolSelected()), this, SLOT(_q_changeToZoomTool()));
- QObject::connect(toolBar, SIGNAL(selectToolSelected()), this, SLOT(_q_changeToSingleSelectTool()));
- QObject::connect(toolBar, SIGNAL(marqueeSelectToolSelected()),
- this, SLOT(_q_changeToMarqueeSelectTool()));
-
- QObject::connect(toolBar, SIGNAL(applyChangesFromQmlFileSelected()),
- this, SLOT(_q_applyChangesFromClient()));
-
- QObject::connect(q, SIGNAL(animationSpeedChanged(qreal)), toolBar, SLOT(setAnimationSpeed(qreal)));
- QObject::connect(q, SIGNAL(animationPausedChanged(bool)), toolBar, SLOT(setAnimationPaused(bool)));
-
- QObject::connect(q, SIGNAL(selectToolActivated()), toolBar, SLOT(activateSelectTool()));
-
- // disabled features
- //connect(d->m_toolBar, SIGNAL(applyChangesToQmlFileSelected()), SLOT(applyChangesToClient()));
- //connect(q, SIGNAL(resizeToolActivated()), d->m_toolBar, SLOT(activateSelectTool()));
- //connect(q, SIGNAL(moveToolActivated()), d->m_toolBar, SLOT(activateSelectTool()));
-
- QObject::connect(q, SIGNAL(colorPickerActivated()), toolBar, SLOT(activateColorPicker()));
- QObject::connect(q, SIGNAL(zoomToolActivated()), toolBar, SLOT(activateZoom()));
- QObject::connect(q, SIGNAL(marqueeSelectToolActivated()),
- toolBar, SLOT(activateMarqueeSelectTool()));
-}
-
-void QDeclarativeViewInspector::handleMessage(const QByteArray &message)
-{
- QDataStream ds(message);
-
- InspectorProtocol::Message type;
- ds >> type;
-
- switch (type) {
- case InspectorProtocol::SetCurrentObjects: {
- int itemCount = 0;
- ds >> itemCount;
-
- QList<QObject*> selectedObjects;
- for (int i = 0; i < itemCount; ++i) {
- int debugId = -1;
- ds >> debugId;
- if (QObject *obj = QDeclarativeDebugService::objectForId(debugId))
- selectedObjects << obj;
- }
-
- data->_q_onCurrentObjectsChanged(selectedObjects);
- break;
- }
- case InspectorProtocol::Reload: {
- data->_q_reloadView();
- break;
- }
- case InspectorProtocol::SetAnimationSpeed: {
- qreal speed;
- ds >> speed;
- animationSpeedChangeRequested(speed);
- break;
- }
- case InspectorProtocol::SetAnimationPaused: {
- bool paused;
- ds >> paused;
- animationPausedChangeRequested(paused);
- break;
- }
- case InspectorProtocol::ChangeTool: {
- InspectorProtocol::Tool tool;
- ds >> tool;
- switch (tool) {
- case InspectorProtocol::ColorPickerTool:
- data->_q_changeToColorPickerTool();
- break;
- case InspectorProtocol::SelectTool:
- data->_q_changeToSingleSelectTool();
- break;
- case InspectorProtocol::SelectMarqueeTool:
- data->_q_changeToMarqueeSelectTool();
- break;
- case InspectorProtocol::ZoomTool:
- data->_q_changeToZoomTool();
- break;
- default:
- qWarning() << "Warning: Unhandled tool:" << tool;
- }
- break;
- }
- case InspectorProtocol::SetDesignMode: {
- bool inDesignMode;
- ds >> inDesignMode;
- setDesignModeBehavior(inDesignMode);
- break;
- }
- case InspectorProtocol::ShowAppOnTop: {
- bool showOnTop;
- ds >> showOnTop;
- setShowAppOnTop(showOnTop);
- break;
- }
- case InspectorProtocol::CreateObject: {
- QString qml;
- int parentId;
- QString filename;
- QStringList imports;
- ds >> qml >> parentId >> imports >> filename;
- data->_q_createQmlObject(qml, QDeclarativeDebugService::objectForId(parentId),
- imports, filename);
- break;
- }
- case InspectorProtocol::DestroyObject: {
- int debugId;
- ds >> debugId;
- if (QObject* obj = QDeclarativeDebugService::objectForId(debugId))
- obj->deleteLater();
- break;
- }
- case InspectorProtocol::MoveObject: {
- int debugId, newParent;
- ds >> debugId >> newParent;
- data->_q_reparentQmlObject(QDeclarativeDebugService::objectForId(debugId),
- QDeclarativeDebugService::objectForId(newParent));
- break;
- }
- case InspectorProtocol::ObjectIdList: {
- int itemCount;
- ds >> itemCount;
- data->stringIdForObjectId.clear();
- for (int i = 0; i < itemCount; ++i) {
- int itemDebugId;
- QString itemIdString;
- ds >> itemDebugId
- >> itemIdString;
-
- data->stringIdForObjectId.insert(itemDebugId, itemIdString);
- }
- break;
- }
- case InspectorProtocol::ClearComponentCache: {
- data->_q_clearComponentCache();
- break;
- }
- default:
- qWarning() << "Warning: Not handling message:" << type;
- }
-}
-
-void QDeclarativeViewInspector::sendDesignModeBehavior(bool inDesignMode)
-{
- QByteArray message;
- QDataStream ds(&message, QIODevice::WriteOnly);
-
- ds << InspectorProtocol::SetDesignMode
- << inDesignMode;
-
- data->debugService->sendMessage(message);
-}
-
-void QDeclarativeViewInspector::sendCurrentObjects(const QList<QObject*> &objects)
-{
- QByteArray message;
- QDataStream ds(&message, QIODevice::WriteOnly);
-
- ds << InspectorProtocol::CurrentObjectsChanged
- << objects.length();
-
- foreach (QObject *object, objects) {
- int id = QDeclarativeDebugService::idForObject(object);
- ds << id;
- }
-
- data->debugService->sendMessage(message);
-}
-
-void QDeclarativeViewInspector::sendCurrentTool(Constants::DesignTool toolId)
-{
- QByteArray message;
- QDataStream ds(&message, QIODevice::WriteOnly);
-
- ds << InspectorProtocol::ToolChanged
- << toolId;
-
- data->debugService->sendMessage(message);
-}
-
-void QDeclarativeViewInspector::sendAnimationSpeed(qreal slowDownFactor)
-{
- QByteArray message;
- QDataStream ds(&message, QIODevice::WriteOnly);
-
- ds << InspectorProtocol::AnimationSpeedChanged
- << slowDownFactor;
-
- data->debugService->sendMessage(message);
-}
-
-void QDeclarativeViewInspector::sendAnimationPaused(bool paused)
-{
- QByteArray message;
- QDataStream ds(&message, QIODevice::WriteOnly);
-
- ds << InspectorProtocol::AnimationPausedChanged
- << paused;
-
- data->debugService->sendMessage(message);
-}
-
-void QDeclarativeViewInspector::sendReloaded()
-{
- QByteArray message;
- QDataStream ds(&message, QIODevice::WriteOnly);
-
- ds << InspectorProtocol::Reloaded;
-
- data->debugService->sendMessage(message);
-}
-
-void QDeclarativeViewInspector::sendShowAppOnTop(bool showAppOnTop)
-{
- QByteArray message;
- QDataStream ds(&message, QIODevice::WriteOnly);
-
- ds << InspectorProtocol::ShowAppOnTop << showAppOnTop;
-
- data->debugService->sendMessage(message);
-}
-
-void QDeclarativeViewInspector::sendColorChanged(const QColor &color)
-{
- QByteArray message;
- QDataStream ds(&message, QIODevice::WriteOnly);
-
- ds << InspectorProtocol::ColorChanged
- << color;
-
- data->debugService->sendMessage(message);
-}
-
-QString QDeclarativeViewInspector::idStringForObject(QObject *obj) const
-{
- int id = QDeclarativeDebugService::idForObject(obj);
- QString idString = data->stringIdForObjectId.value(id, QString());
- return idString;
-}
-
QT_END_NAMESPACE
-
-#include "qdeclarativeviewinspector.moc"