1 /***************************************************************************
2 effectslist.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 ***************************************************************************/
19 #include "effectslist.h"
25 EffectsList::EffectsList() :
26 QList < QDomElement > ()
30 EffectsList::~EffectsList()
34 QDomElement EffectsList::getEffectByName(const QString & name) const
37 for (int i = 0; i < size(); ++i) {
38 QDomElement effect = at(i);
39 QDomNode namenode = effect.elementsByTagName("name").item(0);
40 if (!namenode.isNull()) effectName = i18n(namenode.toElement().text().toUtf8().data());
41 if (name == effectName) {
42 QDomNodeList params = effect.elementsByTagName("parameter");
43 for (int i = 0; i < params.count(); i++) {
44 QDomElement e = params.item(i).toElement();
45 if (!e.hasAttribute("value"))
46 e.setAttribute("value", e.attribute("default"));
55 QDomElement EffectsList::getEffectByTag(const QString & tag, const QString & id) const
58 if (!id.isEmpty()) for (int i = 0; i < size(); ++i) {
59 QDomElement effect = at(i);
60 //kDebug() << "// SRCH EFFECT; " << id << ", LKING: " << effect.attribute("id");
61 if (effect.attribute("id") == id) {
62 QDomNodeList params = effect.elementsByTagName("parameter");
63 for (int i = 0; i < params.count(); i++) {
64 QDomElement e = params.item(i).toElement();
65 if (!e.hasAttribute("value"))
66 e.setAttribute("value", e.attribute("default"));
72 if (!tag.isEmpty()) for (int i = 0; i < size(); ++i) {
73 QDomElement effect = at(i);
74 if (effect.attribute("tag") == tag) {
75 QDomNodeList params = effect.elementsByTagName("parameter");
76 for (int i = 0; i < params.count(); i++) {
77 QDomElement e = params.item(i).toElement();
78 if (!e.hasAttribute("value"))
79 e.setAttribute("value", e.attribute("default"));
88 int EffectsList::hasEffect(const QString & tag, const QString & id) const
90 for (int i = 0; i < size(); ++i) {
91 QDomElement effect = at(i);
93 if (effect.attribute("id") == id) return i;
94 } else if (!tag.isEmpty() && effect.attribute("tag") == tag) return i;
99 QStringList EffectsList::effectIdInfo(const int ix) const
102 QDomElement effect = at(ix);
103 QDomNode namenode = effect.elementsByTagName("name").item(0);
104 info << i18n(namenode.toElement().text().toUtf8().data()) << effect.attribute("tag") << effect.attribute("id");
108 QStringList EffectsList::effectNames()
111 for (int i = 0; i < size(); ++i) {
112 QDomElement effect = at(i);
113 QDomNode namenode = effect.elementsByTagName("name").item(0);
114 if (!namenode.isNull()) list.append(i18n(namenode.toElement().text().toUtf8().data()));
119 QString EffectsList::getInfo(const QString & tag, const QString & id) const
122 QDomElement effect = getEffectByTag(tag, id);
123 QDomNode namenode = effect.elementsByTagName("description").item(0);
124 if (!namenode.isNull()) info = i18n(namenode.toElement().text().toUtf8().data());
125 namenode = effect.elementsByTagName("author").item(0);
126 if (!namenode.isNull()) info.append("<br /><strong>" + i18n("Author:") + " </strong>" + i18n(namenode.toElement().text().toUtf8().data()));
130 QString EffectsList::getInfoFromIndex(const int ix) const
133 QDomElement effect = at(ix);
134 QDomNode namenode = effect.elementsByTagName("description").item(0);
135 if (!namenode.isNull()) info = i18n(namenode.toElement().text().toUtf8().data());
136 namenode = effect.elementsByTagName("author").item(0);
137 if (!namenode.isNull()) info.append("<br /><strong>" + i18n("Author:") + " </strong>" + i18n(namenode.toElement().text().toUtf8().data()));
141 bool EffectsList::hasKeyFrames(QDomElement effect)
143 QDomNodeList params = effect.elementsByTagName("parameter");
144 for (int i = 0; i < params.count(); i++) {
145 QDomElement e = params.item(i).toElement();
146 if (e.attribute("type") == "keyframe") return true;
151 EffectsList EffectsList::clone() const
154 for (int i = 0; i < size(); ++i) {
155 list.append(at(i).cloneNode().toElement());
161 void EffectsList::setParameter(QDomElement effect, const QString &name, const QString &value)
163 QDomNodeList params = effect.elementsByTagName("parameter");
164 for (int i = 0; i < params.count(); i++) {
165 QDomElement e = params.item(i).toElement();
166 if (e.attribute("name") == name) {
167 e.setAttribute("value", value);
174 QString EffectsList::parameter(QDomElement effect, const QString &name)
176 QDomNodeList params = effect.elementsByTagName("parameter");
177 for (int i = 0; i < params.count(); i++) {
178 QDomElement e = params.item(i).toElement();
179 if (e.attribute("name") == name) {
180 return e.attribute("value");