diff --git a/sources/diagramview.cpp b/sources/diagramview.cpp index c1f254fd1..e6e8def71 100644 --- a/sources/diagramview.cpp +++ b/sources/diagramview.cpp @@ -625,11 +625,15 @@ void DiagramView::keyReleaseEvent(QKeyEvent *e) { */ void DiagramView::scrollOnMovement(QKeyEvent *e) { - QList selected_elmts = DiagramContent(m_diagram).items(DiagramContent::All); + const QList selected_elmts = DiagramContent(m_diagram).items(DiagramContent::All); QRectF viewed_scene = viewedSceneRect(); - foreach (QGraphicsItem *qgi, selected_elmts){ - if (qgraphicsitem_cast(qgi)) continue; - if (qgraphicsitem_cast(qgi)) continue; + for (QGraphicsItem *qgi : selected_elmts) + { + if (qgraphicsitem_cast(qgi)) + continue; + if(qgi->parentItem() && qgi->parentItem()->isSelected()) + continue; + qreal x = qgi->pos().x(); qreal y = qgi->pos().y(); qreal bottom = viewed_scene.bottom(); @@ -640,12 +644,15 @@ void DiagramView::scrollOnMovement(QKeyEvent *e) qreal elmt_bottom = y + qgi->boundingRect().bottom(); qreal elmt_right = x + qgi->boundingRect().right(); qreal elmt_left = x + qgi->boundingRect().left(); + bool elmt_right_of_left_margin = elmt_left>=left; bool elmt_left_of_right_margin = elmt_right<=right; - bool elmt_below_top_margin = elmt_top>=top; - bool elmt_above_bottom_margin = elmt_bottom<=bottom; + bool elmt_below_top_margin = elmt_top>=top; + bool elmt_above_bottom_margin = elmt_bottom<=bottom; + if (!(elmt_right_of_left_margin && elmt_left_of_right_margin) || - !(elmt_below_top_margin && elmt_above_bottom_margin ) ) { + !(elmt_below_top_margin && elmt_above_bottom_margin ) ) + { QScrollBar *h = horizontalScrollBar(); QScrollBar *v = verticalScrollBar(); int h_increment=0;