]> git.sesse.net Git - kdenlive/blobdiff - src/clipitem.cpp
Try to fix build error on some systems.
[kdenlive] / src / clipitem.cpp
index 1f350225b13cdbe50ec1da04c6cebcae6377e398..bf0013083c759fcbbd2f2c27e496bc939b70f750 100644 (file)
@@ -1371,7 +1371,7 @@ QDomElement ClipItem::getEffectAt(int ix) const
     return m_effectList.itemFromIndex(ix);
 }
 
-bool ClipItem::updateEffect(QDomElement effect)
+void ClipItem::updateEffect(QDomElement effect)
 {
     //kDebug() << "CHange EFFECT AT: " << ix << ", CURR: " << m_effectList.at(ix).attribute("tag") << ", NEW: " << effect.attribute("tag");
     m_effectList.updateEffect(effect);
@@ -1384,7 +1384,11 @@ bool ClipItem::updateEffect(QDomElement effect)
         r.setHeight(20);
         update(r);
     }
-    return true;
+}
+
+void ClipItem::enableEffects(QList <int> indexes, bool disable)
+{
+    m_effectList.enableEffects(indexes, disable);
 }
 
 bool ClipItem::moveEffect(QDomElement effect, int ix)
@@ -1415,6 +1419,7 @@ EffectsParameterList ClipItem::addEffect(QDomElement effect, bool /*animate*/)
     int ix;
     QDomElement insertedEffect;
     if (!effect.hasAttribute("kdenlive_ix")) {
+       // effect dropped from effect list
         ix = effectsCounter();
     } else ix = effect.attribute("kdenlive_ix").toInt();
     if (!m_effectList.isEmpty() && ix <= m_effectList.count()) {
@@ -1570,10 +1575,10 @@ void ClipItem::deleteEffect(QString index)
     m_effectList.removeAt(ix);
     m_effectNames = m_effectList.effectNames().join(" / ");
 
-    if (m_effectList.isEmpty() || m_selectedEffect + 1 == ix) {
+    if (m_effectList.isEmpty() || m_selectedEffect == ix) {
         // Current effect was removed
-        if (ix > m_effectList.count() - 1) {
-            setSelectedEffect(m_effectList.count() - 1);
+        if (ix > m_effectList.count()) {
+            setSelectedEffect(m_effectList.count());
         } else setSelectedEffect(ix);
     }
     if (needRepaint) update(boundingRect());
@@ -1629,6 +1634,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 +1660,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