mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 20:50:34 +01:00
Minor fix: conductor text don't move with element.
When move two elements connected by a conductor, the conductor text don't follow the movement when he is previously moved by the user.
This commit is contained in:
@@ -101,8 +101,10 @@ DiagramContent::DiagramContent(Diagram *diagram, bool selected) :
|
|||||||
other_terminal = conductor->terminal1;
|
other_terminal = conductor->terminal1;
|
||||||
|
|
||||||
//If the two elements of conductor are movable
|
//If the two elements of conductor are movable
|
||||||
if (m_elements.contains(other_terminal -> parentElement()) && !m_conductors_to_move.contains(conductor))
|
if (m_elements.contains(other_terminal -> parentElement())) {
|
||||||
|
if (!m_conductors_to_move.contains(conductor))
|
||||||
m_conductors_to_move << conductor;
|
m_conductors_to_move << conductor;
|
||||||
|
}
|
||||||
else if (!m_conductors_to_update.contains(conductor))
|
else if (!m_conductors_to_update.contains(conductor))
|
||||||
m_conductors_to_update << conductor;
|
m_conductors_to_update << conductor;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,14 +109,15 @@ int ElementsMover::beginMovement(Diagram *diagram, QGraphicsItem *driver_item)
|
|||||||
* Add a move to the current movement.
|
* Add a move to the current movement.
|
||||||
* @param movement movement to applied
|
* @param movement movement to applied
|
||||||
*/
|
*/
|
||||||
void ElementsMover::continueMovement(const QPointF &movement) {
|
void ElementsMover::continueMovement(const QPointF &movement)
|
||||||
|
{
|
||||||
if (!movement_running_ || movement.isNull()) return;
|
if (!movement_running_ || movement.isNull()) return;
|
||||||
|
|
||||||
current_movement_ += movement;
|
current_movement_ += movement;
|
||||||
|
|
||||||
//Move every movable item, except conductor
|
//Move every movable item, except conductor
|
||||||
typedef DiagramContent dc;
|
typedef DiagramContent dc;
|
||||||
for (QGraphicsItem *qgi : m_moved_content.items(dc::Elements | dc::TextFields | dc::Images | dc::Shapes | dc::ElementTextFields | dc::TextGroup))
|
for (QGraphicsItem *qgi : m_moved_content.items(dc::Elements | dc::TextFields | dc::Images | dc::Shapes | dc::ElementTextFields | dc::TextGroup | dc::ConductorsToMove))
|
||||||
{
|
{
|
||||||
if (qgi == m_movement_driver)
|
if (qgi == m_movement_driver)
|
||||||
continue;
|
continue;
|
||||||
@@ -124,20 +125,18 @@ void ElementsMover::continueMovement(const QPointF &movement) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Move some conductors
|
// Move some conductors
|
||||||
QList<Conductor *> c_list;
|
for (Conductor *c : m_moved_content.m_conductors_to_update)
|
||||||
c_list.append(m_moved_content.m_conductors_to_move);
|
|
||||||
c_list.append(m_moved_content.m_conductors_to_update);
|
|
||||||
|
|
||||||
for (Conductor *c : c_list)
|
|
||||||
{
|
{
|
||||||
//Due to a weird behavior, we must to ensure that the position of the conductor is to (0,0).
|
//Due to a weird behavior, we must to ensure that the position of the conductor is to (0,0).
|
||||||
//If not, in some unknown case the function QGraphicsScene::itemsBoundingRect() return a rectangle
|
//If not, in some unknown case the function QGraphicsScene::itemsBoundingRect() return a rectangle
|
||||||
//that take in acount the pos() of the conductor, even if the bounding rect returned by the conductor is not in the pos().
|
//that take in acount the pos() of the conductor, even if the bounding rect returned by the conductor is not in the pos().
|
||||||
//For the user this situation appear when the top right of the folio is not at the top right of the graphicsview,
|
//For the user this situation appear when the top right of the folio is not at the top right of the graphicsview,
|
||||||
//but displaced to the right and/or bottom.
|
//but displaced to the right and/or bottom.
|
||||||
if (c->pos() != QPointF(0,0)) {
|
|
||||||
c->setPos(0,0);
|
//@TODO fix this problem correctly, probably we must to see conductor class.
|
||||||
}
|
// if (c->pos() != QPointF(0,0)) { //<- they work, but the conductor text return to her original pos when the pos is set by user and not auto
|
||||||
|
// c->setPos(0,0); // because set the pos to 0,0 so text move to, and after call updatePath but because text pos is user defined
|
||||||
|
// } // we don't move it.
|
||||||
c->updatePath();
|
c->updatePath();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -209,7 +208,7 @@ void ElementsMover::endMovement()
|
|||||||
ConductorAutoNumerotation can (conductor, diagram_, undo_object);
|
ConductorAutoNumerotation can (conductor, diagram_, undo_object);
|
||||||
can.numerate();
|
can.numerate();
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Add undo_object if have child
|
//Add undo_object if have child
|
||||||
|
|||||||
Reference in New Issue
Block a user