]> git.sesse.net Git - kdenlive/commitdiff
Spacer tool should never allow to move clips before another clip, fixes timeline...
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 1 Apr 2013 12:54:48 +0000 (14:54 +0200)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 1 Apr 2013 12:54:48 +0000 (14:54 +0200)
src/abstractgroupitem.cpp
src/abstractgroupitem.h
src/customtrackview.cpp
src/documentchecker.cpp

index ff66ac007b57f56af46c9fe835d6d18e0dc53b76..83f5e59fea65067eeadbe5f11e1fa228f9e8e401 100644 (file)
@@ -92,6 +92,11 @@ CustomTrackScene* AbstractGroupItem::projectScene()
     return NULL;
 }
 
+QPainterPath AbstractGroupItem::clipGroupSpacerShape(QPointF offset) const
+{
+    return spacerGroupShape(AVWIDGET, offset);
+}
+
 QPainterPath AbstractGroupItem::clipGroupShape(QPointF offset) const
 {
     return groupShape(AVWIDGET, offset);
@@ -125,6 +130,31 @@ QPainterPath AbstractGroupItem::groupShape(GRAPHICSRECTITEM type, QPointF offset
     return path;
 }
 
+QPainterPath AbstractGroupItem::spacerGroupShape(GRAPHICSRECTITEM type, QPointF offset) const
+{
+    QPainterPath path;
+    QList<QGraphicsItem *> children = childItems();
+    for (int i = 0; i < children.count(); i++) {
+        if (children.at(i)->type() == (int)type) {
+            QRectF r(children.at(i)->sceneBoundingRect());
+            r.translate(offset);
+           r.setRight(scene()->width());
+            path.addRect(r);
+        } else if (children.at(i)->type() == GROUPWIDGET) {
+            QList<QGraphicsItem *> subchildren = children.at(i)->childItems();
+            for (int j = 0; j < subchildren.count(); j++) {
+                if (subchildren.at(j)->type() == (int)type) {
+                    QRectF r(subchildren.at(j)->sceneBoundingRect());
+                    r.translate(offset);
+                   r.setRight(scene()->width());
+                    path.addRect(r);
+                }
+            }
+        }
+    }
+    return path;
+}
+
 void AbstractGroupItem::addItem(QGraphicsItem * item)
 {
     addToGroup(item);
index c68d22378d8c556caac56b1d222167cd40612d68..0f16f32e193f12ce6bbee1b1563581353b580930 100644 (file)
@@ -41,6 +41,7 @@ public:
     void removeItem(QGraphicsItem * item);
     int track() const;
     QPainterPath clipGroupShape(QPointF offset) const;
+    QPainterPath clipGroupSpacerShape(QPointF offset) const;
     QPainterPath transitionGroupShape(QPointF offset) const;
     void setItemLocked(bool locked);
     bool isItemLocked() const;
@@ -71,6 +72,7 @@ protected:
 private:
     void fixItemRect();
     QPainterPath groupShape(GRAPHICSRECTITEM type, QPointF offset) const;
+    QPainterPath spacerGroupShape(GRAPHICSRECTITEM type, QPointF offset) const;
     /** Stores the original info of the items beeing resized. */
     QList <ItemInfo> m_resizeInfos;
 };
index b178039a6fbcc8cdc79f430bd477f031344936f1..bd5d4d720dd44f2adb539c467dfe9c89b78b33b5 100644 (file)
@@ -511,7 +511,7 @@ void CustomTrackView::mouseMoveEvent(QMouseEvent * event)
 
             // Make sure there is no collision
             QList<QGraphicsItem *> children = m_selectionGroup->childItems();
-            QPainterPath shape = m_selectionGroup->clipGroupShape(QPointF(snappedPos - m_selectionGroup->sceneBoundingRect().left(), 0));
+            QPainterPath shape = m_selectionGroup->clipGroupSpacerShape(QPointF(snappedPos - m_selectionGroup->sceneBoundingRect().left(), 0));
             QList<QGraphicsItem*> collidingItems = scene()->items(shape, Qt::IntersectsItemShape);
             collidingItems.removeAll(m_selectionGroup);
             for (int i = 0; i < children.count(); i++) {
@@ -537,7 +537,7 @@ void CustomTrackView::mouseMoveEvent(QMouseEvent * event)
             }
             snappedPos += offset;
             // make sure we have no collision
-            shape = m_selectionGroup->clipGroupShape(QPointF(snappedPos - m_selectionGroup->sceneBoundingRect().left(), 0));
+            shape = m_selectionGroup->clipGroupSpacerShape(QPointF(snappedPos - m_selectionGroup->sceneBoundingRect().left(), 0));
             collidingItems = scene()->items(shape, Qt::IntersectsItemShape);
             collidingItems.removeAll(m_selectionGroup);
             for (int i = 0; i < children.count(); i++) {
index ca612bc18a2ce791fbd87404f53f23712fb7d8db..41067fd5281eff569d353370a3a141d67dd274f3 100644 (file)
@@ -465,7 +465,8 @@ void DocumentChecker::slotSearchClips()
     if (newpath.isEmpty()) return;
     int ix = 0;
     bool fixed = false;
-    m_ui.recursiveSearch->setEnabled(false);
+    m_ui.recursiveSearch->setChecked(true);
+    qApp->processEvents();
     QTreeWidgetItem *child = m_ui.treeWidget->topLevelItem(ix);
     QDir searchDir(newpath);
     while (child) {
@@ -514,6 +515,7 @@ void DocumentChecker::slotSearchClips()
         ix++;
         child = m_ui.treeWidget->topLevelItem(ix);
     }
+    m_ui.recursiveSearch->setChecked(false);
     m_ui.recursiveSearch->setEnabled(true);
     if (fixed) {
         // original doc was modified