Commit 335f6ad0 authored by Thorbjørn Lindeijer's avatar Thorbjørn Lindeijer Committed by Kai Koehne

QmlJSInspector: Renamed Observer to Inspector

Manually redid Qt 4.8 commit 206ebd5af21d94c3f3b49d2cb645105a63e6f5fb,
to make future code synchronization easier.

In order not to have to change the QmlApplicationViewer again, a
compatibility class QDeclarativeViewObserver is retained that subclasses
QDeclarativeViewInspector.

Change-Id: Ief87ae2f8f76b1db0c9d65085e4832424b277603
Reviewed-on: http://codereview.qt.nokia.com/242Reviewed-by: default avatarQt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: default avatarKai Koehne <kai.koehne@nokia.com>
parent e0f79761
......@@ -31,8 +31,8 @@
**************************************************************************/
#include "abstractliveedittool.h"
#include "qdeclarativeviewobserver.h"
#include "../qdeclarativeviewobserver_p.h"
#include "qdeclarativeviewinspector.h"
#include "../qdeclarativeviewinspector_p.h"
#include <QDeclarativeEngine>
......@@ -42,8 +42,8 @@
namespace QmlJSDebugger {
AbstractLiveEditTool::AbstractLiveEditTool(QDeclarativeViewObserver *editorView)
: QObject(editorView), m_observer(editorView)
AbstractLiveEditTool::AbstractLiveEditTool(QDeclarativeViewInspector *editorView)
: QObject(editorView), m_inspector(editorView)
{
}
......@@ -52,14 +52,14 @@ AbstractLiveEditTool::~AbstractLiveEditTool()
{
}
QDeclarativeViewObserver *AbstractLiveEditTool::observer() const
QDeclarativeViewInspector *AbstractLiveEditTool::inspector() const
{
return m_observer;
return m_inspector;
}
QDeclarativeView *AbstractLiveEditTool::view() const
{
return m_observer->declarativeView();
return m_inspector->declarativeView();
}
QGraphicsScene* AbstractLiveEditTool::scene() const
......@@ -74,7 +74,7 @@ void AbstractLiveEditTool::updateSelectedItems()
QList<QGraphicsItem*> AbstractLiveEditTool::items() const
{
return observer()->selectedItems();
return inspector()->selectedItems();
}
bool AbstractLiveEditTool::topItemIsMovable(const QList<QGraphicsItem*> & itemList)
......@@ -91,7 +91,7 @@ bool AbstractLiveEditTool::topItemIsMovable(const QList<QGraphicsItem*> & itemLi
bool AbstractLiveEditTool::topSelectedItemIsMovable(const QList<QGraphicsItem*> &itemList)
{
QList<QGraphicsItem*> selectedItems = observer()->selectedItems();
QList<QGraphicsItem*> selectedItems = inspector()->selectedItems();
foreach (QGraphicsItem *item, itemList) {
QDeclarativeItem *declarativeItem = toQDeclarativeItem(item);
......@@ -167,7 +167,7 @@ QString AbstractLiveEditTool::titleForItem(QGraphicsItem *item)
QDeclarativeItem *declarativeItem = qobject_cast<QDeclarativeItem*>(gfxObject);
if (declarativeItem) {
objectStringId = QDeclarativeViewObserver::idStringForObject(declarativeItem);
objectStringId = QDeclarativeViewInspector::idStringForObject(declarativeItem);
}
if (!objectStringId.isEmpty()) {
......
......@@ -49,7 +49,7 @@ QT_END_NAMESPACE
namespace QmlJSDebugger {
class QDeclarativeViewObserver;
class QDeclarativeViewInspector;
class FormEditorView;
......@@ -57,7 +57,7 @@ class AbstractLiveEditTool : public QObject
{
Q_OBJECT
public:
AbstractLiveEditTool(QDeclarativeViewObserver *observer);
AbstractLiveEditTool(QDeclarativeViewInspector *inspector);
virtual ~AbstractLiveEditTool();
......@@ -93,12 +93,12 @@ public:
protected:
virtual void selectedItemsChanged(const QList<QGraphicsItem*> &objectList) = 0;
QDeclarativeViewObserver *observer() const;
QDeclarativeViewInspector *inspector() const;
QDeclarativeView *view() const;
QGraphicsScene *scene() const;
private:
QDeclarativeViewObserver *m_observer;
QDeclarativeViewInspector *m_inspector;
QList<QGraphicsItem*> m_itemList;
};
......
......@@ -31,8 +31,8 @@
**************************************************************************/
#include "boundingrecthighlighter.h"
#include "qdeclarativeviewobserver.h"
#include "qmlobserverconstants.h"
#include "qdeclarativeviewinspector.h"
#include "qmlinspectorconstants.h"
#include <QtGui/QGraphicsPolygonItem>
......@@ -81,7 +81,7 @@ int BoundingBoxPolygonItem::type() const
return Constants::EditorItemType;
}
BoundingRectHighlighter::BoundingRectHighlighter(QDeclarativeViewObserver *view) :
BoundingRectHighlighter::BoundingRectHighlighter(QDeclarativeViewInspector *view) :
LiveLayerItem(view->declarativeView()->scene()),
m_view(view),
m_animFrame(0)
......
......@@ -46,14 +46,14 @@ QT_FORWARD_DECLARE_CLASS(QTimer)
namespace QmlJSDebugger {
class QDeclarativeViewObserver;
class QDeclarativeViewInspector;
class BoundingBox;
class BoundingRectHighlighter : public LiveLayerItem
{
Q_OBJECT
public:
explicit BoundingRectHighlighter(QDeclarativeViewObserver *view);
explicit BoundingRectHighlighter(QDeclarativeViewInspector *view);
~BoundingRectHighlighter();
void clear();
void highlight(QList<QGraphicsObject*> items);
......@@ -74,7 +74,7 @@ private:
private:
Q_DISABLE_COPY(BoundingRectHighlighter)
QDeclarativeViewObserver *m_view;
QDeclarativeViewInspector *m_view;
QList<BoundingBox* > m_boxes;
QList<BoundingBox* > m_freeBoxes;
QTimer *m_animTimer;
......
......@@ -31,7 +31,7 @@
**************************************************************************/
#include "colorpickertool.h"
#include "qdeclarativeviewobserver.h"
#include "qdeclarativeviewinspector.h"
#include <QtGui/QMouseEvent>
#include <QtGui/QKeyEvent>
......@@ -43,7 +43,7 @@
namespace QmlJSDebugger {
ColorPickerTool::ColorPickerTool(QDeclarativeViewObserver *view) :
ColorPickerTool::ColorPickerTool(QDeclarativeViewInspector *view) :
AbstractLiveEditTool(view)
{
m_selectedColor.setRgb(0,0,0);
......
......@@ -45,7 +45,7 @@ class ColorPickerTool : public AbstractLiveEditTool
{
Q_OBJECT
public:
explicit ColorPickerTool(QDeclarativeViewObserver *view);
explicit ColorPickerTool(QDeclarativeViewInspector *view);
virtual ~ColorPickerTool();
......
......@@ -18,7 +18,7 @@
<file>images/zoom-24.png</file>
<file>images/select-24.png</file>
<file>images/select-marquee-24.png</file>
<file>images/observermode.png</file>
<file>images/observermode-24.png</file>
<file>images/inspectormode.png</file>
<file>images/inspectormode-24.png</file>
</qresource>
</RCC>
......@@ -31,7 +31,7 @@
**************************************************************************/
#include "livelayeritem.h"
#include "qmlobserverconstants.h"
#include "qmlinspectorconstants.h"
#include <QGraphicsScene>
......
......@@ -31,7 +31,7 @@
**************************************************************************/
#include "liverubberbandselectionmanipulator.h"
#include "../qdeclarativeviewobserver_p.h"
#include "../qdeclarativeviewinspector_p.h"
#include <QtGui/QGraphicsItem>
......@@ -40,7 +40,7 @@
namespace QmlJSDebugger {
LiveRubberBandSelectionManipulator::LiveRubberBandSelectionManipulator(QGraphicsObject *layerItem,
QDeclarativeViewObserver *editorView)
QDeclarativeViewInspector *editorView)
: m_selectionRectangleElement(layerItem),
m_editorView(editorView),
m_beginFormEditorItem(0),
......@@ -73,9 +73,9 @@ void LiveRubberBandSelectionManipulator::begin(const QPointF &beginPoint)
m_selectionRectangleElement.setRect(m_beginPoint, m_beginPoint);
m_selectionRectangleElement.show();
m_isActive = true;
QDeclarativeViewObserverPrivate *observerPrivate
= QDeclarativeViewObserverPrivate::get(m_editorView);
m_beginFormEditorItem = topFormEditorItem(observerPrivate->selectableItems(beginPoint));
QDeclarativeViewInspectorPrivate *inspectorPrivate
= QDeclarativeViewInspectorPrivate::get(m_editorView);
m_beginFormEditorItem = topFormEditorItem(inspectorPrivate->selectableItems(beginPoint));
m_oldSelectionList = m_editorView->selectedItems();
}
......@@ -93,10 +93,10 @@ void LiveRubberBandSelectionManipulator::end()
void LiveRubberBandSelectionManipulator::select(SelectionType selectionType)
{
QDeclarativeViewObserverPrivate *observerPrivate
= QDeclarativeViewObserverPrivate::get(m_editorView);
QDeclarativeViewInspectorPrivate *inspectorPrivate
= QDeclarativeViewInspectorPrivate::get(m_editorView);
QList<QGraphicsItem*> itemList
= observerPrivate->selectableItems(m_selectionRectangleElement.rect(),
= inspectorPrivate->selectableItems(m_selectionRectangleElement.rect(),
Qt::IntersectsItemShape);
QList<QGraphicsItem*> newSelectionList;
......
......@@ -42,7 +42,7 @@ QT_FORWARD_DECLARE_CLASS(QGraphicsItem)
namespace QmlJSDebugger {
class QDeclarativeViewObserver;
class QDeclarativeViewInspector;
class LiveRubberBandSelectionManipulator
{
......@@ -54,7 +54,7 @@ public:
};
LiveRubberBandSelectionManipulator(QGraphicsObject *layerItem,
QDeclarativeViewObserver *editorView);
QDeclarativeViewInspector *editorView);
void setItems(const QList<QGraphicsItem*> &itemList);
......@@ -78,7 +78,7 @@ private:
QList<QGraphicsItem*> m_oldSelectionList;
LiveSelectionRectangle m_selectionRectangleElement;
QPointF m_beginPoint;
QDeclarativeViewObserver *m_editorView;
QDeclarativeViewInspector *m_editorView;
QGraphicsItem *m_beginFormEditorItem;
bool m_isActive;
};
......
......@@ -31,8 +31,8 @@
**************************************************************************/
#include "liveselectionindicator.h"
#include "../qdeclarativeviewobserver_p.h"
#include "qmlobserverconstants.h"
#include "../qdeclarativeviewinspector_p.h"
#include "qmlinspectorconstants.h"
#include <QtGui/QGraphicsRectItem>
#include <QtGui/QGraphicsObject>
......@@ -41,10 +41,10 @@
namespace QmlJSDebugger {
LiveSelectionIndicator::LiveSelectionIndicator(QDeclarativeViewObserver *viewObserver,
LiveSelectionIndicator::LiveSelectionIndicator(QDeclarativeViewInspector *viewInspector,
QGraphicsObject *layerItem)
: m_layerItem(layerItem)
, m_view(viewObserver)
, m_view(viewInspector)
{
}
......
......@@ -45,12 +45,12 @@ QT_END_NAMESPACE
namespace QmlJSDebugger {
class QDeclarativeViewObserver;
class QDeclarativeViewInspector;
class LiveSelectionIndicator
{
public:
LiveSelectionIndicator(QDeclarativeViewObserver *viewObserver, QGraphicsObject *layerItem);
LiveSelectionIndicator(QDeclarativeViewInspector *viewInspector, QGraphicsObject *layerItem);
~LiveSelectionIndicator();
void show();
......@@ -63,7 +63,7 @@ public:
private:
QHash<QGraphicsItem*, QGraphicsRectItem *> m_indicatorShapeHash;
QWeakPointer<QGraphicsObject> m_layerItem;
QDeclarativeViewObserver *m_view;
QDeclarativeViewInspector *m_view;
};
}
......
......@@ -31,7 +31,7 @@
**************************************************************************/
#include "liveselectionrectangle.h"
#include "qmlobserverconstants.h"
#include "qmlinspectorconstants.h"
#include <QtGui/QPen>
#include <QtGui/QGraphicsRectItem>
......
......@@ -33,7 +33,7 @@
#include "liveselectiontool.h"
#include "livelayeritem.h"
#include "../qdeclarativeviewobserver_p.h"
#include "../qdeclarativeviewinspector_p.h"
#include <QtGui/QApplication>
#include <QtGui/QWheelEvent>
......@@ -50,14 +50,14 @@
namespace QmlJSDebugger {
LiveSelectionTool::LiveSelectionTool(QDeclarativeViewObserver *editorView) :
LiveSelectionTool::LiveSelectionTool(QDeclarativeViewInspector *editorView) :
AbstractLiveEditTool(editorView),
m_rubberbandSelectionMode(false),
m_rubberbandSelectionManipulator(
QDeclarativeViewObserverPrivate::get(editorView)->manipulatorLayer, editorView),
QDeclarativeViewInspectorPrivate::get(editorView)->manipulatorLayer, editorView),
m_singleSelectionManipulator(editorView),
m_selectionIndicator(editorView,
QDeclarativeViewObserverPrivate::get(editorView)->manipulatorLayer),
QDeclarativeViewInspectorPrivate::get(editorView)->manipulatorLayer),
//m_resizeIndicator(editorView->manipulatorLayer()),
m_selectOnlyContentItems(true)
{
......@@ -88,9 +88,9 @@ LiveSingleSelectionManipulator::SelectionType LiveSelectionTool::getSelectionTyp
bool LiveSelectionTool::alreadySelected(const QList<QGraphicsItem*> &itemList) const
{
QDeclarativeViewObserverPrivate *observerPrivate
= QDeclarativeViewObserverPrivate::get(observer());
const QList<QGraphicsItem*> selectedItems = observerPrivate->selectedItems();
QDeclarativeViewInspectorPrivate *inspectorPrivate
= QDeclarativeViewInspectorPrivate::get(inspector());
const QList<QGraphicsItem*> selectedItems = inspectorPrivate->selectedItems();
if (selectedItems.isEmpty())
return false;
......@@ -104,9 +104,9 @@ bool LiveSelectionTool::alreadySelected(const QList<QGraphicsItem*> &itemList) c
void LiveSelectionTool::mousePressEvent(QMouseEvent *event)
{
QDeclarativeViewObserverPrivate *observerPrivate
= QDeclarativeViewObserverPrivate::get(observer());
QList<QGraphicsItem*> itemList = observerPrivate->selectableItems(event->pos());
QDeclarativeViewInspectorPrivate *inspectorPrivate
= QDeclarativeViewInspectorPrivate::get(inspector());
QList<QGraphicsItem*> itemList = inspectorPrivate->selectableItems(event->pos());
LiveSingleSelectionManipulator::SelectionType selectionType = getSelectionType(event->modifiers());
if (event->buttons() & Qt::LeftButton) {
......@@ -142,7 +142,7 @@ void LiveSelectionTool::createContextMenu(QList<QGraphicsItem*> itemList, QPoint
QAction *elementAction = contextMenu.addAction(itemTitle, this,
SLOT(contextMenuElementSelected()));
if (observer()->selectedItems().contains(item)) {
if (inspector()->selectedItems().contains(item)) {
QFont boldFont = elementAction->font();
boldFont.setBold(true);
elementAction->setFont(boldFont);
......@@ -188,7 +188,7 @@ void LiveSelectionTool::contextMenuElementHovered(QAction *action)
int itemListIndex = action->data().toInt();
if (itemListIndex >= 0 && itemListIndex < m_contextMenuItemList.length()) {
QGraphicsObject *item = m_contextMenuItemList.at(itemListIndex)->toGraphicsObject();
QDeclarativeViewObserverPrivate::get(observer())->highlight(item);
QDeclarativeViewInspectorPrivate::get(inspector())->highlight(item);
}
}
......@@ -241,19 +241,19 @@ void LiveSelectionTool::hoverMoveEvent(QMouseEvent * event)
// if (topSelectedItemIsMovable(itemList))
// view()->changeTool(Constants::MoveToolMode);
// }
QDeclarativeViewObserverPrivate *observerPrivate
= QDeclarativeViewObserverPrivate::get(observer());
QDeclarativeViewInspectorPrivate *inspectorPrivate
= QDeclarativeViewInspectorPrivate::get(inspector());
QList<QGraphicsItem*> selectableItemList = observerPrivate->selectableItems(event->pos());
QList<QGraphicsItem*> selectableItemList = inspectorPrivate->selectableItems(event->pos());
if (!selectableItemList.isEmpty()) {
QGraphicsObject *item = selectableItemList.first()->toGraphicsObject();
if (item)
QDeclarativeViewObserverPrivate::get(observer())->highlight(item);
QDeclarativeViewInspectorPrivate::get(inspector())->highlight(item);
return;
}
QDeclarativeViewObserverPrivate::get(observer())->clearHighlight();
QDeclarativeViewInspectorPrivate::get(inspector())->clearHighlight();
}
void LiveSelectionTool::mouseReleaseEvent(QMouseEvent *event)
......@@ -324,16 +324,16 @@ void LiveSelectionTool::wheelEvent(QWheelEvent *event)
if (event->orientation() == Qt::Horizontal || m_rubberbandSelectionMode)
return;
QDeclarativeViewObserverPrivate *observerPrivate
= QDeclarativeViewObserverPrivate::get(observer());
QList<QGraphicsItem*> itemList = observerPrivate->selectableItems(event->pos());
QDeclarativeViewInspectorPrivate *inspectorPrivate
= QDeclarativeViewInspectorPrivate::get(inspector());
QList<QGraphicsItem*> itemList = inspectorPrivate->selectableItems(event->pos());
if (itemList.isEmpty())
return;
int selectedIdx = 0;
if (!observer()->selectedItems().isEmpty()) {
selectedIdx = itemList.indexOf(observer()->selectedItems().first());
if (!inspector()->selectedItems().isEmpty()) {
selectedIdx = itemList.indexOf(inspector()->selectedItems().first());
if (selectedIdx >= 0) {
if (event->delta() > 0) {
selectedIdx++;
......
......@@ -54,7 +54,7 @@ class LiveSelectionTool : public AbstractLiveEditTool
Q_OBJECT
public:
LiveSelectionTool(QDeclarativeViewObserver* editorView);
LiveSelectionTool(QDeclarativeViewInspector* editorView);
~LiveSelectionTool();
void mousePressEvent(QMouseEvent *event);
......
......@@ -31,13 +31,13 @@
**************************************************************************/
#include "livesingleselectionmanipulator.h"
#include "qdeclarativeviewobserver.h"
#include "../qdeclarativeviewobserver_p.h"
#include "qdeclarativeviewinspector.h"
#include "../qdeclarativeviewinspector_p.h"
#include <QtDebug>
namespace QmlJSDebugger {
LiveSingleSelectionManipulator::LiveSingleSelectionManipulator(QDeclarativeViewObserver *editorView)
LiveSingleSelectionManipulator::LiveSingleSelectionManipulator(QDeclarativeViewInspector *editorView)
: m_editorView(editorView),
m_isActive(false)
{
......@@ -48,7 +48,7 @@ void LiveSingleSelectionManipulator::begin(const QPointF &beginPoint)
{
m_beginPoint = beginPoint;
m_isActive = true;
m_oldSelectionList = QDeclarativeViewObserverPrivate::get(m_editorView)->selectedItems();
m_oldSelectionList = QDeclarativeViewInspectorPrivate::get(m_editorView)->selectedItems();
}
void LiveSingleSelectionManipulator::update(const QPointF &/*updatePoint*/)
......@@ -121,9 +121,9 @@ void LiveSingleSelectionManipulator::select(SelectionType selectionType,
void LiveSingleSelectionManipulator::select(SelectionType selectionType, bool selectOnlyContentItems)
{
QDeclarativeViewObserverPrivate *observerPrivate =
QDeclarativeViewObserverPrivate::get(m_editorView);
QList<QGraphicsItem*> itemList = observerPrivate->selectableItems(m_beginPoint);
QDeclarativeViewInspectorPrivate *inspectorPrivate =
QDeclarativeViewInspectorPrivate::get(m_editorView);
QList<QGraphicsItem*> itemList = inspectorPrivate->selectableItems(m_beginPoint);
select(selectionType, itemList, selectOnlyContentItems);
}
......
......@@ -40,12 +40,12 @@ QT_FORWARD_DECLARE_CLASS(QGraphicsItem);
namespace QmlJSDebugger {
class QDeclarativeViewObserver;
class QDeclarativeViewInspector;
class LiveSingleSelectionManipulator
{
public:
LiveSingleSelectionManipulator(QDeclarativeViewObserver *editorView);
LiveSingleSelectionManipulator(QDeclarativeViewInspector *editorView);
enum SelectionType {
ReplaceSelection,
......@@ -71,7 +71,7 @@ public:
private:
QList<QGraphicsItem*> m_oldSelectionList;
QPointF m_beginPoint;
QDeclarativeViewObserver *m_editorView;
QDeclarativeViewInspector *m_editorView;
bool m_isActive;
};
......
......@@ -52,8 +52,8 @@ QmlToolBar::QmlToolBar(QWidget *parent)
ui->playIcon = QIcon(QLatin1String(":/qml/images/play-24.png"));
ui->pauseIcon = QIcon(QLatin1String(":/qml/images/pause-24.png"));
ui->designmode = new QAction(QIcon(QLatin1String(":/qml/images/observermode-24.png")),
tr("Observer Mode"), this);
ui->designmode = new QAction(QIcon(QLatin1String(":/qml/images/inspectormode-24.png")),
tr("Inspector Mode"), this);
ui->play = new QAction(ui->pauseIcon, tr("Play/Pause Animations"), this);
ui->select = new QAction(QIcon(QLatin1String(":/qml/images/select-24.png")), tr("Select"), this);
ui->selectMarquee = new QAction(QIcon(QLatin1String(":/qml/images/select-marquee-24.png")),
......
......@@ -36,7 +36,7 @@
#include <QtGui/QToolBar>
#include <QtGui/QIcon>
#include "qmlobserverconstants.h"
#include "qmlinspectorconstants.h"
QT_FORWARD_DECLARE_CLASS(QActionGroup)
......
......@@ -31,16 +31,16 @@
**************************************************************************/
#include "subcomponentmasklayeritem.h"
#include "qmlobserverconstants.h"
#include "qdeclarativeviewobserver.h"
#include "qmlinspectorconstants.h"
#include "qdeclarativeviewinspector.h"
#include <QtGui/QPolygonF>
namespace QmlJSDebugger {
SubcomponentMaskLayerItem::SubcomponentMaskLayerItem(QDeclarativeViewObserver *observer,
SubcomponentMaskLayerItem::SubcomponentMaskLayerItem(QDeclarativeViewInspector *inspector,
QGraphicsItem *parentItem) :
QGraphicsPolygonItem(parentItem),
m_observer(observer),
m_inspector(inspector),
m_currentItem(0),
m_borderRect(new QGraphicsRectItem(this))
{
......@@ -91,8 +91,8 @@ void SubcomponentMaskLayerItem::setCurrentItem(QGraphicsItem *item)
if (!m_currentItem)
return;
QRect viewRect = m_observer->declarativeView()->rect();
viewRect = m_observer->declarativeView()->mapToScene(viewRect).boundingRect().toRect();
QRect viewRect = m_inspector->declarativeView()->rect();
viewRect = m_inspector->declarativeView()->mapToScene(viewRect).boundingRect().toRect();
QRectF itemRect = item->boundingRect() | item->childrenBoundingRect();
itemRect = item->mapRectToScene(itemRect);
......