Commit f9e65028 authored by Thorbjørn Lindeijer's avatar Thorbjørn Lindeijer

QmlJSDebugger: Prefix live editor related classes

AbstractFormEditorTool -> AbstractLiveEditTool
LayerItem -> LiveLayerItem
SelectionIndicator -> LiveSelectionIndicator
SelectionRectangle -> LiveSelectionRectangle
SelectionTool -> LiveSelectionTool
SingleSelectionManipulator -> LiveSingleSelectionManipulator
RubberBandSelectionManipulator -> LiveRubberBandSelectionManipulator
parent 350eaa50
......@@ -31,7 +31,7 @@
**
**************************************************************************/
#include "abstractformeditortool.h"
#include "abstractliveedittool.h"
#include "qdeclarativeviewobserver.h"
#include "../qdeclarativeviewobserver_p.h"
......@@ -43,48 +43,48 @@
namespace QmlJSDebugger {
AbstractFormEditorTool::AbstractFormEditorTool(QDeclarativeViewObserver *editorView)
AbstractLiveEditTool::AbstractLiveEditTool(QDeclarativeViewObserver *editorView)
: QObject(editorView), m_observer(editorView)
{
}
AbstractFormEditorTool::~AbstractFormEditorTool()
AbstractLiveEditTool::~AbstractLiveEditTool()
{
}
QDeclarativeViewObserver *AbstractFormEditorTool::observer() const
QDeclarativeViewObserver *AbstractLiveEditTool::observer() const
{
return m_observer;
}
QDeclarativeView *AbstractFormEditorTool::view() const
QDeclarativeView *AbstractLiveEditTool::view() const
{
return m_observer->declarativeView();
}
QGraphicsScene* AbstractFormEditorTool::scene() const
QGraphicsScene* AbstractLiveEditTool::scene() const
{
return view()->scene();
}
void AbstractFormEditorTool::updateSelectedItems()
void AbstractLiveEditTool::updateSelectedItems()
{
selectedItemsChanged(items());
}
QList<QGraphicsItem*> AbstractFormEditorTool::items() const
QList<QGraphicsItem*> AbstractLiveEditTool::items() const
{
return observer()->selectedItems();
}
void AbstractFormEditorTool::enterContext(QGraphicsItem *itemToEnter)
void AbstractLiveEditTool::enterContext(QGraphicsItem *itemToEnter)
{
observer()->data->enterContext(itemToEnter);
}
bool AbstractFormEditorTool::topItemIsMovable(const QList<QGraphicsItem*> & itemList)
bool AbstractLiveEditTool::topItemIsMovable(const QList<QGraphicsItem*> & itemList)
{
QGraphicsItem *firstSelectableItem = topMovableGraphicsItem(itemList);
if (firstSelectableItem == 0)
......@@ -100,7 +100,7 @@ bool AbstractFormEditorTool::topItemIsMovable(const QList<QGraphicsItem*> & item
}
bool AbstractFormEditorTool::topSelectedItemIsMovable(const QList<QGraphicsItem*> &itemList)
bool AbstractLiveEditTool::topSelectedItemIsMovable(const QList<QGraphicsItem*> &itemList)
{
QList<QGraphicsItem*> selectedItems = observer()->selectedItems();
......@@ -116,17 +116,17 @@ bool AbstractFormEditorTool::topSelectedItemIsMovable(const QList<QGraphicsItem*
}
bool AbstractFormEditorTool::topItemIsResizeHandle(const QList<QGraphicsItem*> &/*itemList*/)
bool AbstractLiveEditTool::topItemIsResizeHandle(const QList<QGraphicsItem*> &/*itemList*/)
{
return false;
}
QDeclarativeItem *AbstractFormEditorTool::toQDeclarativeItem(QGraphicsItem *item)
QDeclarativeItem *AbstractLiveEditTool::toQDeclarativeItem(QGraphicsItem *item)
{
return dynamic_cast<QDeclarativeItem*>(item->toGraphicsObject());
}
QGraphicsItem *AbstractFormEditorTool::topMovableGraphicsItem(const QList<QGraphicsItem*> &itemList)
QGraphicsItem *AbstractLiveEditTool::topMovableGraphicsItem(const QList<QGraphicsItem*> &itemList)
{
foreach (QGraphicsItem *item, itemList) {
if (item->flags().testFlag(QGraphicsItem::ItemIsMovable))
......@@ -135,8 +135,8 @@ QGraphicsItem *AbstractFormEditorTool::topMovableGraphicsItem(const QList<QGraph
return 0;
}
QDeclarativeItem *AbstractFormEditorTool::topMovableDeclarativeItem(const QList<QGraphicsItem*>
&itemList)
QDeclarativeItem *AbstractLiveEditTool::topMovableDeclarativeItem(const QList<QGraphicsItem*>
&itemList)
{
foreach (QGraphicsItem *item, itemList) {
QDeclarativeItem *declarativeItem = toQDeclarativeItem(item);
......@@ -147,8 +147,8 @@ QDeclarativeItem *AbstractFormEditorTool::topMovableDeclarativeItem(const QList<
return 0;
}
QList<QGraphicsObject*> AbstractFormEditorTool::toGraphicsObjectList(const QList<QGraphicsItem*>
&itemList)
QList<QGraphicsObject*> AbstractLiveEditTool::toGraphicsObjectList(const QList<QGraphicsItem*>
&itemList)
{
QList<QGraphicsObject*> gfxObjects;
foreach(QGraphicsItem *item, itemList) {
......@@ -160,7 +160,7 @@ QList<QGraphicsObject*> AbstractFormEditorTool::toGraphicsObjectList(const QList
return gfxObjects;
}
QString AbstractFormEditorTool::titleForItem(QGraphicsItem *item)
QString AbstractLiveEditTool::titleForItem(QGraphicsItem *item)
{
QString className("QGraphicsItem");
QString objectStringId;
......
......@@ -31,8 +31,8 @@
**
**************************************************************************/
#ifndef ABSTRACTFORMEDITORTOOL_H
#define ABSTRACTFORMEDITORTOOL_H
#ifndef ABSTRACTLIVEEDITTOOL_H
#define ABSTRACTLIVEEDITTOOL_H
#include <QtCore/QList>
#include <QtCore/QObject>
......@@ -54,13 +54,13 @@ class QDeclarativeViewObserver;
class FormEditorView;
class AbstractFormEditorTool : public QObject
class AbstractLiveEditTool : public QObject
{
Q_OBJECT
public:
AbstractFormEditorTool(QDeclarativeViewObserver* observer);
AbstractLiveEditTool(QDeclarativeViewObserver *observer);
virtual ~AbstractFormEditorTool();
virtual ~AbstractLiveEditTool();
virtual void mousePressEvent(QMouseEvent *event) = 0;
virtual void mouseMoveEvent(QMouseEvent *event) = 0;
......@@ -105,4 +105,4 @@ private:
}
#endif // ABSTRACTFORMEDITORTOOL_H
#endif // ABSTRACTLIVEEDITTOOL_H
......@@ -83,7 +83,7 @@ int BoundingBoxPolygonItem::type() const
}
BoundingRectHighlighter::BoundingRectHighlighter(QDeclarativeViewObserver *view) :
LayerItem(view->declarativeView()->scene()),
LiveLayerItem(view->declarativeView()->scene()),
m_view(view),
m_animFrame(0)
{
......
......@@ -50,7 +50,7 @@ namespace QmlJSDebugger {
class QDeclarativeViewObserver;
class BoundingBox;
class BoundingRectHighlighter : public LayerItem
class BoundingRectHighlighter : public LiveLayerItem
{
Q_OBJECT
public:
......
......@@ -45,7 +45,7 @@
namespace QmlJSDebugger {
ColorPickerTool::ColorPickerTool(QDeclarativeViewObserver *view) :
AbstractFormEditorTool(view)
AbstractLiveEditTool(view)
{
m_selectedColor.setRgb(0,0,0);
}
......
......@@ -34,7 +34,7 @@
#ifndef COLORPICKERTOOL_H
#define COLORPICKERTOOL_H
#include "abstractformeditortool.h"
#include "abstractliveedittool.h"
#include <QtGui/QColor>
......@@ -42,7 +42,7 @@ QT_FORWARD_DECLARE_CLASS(QPoint)
namespace QmlJSDebugger {
class ColorPickerTool : public AbstractFormEditorTool
class ColorPickerTool : public AbstractLiveEditTool
{
Q_OBJECT
public:
......@@ -78,7 +78,6 @@ private:
private:
QColor m_selectedColor;
};
} // namespace QmlJSDebugger
......
#ifndef ToolBarColorBox_H
#define ToolBarColorBox_H
#include <QLabel>
#include <QColor>
#include <QPoint>
QT_FORWARD_DECLARE_CLASS(QContextMenuEvent);
QT_FORWARD_DECLARE_CLASS(QAction);
namespace QmlJSDebugger {
class ToolBarColorBox : public QLabel
{
Q_OBJECT
public:
explicit ToolBarColorBox(QWidget *parent = 0);
void setColor(const QColor &color);
protected:
void contextMenuEvent(QContextMenuEvent *ev);
void mouseDoubleClickEvent(QMouseEvent *);
void mousePressEvent(QMouseEvent *ev);
void mouseMoveEvent(QMouseEvent *ev);
private slots:
void copyColorToClipboard();
private:
QPixmap createDragPixmap(int size = 24) const;
private:
bool m_dragStarted;
QPoint m_dragBeginPoint;
QAction *m_copyHexColor;
QColor m_color;
};
} // namespace QmlJSDebugger
#endif // ToolBarColorBox_H
......@@ -31,14 +31,14 @@
**
**************************************************************************/
#include "layeritem.h"
#include "livelayeritem.h"
#include "qmlobserverconstants.h"
#include <QGraphicsScene>
namespace QmlJSDebugger {
LayerItem::LayerItem(QGraphicsScene* scene)
LiveLayerItem::LiveLayerItem(QGraphicsScene* scene)
: QGraphicsObject()
{
scene->addItem(this);
......@@ -46,31 +46,31 @@ LayerItem::LayerItem(QGraphicsScene* scene)
setFlag(QGraphicsItem::ItemIsMovable, false);
}
LayerItem::~LayerItem()
LiveLayerItem::~LiveLayerItem()
{
}
void LayerItem::paint(QPainter * /*painter*/, const QStyleOptionGraphicsItem * /*option*/,
QWidget * /*widget*/)
void LiveLayerItem::paint(QPainter * /*painter*/, const QStyleOptionGraphicsItem * /*option*/,
QWidget * /*widget*/)
{
}
int LayerItem::type() const
int LiveLayerItem::type() const
{
return Constants::EditorItemType;
}
QRectF LayerItem::boundingRect() const
QRectF LiveLayerItem::boundingRect() const
{
return childrenBoundingRect();
}
QList<QGraphicsItem*> LayerItem::findAllChildItems() const
QList<QGraphicsItem*> LiveLayerItem::findAllChildItems() const
{
return findAllChildItems(this);
}
QList<QGraphicsItem*> LayerItem::findAllChildItems(const QGraphicsItem *item) const
QList<QGraphicsItem*> LiveLayerItem::findAllChildItems(const QGraphicsItem *item) const
{
QList<QGraphicsItem*> itemList(item->childItems());
......
......@@ -31,20 +31,18 @@
**
**************************************************************************/
#ifndef LAYERITEM_H
#define LAYERITEM_H
#ifndef LIVELAYERITEM_H
#define LIVELAYERITEM_H
#include <QtGui/QGraphicsObject>
namespace QmlJSDebugger {
class FormEditorScene;
class LayerItem : public QGraphicsObject
class LiveLayerItem : public QGraphicsObject
{
public:
LayerItem(QGraphicsScene *scene);
~LayerItem();
LiveLayerItem(QGraphicsScene *scene);
~LiveLayerItem();
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = 0);
QRectF boundingRect() const;
......@@ -58,4 +56,4 @@ protected:
}
#endif // LAYERITEM_H
#endif // LIVELAYERITEM_H
......@@ -31,7 +31,7 @@
**
**************************************************************************/
#include "rubberbandselectionmanipulator.h"
#include "liverubberbandselectionmanipulator.h"
#include "../qdeclarativeviewobserver_p.h"
#include <QtGui/QGraphicsItem>
......@@ -40,8 +40,8 @@
namespace QmlJSDebugger {
RubberBandSelectionManipulator::RubberBandSelectionManipulator(QGraphicsObject *layerItem,
QDeclarativeViewObserver *editorView)
LiveRubberBandSelectionManipulator::LiveRubberBandSelectionManipulator(QGraphicsObject *layerItem,
QDeclarativeViewObserver *editorView)
: m_selectionRectangleElement(layerItem),
m_editorView(editorView),
m_beginFormEditorItem(0),
......@@ -50,7 +50,7 @@ RubberBandSelectionManipulator::RubberBandSelectionManipulator(QGraphicsObject *
m_selectionRectangleElement.hide();
}
void RubberBandSelectionManipulator::clear()
void LiveRubberBandSelectionManipulator::clear()
{
m_selectionRectangleElement.clear();
m_isActive = false;
......@@ -59,8 +59,8 @@ void RubberBandSelectionManipulator::clear()
m_oldSelectionList.clear();
}
QGraphicsItem *RubberBandSelectionManipulator::topFormEditorItem(const QList<QGraphicsItem*>
&itemList)
QGraphicsItem *LiveRubberBandSelectionManipulator::topFormEditorItem(const QList<QGraphicsItem*>
&itemList)
{
if (itemList.isEmpty())
return 0;
......@@ -68,7 +68,7 @@ QGraphicsItem *RubberBandSelectionManipulator::topFormEditorItem(const QList<QGr
return itemList.first();
}
void RubberBandSelectionManipulator::begin(const QPointF& beginPoint)
void LiveRubberBandSelectionManipulator::begin(const QPointF &beginPoint)
{
m_beginPoint = beginPoint;
m_selectionRectangleElement.setRect(m_beginPoint, m_beginPoint);
......@@ -80,19 +80,19 @@ void RubberBandSelectionManipulator::begin(const QPointF& beginPoint)
m_oldSelectionList = m_editorView->selectedItems();
}
void RubberBandSelectionManipulator::update(const QPointF& updatePoint)
void LiveRubberBandSelectionManipulator::update(const QPointF &updatePoint)
{
m_selectionRectangleElement.setRect(m_beginPoint, updatePoint);
}
void RubberBandSelectionManipulator::end()
void LiveRubberBandSelectionManipulator::end()
{
m_oldSelectionList.clear();
m_selectionRectangleElement.hide();
m_isActive = false;
}
void RubberBandSelectionManipulator::select(SelectionType selectionType)
void LiveRubberBandSelectionManipulator::select(SelectionType selectionType)
{
QDeclarativeViewObserverPrivate *observerPrivate
= QDeclarativeViewObserverPrivate::get(m_editorView);
......@@ -138,17 +138,17 @@ void RubberBandSelectionManipulator::select(SelectionType selectionType)
}
void RubberBandSelectionManipulator::setItems(const QList<QGraphicsItem*> &itemList)
void LiveRubberBandSelectionManipulator::setItems(const QList<QGraphicsItem*> &itemList)
{
m_itemList = itemList;
}
QPointF RubberBandSelectionManipulator::beginPoint() const
QPointF LiveRubberBandSelectionManipulator::beginPoint() const
{
return m_beginPoint;
}
bool RubberBandSelectionManipulator::isActive() const
bool LiveRubberBandSelectionManipulator::isActive() const
{
return m_isActive;
}
......
......@@ -45,7 +45,7 @@ namespace QmlJSDebugger {
class QDeclarativeViewObserver;
class RubberBandSelectionManipulator
class LiveRubberBandSelectionManipulator
{
public:
enum SelectionType {
......@@ -54,8 +54,8 @@ public:
RemoveFromSelection
};
RubberBandSelectionManipulator(QGraphicsObject *layerItem,
QDeclarativeViewObserver *editorView);
LiveRubberBandSelectionManipulator(QGraphicsObject *layerItem,
QDeclarativeViewObserver *editorView);
void setItems(const QList<QGraphicsItem*> &itemList);
......@@ -77,7 +77,7 @@ protected:
private:
QList<QGraphicsItem*> m_itemList;
QList<QGraphicsItem*> m_oldSelectionList;
SelectionRectangle m_selectionRectangleElement;
LiveSelectionRectangle m_selectionRectangleElement;
QPointF m_beginPoint;
QDeclarativeViewObserver *m_editorView;
QGraphicsItem *m_beginFormEditorItem;
......
......@@ -31,7 +31,7 @@
**
**************************************************************************/
#include "selectionindicator.h"
#include "liveselectionindicator.h"
#include "../qdeclarativeviewobserver_p.h"
#include "qmlobserverconstants.h"
......@@ -46,30 +46,30 @@
namespace QmlJSDebugger {
SelectionIndicator::SelectionIndicator(QDeclarativeViewObserver *editorView,
LiveSelectionIndicator::LiveSelectionIndicator(QDeclarativeViewObserver *editorView,
QGraphicsObject *layerItem)
: m_layerItem(layerItem), m_view(editorView)
{
}
SelectionIndicator::~SelectionIndicator()
LiveSelectionIndicator::~LiveSelectionIndicator()
{
clear();
}
void SelectionIndicator::show()
void LiveSelectionIndicator::show()
{
foreach (QGraphicsPolygonItem *item, m_indicatorShapeHash.values())
item->show();
}
void SelectionIndicator::hide()
void LiveSelectionIndicator::hide()
{
foreach (QGraphicsPolygonItem *item, m_indicatorShapeHash.values())
item->hide();
}
void SelectionIndicator::clear()
void LiveSelectionIndicator::clear()
{
if (!m_layerItem.isNull()) {
QHashIterator<QGraphicsItem*, QGraphicsPolygonItem *> iter(m_indicatorShapeHash);
......@@ -84,7 +84,7 @@ void SelectionIndicator::clear()
}
QPolygonF SelectionIndicator::addBoundingRectToPolygon(QGraphicsItem *item, QPolygonF &polygon)
QPolygonF LiveSelectionIndicator::addBoundingRectToPolygon(QGraphicsItem *item, QPolygonF &polygon)
{
// ### remove this if statement when QTBUG-12172 gets fixed
if (item->boundingRect() != QRectF(0,0,0,0)) {
......@@ -100,7 +100,7 @@ QPolygonF SelectionIndicator::addBoundingRectToPolygon(QGraphicsItem *item, QPol
return polygon;
}
void SelectionIndicator::setItems(const QList<QWeakPointer<QGraphicsObject> > &itemList)
void LiveSelectionIndicator::setItems(const QList<QWeakPointer<QGraphicsObject> > &itemList)
{
clear();
......
......@@ -31,8 +31,8 @@
**
**************************************************************************/
#ifndef SELECTIONINDICATOR_H
#define SELECTIONINDICATOR_H
#ifndef LIVESELECTIONINDICATOR_H
#define LIVESELECTIONINDICATOR_H
#include <QtCore/QWeakPointer>
#include <QtCore/QHash>
......@@ -48,11 +48,11 @@ namespace QmlJSDebugger {
class QDeclarativeViewObserver;
class SelectionIndicator
class LiveSelectionIndicator
{
public:
SelectionIndicator(QDeclarativeViewObserver* editorView, QGraphicsObject *layerItem);
~SelectionIndicator();
LiveSelectionIndicator(QDeclarativeViewObserver* editorView, QGraphicsObject *layerItem);
~LiveSelectionIndicator();
void show();
void hide();
......@@ -73,4 +73,4 @@ private:
}
#endif // SELECTIONINDICATOR_H
#endif // LIVESELECTIONINDICATOR_H
......@@ -31,7 +31,7 @@
**
**************************************************************************/
#include "selectionrectangle.h"
#include "liveselectionrectangle.h"
#include "qmlobserverconstants.h"
#include <QtGui/QPen>
......@@ -52,7 +52,7 @@ public:
int type() const { return Constants::EditorItemType; }
};
SelectionRectangle::SelectionRectangle(QGraphicsObject *layerItem)
LiveSelectionRectangle::LiveSelectionRectangle(QGraphicsObject *layerItem)
: m_controlShape(new SelectionRectShape(layerItem)),
m_layerItem(layerItem)
{
......@@ -60,32 +60,32 @@ SelectionRectangle::SelectionRectangle(QGraphicsObject *layerItem)
m_controlShape->setBrush(QColor(128, 128, 128, 50));
}
SelectionRectangle::~SelectionRectangle()
LiveSelectionRectangle::~LiveSelectionRectangle()
{
if (m_layerItem)
m_layerItem.data()->scene()->removeItem(m_controlShape);
}
void SelectionRectangle::clear()
void LiveSelectionRectangle::clear()
{
hide();
}
void SelectionRectangle::show()
void LiveSelectionRectangle::show()
{
m_controlShape->show();
}
void SelectionRectangle::hide()
void LiveSelectionRectangle::hide()
{
m_controlShape->hide();
}
QRectF SelectionRectangle::rect() const
QRectF LiveSelectionRectangle::rect() const
{
return m_controlShape->mapFromScene(m_controlShape->rect()).boundingRect();
}
void SelectionRectangle::setRect(const QPointF &firstPoint,
void LiveSelectionRectangle::setRect(const QPointF &firstPoint,
const QPointF &secondPoint)
{
double firstX = std::floor(firstPoint.x()) + 0.5;
......
......@@ -31,8 +31,8 @@
**
**************************************************************************/