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();
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;
}
}
{
QStringList info;
QDomElement effect = m_baseElement.childNodes().at(ix).toElement();
- QDomElement namenode = effect.firstChildElement("name");
- info << i18n(namenode.text().toUtf8().data()) << effect.attribute("tag") << effect.attribute("id");
+ if (effect.tagName() == "effectgroup") {
+ QString groupName = effect.attribute("name");
+ info << groupName << groupName << effect.attribute("id") << QString::number(Kdenlive::groupEffect);
+ }
+ else {
+ QDomElement namenode = effect.firstChildElement("name");
+ info << i18n(namenode.text().toUtf8().data()) << effect.attribute("tag") << effect.attribute("id");
+ }
return info;
}
void EffectsList::setParameter(QDomElement effect, const QString &name, const QString &value)
{
QDomNodeList params = effect.elementsByTagName("parameter");
+ bool found = false;
for (int i = 0; i < params.count(); i++) {
QDomElement e = params.item(i).toElement();
if (e.attribute("name") == name) {
e.setAttribute("value", value);
+ found = true;
break;
}
}
+ if (!found) {
+ // create property
+ QDomDocument doc = effect.ownerDocument();
+ QDomElement e = doc.createElement("parameter");
+ e.setAttribute("name", name);
+ QDomText val = doc.createTextNode(value);
+ e.appendChild(val);
+ effect.appendChild(e);
+ }
}
// static
QDomNodeList effects = m_baseElement.childNodes();
int ix = effect.attribute("kdenlive_ix").toInt();
QDomElement result;
- if (effect.hasAttribute("kdenlive_ix") && ix > effects.count()) {
- ix = effects.count();
- result = m_baseElement.appendChild(importNode(effect, true)).toElement();
+ if (ix <= 0 || ix > effects.count()) {
+ ix = effects.count();
+ result = m_baseElement.appendChild(importNode(effect, true)).toElement();
}
else {
QDomElement listeffect = effects.at(ix - 1).toElement();
- result = m_baseElement.insertBefore(importNode(effect, true), listeffect).toElement();
+ result = m_baseElement.insertBefore(importNode(effect, true), listeffect).toElement();
}
- if (m_useIndex) updateIndexes(effects, ix - 1);
+ if (m_useIndex && ix > 0)
+ updateIndexes(effects, ix - 1);
return result;
}
{
for (int i = startIndex; i < effects.count(); i++) {
QDomElement listeffect = effects.at(i).toElement();
- listeffect.setAttribute("kdenlive_ix", i + 1);
+ listeffect.setAttribute("kdenlive_ix", i + 1);
+ }
+}
+
+void EffectsList::enableEffects(QList <int> indexes, bool disable)
+{
+ QDomNodeList effects = m_baseElement.childNodes();
+ QDomElement effect;
+ for (int i = 0; i < indexes.count(); i++) {
+ effect = effectFromIndex(effects, indexes.at(i));
+ effect.setAttribute("disable", (int) disable);
}
}
int ix = effect.attribute("kdenlive_ix").toInt();
QDomElement current = effectFromIndex(effects, ix);
if (!current.isNull()) {
- m_baseElement.insertBefore(importNode(effect, true), current);
- m_baseElement.removeChild(current);
+ m_baseElement.insertBefore(importNode(effect, true), current);
+ m_baseElement.removeChild(current);
}
else m_baseElement.appendChild(importNode(effect, true));
}