New Qt4 "Graphics View" Workspace Fix: Fix to aborting a selected Object Icon Move by hitting the ESC key. Checked in to RiverWare 5.1 development on 2-25-2009 The first implementation ran into a Qt 4.3.3 bug related to cancelling the QGraphicsItem Mouse Grab. The problem is described on this QtCentre webpage: http://www.qtcentre.org/forum/showthread.php?t=19050&referrerid=6743 The new implementation overrides the effect of a mouse drag-move after the ESC key is clicked, until the mouse button is released (i.e. without cancelling the grab). It replaces the position value of icon position- change events with the pre-drag-move position. ----------------- SimObjGfxItem.cpp SimObjGfxItem.hpp ----------------- New overridden virtual methods from QGraphicsItem: virtual void keyPressEvent (QKeyEvent*); virtual QVariant itemChange (QGraphicsItem::GraphicsItemChange, const QVariant&); SimObj GraphicsItem Icon Move processing via QGraphicsItem virtual method implementations: Mouse Press Event: Record All Pre-Move Icon Positions. Mouse Release Event: If (Abort Drag-Move Mode) OR (Any Icon Out of Bounds) Restore Selected Obj Pre-Move Icon Positions, and save to model. CANCEL Abort Drag-Move Mode. Mouse Move Event: Save Selected-Item Positions to Model. Key Press Event: If (ESC Key) AND (QGraphicsItem Mouse Grab Active) START Abort Drag-Move Mode, and Restore Selected Obj Pre-Move Icon Positions, and save to model. ItemChange [ItemPositionChange] Event Filter: If (Abort Drag-Move Mode) Replace Mouse Move Postion with the Saved Pre-Move Position ------------------- RwGraphicsScene.cpp RwGraphicsScene.hpp ------------------- Abort Drag-Move Mode support: private: bool _abortDragMoveMode; public: void abortDragMoveMode_START() { _abortDragMoveMode = true; } void abortDragMoveMode_STOP() { _abortDragMoveMode = false; } bool abortDragMoveMode_ON() const { return (_abortDragMoveMode); } --------------------- WorkspaceGfxScene.cpp WorkspaceGfxScene.hpp --------------------- When needing to save the Pre-Move positions of SimObj GraphicsItems, do so for ALL SimObj GraphicsItems items on the workspace -- not just the selected ones. This isn't necessary, but it is safer. OLD: void recordSelSimObjItemPreMovePositions(); NEW: void recordSimObjItemPreMovePositions(); ---