QmlDesigner.FormEditor: Fix cursor handling

Change-Id: I533642ebf5d3937f96b248d7f999eb4928e035e9
Reviewed-on: http://codereview.qt.nokia.com/911
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Thomas Hartmann <Thomas.Hartmann@nokia.com>
This commit is contained in:
Marco Bubke
2011-06-29 16:14:46 +02:00
committed by Thomas Hartmann
parent f7f85b797e
commit 4ae6c1da95
11 changed files with 29 additions and 23 deletions

View File

@@ -239,4 +239,8 @@ void AbstractFormEditorTool::showContextMenu(QGraphicsSceneMouseEvent *event)
view()->showContextMenu(event->screenPos(), event->scenePos().toPoint(), true); view()->showContextMenu(event->screenPos(), event->scenePos().toPoint(), true);
} }
void AbstractFormEditorTool::clear()
{
m_itemList.clear();
}
} }

View File

@@ -77,7 +77,7 @@ public:
// QGraphicsItem::GraphicsItemChange change, // QGraphicsItem::GraphicsItemChange change,
// const QVariant &value ) = 0; // const QVariant &value ) = 0;
// virtual void update() = 0; // virtual void update() = 0;
virtual void clear() = 0; virtual void clear();
virtual void formEditorItemsChanged(const QList<FormEditorItem*> &itemList) = 0; virtual void formEditorItemsChanged(const QList<FormEditorItem*> &itemList) = 0;
@@ -94,10 +94,9 @@ public:
static FormEditorItem* topFormEditorItem(const QList<QGraphicsItem*> &itemList); static FormEditorItem* topFormEditorItem(const QList<QGraphicsItem*> &itemList);
static FormEditorItem* topFormEditorItemWithRootItem(const QList<QGraphicsItem*> &itemList); static FormEditorItem* topFormEditorItemWithRootItem(const QList<QGraphicsItem*> &itemList);
protected: protected:
virtual void selectedItemsChanged(const QList<FormEditorItem*> &itemList) = 0; virtual void selectedItemsChanged(const QList<FormEditorItem*> &itemList) = 0;
virtual void showContextMenu(QGraphicsSceneMouseEvent *event); virtual void showContextMenu(QGraphicsSceneMouseEvent *event);
FormEditorView *view() const; FormEditorView *view() const;

View File

@@ -66,7 +66,6 @@ DragTool::DragTool(FormEditorView *editorView)
m_blockMove(false), m_blockMove(false),
m_Aborted(false) m_Aborted(false)
{ {
// view()->setCursor(Qt::SizeAllCursor);
} }

View File

