- int out = elem.attribute("out", 0).toInt() - in;
- //kDebug()<<"++++++++++++++\n\n / / /ADDING CLIP: "<<clip.cropTime<<", out: "<<clip.duration<<", Producer: "<<clip.producer<<"\n\n++++++++++++++++++++";
- ClipItem *item = new ClipItem(clip, ix, GenTime(position, m_doc->fps()), QRectF(position * m_scale, trackTop + 1, out * m_scale, 49), GenTime(out, m_doc->fps()), m_doc->fps());
- m_scene->addItem(item);
- position += out;
-
+ if (clip != NULL) {
+ int out = elem.attribute("out").toInt();
+
+ ItemInfo clipinfo;
+ clipinfo.startPos = GenTime(position, m_doc->fps());
+ clipinfo.endPos = clipinfo.startPos + GenTime(out, m_doc->fps());
+ clipinfo.track = ix;
+ kDebug() << "// INSERTING CLIP: " << in << "x" << out << ", track: " << ix << ", ID: " << id << ", SCALE: " << m_scale << ", FPS: " << m_doc->fps();
+ ClipItem *item = new ClipItem(clip, clipinfo, m_scale, m_doc->fps());
+ m_scene->addItem(item);
+ position += out;
+
+ // parse clip effects
+ for (QDomNode n2 = elem.firstChild(); !n2.isNull(); n2 = n2.nextSibling()) {
+ QDomElement effect = n2.toElement();
+ if (effect.tagName() == "filter") {
+ // add effect to clip
+ QString effecttag;
+ QString effectindex;
+ // Get effect tag & index
+ for (QDomNode n3 = effect.firstChild(); !n3.isNull(); n3 = n3.nextSibling()) {
+ // parse effect parameters
+ QDomElement effectparam = n3.toElement();
+ if (effectparam.attribute("name") == "tag") {
+ effecttag = effectparam.text();
+ }
+ if (effectparam.attribute("name") == "kdenlive_ix") {
+ effectindex = effectparam.text();
+ }
+ }
+
+ // get effect standard tags
+ QDomElement clipeffect = MainWindow::videoEffects.getEffectByTag(effecttag);
+ clipeffect.setAttribute("kdenlive_ix", effectindex);
+ QDomNodeList clipeffectparams = clipeffect.childNodes();
+
+ // adjust effect parameters
+ for (QDomNode n3 = effect.firstChild(); !n3.isNull(); n3 = n3.nextSibling()) {
+ // parse effect parameters
+ QDomElement effectparam = n3.toElement();
+ QString paramname = effectparam.attribute("name");
+ QString paramvalue = effectparam.text();
+
+ // try to find this parameter in the effect xml
+ QDomElement e;
+ for (int k = 0; k < clipeffectparams.count(); k++) {
+ e = clipeffectparams.item(k).toElement();
+ if (!e.isNull() && e.tagName() == "parameter" && e.attribute("name") == paramname) {
+ e.setAttribute("value", paramvalue);
+ break;
+ }
+ }
+ }
+ item->addEffect(clipeffect, false);
+ }
+ }
+
+ } else kWarning() << "CANNOT INSERT CLIP " << id;