+//virtual
+QVariant Transition::itemChange(GraphicsItemChange change, const QVariant &value) {
+ 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 = scene()->items(sceneShape, Qt::IntersectsItemShape);
+ items.removeAll(this);
+
+ if (!items.isEmpty()) {
+ for (int i = 0; i < items.count(); i++) {
+ 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_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_track = newTrack;
+ //kDebug()<<"// ITEM NEW POS: "<<newPos.x()<<", mapped: "<<mapToScene(newPos.x(), 0).x();
+ m_startPos = GenTime((int) newPos.x(), m_fps);
+ return newPos;
+ }
+ }
+ }
+ m_track = newTrack;
+ m_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);
+}
+
+
+OPERATIONTYPE Transition::operationMode(QPointF pos) {
+ const double scale = projectScene()->scale();
+ double maximumOffset = 6 / scale;
+
+ QRectF rect = sceneBoundingRect();
+ if (qAbs((int)(pos.x() - rect.x())) < maximumOffset) return RESIZESTART;
+ else if (qAbs((int)(pos.x() - (rect.right()))) < maximumOffset) return RESIZEEND;