Mercurial > hg > easyhg
diff src/changesetscene.cpp @ 402:75003687f364
Better version of ensuring the scene size is properly updated and the detail item made visible
author | Chris Cannam |
---|---|
date | Wed, 25 May 2011 16:05:40 +0100 |
parents | c3276f8998ee |
children | 306a62fe851e |
line wrap: on
line diff
--- a/src/changesetscene.cpp Wed May 25 15:38:48 2011 +0100 +++ b/src/changesetscene.cpp Wed May 25 16:05:40 2011 +0100 @@ -106,17 +106,28 @@ void ChangesetScene::itemAddCompleted() { + connect(this, SIGNAL(changed(const QList<QRectF> &)), + this, SLOT(recalculateSceneRect())); + recalculateSceneRect(); +} + +void +ChangesetScene::recalculateSceneRect() +{ + QRectF existingSr = sceneRect(); + QRectF r = itemsBoundingRect(); float minwidth = 300; //!!! - DEBUG << "ChangesetScene::itemAddCompleted: minwidth = " << minwidth + DEBUG << "ChangesetScene::recalculateSceneRect: minwidth = " << minwidth << ", r = " << r << endl; if (r.width() < minwidth) { float edgediff = (minwidth - r.width()) / 2; r.setLeft(r.left() - edgediff); r.setRight(r.right() + edgediff); } - DEBUG << "ChangesetScene::itemAddCompleted: r now is " << r << endl; - setSceneRect(r); + DEBUG << "ChangesetScene::recalculateSceneRect: r now is " << r << endl; + + setSceneRect(r.united(existingSr)); } void @@ -129,8 +140,6 @@ m_detailShown->hideDetail(); } m_detailShown = csi; - itemAddCompleted(); - csi->ensureVisible(); } void