1 /***************************************************************************
2 docclipbaseiterator.cpp - description
4 begin : Sat Aug 10 2002
5 copyright : (C) 2002 by Jason Wood
6 email : jasonwood@blueyonder.co.uk
7 ***************************************************************************/
9 /***************************************************************************
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
16 ***************************************************************************/
21 #include "effectslist.h"
24 EffectsList::EffectsList():
25 QList < QDomElement > () {
28 EffectsList::~EffectsList() {
31 QMap <QString, QString> EffectsList::effect(const QString & name) {
32 QMap <QString, QString> filter;
35 for (int i = 0; i < this->size(); ++i) {
37 QDomNode namenode = effect.elementsByTagName("name").item(0);
38 if (!namenode.isNull()) {
39 effectName = i18n(namenode.toElement().text().toUtf8().data());
40 if (name == effectName) break;
43 filter.insert("mlt_service", effect.attribute("tag"));
44 filter.insert("name", name);
49 QDomElement EffectsList::getEffectByName(const QString & name) const {
51 for (int i = 0; i < this->size(); ++i) {
52 QDomElement effect = this->at(i);
53 QDomNode namenode = effect.elementsByTagName("name").item(0);
54 if (!namenode.isNull()) effectName = i18n(namenode.toElement().text().toUtf8().data());
55 if (name == effectName) {
56 QDomNodeList params = effect.elementsByTagName("parameter");
57 for (int i = 0; i < params.count(); i++) {
58 QDomElement e = params.item(i).toElement();
59 if (!e.hasAttribute("value"))
60 e.setAttribute("value", e.attribute("default"));
69 QDomElement EffectsList::getEffectByTag(const QString & tag, const QString & id) const {
71 if (!id.isEmpty()) for (int i = 0; i < this->size(); ++i) {
72 QDomElement effect = this->at(i);
73 if (effect.attribute("id") == id) {
74 QDomNodeList params = effect.elementsByTagName("parameter");
75 for (int i = 0; i < params.count(); i++) {
76 QDomElement e = params.item(i).toElement();
77 if (!e.hasAttribute("value"))
78 e.setAttribute("value", e.attribute("default"));
84 if (!tag.isEmpty()) for (int i = 0; i < this->size(); ++i) {
85 QDomElement effect = this->at(i);
86 if (effect.attribute("tag") == tag) {
87 QDomNodeList params = effect.elementsByTagName("parameter");
88 for (int i = 0; i < params.count(); i++) {
89 QDomElement e = params.item(i).toElement();
90 if (!e.hasAttribute("value"))
91 e.setAttribute("value", e.attribute("default"));
100 QStringList EffectsList::effectNames() {
102 for (int i = 0; i < this->size(); ++i) {
103 QDomElement effect = this->at(i);
104 QDomNode namenode = effect.elementsByTagName("name").item(0);
105 if (!namenode.isNull()) list.append(i18n(namenode.toElement().text().toUtf8().data()));
110 QString EffectsList::getInfo(QString effectName) {
112 QDomElement effect = getEffectByName(effectName);
113 QDomNode namenode = effect.elementsByTagName("description").item(0);
114 if (!namenode.isNull()) info = i18n(namenode.toElement().text().toUtf8().data());
115 namenode = effect.elementsByTagName("author").item(0);
116 if (!namenode.isNull()) info.append(i18n("<br><b>Author:</b> ") + i18n(namenode.toElement().text().toUtf8().data()));
120 bool EffectsList::hasKeyFrames(QDomElement effect) {
121 QDomNodeList params = effect.elementsByTagName("parameter");
122 for (int i = 0; i < params.count(); i++) {
123 QDomElement e = params.item(i).toElement();
124 if (e.attribute("type") == "keyframe") return true;
130 void EffectsList::setParameter(QDomElement effect, QString name, QString value) {
131 QDomNodeList params = effect.elementsByTagName("parameter");
132 for (int i = 0; i < params.count(); i++) {
133 QDomElement e = params.item(i).toElement();
134 if (e.attribute("name") == name) {
135 e.setAttribute("value", value);