Message info
 
To:kde-commits@kde.org From:Jean-Baptiste Mardelle Subject:[kdenlive] src: Fix adding effect group from timeline context menu: Date:Thu, 12 Apr 2012 17:21:24 +0200 (CEST)
 

Git commit bd18e035dc8e828d84bcd7f043cb4d06d52ad452 by Jean-Baptiste Mardelle.
Committed on 12/04/2012 at 17:20.
Pushed by mardelle into branch 'master'.

Fix adding effect group from timeline context menu:
http://kdenlive.org/mantis/view.php?id=2578

M +22 -13 src/effectslist.cpp
M +3 -0 src/effectslist.h
M +2 -2 src/mainwindow.cpp

http://commits.kde.org/kdenlive/bd18e035dc8e828d84bcd7f043cb4d06d52ad452

diff --git a/src/effectslist.cpp b/src/effectslist.cpp
index af06438..cff4941 100644
--- a/src/effectslist.cpp
+++ b/src/effectslist.cpp
@@ -54,6 +54,17 @@ QDomElement EffectsList::getEffectByName(const QString & name) const
return QDomElement();
}

+
+void EffectsList::initEffect(QDomElement effect) const
+{
+ QDomNodeList params = effect.elementsByTagName("parameter");
+ for (int i = 0; i < params.count(); i++) {
+ QDomElement e = params.item(i).toElement();
+ if (!e.hasAttribute("value"))
+ e.setAttribute("value", e.attribute("default"));
+ }
+}
+
QDomElement EffectsList::getEffectByTag(const QString & tag, const QString & id) const
{
QDomNodeList effects = m_baseElement.childNodes();
@@ -61,22 +72,20 @@ QDomElement EffectsList::getEffectByTag(const QString & tag, const QString & id)
QDomElement effect = effects.at(i).toElement();
if (!id.isEmpty()) {
if (effect.attribute("id") == id) {
- QDomNodeList params = effect.elementsByTagName("parameter");
- for (int i = 0; i < params.count(); i++) {
- QDomElement e = params.item(i).toElement();
- if (!e.hasAttribute("value"))
- e.setAttribute("value", e.attribute("default"));
- }
+ if (effect.tagName() == "effectgroup") {
+ // Effect group
+ QDomNodeList subeffects = effect.elementsByTagName("effect");
+ for (int j = 0; j < subeffects.count(); j++) {
+ QDomElement sub = subeffects.at(j).toElement();
+ initEffect(sub);
+ }
+ }
+ else initEffect(effect);
return effect;
}
} else if (!tag.isEmpty()) {
if (effect.attribute("tag") == tag) {
- QDomNodeList params = effect.elementsByTagName("parameter");
- for (int i = 0; i < params.count(); i++) {
- QDomElement e = params.item(i).toElement();
- if (!e.hasAttribute("value"))
- e.setAttribute("value", e.attribute("default"));
- }
+ initEffect(effect);
return effect;
}
}
@@ -102,7 +111,7 @@ QStringList EffectsList::effectIdInfo(const int ix) const
QDomElement effect = m_baseElement.childNodes().at(ix).toElement();
if (effect.tagName() == "effectgroup") {
QString groupName = effect.attribute("name");
- info << groupName << groupName << groupName << QString::number(Kdenlive::groupEffect);
+ info << groupName << groupName << effect.attribute("id") << QString::number(Kdenlive::groupEffect);
}
else {
QDomElement namenode = effect.firstChildElement("name");
diff --git a/src/effectslist.h b/src/effectslist.h
index 8a851a7..b0abdc1 100644
--- a/src/effectslist.h
+++ b/src/effectslist.h
@@ -96,6 +96,9 @@ public:
private:
QDomElement m_baseElement;
bool m_useIndex;
+
+ /** @brief Init effect default parameter values. */
+ void initEffect(QDomElement effect) const;

};

diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index b16cafd..409dfaa 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -3082,9 +3082,9 @@ void MainWindow::slotAddVideoEffect(QAction *result)

if (info.isEmpty() || info.size() < 3) return;
QDomElement effect ;
- if (info.at(2) == QString::number((int) EFFECT_VIDEO))
+ if (info.last() == QString::number((int) EFFECT_VIDEO))
effect = videoEffects.getEffectByTag(info.at(0), info.at(1));
- else if (info.at(2) == QString::number((int) EFFECT_AUDIO))
+ else if (info.last() == QString::number((int) EFFECT_AUDIO))
effect = audioEffects.getEffectByTag(info.at(0), info.at(1));
else
effect = customEffects.getEffectByTag(info.at(0), info.at(1));