1 /***************************************************************************
2 * Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
20 #include <QCryptographicHash>
24 #include <KStandardDirs>
25 #include <KMessageBox>
27 #include <KFileDialog>
28 #include <KIO/NetAccess>
29 #include <KApplication>
32 #include <mlt++/Mlt.h>
34 #include "kdenlivedoc.h"
35 #include "docclipbase.h"
36 #include "profilesdialog.h"
37 #include "kdenlivesettings.h"
39 #include "clipmanager.h"
40 #include "addfoldercommand.h"
41 #include "editfoldercommand.h"
42 #include "titlewidget.h"
43 #include "mainwindow.h"
46 KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup *undoGroup, const QString &profileName, const QPoint tracks, MainWindow *parent): QObject(parent), m_render(NULL), m_url(url), m_projectFolder(projectFolder), m_commandStack(new QUndoStack(undoGroup)), m_modified(false), m_documentLoadingProgress(0), m_documentLoadingStep(0.0), m_startPos(0), m_zoom(7), m_autosave(NULL) {
47 m_clipManager = new ClipManager(this);
48 m_autoSaveTimer = new QTimer(this);
49 m_autoSaveTimer->setSingleShot(true);
52 if (KIO::NetAccess::download(url.path(), tmpFile, parent)) {
54 m_document.setContent(&file, false);
56 QDomNode infoXmlNode = m_document.elementsByTagName("kdenlivedoc").at(0);
57 QDomNode westley = m_document.elementsByTagName("westley").at(0);
58 if (!infoXmlNode.isNull()) {
59 QDomElement infoXml = infoXmlNode.toElement();
60 QString profilePath = infoXml.attribute("profile");
61 m_startPos = infoXml.attribute("position").toInt();
62 m_zoom = infoXml.attribute("zoom", "7").toInt();
63 setProfilePath(profilePath);
64 double version = infoXml.attribute("version").toDouble();
66 // Upgrade old Kdenlive documents to current version
67 convertDocument(version);
70 QString tracks = infoXml.attribute("tracks");
72 videoTrack.type = VIDEOTRACK;
73 videoTrack.isMute = false;
74 videoTrack.isBlind = false;
77 audioTrack.type = AUDIOTRACK;
78 audioTrack.isMute = false;
79 audioTrack.isBlind = true;
80 for (int i = 0; i < tracks.size(); i++) {
81 if (tracks.data()[i] == 'v') m_tracksList.append(videoTrack);
82 else m_tracksList.append(audioTrack);
87 QDomNodeList producers = m_document.elementsByTagName("producer");
88 QDomNodeList infoproducers = m_document.elementsByTagName("kdenlive_producer");
89 const int max = producers.count();
90 const int infomax = infoproducers.count();
93 m_documentLoadingStep = 100.0 / (max + infomax + m_document.elementsByTagName("entry").count());
94 parent->slotGotProgressInfo(i18n("Loading project clips"), (int) m_documentLoadingProgress);
97 for (int i = 0; i < max; i++) {
98 e = producers.item(i).cloneNode().toElement();
99 if (m_documentLoadingStep > 0) {
100 m_documentLoadingProgress += m_documentLoadingStep;
101 parent->slotGotProgressInfo(QString(), (int) m_documentLoadingProgress);
102 //qApp->processEvents();
104 QString prodId = e.attribute("id");
105 if (!e.isNull() && prodId != "black" && !prodId.startsWith("slowmotion")/*&& prodId.toInt() > 0*/) {
106 // addClip(e, prodId, false);
107 kDebug() << "// PROD: " << prodId;
111 for (int i = 0; i < infomax; i++) {
112 e = infoproducers.item(i).cloneNode().toElement();
113 if (m_documentLoadingStep > 0) {
114 m_documentLoadingProgress += m_documentLoadingStep;
115 parent->slotGotProgressInfo(QString(), (int) m_documentLoadingProgress);
116 //qApp->processEvents();
118 QString prodId = e.attribute("id");
119 if (!e.isNull() && prodId != "black" && !prodId.startsWith("slowmotion")) {
120 e.setTagName("producer");
121 addClipInfo(e, prodId);
122 kDebug() << "// NLIVE PROD: " << prodId;
126 QDomNode markers = m_document.elementsByTagName("markers").at(0);
127 if (!markers.isNull()) {
128 QDomNodeList markerslist = markers.childNodes();
129 int maxchild = markerslist.count();
130 for (int k = 0; k < maxchild; k++) {
131 e = markerslist.at(k).toElement();
132 if (e.tagName() == "marker") {
133 m_clipManager->getClipById(e.attribute("id"))->addSnapMarker(GenTime(e.attribute("time").toDouble()), e.attribute("comment"));
136 westley.removeChild(markers);
138 m_document.removeChild(infoXmlNode);
140 kDebug() << "Reading file: " << url.path() << ", found clips: " << producers.count();
142 parent->slotGotProgressInfo(i18n("File %1 is not a Kdenlive project file."), 100);
143 kWarning() << " NO KDENLIVE INFO FOUND IN FILE: " << url.path();
144 m_document = createEmptyDocument(tracks.x(), tracks.y());
145 setProfilePath(profileName);
147 KIO::NetAccess::removeTempFile(tmpFile);
149 KMessageBox::error(parent, KIO::NetAccess::lastErrorString());
150 parent->slotGotProgressInfo(i18n("File %1 is not a Kdenlive project file."), 100);
151 m_document = createEmptyDocument(tracks.x(), tracks.y());
152 setProfilePath(profileName);
155 m_document = createEmptyDocument(tracks.x(), tracks.y());
156 setProfilePath(profileName);
158 m_scenelist = m_document.toString();
159 kDebug() << "KDEnnlive document, init timecode: " << m_fps;
160 if (m_fps == 30000.0 / 1001.0) m_timecode.setFormat(30, true);
161 else m_timecode.setFormat((int) m_fps);
164 connect(m_autoSaveTimer, SIGNAL(timeout()), this, SLOT(slotAutoSave()));
167 KdenliveDoc::~KdenliveDoc() {
168 delete m_commandStack;
169 delete m_clipManager;
170 delete m_autoSaveTimer;
172 m_autosave->remove();
177 QDomDocument KdenliveDoc::createEmptyDocument(const int videotracks, const int audiotracks) {
178 // Creating new document
180 QDomElement westley = doc.createElement("westley");
181 doc.appendChild(westley);
184 TrackInfo videoTrack;
185 videoTrack.type = VIDEOTRACK;
186 videoTrack.isMute = false;
187 videoTrack.isBlind = false;
189 TrackInfo audioTrack;
190 audioTrack.type = AUDIOTRACK;
191 audioTrack.isMute = false;
192 audioTrack.isBlind = true;
194 QDomElement tractor = doc.createElement("tractor");
195 tractor.setAttribute("id", "maintractor");
196 QDomElement multitrack = doc.createElement("multitrack");
197 QDomElement playlist = doc.createElement("playlist");
198 playlist.setAttribute("id", "black_track");
199 westley.appendChild(playlist);
203 int total = audiotracks + videotracks + 1;
205 for (int i = 1; i < total; i++) {
206 QDomElement playlist = doc.createElement("playlist");
207 playlist.setAttribute("id", "playlist" + QString::number(i));
208 westley.appendChild(playlist);
211 QDomElement track0 = doc.createElement("track");
212 track0.setAttribute("producer", "black_track");
213 tractor.appendChild(track0);
215 // create audio tracks
216 for (int i = 1; i < audiotracks + 1; i++) {
217 QDomElement track = doc.createElement("track");
218 track.setAttribute("producer", "playlist" + QString::number(i));
219 track.setAttribute("hide", "video");
220 tractor.appendChild(track);
221 m_tracksList.append(audioTrack);
224 // create video tracks
225 for (int i = audiotracks + 1; i < total; i++) {
226 QDomElement track = doc.createElement("track");
227 track.setAttribute("producer", "playlist" + QString::number(i));
228 tractor.appendChild(track);
229 m_tracksList.append(videoTrack);
232 for (uint i = 2; i < total ; i++) {
233 QDomElement transition = doc.createElement("transition");
234 transition.setAttribute("always_active", "1");
236 QDomElement property = doc.createElement("property");
237 property.setAttribute("name", "a_track");
238 QDomText value = doc.createTextNode(QString::number(1));
239 property.appendChild(value);
240 transition.appendChild(property);
242 property = doc.createElement("property");
243 property.setAttribute("name", "b_track");
244 value = doc.createTextNode(QString::number(i));
245 property.appendChild(value);
246 transition.appendChild(property);
248 property = doc.createElement("property");
249 property.setAttribute("name", "mlt_service");
250 value = doc.createTextNode("mix");
251 property.appendChild(value);
252 transition.appendChild(property);
254 property = doc.createElement("property");
255 property.setAttribute("name", "combine");
256 value = doc.createTextNode("1");
257 property.appendChild(value);
258 transition.appendChild(property);
260 property = doc.createElement("property");
261 property.setAttribute("name", "internal_added");
262 value = doc.createTextNode("237");
263 property.appendChild(value);
264 transition.appendChild(property);
265 tractor.appendChild(transition);
267 westley.appendChild(tractor);
272 void KdenliveDoc::syncGuides(QList <Guide *> guides) {
276 m_guidesXml = doc.createElement("guides");
278 for (int i = 0; i < guides.count(); i++) {
279 e = doc.createElement("guide");
280 e.setAttribute("time", guides.at(i)->position().ms() / 1000);
281 e.setAttribute("comment", guides.at(i)->label());
282 m_guidesXml.appendChild(e);
284 emit guidesUpdated();
287 QDomElement KdenliveDoc::guidesXml() const {
291 void KdenliveDoc::slotAutoSave() {
292 if (m_render && m_autosave) {
293 if (!m_autosave->isOpen() && !m_autosave->open(QIODevice::ReadWrite)) {
294 // show error: could not open the autosave file
295 kDebug() << "ERROR; CANNOT CREATE AUTOSAVE FILE";
297 kDebug() << "// AUTOSAVE FILE: " << m_autosave->fileName();
299 doc.setContent(m_render->sceneList());
300 saveSceneList(m_autosave->fileName(), doc);
304 void KdenliveDoc::setZoom(int factor) {
308 int KdenliveDoc::zoom() const {
312 void KdenliveDoc::convertDocument(double version) {
313 kDebug() << "Opening a document with version " << version;
314 if (version == 0.8) {
315 // Add the tracks information
317 QDomNodeList tracks = m_document.elementsByTagName("track");
318 int max = tracks.count();
319 for (int i = 0; i < max; i++) {
320 QDomElement t = tracks.at(i).toElement();
321 if (t.attribute("hide") == "video") tracksOrder.append('a');
322 else tracksOrder.append('v');
324 QDomNode kdenlivedoc = m_document.elementsByTagName("kdenlivedoc").at(0);
325 QDomElement infoXml = kdenlivedoc.toElement();
326 QString currentTrackOrder = infoXml.attribute("tracks");
327 if (currentTrackOrder.isEmpty()) infoXml.setAttribute("tracks", tracksOrder);
332 // Opening a old Kdenlive document
333 if (version == 0.7) {
334 kDebug() << "Unable to open document with version " << version;
335 // TODO: convert 0.7 files to the new document format.
340 QDomNode westley = m_document.elementsByTagName("westley").at(1);
341 QDomNode tractor = m_document.elementsByTagName("tractor").at(0);
342 QDomNode kdenlivedoc = m_document.elementsByTagName("kdenlivedoc").at(0);
343 QDomElement kdenlivedoc_old = kdenlivedoc.cloneNode(true).toElement(); // Needed for folders
344 QDomNode multitrack = m_document.elementsByTagName("multitrack").at(0);
345 QDomNodeList playlists = m_document.elementsByTagName("playlist");
347 //m_startPos = kdenlivedoc.toElement().attribute("timeline_position").toInt();
349 QDomNode props = m_document.elementsByTagName("properties").at(0).toElement();
350 QString profile = props.toElement().attribute("videoprofile");
351 m_startPos = props.toElement().attribute("timeline_position").toInt();
352 if (profile == "dv_wide") profile = "dv_pal_wide";
353 setProfilePath(profile);
355 // move playlists outside of tractor and add the tracks instead
356 int max = playlists.count();
357 for (int i = 0; i < max; i++) {
358 QDomNode n = playlists.at(i);
359 westley.insertBefore(n, QDomNode());
360 QDomElement pl = n.toElement();
361 QDomElement track = m_document.createElement("track");
362 QString trackType = pl.attribute("hide");
363 if (!trackType.isEmpty()) {
364 track.setAttribute("hide", trackType);
365 if (trackType == "video") tracksOrder.append('a');
366 else tracksOrder.append('v');
367 } else tracksOrder.append('v');
368 QString playlist_id = pl.attribute("id");
369 if (playlist_id.isEmpty()) {
370 playlist_id = "black_track";
371 pl.setAttribute("id", playlist_id);
373 track.setAttribute("producer", playlist_id);
374 //tractor.appendChild(track);
375 #define KEEP_TRACK_ORDER 1
376 #ifdef KEEP_TRACK_ORDER
377 tractor.insertAfter(track, QDomNode());
379 // Insert the new track in an order that hopefully matches the 3 video, then 2 audio tracks of Kdenlive 0.7.0
380 // insertion sort - O( tracks*tracks )
381 // Note, this breaks _all_ transitions - but you can move them up and down afterwards.
382 QDomElement tractor_elem = tractor.toElement();
383 if (! tractor_elem.isNull()) {
384 QDomNodeList tracks = tractor_elem.elementsByTagName("track");
385 int size = tracks.size();
387 tractor.insertAfter(track, QDomNode());
389 bool inserted = false;
390 for (int i = 0; i < size; ++i) {
391 QDomElement track_elem = tracks.at(i).toElement();
392 if (track_elem.isNull()) {
393 tractor.insertAfter(track, QDomNode());
397 kDebug() << "playlist_id: " << playlist_id << " producer:" << track_elem.attribute("producer");
398 if (playlist_id < track_elem.attribute("producer")) {
399 tractor.insertBefore(track, track_elem);
405 // Reach here, no insertion, insert last
407 tractor.insertAfter(track, QDomNode());
411 kWarning() << "tractor was not a QDomElement";
412 tractor.insertAfter(track, QDomNode());
416 tractor.removeChild(multitrack);
418 //Â audio track mixing transitions should not be added to track view, so add required attribute
419 QDomNodeList transitions = m_document.elementsByTagName("transition");
420 max = transitions.count();
421 for (int i = 0; i < max; i++) {
422 QDomElement tr = transitions.at(i).toElement();
423 if (tr.attribute("combine") == "1" && tr.attribute("mlt_service") == "mix") {
424 QDomElement property = m_document.createElement("property");
425 property.setAttribute("name", "internal_added");
426 QDomText value = m_document.createTextNode("237");
427 property.appendChild(value);
428 tr.appendChild(property);
430 // convert transition
431 QDomNamedNodeMap attrs = tr.attributes();
432 for (unsigned int j = 0; j < attrs.count(); j++) {
433 QString attrName = attrs.item(j).nodeName();
434 if (attrName != "in" && attrName != "out" && attrName != "id") {
435 QDomElement property = m_document.createElement("property");
436 property.setAttribute("name", attrName);
437 QDomText value = m_document.createTextNode(attrs.item(j).nodeValue());
438 property.appendChild(value);
439 tr.appendChild(property);
445 //Â move transitions after tracks
446 for (int i = 0; i < max; i++) {
447 tractor.insertAfter(transitions.at(0), QDomNode());
450 // Fix filters format
451 QDomNodeList entries = m_document.elementsByTagName("entry");
452 max = entries.count();
453 for (int i = 0; i < max; i++) {
456 QDomNode m = entries.at(i).firstChild();
457 while (!m.isNull()) {
458 if (m.toElement().tagName() == "filter") {
459 QDomElement filt = m.toElement();
460 QDomNamedNodeMap attrs = filt.attributes();
461 QString current_id = filt.attribute("kdenlive_id");
462 if (current_id != last_id) {
464 last_id = current_id;
466 QDomElement e = m_document.createElement("property");
467 e.setAttribute("name", "kdenlive_ix");
468 QDomText value = m_document.createTextNode(QString::number(effectix));
469 e.appendChild(value);
471 for (int j = 0; j < attrs.count(); j++) {
472 QDomAttr a = attrs.item(j).toAttr();
474 kDebug() << " FILTER; adding :" << a.name() << ":" << a.value();
475 QDomElement e = m_document.createElement("property");
476 e.setAttribute("name", a.name());
477 QDomText value = m_document.createTextNode(a.value());
478 e.appendChild(value);
489 QDomNodeList filters = m_document.elementsByTagName("filter");
490 max = filters.count();
493 for (int i = 0; i < max; i++) {
494 QDomElement filt = filters.at(i).toElement();
495 QDomNamedNodeMap attrs = filt.attributes();
496 QString current_id = filt.attribute("kdenlive_id");
497 if (current_id != last_id) {
499 last_id = current_id;
501 QDomElement e = m_document.createElement("property");
502 e.setAttribute("name", "kdenlive_ix");
503 QDomText value = m_document.createTextNode(QString::number(1));
504 e.appendChild(value);
506 for (int j = 0; j < attrs.count(); j++) {
507 QDomAttr a = attrs.item(j).toAttr();
509 kDebug() << " FILTER; adding :" << a.name() << ":" << a.value();
510 QDomElement e = m_document.createElement("property");
511 e.setAttribute("name", a.name());
512 QDomText value = m_document.createTextNode(a.value());
513 e.appendChild(value);
520 QDomNodeList producers = westley.toElement().elementsByTagName("producer");
521 max = producers.count();
522 for (int i = 0; i < max; i++) {
523 QDomElement prod = producers.at(i).toElement();
524 if (prod.attribute("mlt_service") == "framebuffer") {
525 QString slowmotionprod = prod.attribute("resource");
526 slowmotionprod.replace(':', '?');
527 kDebug() << "// FOUND WRONG SLOWMO, new: " << slowmotionprod;
528 prod.setAttribute("resource", slowmotionprod);
531 //Â move producers to correct place, markers to a global list, fix clip descriptions
532 QDomElement markers = m_document.createElement("markers");
533 // This will get the westley producers:
534 producers = m_document.elementsByTagName("producer");
535 max = producers.count();
536 for (int i = 0; i < max; i++) {
537 QDomElement prod = producers.at(0).toElement();
538 // add resource also as a property (to allow path correction in setNewResource())
539 // TODO: will it work with slowmotion? needs testing
540 if (!prod.attribute("resource").isEmpty()) {
541 QDomElement prop_resource = m_document.createElement("property");
542 prop_resource.setAttribute("name", "resource");
543 QDomText resource = m_document.createTextNode(prod.attribute("resource"));
544 prop_resource.appendChild(resource);
545 prod.appendChild(prop_resource);
547 QDomNode m = prod.firstChild();
549 if (m.toElement().tagName() == "markers") {
550 QDomNodeList prodchilds = m.childNodes();
551 int maxchild = prodchilds.count();
552 for (int k = 0; k < maxchild; k++) {
553 QDomElement mark = prodchilds.at(0).toElement();
554 mark.setAttribute("id", prod.attribute("id"));
555 markers.insertAfter(mark, QDomNode());
558 } else if (prod.attribute("type").toInt() == TEXT) {
559 // convert title clip
560 if (m.toElement().tagName() == "textclip") {
562 QDomElement titleclip = m.toElement();
563 QDomElement title = tdoc.createElement("kdenlivetitle");
564 tdoc.appendChild(title);
565 QDomNodeList objects = titleclip.childNodes();
566 int maxchild = objects.count();
567 for (int k = 0; k < maxchild; k++) {
569 QDomElement ob = objects.at(k).toElement();
570 if (ob.attribute("type") == "3") {
571 // text object - all of this goes into "xmldata"...
572 QDomElement item = tdoc.createElement("item");
573 item.setAttribute("z-index", ob.attribute("z"));
574 item.setAttribute("type", "QGraphicsTextItem");
575 QDomElement position = tdoc.createElement("position");
576 position.setAttribute("x", ob.attribute("x"));
577 position.setAttribute("y", ob.attribute("y"));
578 QDomElement content = tdoc.createElement("content");
579 content.setAttribute("font", ob.attribute("font_family"));
580 content.setAttribute("font-size", ob.attribute("font_size"));
581 content.setAttribute("font-bold", ob.attribute("bold"));
582 content.setAttribute("font-italic", ob.attribute("italic"));
583 content.setAttribute("font-underline", ob.attribute("underline"));
584 QString col = ob.attribute("color");
586 content.setAttribute("font-color", colorToString(c));
587 // todo: These fields are missing from the newly generated xmldata:
588 // transform, startviewport, endviewport, background
590 QDomText conttxt = tdoc.createTextNode(ob.attribute("text"));
591 content.appendChild(conttxt);
592 item.appendChild(position);
593 item.appendChild(content);
594 title.appendChild(item);
595 } else if (ob.attribute("type") == "5") {
597 QDomElement item = tdoc.createElement("item");
598 item.setAttribute("z-index", ob.attribute("z"));
599 item.setAttribute("type", "QGraphicsRectItem");
600 QDomElement position = tdoc.createElement("position");
601 position.setAttribute("x", ob.attribute("x"));
602 position.setAttribute("y", ob.attribute("y"));
603 QDomElement content = tdoc.createElement("content");
604 QString col = ob.attribute("color");
606 content.setAttribute("brushcolor", colorToString(c));
607 QString rect = "0,0,";
608 rect.append(ob.attribute("width"));
610 rect.append(ob.attribute("height"));
611 content.setAttribute("rect", rect);
612 item.appendChild(position);
613 item.appendChild(content);
614 title.appendChild(item);
617 prod.setAttribute("xmldata", tdoc.toString());
618 // mbd todo: This clearly does not work, as every title gets the same name - trying to leave it empty
619 // QStringList titleInfo = TitleWidget::getFreeTitleInfo(projectFolder());
620 // prod.setAttribute("titlename", titleInfo.at(0));
621 // prod.setAttribute("resource", titleInfo.at(1));
622 //kDebug()<<"TITLE DATA:\n"<<tdoc.toString();
624 } // End conversion of title clips.
626 } else if (m.isText()) {
627 QString comment = m.nodeValue();
628 if (!comment.isEmpty()) {
629 prod.setAttribute("description", comment);
634 int duration = prod.attribute("duration").toInt();
635 if (duration > 0) prod.setAttribute("out", QString::number(duration));
636 // The clip goes back in, but text clips should not go back in, at least not modified
637 westley.insertBefore(prod, QDomNode());
641 QDomNode westley0 = m_document.elementsByTagName("westley").at(0);
642 if (!markers.firstChild().isNull()) westley0.appendChild(markers);
645 // Convert as much of the kdenlivedoc as possible. Use the producer in westley
646 // First, remove the old stuff from westley, and add a new empty one
647 // Also, track the max id in order to use it for the adding of groups/folders
648 int max_kproducer_id = 0;
649 westley0.removeChild(kdenlivedoc);
650 QDomElement kdenlivedoc_new = m_document.createElement("kdenlivedoc");
651 kdenlivedoc_new.setAttribute("profile", profile);
652 kdenlivedoc_new.setAttribute("tracks", tracksOrder);
653 // Add all the producers that has a ressource in westley
654 QDomElement westley_element = westley0.toElement();
655 if (westley_element.isNull()) {
656 kWarning() << "westley0 element in document was not a QDomElement - unable to add producers to new kdenlivedoc";
658 QDomNodeList wproducers = westley_element.elementsByTagName("producer");
659 int kmax = wproducers.count();
660 for (int i = 0; i < kmax; i++) {
661 QDomElement wproducer = wproducers.at(i).toElement();
662 if (wproducer.isNull()) {
663 kWarning() << "Found producer in westley0, that was not a QDomElement";
665 // We have to do slightly different things, depending on the type
666 kDebug() << "Converting producer element with type" << wproducer.attribute("type");
667 if (wproducer.attribute("type").toInt() == TEXT) {
668 kDebug() << "Found TEXT element in producer" << endl;
669 QDomElement kproducer = wproducer.cloneNode(true).toElement();
670 kproducer.setTagName("kdenlive_producer");
671 kdenlivedoc_new.appendChild(kproducer);
672 // TODO: Perhaps needs some more changes here to "frequency", aspect ratio as a float, frame_size, channels, and later, ressource and title name
674 QDomElement kproducer = m_document.createElement("kdenlive_producer");
675 kproducer.setAttribute("id", wproducer.attribute("id"));
676 if (!wproducer.attribute("description").isEmpty())
677 kproducer.setAttribute("description", wproducer.attribute("description"));
678 kproducer.setAttribute("resource", wproducer.attribute("resource"));
679 kproducer.setAttribute("type", wproducer.attribute("type"));
680 // Testing fix for 358
681 if (!wproducer.attribute("aspect_ratio").isEmpty()) {
682 kproducer.setAttribute("aspect_ratio", wproducer.attribute("aspect_ratio"));
684 if (!wproducer.attribute("source_fps").isEmpty()) {
685 kproducer.setAttribute("fps", wproducer.attribute("source_fps"));
687 if (!wproducer.attribute("length").isEmpty()) {
688 kproducer.setAttribute("duration", wproducer.attribute("length"));
690 kdenlivedoc_new.appendChild(kproducer);
692 if (wproducer.attribute("id").toInt() > max_kproducer_id) {
693 max_kproducer_id = wproducer.attribute("id").toInt();
698 #define LOOKUP_FOLDER 1
700 // Look through all the folder elements of the old doc, for each folder, for each producer,
701 // get the id, look it up in the new doc, set the groupname and groupid
702 // Note, this does not work at the moment - at least one folders shows up missing, and clips with no folder
704 // QDomElement kdenlivedoc_old = kdenlivedoc.toElement();
705 if (!kdenlivedoc_old.isNull()) {
706 QDomNodeList folders = kdenlivedoc_old.elementsByTagName("folder");
707 int fsize = folders.size();
708 int groupId = max_kproducer_id + 1; // Start at +1 of max id of the kdenlive_producers
709 for (int i = 0; i < fsize; ++i) {
710 QDomElement folder = folders.at(i).toElement();
711 if (!folder.isNull()) {
712 QString groupName = folder.attribute("name");
713 kDebug() << "groupName: " << groupName << " with groupId: " << groupId;
714 QDomNodeList fproducers = folder.elementsByTagName("producer");
715 int psize = fproducers.size();
716 for (int j = 0; j < psize; ++j) {
717 QDomElement fproducer = fproducers.at(j).toElement();
718 if (!fproducer.isNull()) {
719 QString id = fproducer.attribute("id");
720 // This is not very effective, but compared to loading the clips, its a breeze
721 QDomNodeList kdenlive_producers = kdenlivedoc_new.elementsByTagName("kdenlive_producer");
722 int kpsize = kdenlive_producers.size();
723 for (int k = 0; k < kpsize; ++k) {
724 QDomElement kproducer = kdenlive_producers.at(k).toElement(); // Its an element for sure
725 if (id == kproducer.attribute("id")) {
726 // We do not check that it already is part of a folder
727 kproducer.setAttribute("groupid", groupId);
728 kproducer.setAttribute("groupname", groupName);
739 westley0.appendChild(kdenlivedoc_new);
741 QDomNodeList elements = westley.childNodes();
742 max = elements.count();
743 for (int i = 0; i < max; i++) {
744 QDomElement prod = elements.at(0).toElement();
745 westley0.insertAfter(prod, QDomNode());
748 westley0.removeChild(westley);
750 // experimental and probably slow
751 // adds <avfile /> information to <kdenlive_producer />
752 QDomNodeList kproducers = m_document.elementsByTagName("kdenlive_producer");
753 QDomNodeList avfiles = kdenlivedoc_old.elementsByTagName("avfile");
754 kDebug() << "found" << avfiles.count() << "<avfile />s and" << kproducers.count() << "<kdenlive_producer />s";
755 for (int i = 0; i < avfiles.count(); ++i) {
756 QDomElement avfile = avfiles.at(i).toElement();
757 QDomElement kproducer = QDomElement();
759 kWarning() << "found an <avfile /> that is not a QDomElement";
761 QString id = avfile.attribute("id");
762 // this is horrible, must be rewritten, it's just for test
763 for (int j = 0; j < kproducers.count(); ++j) {
764 //kDebug() << "checking <kdenlive_producer /> with id" << kproducers.at(j).toElement().attribute("id");
765 if (kproducers.at(j).toElement().attribute("id") == id) {
766 kproducer = kproducers.at(j).toElement();
770 if (kproducer == QDomElement())
771 kWarning() << "no match for <avfile /> with id =" << id;
773 //kDebug() << "ready to set additional <avfile />'s attributes (id =" << id << ")";
774 kproducer.setAttribute("channels", avfile.attribute("channels"));
775 kproducer.setAttribute("duration", avfile.attribute("duration"));
776 kproducer.setAttribute("frame_size", avfile.attribute("width") + "x" + avfile.attribute("height"));
777 kproducer.setAttribute("frequency", avfile.attribute("frequency"));
778 if (kproducer.attribute("description").isEmpty() && !avfile.attribute("description").isEmpty())
779 kproducer.setAttribute("description", avfile.attribute("description"));
784 //kDebug() << "///////////////// CONVERTEDÂ DOC:";
785 //kDebug() << m_document.toString();
787 QFile file( "converted.kdenlive" );
788 if ( file.open( QIODevice::WriteOnly ) ) {
789 QTextStream stream( &file );
790 stream << m_document.toString();
793 kDebug() << "Unable to dump file to converted.kdenlive";
796 //kDebug() << "///////////////// END CONVERTEDÂ DOC:";
799 QString KdenliveDoc::colorToString(const QColor& c) {
800 QString ret = "%1,%2,%3,%4";
801 ret = ret.arg(c.red()).arg(c.green()).arg(c.blue()).arg(c.alpha());
805 bool KdenliveDoc::saveSceneList(const QString &path, QDomDocument sceneList) {
806 QDomNode wes = sceneList.elementsByTagName("westley").at(0);
808 QDomElement addedXml = sceneList.createElement("kdenlivedoc");
809 QDomElement markers = sceneList.createElement("markers");
810 addedXml.setAttribute("version", "0.8");
811 addedXml.setAttribute("profile", profilePath());
812 addedXml.setAttribute("position", m_render->seekPosition().frames(m_fps));
813 addedXml.setAttribute("tracks", getTracksInfo());
814 addedXml.setAttribute("zoom", m_zoom);
817 QList <DocClipBase*> list = m_clipManager->documentClipList();
818 for (int i = 0; i < list.count(); i++) {
819 e = list.at(i)->toXML();
820 e.setTagName("kdenlive_producer");
821 addedXml.appendChild(sceneList.importNode(e, true));
822 QList < CommentedTime > marks = list.at(i)->commentedSnapMarkers();
823 for (int j = 0; j < marks.count(); j++) {
824 QDomElement marker = sceneList.createElement("marker");
825 marker.setAttribute("time", marks.at(j).time().ms() / 1000);
826 marker.setAttribute("comment", marks.at(j).comment());
827 marker.setAttribute("id", e.attribute("id"));
828 markers.appendChild(marker);
831 addedXml.appendChild(markers);
832 if (!m_guidesXml.isNull()) addedXml.appendChild(sceneList.importNode(m_guidesXml, true));
834 wes.appendChild(addedXml);
835 //wes.appendChild(doc.importNode(kdenliveData, true));
838 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
839 kWarning() << "////// ERROR writing to file: " << path;
840 KMessageBox::error(kapp->activeWindow(), i18n("Cannot write to file %1", path));
843 QTextStream out(&file);
844 out << sceneList.toString();
849 ClipManager *KdenliveDoc::clipManager() {
850 return m_clipManager;
853 KUrl KdenliveDoc::projectFolder() const {
854 if (m_projectFolder.isEmpty()) return KUrl(KStandardDirs::locateLocal("appdata", "/projects/"));
855 return m_projectFolder;
858 QString KdenliveDoc::profilePath() const {
859 return m_profile.path;
862 MltVideoProfile KdenliveDoc::mltProfile() const {
866 void KdenliveDoc::setProfilePath(QString path) {
867 if (path.isEmpty()) path = KdenliveSettings::default_profile();
868 if (path.isEmpty()) path = "dv_pal";
869 m_profile = ProfilesDialog::getVideoProfile(path);
870 KdenliveSettings::setProject_display_ratio((double) m_profile.display_aspect_num / m_profile.display_aspect_den);
871 m_fps = (double) m_profile.frame_rate_num / m_profile.frame_rate_den;
872 m_width = m_profile.width;
873 m_height = m_profile.height;
874 kDebug() << "KDEnnlive document, init timecode from path: " << path << ", " << m_fps;
875 if (m_fps == 30000.0 / 1001.0) m_timecode.setFormat(30, true);
876 else m_timecode.setFormat((int) m_fps);
879 const double KdenliveDoc::dar() {
880 return (double) m_profile.display_aspect_num / m_profile.display_aspect_den;
883 void KdenliveDoc::setThumbsProgress(const QString &message, int progress) {
884 emit progressInfo(message, progress);
887 void KdenliveDoc::loadingProgressed() {
888 m_documentLoadingProgress += m_documentLoadingStep;
889 emit progressInfo(QString(), (int) m_documentLoadingProgress);
892 QUndoStack *KdenliveDoc::commandStack() {
893 return m_commandStack;
896 void KdenliveDoc::setRenderer(Render *render) {
897 if (m_render) return;
899 emit progressInfo(i18n("Loading playlist..."), 0);
900 //qApp->processEvents();
902 m_render->setSceneList(m_document.toString(), m_startPos);
903 kDebug() << "// SETTING SCENE LIST:\n\n" << m_document.toString();
906 emit progressInfo(QString(), -1);
909 void KdenliveDoc::checkProjectClips() {
910 if (m_render == NULL) return;
911 QList <Mlt::Producer *> prods = m_render->producersList();
915 for (int i = 0; i < prods.count(); i++) {
916 id = prods.at(i)->get("id");
917 prodId = id.section('_', 0, 0);
918 prodTrack = id.section('_', 1, 1);
919 kDebug() << "CHECK PRO CLIP, ID: " << id;
920 DocClipBase *clip = m_clipManager->getClipById(prodId);
921 if (clip) clip->setProducer(prods.at(i));
922 kDebug() << "CHECK PRO CLIP, ID: " << id << " DONE";
923 if (clip && clip->clipType() == TEXT && !QFile::exists(clip->fileURL().path())) {
924 // regenerate text clip image if required
925 kDebug() << "// TITLE: " << clip->getProperty("titlename") << " Preview file: " << clip->getProperty("resource") << " DOES NOT EXIST";
926 QString titlename = clip->getProperty("titlename");
927 QString titleresource;
928 if (titlename.isEmpty()) {
929 QStringList titleInfo = TitleWidget::getFreeTitleInfo(projectFolder());
930 titlename = titleInfo.at(0);
931 titleresource = titleInfo.at(1);
932 clip->setProperty("titlename", titlename);
933 kDebug() << "// New title set to: " << titlename;
935 titleresource = TitleWidget::getTitleResourceFromName(projectFolder(), titlename);
937 QString titlepath = projectFolder().path() + "/titles/";
938 TitleWidget *dia_ui = new TitleWidget(KUrl(), titlepath, m_render, kapp->activeWindow());
940 doc.setContent(clip->getProperty("xmldata"));
942 QPixmap pix = dia_ui->renderedPixmap();
943 pix.save(titleresource);
944 clip->setProperty("resource", titleresource);
946 clip->producer()->set("force_reload", 1);
951 Render *KdenliveDoc::renderer() {
955 void KdenliveDoc::updateClip(const QString &id) {
956 emit updateClipDisplay(id);
959 int KdenliveDoc::getFramePos(QString duration) {
960 return m_timecode.getFrameCount(duration, m_fps);
963 QString KdenliveDoc::producerName(const QString &id) {
964 QString result = "unnamed";
965 QDomNodeList prods = producersList();
966 int ct = prods.count();
967 for (int i = 0; i < ct ; i++) {
968 QDomElement e = prods.item(i).toElement();
969 if (e.attribute("id") != "black" && e.attribute("id") == id) {
970 result = e.attribute("name");
971 if (result.isEmpty()) result = KUrl(e.attribute("resource")).fileName();
978 void KdenliveDoc::setProducerDuration(const QString &id, int duration) {
979 QDomNodeList prods = producersList();
980 int ct = prods.count();
981 for (int i = 0; i < ct ; i++) {
982 QDomElement e = prods.item(i).toElement();
983 if (e.attribute("id") != "black" && e.attribute("id") == id) {
984 e.setAttribute("duration", QString::number(duration));
990 int KdenliveDoc::getProducerDuration(const QString &id) {
992 QDomNodeList prods = producersList();
993 int ct = prods.count();
994 for (int i = 0; i < ct ; i++) {
995 QDomElement e = prods.item(i).toElement();
996 if (e.attribute("id") != "black" && e.attribute("id") == id) {
997 result = e.attribute("duration").toInt();
1005 QDomDocument KdenliveDoc::generateSceneList() {
1007 QDomElement westley = doc.createElement("westley");
1008 doc.appendChild(westley);
1009 QDomElement prod = doc.createElement("producer");
1012 QDomDocument KdenliveDoc::toXml() const {
1016 Timecode KdenliveDoc::timecode() const {
1020 QDomNodeList KdenliveDoc::producersList() {
1021 return m_document.elementsByTagName("producer");
1024 void KdenliveDoc::backupMltPlaylist() {
1025 if (m_render) m_scenelist = m_render->sceneList();
1028 double KdenliveDoc::projectDuration() const {
1029 if (m_render) return GenTime(m_render->getLength(), m_fps).ms() / 1000;
1032 double KdenliveDoc::fps() const {
1036 int KdenliveDoc::width() const {
1040 int KdenliveDoc::height() const {
1044 KUrl KdenliveDoc::url() const {
1048 void KdenliveDoc::setUrl(KUrl url) {
1052 void KdenliveDoc::setModified(bool mod) {
1053 if (!m_url.isEmpty() && mod && KdenliveSettings::crashrecovery()) {
1054 m_autoSaveTimer->start(3000);
1056 if (mod == m_modified) return;
1058 emit docModified(m_modified);
1061 bool KdenliveDoc::isModified() const {
1065 QString KdenliveDoc::description() const {
1066 if (m_url.isEmpty())
1067 return i18n("Untitled") + " / " + m_profile.description;
1069 return m_url.fileName() + " / " + m_profile.description;
1072 void KdenliveDoc::addClip(QDomElement elem, QString clipId, bool createClipItem) {
1073 const QString producerId = clipId.section('_', 0, 0);
1074 int subtrack = clipId.section('_', 1, 1).toInt();
1075 DocClipBase *clip = m_clipManager->getClipById(producerId);
1077 elem.setAttribute("id", producerId);
1078 QString path = elem.attribute("resource");
1080 if (elem.attribute("type").toInt() == SLIDESHOW) {
1081 extension = KUrl(path).fileName();
1082 path = KUrl(path).directory();
1084 if (!path.isEmpty() && !QFile::exists(path)) {
1085 const QString size = elem.attribute("file_size");
1086 const QString hash = elem.attribute("file_hash");
1088 KMessageBox::ButtonCode action = KMessageBox::No;
1089 if (!size.isEmpty() && !hash.isEmpty()) {
1090 if (!m_searchFolder.isEmpty()) newpath = searchFileRecursively(m_searchFolder, size, hash);
1091 else action = (KMessageBox::ButtonCode)KMessageBox::messageBox(kapp->activeWindow(), KMessageBox::WarningYesNo, i18n("<qt>Clip <b>%1</b><br>is invalid, what do you want to do?", path), i18n("File not found"), KGuiItem(i18n("Search automatically")), /*KGuiItem(i18n("Remove from project")), */KGuiItem(i18n("Keep as placeholder")));
1093 if (elem.attribute("type").toInt() == SLIDESHOW) {
1094 if (KMessageBox::messageBox(kapp->activeWindow(), KMessageBox::WarningYesNo, i18n("<qt>Clip <b>%1</b><br>is invalid, what do you want to do?", path), i18n("File not found"), KGuiItem(i18n("Search automatically")), /*KGuiItem(i18n("Remove from project")),*/ KGuiItem(i18n("Keep as placeholder"))) == KMessageBox::Yes)
1095 newpath = KFileDialog::getExistingDirectory(KUrl("kfiledialog:///clipfolder"), kapp->activeWindow(), i18n("Looking for %1", path));
1096 } else newpath = KFileDialog::getOpenFileName(KUrl("kfiledialog:///clipfolder"), QString(), kapp->activeWindow(), i18n("Looking for %1", path));
1098 if (action == KMessageBox::Yes) {
1099 kDebug() << "// ASKED FOR SRCH CLIP: " << clipId;
1100 m_searchFolder = KFileDialog::getExistingDirectory(KUrl("kfiledialog:///clipfolder"), kapp->activeWindow());
1101 if (!m_searchFolder.isEmpty()) {
1102 newpath = searchFileRecursively(QDir(m_searchFolder), size, hash);
1105 if (!newpath.isEmpty()) {
1106 if (elem.attribute("type").toInt() == SLIDESHOW) newpath.append('/' + extension);
1107 elem.setAttribute("resource", newpath);
1108 setNewClipResource(clipId, newpath);
1112 clip = new DocClipBase(m_clipManager, elem, producerId);
1113 m_clipManager->addClip(clip);
1115 if (createClipItem) emit addProjectClip(clip);
1118 void KdenliveDoc::setNewClipResource(const QString &id, const QString &path) {
1119 QDomNodeList prods = m_document.elementsByTagName("producer");
1120 int maxprod = prods.count();
1121 for (int i = 0; i < maxprod; i++) {
1122 QDomNode m = prods.at(i);
1123 QString prodId = m.toElement().attribute("id");
1124 if (prodId == id || prodId.startsWith(id + "_")) {
1125 QDomNodeList params = m.childNodes();
1126 for (int j = 0; j < params.count(); j++) {
1127 QDomElement e = params.item(j).toElement();
1128 if (e.attribute("name") == "resource") {
1129 e.firstChild().setNodeValue(path);
1137 QString KdenliveDoc::searchFileRecursively(const QDir &dir, const QString &matchSize, const QString &matchHash) const {
1138 QString foundFileName;
1139 QByteArray fileData;
1140 QByteArray fileHash;
1141 QStringList filesAndDirs = dir.entryList(QDir::Files | QDir::Readable);
1142 for (int i = 0; i < filesAndDirs.size() && foundFileName.isEmpty(); i++) {
1143 QFile file(dir.absoluteFilePath(filesAndDirs.at(i)));
1144 if (file.open(QIODevice::ReadOnly)) {
1145 if (QString::number(file.size()) == matchSize) {
1147 * 1 MB = 1 second per 450 files (or faster)
1148 * 10 MB = 9 seconds per 450 files (or faster)
1150 if (file.size() > 1000000*2) {
1151 fileData = file.read(1000000);
1152 if (file.seek(file.size() - 1000000))
1153 fileData.append(file.readAll());
1155 fileData = file.readAll();
1157 fileHash = QCryptographicHash::hash(fileData, QCryptographicHash::Md5);
1158 if (QString(fileHash.toHex()) == matchHash)
1159 return file.fileName();
1162 kDebug() << filesAndDirs.at(i) << file.size() << fileHash.toHex();
1164 filesAndDirs = dir.entryList(QDir::Dirs | QDir::Readable | QDir::Executable | QDir::NoDotAndDotDot);
1165 for (int i = 0; i < filesAndDirs.size() && foundFileName.isEmpty(); i++) {
1166 foundFileName = searchFileRecursively(dir.absoluteFilePath(filesAndDirs.at(i)), matchSize, matchHash);
1167 if (!foundFileName.isEmpty())
1170 return foundFileName;
1173 void KdenliveDoc::addClipInfo(QDomElement elem, QString clipId) {
1174 DocClipBase *clip = m_clipManager->getClipById(clipId);
1176 addClip(elem, clipId);
1178 QMap <QString, QString> properties;
1179 QDomNamedNodeMap attributes = elem.attributes();
1181 for (unsigned int i = 0; i < attributes.count(); i++) {
1182 attrname = attributes.item(i).nodeName();
1183 if (attrname != "resource")
1184 properties.insert(attrname, attributes.item(i).nodeValue());
1185 kDebug() << attrname << " = " << attributes.item(i).nodeValue();
1187 clip->setProperties(properties);
1188 emit addProjectClip(clip);
1192 void KdenliveDoc::addFolder(const QString foldername, const QString &clipId, bool edit) {
1193 emit addProjectFolder(foldername, clipId, false, edit);
1196 void KdenliveDoc::deleteFolder(const QString foldername, const QString &clipId) {
1197 emit addProjectFolder(foldername, clipId, true);
1200 void KdenliveDoc::deleteProjectClip(QList <QString> ids) {
1201 for (int i = 0; i < ids.size(); ++i) {
1202 emit deleteTimelineClip(ids.at(i));
1203 m_clipManager->slotDeleteClip(ids.at(i));
1208 void KdenliveDoc::deleteProjectFolder(QMap <QString, QString> map) {
1209 QMapIterator<QString, QString> i(map);
1210 while (i.hasNext()) {
1212 slotDeleteFolder(i.key(), i.value());
1217 void KdenliveDoc::deleteClip(const QString &clipId) {
1218 emit signalDeleteProjectClip(clipId);
1219 m_clipManager->deleteClip(clipId);
1222 void KdenliveDoc::slotAddClipList(const KUrl::List urls, const QString group, const QString &groupId) {
1223 m_clipManager->slotAddClipList(urls, group, groupId);
1224 emit selectLastAddedClip(QString::number(m_clipManager->lastClipId()));
1229 void KdenliveDoc::slotAddClipFile(const KUrl url, const QString group, const QString &groupId) {
1230 kDebug() << "///////// DOCUM, ADD CLP: " << url;
1231 m_clipManager->slotAddClipFile(url, group, groupId);
1232 emit selectLastAddedClip(QString::number(m_clipManager->lastClipId()));
1236 void KdenliveDoc::slotAddFolder(const QString folderName) {
1237 AddFolderCommand *command = new AddFolderCommand(this, folderName, QString::number(m_clipManager->getFreeClipId()), true);
1238 commandStack()->push(command);
1242 void KdenliveDoc::slotDeleteFolder(const QString folderName, const QString &id) {
1243 AddFolderCommand *command = new AddFolderCommand(this, folderName, id, false);
1244 commandStack()->push(command);
1248 void KdenliveDoc::slotEditFolder(const QString newfolderName, const QString oldfolderName, const QString &clipId) {
1249 EditFolderCommand *command = new EditFolderCommand(this, newfolderName, oldfolderName, clipId, false);
1250 commandStack()->push(command);
1254 const QString&KdenliveDoc::getFreeClipId() {
1255 return QString::number(m_clipManager->getFreeClipId());
1258 DocClipBase *KdenliveDoc::getBaseClip(const QString &clipId) {
1259 return m_clipManager->getClipById(clipId);
1262 void KdenliveDoc::slotAddColorClipFile(const QString name, const QString color, QString duration, const QString group, const QString &groupId) {
1263 m_clipManager->slotAddColorClipFile(name, color, duration, group, groupId);
1267 void KdenliveDoc::slotAddSlideshowClipFile(const QString name, const QString path, int count, const QString duration, const bool loop, const bool fade, const QString &luma_duration, const QString &luma_file, const int softness, const QString group, const QString &groupId) {
1268 m_clipManager->slotAddSlideshowClipFile(name, path, count, duration, loop, fade, luma_duration, luma_file, softness, group, groupId);
1272 void KdenliveDoc::slotCreateTextClip(QString group, const QString &groupId) {
1273 QString titlesFolder = projectFolder().path() + "/titles/";
1274 KStandardDirs::makeDir(titlesFolder);
1275 TitleWidget *dia_ui = new TitleWidget(KUrl(), titlesFolder, m_render, kapp->activeWindow());
1276 if (dia_ui->exec() == QDialog::Accepted) {
1277 QStringList titleInfo = TitleWidget::getFreeTitleInfo(projectFolder());
1278 QPixmap pix = dia_ui->renderedPixmap();
1279 pix.save(titleInfo.at(1));
1280 //dia_ui->saveTitle(path + ".kdenlivetitle");
1281 m_clipManager->slotAddTextClipFile(titleInfo.at(0), titleInfo.at(1), dia_ui->xml().toString(), QString(), QString());
1287 int KdenliveDoc::tracksCount() const {
1288 return m_tracksList.count();
1291 TrackInfo KdenliveDoc::trackInfoAt(int ix) const {
1292 return m_tracksList.at(ix);
1295 void KdenliveDoc::switchTrackAudio(int ix, bool hide) {
1296 m_tracksList[ix].isMute = hide; // !m_tracksList.at(ix).isMute;
1299 void KdenliveDoc::switchTrackVideo(int ix, bool hide) {
1300 m_tracksList[ix].isBlind = hide; // !m_tracksList.at(ix).isBlind;
1303 void KdenliveDoc::insertTrack(int ix, TrackInfo type) {
1304 if (ix == -1) m_tracksList << type;
1305 else m_tracksList.insert(ix, type);
1308 void KdenliveDoc::deleteTrack(int ix) {
1309 m_tracksList.removeAt(ix);
1312 void KdenliveDoc::setTrackType(int ix, TrackInfo type) {
1313 m_tracksList[ix].type = type.type;
1314 m_tracksList[ix].isMute = type.isMute;
1315 m_tracksList[ix].isBlind = type.isBlind;
1318 const QList <TrackInfo> KdenliveDoc::tracksList() const {
1319 return m_tracksList;
1322 QPoint KdenliveDoc::getTracksCount() const {
1325 foreach(const TrackInfo &info, m_tracksList) {
1326 if (info.type == VIDEOTRACK) video++;
1329 return QPoint(video, audio);
1332 QString KdenliveDoc::getTracksInfo() const {
1334 foreach(const TrackInfo &info, m_tracksList) {
1335 if (info.type == VIDEOTRACK) result.append('v');
1336 else result.append('a');
1341 #include "kdenlivedoc.moc"