]> git.sesse.net Git - kdenlive/blobdiff - src/clipitem.cpp
Don't allow clip moving over another one
[kdenlive] / src / clipitem.cpp
index b7fbfbdba19e8ba7cf42bc33c76fd57bb205cb3c..dce5bed7c037f185f0101b986776fe151dfe5c7c 100644 (file)
@@ -949,11 +949,27 @@ QVariant ClipItem::itemChange(GraphicsItemChange change, const QVariant &value)
                     if (pos().x() < otherPos.x()) {
                         // move clip just before colliding clip
                         int npos = (static_cast < AbstractClipItem* >(items.at(i))->startPos() - m_cropDuration).frames(m_fps);
+                        // check we don't run into another clip
                         newPos.setX(npos);
+                        sceneShape = rect();
+                        sceneShape.translate(newPos);
+                        QList<QGraphicsItem*> subitems = scene()->items(sceneShape, Qt::IntersectsItemShape);
+                        items.removeAll(this);
+                        for (int j = 0; j < subitems.count(); i++) {
+                            if (subitems.at(j)->type() == type()) return pos();
+                        }
                     } else {
                         // get pos just after colliding clip
                         int npos = static_cast < AbstractClipItem* >(items.at(i))->endPos().frames(m_fps);
+                        // check we don't run into another clip
                         newPos.setX(npos);
+                        sceneShape = rect();
+                        sceneShape.translate(newPos);
+                        QList<QGraphicsItem*> subitems = scene()->items(sceneShape, Qt::IntersectsItemShape);
+                        items.removeAll(this);
+                        for (int j = 0; j < subitems.count(); i++) {
+                            if (subitems.at(j)->type() == type()) return pos();
+                        }
                     }
                     m_track = newTrack;
                     m_startPos = GenTime((int) newPos.x(), m_fps);