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 ***************************************************************************/
19 #include "effectslist.h"
25 EffectsList::EffectsList():
26 QList < QDomElement > () {
29 EffectsList::~EffectsList() {
32 QDomElement EffectsList::getEffectByName(const QString & name) const {
34 for (int i = 0; i < this->size(); ++i) {
35 QDomElement effect = this->at(i);
36 QDomNode namenode = effect.elementsByTagName("name").item(0);
37 if (!namenode.isNull()) effectName = i18n(namenode.toElement().text().toUtf8().data());
38 if (name == effectName) {
39 QDomNodeList params = effect.elementsByTagName("parameter");
40 for (int i = 0; i < params.count(); i++) {
41 QDomElement e = params.item(i).toElement();
42 if (!e.hasAttribute("value"))
43 e.setAttribute("value", e.attribute("default"));
52 QDomElement EffectsList::getEffectByTag(const QString & tag, const QString & id) const {
54 if (!id.isEmpty()) for (int i = 0; i < this->size(); ++i) {
55 QDomElement effect = this->at(i);
56 //kDebug() << "// SRCH EFFECT; " << id << ", LKING: " << effect.attribute("id");
57 if (effect.attribute("id") == id) {
58 QDomNodeList params = effect.elementsByTagName("parameter");
59 for (int i = 0; i < params.count(); i++) {
60 QDomElement e = params.item(i).toElement();
61 if (!e.hasAttribute("value"))
62 e.setAttribute("value", e.attribute("default"));
68 if (!tag.isEmpty()) for (int i = 0; i < this->size(); ++i) {
69 QDomElement effect = this->at(i);
70 if (effect.attribute("tag") == tag) {
71 QDomNodeList params = effect.elementsByTagName("parameter");
72 for (int i = 0; i < params.count(); i++) {
73 QDomElement e = params.item(i).toElement();
74 if (!e.hasAttribute("value"))
75 e.setAttribute("value", e.attribute("default"));
84 int EffectsList::hasEffect(const QString & tag, const QString & id) const {
85 for (int i = 0; i < this->size(); ++i) {
86 QDomElement effect = this->at(i);
88 if (effect.attribute("id") == id) return i;
89 } else if (!tag.isEmpty() && effect.attribute("tag") == tag) return i;
94 QStringList EffectsList::effectIdInfo(const int ix) const {
96 QDomElement effect = this->at(ix);
97 QDomNode namenode = effect.elementsByTagName("name").item(0);
98 info << i18n(namenode.toElement().text().toUtf8().data()) << effect.attribute("tag") << effect.attribute("id");
102 QStringList EffectsList::effectNames() {
104 for (int i = 0; i < this->size(); ++i) {
105 QDomElement effect = this->at(i);
106 QDomNode namenode = effect.elementsByTagName("name").item(0);
107 if (!namenode.isNull()) list.append(i18n(namenode.toElement().text().toUtf8().data()));
112 QString EffectsList::getInfo(const QString & tag, const QString & id) const {
114 QDomElement effect = getEffectByTag(tag, id);
115 QDomNode namenode = effect.elementsByTagName("description").item(0);
116 if (!namenode.isNull()) info = i18n(namenode.toElement().text().toUtf8().data());
117 namenode = effect.elementsByTagName("author").item(0);
118 if (!namenode.isNull()) info.append("<br /><strong>" + i18n("Author:") + " </strong>" + i18n(namenode.toElement().text().toUtf8().data()));
122 QString EffectsList::getInfoFromIndex(const int ix) const {
124 QDomElement effect = this->at(ix);
125 QDomNode namenode = effect.elementsByTagName("description").item(0);
126 if (!namenode.isNull()) info = i18n(namenode.toElement().text().toUtf8().data());
127 namenode = effect.elementsByTagName("author").item(0);
128 if (!namenode.isNull()) info.append("<br /><strong>" + i18n("Author:") + " </strong>" + i18n(namenode.toElement().text().toUtf8().data()));
132 bool EffectsList::hasKeyFrames(QDomElement effect) {
133 QDomNodeList params = effect.elementsByTagName("parameter");
134 for (int i = 0; i < params.count(); i++) {
135 QDomElement e = params.item(i).toElement();
136 if (e.attribute("type") == "keyframe") return true;
141 EffectsList EffectsList::clone() const {
142 EffectsList list = EffectsList();
143 for (int i = 0; i < this->size(); ++i) {
144 list.append(this->at(i).cloneNode().toElement());
150 void EffectsList::setParameter(QDomElement effect, const QString &name, const QString &value) {
151 QDomNodeList params = effect.elementsByTagName("parameter");
152 for (int i = 0; i < params.count(); i++) {
153 QDomElement e = params.item(i).toElement();
154 if (e.attribute("name") == name) {
155 e.setAttribute("value", value);
162 QString EffectsList::parameter(QDomElement effect, const QString &name) {
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 return e.attribute("value");