X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fclipitem.cpp;h=7570202b77e49dd8f4692457e32add58dbd628bd;hb=2cd321d36c5d172057c5095cc5f23ea92dedd11c;hp=3e77c933efc6db01a22d32f67c762951fd61582a;hpb=5ec91b2a42472711c8336f4171d011fc8f2363fd;p=kdenlive diff --git a/src/clipitem.cpp b/src/clipitem.cpp index 3e77c933..7570202b 100644 --- a/src/clipitem.cpp +++ b/src/clipitem.cpp @@ -433,7 +433,7 @@ void ClipItem::setSelectedEffect(const int ix) { m_selectedEffect = ix; QLocale locale; - QDomElement effect = effectAt(m_selectedEffect); + QDomElement effect = effectAtIndex(m_selectedEffect); if (!effect.isNull() && effect.attribute("disable") != "1") { QDomNodeList params = effect.elementsByTagName("parameter"); for (int i = 0; i < params.count(); i++) { @@ -487,7 +487,7 @@ QStringList ClipItem::keyframes(const int index) void ClipItem::updateKeyframeEffect() { // regenerate xml parameter from the clip keyframes - QDomElement effect = getEffectAt(m_selectedEffect); + QDomElement effect = getEffectAtIndex(m_selectedEffect); if (effect.attribute("disable") == "1") return; QDomNodeList params = effect.elementsByTagName("parameter"); QDomElement e = params.item(m_visibleParam).toElement(); @@ -509,7 +509,7 @@ void ClipItem::updateKeyframeEffect() QDomElement ClipItem::selectedEffect() { if (m_selectedEffect == -1 || m_effectList.isEmpty()) return QDomElement(); - return effectAt(m_selectedEffect); + return effectAtIndex(m_selectedEffect); } void ClipItem::resetThumbs(bool clearExistingThumbs) @@ -1359,13 +1359,19 @@ QStringList ClipItem::effectNames() return m_effectList.effectNames(); } -QDomElement ClipItem::effectAt(int ix) const +QDomElement ClipItem::effect(int ix) const +{ + if (ix >= m_effectList.count() || ix < 0) return QDomElement(); + return m_effectList.at(ix).cloneNode().toElement(); +} + +QDomElement ClipItem::effectAtIndex(int ix) const { if (ix > m_effectList.count() || ix <= 0) return QDomElement(); return m_effectList.itemFromIndex(ix).cloneNode().toElement(); } -QDomElement ClipItem::getEffectAt(int ix) const +QDomElement ClipItem::getEffectAtIndex(int ix) const { if (ix > m_effectList.count() || ix <= 0) return QDomElement(); return m_effectList.itemFromIndex(ix); @@ -1386,6 +1392,11 @@ void ClipItem::updateEffect(QDomElement effect) } } +void ClipItem::enableEffects(QList indexes, bool disable) +{ + m_effectList.enableEffects(indexes, disable); +} + bool ClipItem::moveEffect(QDomElement effect, int ix) { if (ix <= 0 || ix > (m_effectList.count()) || effect.isNull()) { @@ -1570,10 +1581,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 +1640,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 +1666,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