+//virtual
+QVariant Transition::itemChange(GraphicsItemChange change, const QVariant &value)
+{
+ if (change == QGraphicsItem::ItemSelectedChange) {
+ if (value.toBool()) setZValue(10);
+ else setZValue(3);
+ }
+ if (change == ItemPositionChange && scene()) {
+ // calculate new position.
+ QPointF newPos = value.toPointF();
+ int xpos = projectScene()->getSnapPointForPos((int) newPos.x(), KdenliveSettings::snaptopoints());
+ xpos = qMax(xpos, 0);
+ newPos.setX(xpos);
+ int newTrack = newPos.y() / KdenliveSettings::trackheight();
+ newTrack = qMin(newTrack, projectScene()->tracksCount() - 1);
+ newTrack = qMax(newTrack, 0);
+ newPos.setY((int)(newTrack * KdenliveSettings::trackheight() + KdenliveSettings::trackheight() / 3 * 2));
+ // Only one clip is moving
+ QRectF sceneShape = rect();
+ sceneShape.translate(newPos);
+ QList<QGraphicsItem*> items;
+ if (projectScene()->editMode() == NORMALEDIT)
+ items = scene()->items(sceneShape, Qt::IntersectsItemShape);
+ items.removeAll(this);
+
+ if (!items.isEmpty()) {
+ for (int i = 0; i < items.count(); i++) {
+ if (!items.at(i)->isEnabled()) continue;
+ if (items.at(i)->type() == type()) {
+ // Collision! Don't move.
+ //kDebug()<<"/// COLLISION WITH ITEM: "<<items.at(i)->boundingRect()<<", POS: "<<items.at(i)->pos()<<", ME: "<<newPos;
+ QPointF otherPos = items.at(i)->pos();
+ if ((int) otherPos.y() != (int) pos().y()) return pos();
+ //kDebug()<<"//// CURRENT Y: "<<pos().y()<<", COLLIDING Y: "<<otherPos.y();
+ if (pos().x() < otherPos.x()) {
+ int npos = (static_cast < AbstractClipItem* >(items.at(i))->startPos() - m_info.cropDuration).frames(m_fps);
+ newPos.setX(npos);
+ } else {
+ // get pos just after colliding clip
+ int npos = static_cast < AbstractClipItem* >(items.at(i))->endPos().frames(m_fps);
+ newPos.setX(npos);
+ }
+ m_info.track = newTrack;
+ //kDebug()<<"// ITEM NEW POS: "<<newPos.x()<<", mapped: "<<mapToScene(newPos.x(), 0).x();
+ m_info.startPos = GenTime((int) newPos.x(), m_fps);
+ return newPos;
+ }
+ }
+ }
+ m_info.track = newTrack;
+ m_info.startPos = GenTime((int) newPos.x(), m_fps);
+ //kDebug()<<"// ITEM NEW POS: "<<newPos.x()<<", mapped: "<<mapToScene(newPos.x(), 0).x();
+ return newPos;
+ }
+ return QGraphicsItem::itemChange(change, value);