@@ -296,7 +296,6 @@ bool FormEditorView::changeToMoveTool()
scene()->setPaintMode(FormEditorScene::NormalMode); scene()->setPaintMode(FormEditorScene::NormalMode);
m_scene->updateAllFormEditorItems(); m_scene->updateAllFormEditorItems();
setCursor(Qt::SizeAllCursor);
m_currentTool->clear(); m_currentTool->clear();
m_currentTool = m_moveTool; m_currentTool = m_moveTool;
m_currentTool->clear(); m_currentTool->clear();
@@ -311,7 +310,6 @@ void FormEditorView::changeToDragTool()
scene()->setPaintMode(FormEditorScene::NormalMode); scene()->setPaintMode(FormEditorScene::NormalMode);
m_scene->updateAllFormEditorItems(); m_scene->updateAllFormEditorItems();
setCursor(Qt::ArrowCursor);
m_currentTool->clear(); m_currentTool->clear();
m_currentTool = m_dragTool; m_currentTool = m_dragTool;
m_currentTool->clear(); m_currentTool->clear();
@@ -329,7 +327,6 @@ bool FormEditorView::changeToMoveTool(const QPointF &beginPoint)
scene()->setPaintMode(FormEditorScene::NormalMode); scene()->setPaintMode(FormEditorScene::NormalMode);
m_scene->updateAllFormEditorItems(); m_scene->updateAllFormEditorItems();
setCursor(Qt::SizeAllCursor);
m_currentTool->clear(); m_currentTool->clear();
m_currentTool = m_moveTool; m_currentTool = m_moveTool;
m_currentTool->clear(); m_currentTool->clear();
@@ -345,7 +342,6 @@ void FormEditorView::changeToSelectionTool()
scene()->setPaintMode(FormEditorScene::NormalMode); scene()->setPaintMode(FormEditorScene::NormalMode);
m_scene->updateAllFormEditorItems(); m_scene->updateAllFormEditorItems();
setCursor(Qt::ArrowCursor);
m_currentTool->clear(); m_currentTool->clear();
m_currentTool = m_selectionTool; m_currentTool = m_selectionTool;
m_currentTool->clear(); m_currentTool->clear();
@@ -359,7 +355,6 @@ void FormEditorView::changeToItemCreatorTool()
scene()->setPaintMode(FormEditorScene::NormalMode); scene()->setPaintMode(FormEditorScene::NormalMode);
m_scene->updateAllFormEditorItems(); m_scene->updateAllFormEditorItems();
setCursor(Qt::CrossCursor);
m_currentTool->clear(); m_currentTool->clear();
m_currentTool = m_itemCreatorTool; m_currentTool = m_itemCreatorTool;
m_currentTool->clear(); m_currentTool->clear();
@@ -374,7 +369,6 @@ void FormEditorView::changeToSelectionTool(QGraphicsSceneMouseEvent *event)
scene()->setPaintMode(FormEditorScene::NormalMode); scene()->setPaintMode(FormEditorScene::NormalMode);
m_scene->updateAllFormEditorItems(); m_scene->updateAllFormEditorItems();
setCursor(Qt::ArrowCursor);
m_currentTool->clear(); m_currentTool->clear();
m_currentTool = m_selectionTool; m_currentTool = m_selectionTool;
m_currentTool->clear(); m_currentTool->clear();
@@ -390,7 +384,6 @@ void FormEditorView::changeToResizeTool()
scene()->setPaintMode(FormEditorScene::NormalMode); scene()->setPaintMode(FormEditorScene::NormalMode);
m_scene->updateAllFormEditorItems(); m_scene->updateAllFormEditorItems();
setCursor(Qt::ArrowCursor);
m_currentTool->clear(); m_currentTool->clear();
m_currentTool = m_resizeTool; m_currentTool = m_resizeTool;
m_currentTool->clear(); m_currentTool->clear();
@@ -404,7 +397,6 @@ void FormEditorView::changeToAnchorTool()
scene()->setPaintMode(FormEditorScene::AnchorMode); scene()->setPaintMode(FormEditorScene::AnchorMode);
m_scene->updateAllFormEditorItems(); m_scene->updateAllFormEditorItems();
setCursor(Qt::ArrowCursor);
m_currentTool->clear(); m_currentTool->clear();
m_currentTool = m_anchorTool; m_currentTool = m_anchorTool;
m_currentTool->clear(); m_currentTool->clear();
@@ -421,11 +413,6 @@ void FormEditorView::changeToTransformTools()
changeToSelectionTool(); changeToSelectionTool();
} }
void FormEditorView::setCursor(const QCursor &cursor)
{
m_formEditorWidget->setCursor(cursor);
}
void FormEditorView::nodeSlidedToIndex(const NodeListProperty &listProperty, int /*newIndex*/, int /*oldIndex*/) void FormEditorView::nodeSlidedToIndex(const NodeListProperty &listProperty, int /*newIndex*/, int /*oldIndex*/)
{ {
QList<ModelNode> newOrderModelNodeList = listProperty.toModelNodeList(); QList<ModelNode> newOrderModelNodeList = listProperty.toModelNodeList();

View File

@@ -100,8 +100,6 @@ public:
void changeToAnchorTool(); void changeToAnchorTool();
void changeToTransformTools(); void changeToTransformTools();
void setCursor(const QCursor &cursor);
void nodeSlidedToIndex(const NodeListProperty &listProperty, int newIndex, int oldIndex); void nodeSlidedToIndex(const NodeListProperty &listProperty, int newIndex, int oldIndex);
void auxiliaryDataChanged(const ModelNode &node, const QString &name, const QVariant &data); void auxiliaryDataChanged(const ModelNode &node, const QString &name, const QVariant &data);

View File

@@ -70,7 +70,6 @@ void ItemCreatorTool::mousePressEvent(const QList<QGraphicsItem*> &/*itemList*/,
void ItemCreatorTool::mouseMoveEvent(const QList<QGraphicsItem*> &/*itemList*/, void ItemCreatorTool::mouseMoveEvent(const QList<QGraphicsItem*> &/*itemList*/,
QGraphicsSceneMouseEvent *event) QGraphicsSceneMouseEvent *event)
{ {
view()->setCursor(Qt::CrossCursor);
if (m_rubberbandSelectionManipulator.isActive()) { if (m_rubberbandSelectionManipulator.isActive()) {
m_rubberbandSelectionManipulator.update(event->scenePos()); m_rubberbandSelectionManipulator.update(event->scenePos());
} else { } else {

View File

@@ -54,7 +54,7 @@ MoveTool::MoveTool(FormEditorView *editorView)
m_selectionIndicator(editorView->scene()->manipulatorLayerItem()), m_selectionIndicator(editorView->scene()->manipulatorLayerItem()),
m_resizeIndicator(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_movingItems.clear();
m_selectionIndicator.clear(); m_selectionIndicator.clear();
m_resizeIndicator.clear(); m_resizeIndicator.clear();
AbstractFormEditorTool::clear();
} }
void MoveTool::mousePressEvent(const QList<QGraphicsItem*> &itemList, void MoveTool::mousePressEvent(const QList<QGraphicsItem*> &itemList,

View File

@@ -102,6 +102,7 @@ void SelectionIndicator::setItems(const QList<FormEditorItem*> &itemList)
QPen pen; QPen pen;
pen.setColor(QColor(108, 141, 221)); pen.setColor(QColor(108, 141, 221));
newSelectionIndicatorGraphicsItem->setPen(pen); 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);
}
} }

View File

@@ -37,7 +37,7 @@
#include <QGraphicsPolygonItem> #include <QGraphicsPolygonItem>
#include "layeritem.h" #include "layeritem.h"
#include "formeditoritem.h" #include "formeditoritem.h"
#include <QCursor>
namespace QmlDesigner { namespace QmlDesigner {
@@ -57,9 +57,12 @@ public:
void setItems(const QList<FormEditorItem*> &itemList); void setItems(const QList<FormEditorItem*> &itemList);
void updateItems(const QList<FormEditorItem*> &itemList); void updateItems(const QList<FormEditorItem*> &itemList);
void setCursor(const QCursor &cursor);
private: private:
QHash<FormEditorItem*, QGraphicsPolygonItem *> m_indicatorShapeHash; QHash<FormEditorItem*, QGraphicsPolygonItem *> m_indicatorShapeHash;
QWeakPointer<LayerItem> m_layerItem; QWeakPointer<LayerItem> m_layerItem;
QCursor m_cursor;
}; };

View File

@@ -56,7 +56,7 @@ SelectionTool::SelectionTool(FormEditorView *editorView)
m_resizeIndicator(editorView->scene()->manipulatorLayerItem()), m_resizeIndicator(editorView->scene()->manipulatorLayerItem()),
m_selectOnlyContentItems(false) 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); AbstractFormEditorTool::mousePressEvent(itemList, event);
} }
@@ -254,6 +255,8 @@ void SelectionTool::clear()
m_singleSelectionManipulator.clear(); m_singleSelectionManipulator.clear();
m_selectionIndicator.clear(); m_selectionIndicator.clear();
m_resizeIndicator.clear(); m_resizeIndicator.clear();
AbstractFormEditorTool::clear();
} }
void SelectionTool::selectedItemsChanged(const QList<FormEditorItem*> &itemList) void SelectionTool::selectedItemsChanged(const QList<FormEditorItem*> &itemList)

View File

@@ -85,6 +85,8 @@ public:
void setSelectOnlyContentItems(bool selectOnlyContentItems); void setSelectOnlyContentItems(bool selectOnlyContentItems);
void setCursor(const QCursor &cursor);
private: private:
RubberBandSelectionManipulator m_rubberbandSelectionManipulator; RubberBandSelectionManipulator m_rubberbandSelectionManipulator;
SingleSelectionManipulator m_singleSelectionManipulator; SingleSelectionManipulator m_singleSelectionManipulator;
@@ -92,6 +94,7 @@ private:
ResizeIndicator m_resizeIndicator; ResizeIndicator m_resizeIndicator;
QTime m_mousePressTimer; QTime m_mousePressTimer;
bool m_selectOnlyContentItems; bool m_selectOnlyContentItems;
QCursor m_cursor;
}; };
} }