+}
+
+EffectsParameterList ClipItem::addEffect(QDomElement effect, bool animate) {
+
+ bool needRepaint = false;
+ /*QDomDocument doc;
+ doc.appendChild(doc.importNode(effect, true));
+ kDebug() << "/////// CLIP ADD EFFECT: " << doc.toString();*/
+ m_effectList.append(effect);
+
+ EffectsParameterList parameters;
+ parameters.addParam("tag", effect.attribute("tag"));
+ parameters.addParam("kdenlive_ix", effect.attribute("kdenlive_ix"));
+ if (effect.hasAttribute("src")) parameters.addParam("src", effect.attribute("src"));
+
+ QString state = effect.attribute("disabled");
+ if (!state.isEmpty()) {
+ parameters.addParam("disabled", state);
+ }
+
+ QString effectId = effect.attribute("id");
+ if (effectId.isEmpty()) effectId = effect.attribute("tag");
+ parameters.addParam("id", effectId);
+
+ QDomNodeList params = effect.elementsByTagName("parameter");
+ int fade = 0;
+ for (int i = 0; i < params.count(); i++) {
+ QDomElement e = params.item(i).toElement();
+ if (!e.isNull()) {
+ if (e.attribute("type") == "keyframe") {
+ parameters.addParam("keyframes", e.attribute("keyframes"));
+ parameters.addParam("max", e.attribute("max"));
+ parameters.addParam("min", e.attribute("min"));
+ parameters.addParam("factor", e.attribute("factor", "1"));
+ parameters.addParam("starttag", e.attribute("starttag", "start"));
+ parameters.addParam("endtag", e.attribute("endtag", "end"));
+ }
+
+ double f = e.attribute("factor", "1").toDouble();
+
+ if (f == 1) {
+ parameters.addParam(e.attribute("name"), e.attribute("value"));
+
+ // check if it is a fade effect
+ if (effectId == "fadein") {
+ needRepaint = true;
+ if (m_effectList.hasEffect(QString(), "fade_from_black") == -1) {
+ if (e.attribute("name") == "out") fade += e.attribute("value").toInt();
+ else if (e.attribute("name") == "in") fade -= e.attribute("value").toInt();
+ } else {
+ QDomElement fadein = m_effectList.getEffectByTag(QString(), "fade_from_black");
+ if (fadein.attribute("name") == "out") fade += fadein.attribute("value").toInt();
+ else if (fadein.attribute("name") == "in") fade -= fadein.attribute("value").toInt();
+ }
+ } else if (effectId == "fade_from_black") {
+ needRepaint = true;
+ if (m_effectList.hasEffect(QString(), "fadein") == -1) {
+ if (e.attribute("name") == "out") fade += e.attribute("value").toInt();
+ else if (e.attribute("name") == "in") fade -= e.attribute("value").toInt();
+ } else {
+ QDomElement fadein = m_effectList.getEffectByTag(QString(), "fadein");
+ if (fadein.attribute("name") == "out") fade += fadein.attribute("value").toInt();
+ else if (fadein.attribute("name") == "in") fade -= fadein.attribute("value").toInt();
+ }
+ } else if (effectId == "fadeout") {
+ needRepaint = true;
+ if (m_effectList.hasEffect(QString(), "fade_to_black") == -1) {
+ if (e.attribute("name") == "out") fade -= e.attribute("value").toInt();
+ else if (e.attribute("name") == "in") fade += e.attribute("value").toInt();
+ } else {
+ QDomElement fadeout = m_effectList.getEffectByTag(QString(), "fade_to_black");
+ if (fadeout.attribute("name") == "out") fade -= fadeout.attribute("value").toInt();
+ else if (fadeout.attribute("name") == "in") fade += fadeout.attribute("value").toInt();
+ }
+ } else if (effectId == "fade_to_black") {
+ needRepaint = true;
+ if (m_effectList.hasEffect(QString(), "fadeout") == -1) {
+ if (e.attribute("name") == "out") fade -= e.attribute("value").toInt();
+ else if (e.attribute("name") == "in") fade += e.attribute("value").toInt();
+ } else {
+ QDomElement fadeout = m_effectList.getEffectByTag(QString(), "fadeout");
+ if (fadeout.attribute("name") == "out") fade -= fadeout.attribute("value").toInt();
+ else if (fadeout.attribute("name") == "in") fade += fadeout.attribute("value").toInt();
+ }
+ }
+ } else {
+ parameters.addParam(e.attribute("name"), QString::number(e.attribute("value").toDouble() / f));
+ }
+ }
+ }
+ m_effectNames = m_effectList.effectNames().join(" / ");
+ if (fade > 0) m_startFade = fade;
+ else if (fade < 0) m_endFade = -fade;
+ if (needRepaint) update(boundingRect());
+ if (animate) {
+ flashClip();
+ } else if (!needRepaint) {
+ QRectF r = boundingRect();
+ r.setHeight(20);
+ update(r);
+ }
+ if (m_selectedEffect == -1) {
+ m_selectedEffect = 0;
+ setSelectedEffect(m_selectedEffect);
+ }
+ return parameters;
+}
+
+EffectsParameterList ClipItem::getEffectArgs(QDomElement effect) {
+ EffectsParameterList parameters;
+ parameters.addParam("tag", effect.attribute("tag"));
+ parameters.addParam("kdenlive_ix", effect.attribute("kdenlive_ix"));
+ parameters.addParam("id", effect.attribute("id"));
+ if (effect.hasAttribute("src")) parameters.addParam("src", effect.attribute("src"));
+ QString state = effect.attribute("disabled");
+ if (!state.isEmpty()) {
+ parameters.addParam("disabled", state);
+ }
+
+ QDomNodeList params = effect.elementsByTagName("parameter");
+ for (int i = 0; i < params.count(); i++) {
+ QDomElement e = params.item(i).toElement();
+ //kDebug() << "/ / / /SENDING EFFECT PARAM: " << e.attribute("type") << ", NAME_ " << e.attribute("tag");
+ if (e.attribute("type") == "keyframe") {
+ kDebug() << "/ / / /SENDING KEYFR EFFECT TYPE";
+ parameters.addParam("keyframes", e.attribute("keyframes"));
+ parameters.addParam("max", e.attribute("max"));
+ parameters.addParam("min", e.attribute("min"));
+ parameters.addParam("factor", e.attribute("factor", "1"));
+ parameters.addParam("starttag", e.attribute("starttag", "start"));
+ parameters.addParam("endtag", e.attribute("endtag", "end"));
+ } else if (e.attribute("namedesc").contains(';')) {
+ QString format = e.attribute("format");
+ QStringList separators = format.split("%d", QString::SkipEmptyParts);
+ QStringList values = e.attribute("value").split(QRegExp("[,:;x]"));
+ QString neu;
+ QTextStream txtNeu(&neu);
+ if (values.size() > 0)
+ txtNeu << (int)values[0].toDouble();
+ for (int i = 0;i < separators.size() && i + 1 < values.size();i++) {
+ txtNeu << separators[i];
+ txtNeu << (int)(values[i+1].toDouble());
+ }
+ parameters.addParam("start", neu);
+ } else {
+ if (e.attribute("factor", "1") != "1") {
+ parameters.addParam(e.attribute("name"), QString::number(e.attribute("value").toDouble() / e.attribute("factor").toDouble()));
+ } else {
+ parameters.addParam(e.attribute("name"), e.attribute("value"));
+ }
+ }
+ }
+ return parameters;
+}
+
+void ClipItem::deleteEffect(QString index) {
+ bool needRepaint = false;
+ QString ix;
+
+ for (int i = 0; i < m_effectList.size(); ++i) {
+ ix = m_effectList.at(i).attribute("kdenlive_ix");
+ if (ix == index) {
+ QString effectId = m_effectList.at(i).attribute("id");
+ if ((effectId == "fadein" && hasEffect(QString(), "fade_from_black") == -1) ||
+ (effectId == "fade_from_black" && hasEffect(QString(), "fadein") == -1)) {
+ m_startFade = 0;
+ needRepaint = true;
+ } else if ((effectId == "fadeout" && hasEffect(QString(), "fade_to_black") == -1) ||
+ (effectId == "fade_to_black" && hasEffect(QString(), "fadeout") == -1)) {
+ m_endFade = 0;
+ needRepaint = true;
+ }
+ m_effectList.removeAt(i);
+ i--;
+ } else if (ix.toInt() > index.toInt()) {
+ m_effectList[i].setAttribute("kdenlive_ix", ix.toInt() - 1);
+ }
+ }
+ m_effectNames = m_effectList.effectNames().join(" / ");
+ if (needRepaint) update(boundingRect());
+ flashClip();
+}
+
+double ClipItem::speed() const {
+ return m_speed;
+}
+
+void ClipItem::setSpeed(const double speed) {
+ m_speed = speed;
+ if (m_speed == 1.0) m_clipName = baseClip()->name();
+ else m_clipName = baseClip()->name() + " - " + QString::number(speed * 100, 'f', 0) + '%';
+ //update();
+}
+
+GenTime ClipItem::maxDuration() const {
+ return m_maxDuration / m_speed;
+}
+
+GenTime ClipItem::cropStart() const {
+ return m_cropStart / m_speed;
+}
+
+GenTime ClipItem::cropDuration() const {
+ return m_cropDuration / m_speed;
+}
+
+GenTime ClipItem::endPos() const {
+ return m_startPos + cropDuration();