+void KdenliveDoc::convertDocument(double version) {
+ // Opening a old Kdenlive document
+ QDomNode westley = m_document.elementsByTagName("westley").at(1);
+ QDomNode tractor = m_document.elementsByTagName("tractor").at(0);
+ QDomNode kdenlivedoc = m_document.elementsByTagName("kdenlivedoc").at(0);
+ QDomNode multitrack = m_document.elementsByTagName("multitrack").at(0);
+ QDomNodeList playlists = m_document.elementsByTagName("playlist");
+
+ QDomNode props = m_document.elementsByTagName("properties").at(0).toElement();
+ QString profile = props.toElement().attribute("videoprofile");
+ if (profile == "dv_wide") profile = "dv_pal_wide";
+ if (!profile.isEmpty()) {
+ setProfilePath(profile);
+ } else setProfilePath("dv_pal");
+
+ // move playlists outside of tractor and add the tracks instead
+ int max = playlists.count();
+ for (int i = 0; i < max; i++) {
+ QDomNode n = playlists.at(i);
+ westley.insertBefore(n, QDomNode());
+ QDomElement pl = n.toElement();
+ QDomElement track = m_document.createElement("track");
+ QString trackType = pl.attribute("hide");
+ if (!trackType.isEmpty()) track.setAttribute("hide", trackType);
+ QString playlist_id = pl.attribute("id");
+ if (playlist_id.isEmpty()) {
+ playlist_id = "black_track";
+ pl.setAttribute("id", playlist_id);
+ }
+ track.setAttribute("producer", playlist_id);
+ tractor.appendChild(track);
+ }
+ tractor.removeChild(multitrack);
+
+ // audio track mixing transitions should not be added to track view, so add required attribute
+ QDomNodeList transitions = m_document.elementsByTagName("transition");
+ max = transitions.count();
+ for (int i = 0; i < max; i++) {
+ QDomElement tr = transitions.at(i).toElement();
+ if (tr.attribute("combine") == "1" && tr.attribute("mlt_service") == "mix") {
+ QDomElement property = m_document.createElement("property");
+ property.setAttribute("name", "internal_added");
+ QDomText value = m_document.createTextNode("237");
+ property.appendChild(value);
+ tr.appendChild(property);
+ } else {
+ // convert transition
+ QDomNamedNodeMap attrs = tr.attributes();
+ for (unsigned int j = 0; j < attrs.count(); j++) {
+ QString attrName = attrs.item(j).nodeName();
+ if (attrName != "in" && attrName != "out" && attrName != "id") {
+ QDomElement property = m_document.createElement("property");
+ property.setAttribute("name", attrName);
+ QDomText value = m_document.createTextNode(attrs.item(j).nodeValue());
+ property.appendChild(value);
+ tr.appendChild(property);
+ }
+ }
+ }
+ }
+
+ // move transitions after tracks
+ for (int i = 0; i < max; i++) {
+ tractor.insertAfter(transitions.at(0), QDomNode());
+ }
+
+ QDomElement markers = m_document.createElement("markers");
+
+ // change producer names
+ QDomNodeList producers = m_document.elementsByTagName("producer");
+ max = producers.count();
+ for (int i = 0; i < max; i++) {
+ QDomElement prod = producers.at(0).toElement();
+ QDomNode m = prod.firstChild();
+ if (!m.isNull() && m.toElement().tagName() == "markers") {
+ QDomNodeList prodchilds = m.childNodes();
+ int maxchild = prodchilds.count();
+ for (int k = 0; k < maxchild; k++) {
+ QDomElement mark = prodchilds.at(0).toElement();
+ mark.setAttribute("id", prod.attribute("id"));
+ markers.insertAfter(mark, QDomNode());
+ }
+ prod.removeChild(m);
+ }
+ int duration = prod.attribute("duration").toInt();
+ if (duration > 0) prod.setAttribute("out", QString::number(duration));
+ westley.insertBefore(prod, QDomNode());
+ }
+
+ QDomNode westley0 = m_document.elementsByTagName("westley").at(0);
+ if (!markers.firstChild().isNull()) westley0.appendChild(markers);
+ westley0.removeChild(kdenlivedoc);
+
+ QDomNodeList elements = westley.childNodes();
+ max = elements.count();
+ for (int i = 0; i < max; i++) {
+ QDomElement prod = elements.at(0).toElement();
+ westley0.insertAfter(prod, QDomNode());
+ }
+
+ westley0.removeChild(westley);
+
+ //kDebug() << "///////////////// CONVERTED DOC:";
+ //kDebug() << m_document.toString();
+ //kDebug() << "///////////////// END CONVERTED DOC:";
+}
+
+QDomElement KdenliveDoc::documentInfoXml(QDomElement timelineInfo) {
+ QDomDocument doc;
+ QDomElement e;
+ QDomElement addedXml = doc.createElement("kdenlivedoc");
+ QDomElement markers = doc.createElement("markers");