]> git.sesse.net Git - kdenlive/commitdiff
Saved effect groups should not be merged when added to a clip with existing group:
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Thu, 12 Apr 2012 22:09:05 +0000 (00:09 +0200)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Thu, 12 Apr 2012 22:09:05 +0000 (00:09 +0200)
http://kdenlive.org/mantis/view.php?id=2576

src/clipitem.cpp
src/clipitem.h
src/customtrackview.cpp
src/effectstack/collapsiblegroup.cpp

index d5c03901631d67def268ef491196d0d449adfd5d..d6be7a43ec0892520f2aeecfa9ad029058d6e0ac 100644 (file)
@@ -1629,6 +1629,20 @@ const ItemInfo ClipItem::speedIndependantInfo() const
     return m_speedIndependantInfo;
 }
 
+int ClipItem::nextFreeEffectGroupIndex() const
+{
+    int freeGroupIndex = 0;
+    for (int i = 0; i < m_effectList.count(); i++) {
+        QDomElement effect = m_effectList.at(i);
+       EffectInfo effectInfo;
+       effectInfo.fromString(effect.attribute("kdenlive_info"));
+       if (effectInfo.groupIndex >= freeGroupIndex) {
+           freeGroupIndex = effectInfo.groupIndex + 1;
+       }
+    }
+    return freeGroupIndex;
+}
+
 //virtual
 void ClipItem::dropEvent(QGraphicsSceneDragDropEvent * event)
 {
@@ -1641,8 +1655,14 @@ void ClipItem::dropEvent(QGraphicsSceneDragDropEvent * event)
        if (e.tagName() == "effectgroup") {
            // dropped an effect group
            QDomNodeList effectlist = e.elementsByTagName("effect");
+           int freeGroupIndex = nextFreeEffectGroupIndex();
+           EffectInfo effectInfo;
            for (int i = 0; i < effectlist.count(); i++) {
-               effectlist.at(i).toElement().removeAttribute("kdenlive_ix");
+               QDomElement effect = effectlist.at(i).toElement();
+               effectInfo.fromString(effect.attribute("kdenlive_info"));
+               effectInfo.groupIndex = freeGroupIndex;
+               effect.setAttribute("kdenlive_info", effectInfo.toString());
+               effect.removeAttribute("kdenlive_ix");
            }
        } else {
            // single effect dropped
index 682bb9fc07ceb5d435810c0373768c37afd2aa8a..978585c64f244362294066c8d8b4fe5b10f2a307 100644 (file)
@@ -176,6 +176,9 @@ public:
     void resetFrameWidth(int width);
     /** @brief Clip is about to be deleted, block thumbs. */
     void stopThumbs();
+    
+    /** @brief Get a free index value for effect group. */
+    int nextFreeEffectGroupIndex() const;
 
 protected:
     //virtual void mouseMoveEvent(QGraphicsSceneMouseEvent * event);
index 4651997e78b6dd999c84f5562f3878cb4b0a0858..2712dff794b56fb86d41f9bdac2a201d435c768d 100644 (file)
@@ -1734,7 +1734,18 @@ void CustomTrackView::slotAddGroupEffect(QDomElement effect, AbstractGroupItem *
             if (effect.tagName() == "effectgroup") {
                QDomNodeList effectlist = effect.elementsByTagName("effect");
                for (int j = 0; j < effectlist.count(); j++) {
-                   processEffect(item, effectlist.at(j).toElement(), effectCommand);
+                   QDomElement subeffect = effectlist.at(j).toElement();
+                   if (subeffect.hasAttribute("kdenlive_info")) {
+                       // effect is in a group
+                       EffectInfo effectInfo;
+                       effectInfo.fromString(subeffect.attribute("kdenlive_info"));
+                       if (effectInfo.groupIndex < 0) {
+                           // group needs to be appended
+                           effectInfo.groupIndex = item->nextFreeEffectGroupIndex();
+                           subeffect.setAttribute("kdenlive_info", effectInfo.toString());
+                       }
+                   }
+                   processEffect(item, subeffect, effectCommand);
                }
            }
             else {
@@ -1790,7 +1801,18 @@ void CustomTrackView::slotAddEffect(QDomElement effect, GenTime pos, int track)
            if (effect.tagName() == "effectgroup") {
                QDomNodeList effectlist = effect.elementsByTagName("effect");
                for (int j = 0; j < effectlist.count(); j++) {
-                   processEffect(item, effectlist.at(j).toElement(), effectCommand);
+                   QDomElement subeffect = effectlist.at(j).toElement();
+                   if (subeffect.hasAttribute("kdenlive_info")) {
+                       // effect is in a group
+                       EffectInfo effectInfo;
+                       effectInfo.fromString(subeffect.attribute("kdenlive_info"));
+                       if (effectInfo.groupIndex < 0) {
+                           // group needs to be appended
+                           effectInfo.groupIndex = item->nextFreeEffectGroupIndex();
+                           subeffect.setAttribute("kdenlive_info", effectInfo.toString());
+                       }
+                   }
+                   processEffect(item, subeffect, effectCommand);
                }
            }
             else processEffect(item, effect, effectCommand);
index cb1ad1d559ea510870804321858b73e3f0fdf74b..7f89038f89503ba310603da0034bdef02b516da3 100644 (file)
@@ -167,11 +167,14 @@ void CollapsibleGroup::slotSaveGroup()
     for (int i = 0; i < effects.count(); i++) {
        QDomElement eff = effects.at(i).toElement();
         eff.removeAttribute("kdenlive_ix");
-       QString kdenliveInfo = eff.attribute("kdenlive_info");
+       EffectInfo info;
+       info.fromString(eff.attribute("kdenlive_info"));
        // Make sure all effects have the correct new group name
-       if (kdenliveInfo.count('/') >= 2) {
-           eff.setAttribute("kdenlive_info", kdenliveInfo.section('/', 0, 1) + "/" + name);
-       }
+       info.groupName = name;
+       // Saved effect group should have a group index of -1
+       info.groupIndex = -1;
+       eff.setAttribute("kdenlive_info", info.toString());
+
     }
     
     base.setAttribute("name", name);