[qet] [2450] fix the bug when drag a image item |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/qet Archives
]
Revision: 2450
Author: blacksun
Date: 2013-08-24 17:32:07 +0200 (Sat, 24 Aug 2013)
Log Message:
-----------
fix the bug when drag a image item
Modified Paths:
--------------
trunk/sources/diagramimageitem.cpp
trunk/sources/diagramimageitem.h
Modified: trunk/sources/diagramimageitem.cpp
===================================================================
--- trunk/sources/diagramimageitem.cpp 2013-08-24 15:18:45 UTC (rev 2449)
+++ trunk/sources/diagramimageitem.cpp 2013-08-24 15:32:07 UTC (rev 2450)
@@ -21,7 +21,8 @@
#include "qetapp.h"
DiagramImageItem::DiagramImageItem(Diagram *parent_diagram) :
- QGraphicsPixmapItem(0, parent_diagram)
+ QGraphicsPixmapItem(0, parent_diagram),
+ first_move_(false)
{
setFlags(QGraphicsItem::ItemIsSelectable|QGraphicsItem::ItemIsMovable);
#if QT_VERSION >= 0x040600
@@ -246,10 +247,14 @@
//we apply the mouse movement
QPointF old_pos = pos();
- setPos(mapToParent(e -> pos()) - matrix().map(e -> buttonDownPos(Qt::LeftButton)));
+ if (first_move_) {
+ mouse_to_origin_movement_ = old_pos - e -> buttonDownScenePos(Qt::LeftButton);
+ }
+ QPointF expected_pos = e-> scenePos() + mouse_to_origin_movement_;
+ setPos(expected_pos); // setPos() will snap the expected position to the grid
+
//we calcul the real movement apply by setPos()
QPointF effective_movement = pos() - old_pos;
-
if (diagram()) {
//we signal the real movement apply to diagram,
//who he apply to other selected item
Modified: trunk/sources/diagramimageitem.h
===================================================================
--- trunk/sources/diagramimageitem.h 2013-08-24 15:18:45 UTC (rev 2449)
+++ trunk/sources/diagramimageitem.h 2013-08-24 15:32:07 UTC (rev 2450)
@@ -81,5 +81,6 @@
private:
bool first_move_;
+ QPointF mouse_to_origin_movement_;
};
#endif