mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-04-24 21:39:58 +02:00
Fixed behaviour when moving conductor/independent text items.
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/branches/0.3@1654 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -142,8 +142,11 @@ void ConductorTextItem::mouseMoveEvent(QGraphicsSceneMouseEvent *e) {
|
|||||||
if (textInteractionFlags() & Qt::TextEditable) {
|
if (textInteractionFlags() & Qt::TextEditable) {
|
||||||
QGraphicsTextItem::mouseMoveEvent(e);
|
QGraphicsTextItem::mouseMoveEvent(e);
|
||||||
} else if ((flags() & QGraphicsItem::ItemIsMovable) && (e -> buttons() & Qt::LeftButton)) {
|
} 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
|
// si ce texte est attache a un conducteur, alors ses mouvements seront
|
||||||
// limites a une certaine distance du trace de ce conducteur
|
// limites a une certaine distance du trace de ce conducteur
|
||||||
if (parent_conductor_) {
|
if (parent_conductor_) {
|
||||||
|
|||||||
@@ -61,5 +61,6 @@ class ConductorTextItem : public DiagramTextItem {
|
|||||||
bool moved_by_user_;
|
bool moved_by_user_;
|
||||||
QPointF before_mov_pos_;
|
QPointF before_mov_pos_;
|
||||||
bool first_move_;
|
bool first_move_;
|
||||||
|
QPointF mouse_to_origin_movement_;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -102,11 +102,14 @@ void IndependentTextItem::mouseMoveEvent(QGraphicsSceneMouseEvent *e) {
|
|||||||
|
|
||||||
// on applique le mouvement impose par la souris
|
// on applique le mouvement impose par la souris
|
||||||
QPointF old_pos = pos();
|
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()
|
// on calcule le mouvement reellement applique par setPos()
|
||||||
QPointF effective_movement = pos() - old_pos;
|
QPointF effective_movement = pos() - old_pos;
|
||||||
|
|
||||||
if (diagram_ptr) {
|
if (diagram_ptr) {
|
||||||
// on signale le mouvement ainsi applique au schema parent, qui
|
// on signale le mouvement ainsi applique au schema parent, qui
|
||||||
// l'appliquera aux autres items selectionnes selon son bon vouloir
|
// l'appliquera aux autres items selectionnes selon son bon vouloir
|
||||||
|
|||||||
@@ -52,5 +52,6 @@ class IndependentTextItem : public DiagramTextItem {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
bool first_move_;
|
bool first_move_;
|
||||||
|
QPointF mouse_to_origin_movement_;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user