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
This commit is contained in:
blacksun
2018-03-24 14:29:43 +00:00
parent a58274c219
commit 0a4bca6acc

View File

@@ -625,11 +625,15 @@ void DiagramView::keyReleaseEvent(QKeyEvent *e) {
*/
void DiagramView::scrollOnMovement(QKeyEvent *e)
{
QList<QGraphicsItem *> selected_elmts = DiagramContent(m_diagram).items(DiagramContent::All);
const QList<QGraphicsItem *> selected_elmts = DiagramContent(m_diagram).items(DiagramContent::All);
QRectF viewed_scene = viewedSceneRect();
foreach (QGraphicsItem *qgi, selected_elmts){
if (qgraphicsitem_cast<Conductor *>(qgi)) continue;
if (qgraphicsitem_cast<QetShapeItem *>(qgi)) continue;
for (QGraphicsItem *qgi : selected_elmts)
{
if (qgraphicsitem_cast<Conductor *>(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;