From 0a4bca6acc0550cc670ecf2ae586c3be5df6b89c Mon Sep 17 00:00:00 2001 From: blacksun Date: Sat, 24 Mar 2018 14:29:43 +0000 Subject: [PATCH] Minor diagram editor : fix minor wrong behavior when naviagte with the arrow key git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@5274 bfdf4180-ca20-0410-9c96-a3a8aa849046 --- sources/diagramview.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) 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;