comparison 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
comparison
equal deleted inserted replaced
401:c3276f8998ee 402:75003687f364
104 } 104 }
105 105
106 void 106 void
107 ChangesetScene::itemAddCompleted() 107 ChangesetScene::itemAddCompleted()
108 { 108 {
109 connect(this, SIGNAL(changed(const QList<QRectF> &)),
110 this, SLOT(recalculateSceneRect()));
111 recalculateSceneRect();
112 }
113
114 void
115 ChangesetScene::recalculateSceneRect()
116 {
117 QRectF existingSr = sceneRect();
118
109 QRectF r = itemsBoundingRect(); 119 QRectF r = itemsBoundingRect();
110 float minwidth = 300; //!!! 120 float minwidth = 300; //!!!
111 DEBUG << "ChangesetScene::itemAddCompleted: minwidth = " << minwidth 121 DEBUG << "ChangesetScene::recalculateSceneRect: minwidth = " << minwidth
112 << ", r = " << r << endl; 122 << ", r = " << r << endl;
113 if (r.width() < minwidth) { 123 if (r.width() < minwidth) {
114 float edgediff = (minwidth - r.width()) / 2; 124 float edgediff = (minwidth - r.width()) / 2;
115 r.setLeft(r.left() - edgediff); 125 r.setLeft(r.left() - edgediff);
116 r.setRight(r.right() + edgediff); 126 r.setRight(r.right() + edgediff);
117 } 127 }
118 DEBUG << "ChangesetScene::itemAddCompleted: r now is " << r << endl; 128 DEBUG << "ChangesetScene::recalculateSceneRect: r now is " << r << endl;
119 setSceneRect(r); 129
130 setSceneRect(r.united(existingSr));
120 } 131 }
121 132
122 void 133 void
123 ChangesetScene::changesetDetailShown() 134 ChangesetScene::changesetDetailShown()
124 { 135 {
127 138
128 if (m_detailShown && m_detailShown != csi) { 139 if (m_detailShown && m_detailShown != csi) {
129 m_detailShown->hideDetail(); 140 m_detailShown->hideDetail();
130 } 141 }
131 m_detailShown = csi; 142 m_detailShown = csi;
132 itemAddCompleted();
133 csi->ensureVisible();
134 } 143 }
135 144
136 void 145 void
137 ChangesetScene::changesetDetailHidden() 146 ChangesetScene::changesetDetailHidden()
138 { 147 {