[qet] [1654] Fixed behaviour when moving conductor/independent text items. |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/qet Archives
]
Revision: 1654
Author: xavier
Date: 2012-04-15 16:14:34 +0200 (Sun, 15 Apr 2012)
Log Message:
-----------
Fixed behaviour when moving conductor/independent text items.
Modified Paths:
--------------
branches/0.3/sources/conductortextitem.cpp
branches/0.3/sources/conductortextitem.h
branches/0.3/sources/independenttextitem.cpp
branches/0.3/sources/independenttextitem.h
Modified: branches/0.3/sources/conductortextitem.cpp
===================================================================
--- branches/0.3/sources/conductortextitem.cpp 2012-04-10 17:22:49 UTC (rev 1653)
+++ branches/0.3/sources/conductortextitem.cpp 2012-04-15 14:14:34 UTC (rev 1654)
@@ -142,8 +142,11 @@
if (textInteractionFlags() & Qt::TextEditable) {
QGraphicsTextItem::mouseMoveEvent(e);
} else if ((flags() & QGraphicsItem::ItemIsMovable) && (e -> buttons() & Qt::LeftButton)) {
- QPointF intended_pos = mapToParent(e -> pos()) - matrix().map(e -> buttonDownPos(Qt::LeftButton));
+ if (first_move_) {
+ mouse_to_origin_movement_ = before_mov_pos_ - mapToParent(e -> buttonDownPos(Qt::LeftButton));
+ }
+ QPointF intended_pos = mapToParent(e -> pos()) + mouse_to_origin_movement_;
// si ce texte est attache a un conducteur, alors ses mouvements seront
// limites a une certaine distance du trace de ce conducteur
if (parent_conductor_) {
Modified: branches/0.3/sources/conductortextitem.h
===================================================================
--- branches/0.3/sources/conductortextitem.h 2012-04-10 17:22:49 UTC (rev 1653)
+++ branches/0.3/sources/conductortextitem.h 2012-04-15 14:14:34 UTC (rev 1654)
@@ -61,5 +61,6 @@
bool moved_by_user_;
QPointF before_mov_pos_;
bool first_move_;
+ QPointF mouse_to_origin_movement_;
};
#endif
Modified: branches/0.3/sources/independenttextitem.cpp
===================================================================
--- branches/0.3/sources/independenttextitem.cpp 2012-04-10 17:22:49 UTC (rev 1653)
+++ branches/0.3/sources/independenttextitem.cpp 2012-04-15 14:14:34 UTC (rev 1654)
@@ -102,11 +102,14 @@
// on applique le mouvement impose par la souris
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
// on calcule le mouvement reellement applique par setPos()
QPointF effective_movement = pos() - old_pos;
-
if (diagram_ptr) {
// on signale le mouvement ainsi applique au schema parent, qui
// l'appliquera aux autres items selectionnes selon son bon vouloir
Modified: branches/0.3/sources/independenttextitem.h
===================================================================
--- branches/0.3/sources/independenttextitem.h 2012-04-10 17:22:49 UTC (rev 1653)
+++ branches/0.3/sources/independenttextitem.h 2012-04-15 14:14:34 UTC (rev 1654)
@@ -52,5 +52,6 @@
private:
bool first_move_;
+ QPointF mouse_to_origin_movement_;
};
#endif