} while (changed);
for (BasicBlockWidget * widget : widgets) {
- for (QGraphicsItem * item : widget->collidingItems()) {
- while (widget->collidesWithItem(item)) {
- if (widget->scenePos().x() > item->scenePos().x())
+ QRectF relevantRect = widget->boundingRect();
+ relevantRect.moveTo(widget->scenePos());
+ relevantRect.adjust(-20, -20, 20, 20);
+ for (QGraphicsItem * item : items(relevantRect)) {
+ if (item == widget) continue;
+ QRectF itemrect = item->boundingRect();
+ itemrect.moveTo(item->scenePos());
+ while (relevantRect.intersects(itemrect)) {
+ if (widget->scenePos().x() > item->scenePos().x()) {
widget->moveBy(1, 0);
- else
+ relevantRect.moveTo(widget->scenePos());
+ } else {
item->moveBy(1, 0);
+ itemrect.moveTo(item->scenePos());
+ }
}
}
}