Commit 933d23bc authored by Olivier Goffart's avatar Olivier Goffart

QmlJsDebugger: QDeclarativeDesignView: move private stuff to QDeclarativeDesignViewPrivate

parent 8918cff9
......@@ -28,7 +28,7 @@
**************************************************************************/
#include "rubberbandselectionmanipulator.h"
#include "qdeclarativedesignview.h"
#include "qdeclarativedesignview_p.h"
#include <QDebug>
......@@ -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(m_editorView->selectableItems(beginPoint));
m_beginFormEditorItem = topFormEditorItem(QDeclarativeDesignViewPrivate::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 = m_editorView->selectableItems(m_selectionRectangleElement.rect(),
QList<QGraphicsItem*> itemList = QDeclarativeDesignViewPrivate::get(m_editorView)->selectableItems(m_selectionRectangleElement.rect(),
Qt::IntersectsItemShape);
QList<QGraphicsItem*> newSelectionList;
......
......@@ -28,7 +28,7 @@
**************************************************************************/
#include "selectionindicator.h"
#include "qdeclarativedesignview.h"
#include "qdeclarativedesignview_p.h"
#include "qmlviewerconstants.h"
#include <QPen>
......@@ -75,7 +75,7 @@ QPolygonF SelectionIndicator::addBoundingRectToPolygon(QGraphicsItem *item, QPol
polygon = polygon.united(item->mapToScene(item->boundingRect()));
foreach(QGraphicsItem *child, item->childItems()) {
if (!m_view->isEditorItem(child))
if (!QDeclarativeDesignViewPrivate::get(m_view)->isEditorItem(child))
addBoundingRectToPolygon(child, polygon);
}
return polygon;
......
......@@ -28,9 +28,10 @@
**************************************************************************/
#include "selectiontool.h"
#include "layeritem.h"
//#include "resizehandleitem.h"
#include "qdeclarativedesignview.h"
#include "qdeclarativedesignview_p.h"
#include <private/qdeclarativeitem_p.h>
#include <private/qdeclarativecontext_p.h>
......@@ -52,9 +53,9 @@ namespace QmlViewer {
SelectionTool::SelectionTool(QDeclarativeDesignView *editorView)
: AbstractFormEditorTool(editorView),
m_rubberbandSelectionMode(false),
m_rubberbandSelectionManipulator(editorView->manipulatorLayer(), editorView),
m_rubberbandSelectionManipulator(QDeclarativeDesignViewPrivate::get(editorView)->manipulatorLayer, editorView),
m_singleSelectionManipulator(editorView),
m_selectionIndicator(editorView, editorView->manipulatorLayer()),
m_selectionIndicator(editorView, QDeclarativeDesignViewPrivate::get(editorView)->manipulatorLayer),
//m_resizeIndicator(editorView->manipulatorLayer()),
m_selectOnlyContentItems(true)
{
......@@ -83,7 +84,7 @@ SingleSelectionManipulator::SelectionType SelectionTool::getSelectionType(Qt::Ke
bool SelectionTool::alreadySelected(const QList<QGraphicsItem*> &itemList) const
{
const QList<QGraphicsItem*> selectedItems = view()->selectedItems();
const QList<QGraphicsItem*> selectedItems = QDeclarativeDesignViewPrivate::get(view())->selectedItems();
if (selectedItems.isEmpty())
return false;
......@@ -99,7 +100,7 @@ bool SelectionTool::alreadySelected(const QList<QGraphicsItem*> &itemList) const
void SelectionTool::mousePressEvent(QMouseEvent *event)
{
QList<QGraphicsItem*> itemList = view()->selectableItems(event->pos());
QList<QGraphicsItem*> itemList = QDeclarativeDesignViewPrivate::get(view())->selectableItems(event->pos());
SingleSelectionManipulator::SelectionType selectionType = getSelectionType(event->modifiers());
if (event->buttons() & Qt::LeftButton) {
......@@ -110,7 +111,7 @@ void SelectionTool::mousePressEvent(QMouseEvent *event)
} else {
if (itemList.isEmpty()) {
view()->setSelectedItems(itemList);
QDeclarativeDesignViewPrivate::get(view())->setSelectedItems(itemList);
return;
}
......@@ -160,7 +161,7 @@ void SelectionTool::mousePressEvent(QMouseEvent *event)
void SelectionTool::createContextMenu(QList<QGraphicsItem*> itemList, QPoint globalPos)
{
if (!view()->mouseInsideContextItem())
if (!QDeclarativeDesignViewPrivate::get(view())->mouseInsideContextItem())
return;
QMenu contextMenu;
......@@ -222,7 +223,7 @@ void SelectionTool::contextMenuElementHovered(QAction *action)
{
int itemListIndex = action->data().toInt();
if (itemListIndex >= 0 && itemListIndex < m_contextMenuItemList.length()) {
view()->highlight(m_contextMenuItemList.at(itemListIndex));
QDeclarativeDesignViewPrivate::get(view())->highlight(m_contextMenuItemList.at(itemListIndex));
}
}
......@@ -277,7 +278,7 @@ void SelectionTool::hoverMoveEvent(QMouseEvent * event)
QGraphicsItem *topSelectableItem = 0;
foreach(QGraphicsItem* item, selectableItemList)
{
if (!view()->isEditorItem(item)
if (!QDeclarativeDesignViewPrivate::get(view())->isEditorItem(item)
/*&& !item->qmlItemNode().isRootNode()
&& (QGraphicsItem->qmlItemNode().hasShowContent() || !m_selectOnlyContentItems)*/)
{
......@@ -286,9 +287,9 @@ void SelectionTool::hoverMoveEvent(QMouseEvent * event)
}
}
view()->highlight(topSelectableItem);
QDeclarativeDesignViewPrivate::get(view())->highlight(topSelectableItem);
} else {
view()->clearHighlight();
QDeclarativeDesignViewPrivate::get(view())->clearHighlight();
}
}
......@@ -356,7 +357,7 @@ void SelectionTool::wheelEvent(QWheelEvent *event)
if (event->orientation() == Qt::Horizontal || m_rubberbandSelectionMode)
return;
QList<QGraphicsItem*> itemList = view()->selectableItems(event->pos());
QList<QGraphicsItem*> itemList = QDeclarativeDesignViewPrivate::get(view())->selectableItems(event->pos());
int selectedIdx = 0;
if (!view()->selectedItems().isEmpty()) {
......
......@@ -29,6 +29,7 @@
#include "singleselectionmanipulator.h"
#include "qdeclarativedesignview.h"
#include "qdeclarativedesignview_p.h"
#include <QtDebug>
namespace QmlViewer {
......@@ -44,7 +45,7 @@ void SingleSelectionManipulator::begin(const QPointF &beginPoint)
{
m_beginPoint = beginPoint;
m_isActive = true;
m_oldSelectionList = m_editorView->selectedItems();
m_oldSelectionList = QDeclarativeDesignViewPrivate::get(m_editorView)->selectedItems();
}
void SingleSelectionManipulator::update(const QPointF &/*updatePoint*/)
......@@ -115,7 +116,7 @@ void SingleSelectionManipulator::select(SelectionType selectionType, const QList
void SingleSelectionManipulator::select(SelectionType selectionType, bool selectOnlyContentItems)
{
QList<QGraphicsItem*> itemList = m_editorView->selectableItems(m_beginPoint);
QList<QGraphicsItem*> itemList = QDeclarativeDesignViewPrivate::get(m_editorView)->selectableItems(m_beginPoint);
select(selectionType, itemList, selectOnlyContentItems);
}
......
#include "subcomponenteditortool.h"
#include "qdeclarativedesignview.h"
#include "qdeclarativedesignview_p.h"
#include "subcomponentmasklayeritem.h"
#include "layeritem.h"
......@@ -21,7 +21,7 @@ SubcomponentEditorTool::SubcomponentEditorTool(QDeclarativeDesignView *view)
m_animIncrement(0.05f),
m_animTimer(new QTimer(this))
{
m_mask = new SubcomponentMaskLayerItem(view, view->manipulatorLayer());
m_mask = new SubcomponentMaskLayerItem(view, QDeclarativeDesignViewPrivate::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) {
view()->clearHighlight();
QDeclarativeDesignViewPrivate::get(view())->clearHighlight();
}
}
......@@ -172,7 +172,7 @@ void SubcomponentEditorTool::setCurrentItem(QGraphicsItem* contextItem)
m_animIncrement = 0.05f;
m_animTimer->start();
view()->clearHighlight();
QDeclarativeDesignViewPrivate::get(view())->clearHighlight();
view()->setSelectedItems(QList<QGraphicsItem*>());
pushContext(gfxObject);
......
#include "zoomtool.h"
#include "qdeclarativedesignview.h"
#include "qdeclarativedesignview_p.h"
#include <QMouseEvent>
#include <QWheelEvent>
......@@ -14,7 +14,7 @@ namespace QmlViewer {
ZoomTool::ZoomTool(QDeclarativeDesignView *view) :
AbstractFormEditorTool(view),
m_rubberbandManipulator(view->manipulatorLayer(), view),
m_rubberbandManipulator(reinterpret_cast<QGraphicsObject *>(QDeclarativeDesignViewPrivate::get(view)->manipulatorLayer), view),
m_smoothZoomMultiplier(0.05f),
m_currentScale(1.0f)
{
......
......@@ -48,10 +48,6 @@ class QMLJSDEBUGGER_EXPORT QDeclarativeDesignView : public QDeclarativeView
{
Q_OBJECT
public:
enum ContextFlags {
IgnoreContext,
ContextSensitive
};
explicit QDeclarativeDesignView(QWidget *parent = 0);
~QDeclarativeDesignView();
......@@ -59,33 +55,13 @@ public:
void setSelectedItems(QList<QGraphicsItem *> items);
QList<QGraphicsItem *> selectedItems();
QGraphicsObject *manipulatorLayer() const;
void changeTool(Constants::DesignTool tool,
Constants::ToolFlags flags = Constants::NoToolFlags);
void clearHighlight();
void highlight(QList<QGraphicsItem *> item, ContextFlags flags = ContextSensitive);
void highlight(QGraphicsItem *item, ContextFlags flags = ContextSensitive);
bool mouseInsideContextItem() const;
bool isEditorItem(QGraphicsItem *item) const;
QList<QGraphicsItem*> selectableItems(const QPoint &pos) const;
QList<QGraphicsItem*> selectableItems(const QPointF &scenePos) const;
QList<QGraphicsItem*> selectableItems(const QRectF &sceneRect, Qt::ItemSelectionMode selectionMode) const;
QGraphicsItem *currentRootItem() const;
QToolBar *toolbar() const;
static QString idStringForObject(QObject *obj);
QRectF adjustToScreenBoundaries(const QRectF &boundingRectInSceneSpace);
public Q_SLOTS:
void setDesignModeBehavior(bool value);
bool designModeBehavior() const;
void changeToSingleSelectTool();
void changeToMarqueeSelectTool();
void changeToZoomTool();
void changeToColorPickerTool();
bool designModeBehavior();
void changeAnimationSpeed(qreal slowdownFactor);
void continueExecution(qreal slowdownFactor = 1.0f);
......@@ -119,25 +95,21 @@ protected:
void mouseDoubleClickEvent(QMouseEvent *event);
void wheelEvent(QWheelEvent *event);
private Q_SLOTS:
void reloadView();
void onStatusChanged(QDeclarativeView::Status status);
void onCurrentObjectsChanged(QList<QObject*> objects);
void applyChangesFromClient();
void createQmlObject(const QString &qml, QObject *parent,
const QStringList &imports, const QString &filename = QString());
private:
void clearEditorItems();
void createToolbar();
void changeToSelectTool();
QList<QGraphicsItem*> filterForCurrentContext(QList<QGraphicsItem*> &itemlist) const;
QList<QGraphicsItem*> filterForSelection(QList<QGraphicsItem*> &itemlist) const;
QDeclarativeDesignViewPrivate *data;
private:
Q_DISABLE_COPY(QDeclarativeDesignView)
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*>))
Q_PRIVATE_SLOT(d_func(), void _q_applyChangesFromClient())
Q_PRIVATE_SLOT(d_func(), void _q_createQmlObject(const QString &, QObject *, const QStringList &, const QString &))
Q_PRIVATE_SLOT(d_func(), void _q_changeToSingleSelectTool())
Q_PRIVATE_SLOT(d_func(), void _q_changeToMarqueeSelectTool())
Q_PRIVATE_SLOT(d_func(), void _q_changeToZoomTool())
Q_PRIVATE_SLOT(d_func(), void _q_changeToColorPickerTool())
inline QDeclarativeDesignViewPrivate *d_func() { return data.data(); }
QScopedPointer<QDeclarativeDesignViewPrivate> data;
friend class QDeclarativeDesignViewPrivate;
};
......
......@@ -33,6 +33,8 @@
#include <QWeakPointer>
#include <QPointF>
#include "qdeclarativedesignview.h"
namespace QmlViewer {
class QDeclarativeDesignView;
......@@ -50,9 +52,16 @@ class QDeclarativeDesignViewPrivate
{
public:
QDeclarativeDesignViewPrivate();
enum ContextFlags {
IgnoreContext,
ContextSensitive
};
QDeclarativeDesignViewPrivate(QDeclarativeDesignView *);
~QDeclarativeDesignViewPrivate();
QDeclarativeDesignView *q;
QPointF cursorPos;
QList<QWeakPointer<QGraphicsObject> > currentSelection;
......@@ -74,6 +83,45 @@ public:
QmlToolbar *toolbar;
void clearEditorItems();
void createToolbar();
void changeToSelectTool();
QList<QGraphicsItem*> filterForCurrentContext(QList<QGraphicsItem*> &itemlist) const;
QList<QGraphicsItem*> filterForSelection(QList<QGraphicsItem*> &itemlist) const;
QList<QGraphicsItem*> selectableItems(const QPoint &pos) const;
QList<QGraphicsItem*> selectableItems(const QPointF &scenePos) const;
QList<QGraphicsItem*> selectableItems(const QRectF &sceneRect, Qt::ItemSelectionMode selectionMode) const;
void setSelectedItems(QList<QGraphicsItem *> items);
QList<QGraphicsItem *> selectedItems();
void changeTool(Constants::DesignTool tool,
Constants::ToolFlags flags = Constants::NoToolFlags);
void clearHighlight();
void highlight(QList<QGraphicsItem *> item, ContextFlags flags = ContextSensitive);
void highlight(QGraphicsItem *item, ContextFlags flags = ContextSensitive);
bool mouseInsideContextItem() const;
bool isEditorItem(QGraphicsItem *item) const;
QGraphicsItem *currentRootItem() const;
void _q_reloadView();
void _q_onStatusChanged(QDeclarativeView::Status status);
void _q_onCurrentObjectsChanged(QList<QObject*> objects);
void _q_applyChangesFromClient();
void _q_createQmlObject(const QString &qml, QObject *parent,
const QStringList &imports, const QString &filename = QString());
void _q_changeToSingleSelectTool();
void _q_changeToMarqueeSelectTool();
void _q_changeToZoomTool();
void _q_changeToColorPickerTool();
static QDeclarativeDesignViewPrivate *get(QDeclarativeDesignView *v) { return v->d_func(); }
};
} // namespace QmlViewer
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment