mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 12:40:35 +01:00
fix the bug when drag a image item
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@2450 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -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 @@ void DiagramImageItem::mouseMoveEvent(QGraphicsSceneMouseEvent *e) {
|
||||
|
||||
//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
|
||||
|
||||
@@ -81,5 +81,6 @@ class DiagramImageItem : public QObject, public QGraphicsPixmapItem {
|
||||
|
||||
private:
|
||||
bool first_move_;
|
||||
QPointF mouse_to_origin_movement_;
|
||||
};
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user