Commit 4ae6c1da authored by Marco Bubke's avatar Marco Bubke Committed by Thomas Hartmann

QmlDesigner.FormEditor: Fix cursor handling

Change-Id: I533642ebf5d3937f96b248d7f999eb4928e035e9
Reviewed-on: http://codereview.qt.nokia.com/911Reviewed-by: default avatarQt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: default avatarThomas Hartmann <Thomas.Hartmann@nokia.com>
parent f7f85b79
......@@ -239,4 +239,8 @@ void AbstractFormEditorTool::showContextMenu(QGraphicsSceneMouseEvent *event)
view()->showContextMenu(event->screenPos(), event->scenePos().toPoint(), true);
}
void AbstractFormEditorTool::clear()
{
m_itemList.clear();
}
}
......@@ -77,7 +77,7 @@ public:
// QGraphicsItem::GraphicsItemChange change,
// const QVariant &value ) = 0;
// virtual void update() = 0;
virtual void clear() = 0;
virtual void clear();
virtual void formEditorItemsChanged(const QList<FormEditorItem*> &itemList) = 0;
......@@ -94,10 +94,9 @@ public:
static FormEditorItem* topFormEditorItem(const QList<QGraphicsItem*> &itemList);
static FormEditorItem* topFormEditorItemWithRootItem(const QList<QGraphicsItem*> &itemList);
protected:
protected:
virtual void selectedItemsChanged(const QList<FormEditorItem*> &itemList) = 0;
virtual void showContextMenu(QGraphicsSceneMouseEvent *event);
FormEditorView *view() const;
......
......@@ -66,7 +66,6 @@ DragTool::DragTool(FormEditorView *editorView)
m_blockMove(false),
m_Aborted(false)
{
// view()->setCursor(Qt::SizeAllCursor);
}
......
......@@ -296,7 +296,6 @@ bool FormEditorView::changeToMoveTool()
scene()->setPaintMode(FormEditorScene::NormalMode);
m_scene->updateAllFormEditorItems();
setCursor(Qt::SizeAllCursor);
m_currentTool->clear();
m_currentTool = m_moveTool;
m_currentTool->clear();
......@@ -311,7 +310,6 @@ void FormEditorView::changeToDragTool()
scene()->setPaintMode(FormEditorScene::NormalMode);
m_scene->updateAllFormEditorItems();
setCursor(Qt::ArrowCursor);
m_currentTool->clear();
m_currentTool = m_dragTool;
m_currentTool->clear();
......@@ -329,7 +327,6 @@ bool FormEditorView::changeToMoveTool(const QPointF &beginPoint)
scene()->setPaintMode(FormEditorScene::NormalMode);
m_scene->updateAllFormEditorItems();
setCursor(Qt::SizeAllCursor);
m_currentTool->clear();
m_currentTool = m_moveTool;
m_currentTool->clear();
......@@ -345,7 +342,6 @@ void FormEditorView::changeToSelectionTool()
scene()->setPaintMode(FormEditorScene::NormalMode);
m_scene->updateAllFormEditorItems();
setCursor(Qt::ArrowCursor);
m_currentTool->clear();
m_currentTool = m_selectionTool;
m_currentTool->clear();
......@@ -359,7 +355,6 @@ void FormEditorView::changeToItemCreatorTool()
scene()->setPaintMode(FormEditorScene::NormalMode);
m_scene->updateAllFormEditorItems();
setCursor(Qt::CrossCursor);
m_currentTool->clear();
m_currentTool = m_itemCreatorTool;
m_currentTool->clear();
......@@ -374,7 +369,6 @@ void FormEditorView::changeToSelectionTool(QGraphicsSceneMouseEvent *event)
scene()->setPaintMode(FormEditorScene::NormalMode);
m_scene->updateAllFormEditorItems();
setCursor(Qt::ArrowCursor);
m_currentTool->clear();
m_currentTool = m_selectionTool;
m_currentTool->clear();
......@@ -390,7 +384,6 @@ void FormEditorView::changeToResizeTool()
scene()->setPaintMode(FormEditorScene::NormalMode);
m_scene->updateAllFormEditorItems();
setCursor(Qt::ArrowCursor);
m_currentTool->clear();
m_currentTool = m_resizeTool;
m_currentTool->clear();
......@@ -404,7 +397,6 @@ void FormEditorView::changeToAnchorTool()
scene()->setPaintMode(FormEditorScene::AnchorMode);
m_scene->updateAllFormEditorItems();
setCursor(Qt::ArrowCursor);
m_currentTool->clear();
m_currentTool = m_anchorTool;
m_currentTool->clear();
......@@ -421,11 +413,6 @@ void FormEditorView::changeToTransformTools()
changeToSelectionTool();
}
void FormEditorView::setCursor(const QCursor &cursor)
{
m_formEditorWidget->setCursor(cursor);
}
void FormEditorView::nodeSlidedToIndex(const NodeListProperty &listProperty, int /*newIndex*/, int /*oldIndex*/)
{
QList<ModelNode> newOrderModelNodeList = listProperty.toModelNodeList();
......
......@@ -100,8 +100,6 @@ public:
void changeToAnchorTool();
void changeToTransformTools();
void setCursor(const QCursor &cursor);
void nodeSlidedToIndex(const NodeListProperty &listProperty, int newIndex, int oldIndex);
void auxiliaryDataChanged(const ModelNode &node, const QString &name, const QVariant &data);
......
......@@ -70,7 +70,6 @@ void ItemCreatorTool::mousePressEvent(const QList<QGraphicsItem*> &/*itemList*/,
void ItemCreatorTool::mouseMoveEvent(const QList<QGraphicsItem*> &/*itemList*/,
QGraphicsSceneMouseEvent *event)
{
view()->setCursor(Qt::CrossCursor);
if (m_rubberbandSelectionManipulator.isActive()) {
m_rubberbandSelectionManipulator.update(event->scenePos());
} else {
......
......@@ -54,7 +54,7 @@ MoveTool::MoveTool(FormEditorView *editorView)
m_selectionIndicator(editorView->scene()->manipulatorLayerItem()),
m_resizeIndicator(editorView->scene()->manipulatorLayerItem())
{
// view()->setCursor(Qt::SizeAllCursor);
m_selectionIndicator.setCursor(Qt::SizeAllCursor);
}
......@@ -69,6 +69,8 @@ void MoveTool::clear()
m_movingItems.clear();
m_selectionIndicator.clear();
m_resizeIndicator.clear();
AbstractFormEditorTool::clear();
}
void MoveTool::mousePressEvent(const QList<QGraphicsItem*> &itemList,
......
......@@ -102,6 +102,7 @@ void SelectionIndicator::setItems(const QList<FormEditorItem*> &itemList)
QPen pen;
pen.setColor(QColor(108, 141, 221));
newSelectionIndicatorGraphicsItem->setPen(pen);
newSelectionIndicatorGraphicsItem->setCursor(m_cursor);
}
}
......@@ -120,5 +121,13 @@ void SelectionIndicator::updateItems(const QList<FormEditorItem*> &itemList)
}
}
void SelectionIndicator::setCursor(const QCursor &cursor)
{
m_cursor = cursor;
foreach (QGraphicsItem *item, m_indicatorShapeHash.values())
item->setCursor(cursor);
}
}
......@@ -37,7 +37,7 @@
#include <QGraphicsPolygonItem>
#include "layeritem.h"
#include "formeditoritem.h"
#include <QCursor>
namespace QmlDesigner {
......@@ -57,9 +57,12 @@ public:
void setItems(const QList<FormEditorItem*> &itemList);
void updateItems(const QList<FormEditorItem*> &itemList);
void setCursor(const QCursor &cursor);
private:
QHash<FormEditorItem*, QGraphicsPolygonItem *> m_indicatorShapeHash;
QWeakPointer<LayerItem> m_layerItem;
QCursor m_cursor;
};
......
......@@ -56,7 +56,7 @@ SelectionTool::SelectionTool(FormEditorView *editorView)
m_resizeIndicator(editorView->scene()->manipulatorLayerItem()),
m_selectOnlyContentItems(false)
{
// view()->setCursor(Qt::CrossCursor);
m_selectionIndicator.setCursor(Qt::ArrowCursor);
}
......@@ -99,6 +99,7 @@ void SelectionTool::mousePressEvent(const QList<QGraphicsItem*> &itemList,
}
}
}
AbstractFormEditorTool::mousePressEvent(itemList, event);
}
......@@ -254,6 +255,8 @@ void SelectionTool::clear()
m_singleSelectionManipulator.clear();
m_selectionIndicator.clear();
m_resizeIndicator.clear();
AbstractFormEditorTool::clear();
}
void SelectionTool::selectedItemsChanged(const QList<FormEditorItem*> &itemList)
......
......@@ -85,6 +85,8 @@ public:
void setSelectOnlyContentItems(bool selectOnlyContentItems);
void setCursor(const QCursor &cursor);
private:
RubberBandSelectionManipulator m_rubberbandSelectionManipulator;
SingleSelectionManipulator m_singleSelectionManipulator;
......@@ -92,6 +94,7 @@ private:
ResizeIndicator m_resizeIndicator;
QTime m_mousePressTimer;
bool m_selectOnlyContentItems;
QCursor m_cursor;
};
}
......
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