+
+ QPolygonF sceneShape = groupShape(newPos - pos());
+ QList<QGraphicsItem*> collindingItems = scene()->items(sceneShape, Qt::IntersectsItemShape);
+ QList<QGraphicsItem *> children = childItems();
+ for (int i = 0; i < children.count(); i++) {
+ collindingItems.removeAll(children.at(i));
+ }
+ if (collindingItems.isEmpty()) return newPos;
+ else {
+ for (int i = 0; i < collindingItems.count(); i++) {
+ QGraphicsItem *collision = collindingItems.at(i);
+ if (collision->type() == AVWIDGET) {
+ // Collision
+ return pos();
+ //TODO: improve movement when collision happens
+ /*if (startTrack != newTrack) return pos();
+ if (collision->pos().x() > pos().x()) {
+ return QPointF(collision->sceneBoundingRect().x() - sceneBoundingRect().width() + pos().x() - start.x() - 1, newPos.y());
+ }*/
+ }
+ }
+ return newPos;
+ }
+