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 ***************************************************************************/
21 #include "trackview.h"
22 #include "definitions.h"
23 #include "headertrack.h"
25 #include "transition.h"
26 #include "kdenlivesettings.h"
27 #include "clipmanager.h"
28 #include "customruler.h"
29 #include "kdenlivedoc.h"
30 #include "mainwindow.h"
31 #include "customtrackview.h"
32 #include "initeffects.h"
35 #include <KMessageBox>
39 TrackView::TrackView(KdenliveDoc *doc, QWidget *parent)
40 : QWidget(parent), m_doc(doc), m_scale(1.0), m_projectTracks(0)
43 view = new Ui::TimeLine_UI();
46 m_scene = new CustomTrackScene(doc);
47 m_trackview = new CustomTrackView(doc, m_scene, parent);
48 m_trackview->scale(1, 1);
49 m_trackview->setAlignment(Qt::AlignLeft | Qt::AlignTop);
50 //m_scene->addRect(QRectF(0, 0, 100, 100), QPen(), QBrush(Qt::red));
52 m_ruler = new CustomRuler(doc->timecode(), m_trackview);
53 connect(m_ruler, SIGNAL(zoneMoved(int, int)), this, SIGNAL(zoneMoved(int, int)));
54 QHBoxLayout *layout = new QHBoxLayout;
55 view->ruler_frame->setLayout(layout);
58 layout->getContentsMargins(&left_margin, 0, &right_margin, 0);
59 layout->setContentsMargins(left_margin, 0, right_margin, 0);
60 layout->addWidget(m_ruler);
62 QHBoxLayout *tracksLayout = new QHBoxLayout;
63 tracksLayout->setContentsMargins(0, 0, 0, 0);
64 view->tracks_frame->setLayout(tracksLayout);
66 view->headers_area->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
67 view->headers_area->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
69 m_headersLayout = new QVBoxLayout;
70 m_headersLayout->setContentsMargins(0, 0, 0, 0);
71 m_headersLayout->setSpacing(0);
72 view->headers_container->setLayout(m_headersLayout);
74 connect(view->headers_area->verticalScrollBar(), SIGNAL(valueChanged(int)), m_trackview->verticalScrollBar(), SLOT(setValue(int)));
76 tracksLayout->addWidget(m_trackview);
78 connect(m_trackview->verticalScrollBar(), SIGNAL(valueChanged(int)), view->headers_area->verticalScrollBar(), SLOT(setValue(int)));
79 connect(m_trackview, SIGNAL(trackHeightChanged()), this, SLOT(slotRebuildTrackHeaders()));
81 parseDocument(m_doc->toXml());
82 m_doc->setSceneList();
83 connect(m_trackview, SIGNAL(cursorMoved(int, int)), m_ruler, SLOT(slotCursorMoved(int, int)));
84 connect(m_trackview->horizontalScrollBar(), SIGNAL(valueChanged(int)), m_ruler, SLOT(slotMoveRuler(int)));
85 connect(m_trackview, SIGNAL(mousePosition(int)), this, SIGNAL(mousePosition(int)));
86 connect(m_trackview, SIGNAL(transitionItemSelected(Transition*, bool)), this, SLOT(slotTransitionItemSelected(Transition*, bool)));
87 connect(m_trackview, SIGNAL(doTrackLock(int, bool)), this, SLOT(slotChangeTrackLock(int, bool)));
89 slotChangeZoom(m_doc->zoom());
90 slotSetZone(m_doc->zone());
94 int TrackView::duration() const
96 return m_trackview->duration();
99 int TrackView::tracksNumber() const
101 return m_projectTracks - 1;
104 int TrackView::inPoint() const
106 return m_ruler->inPoint();
109 int TrackView::outPoint() const
111 return m_ruler->outPoint();
114 void TrackView::slotSetZone(QPoint p)
119 void TrackView::slotTransitionItemSelected(Transition *t, bool update)
121 emit transitionItemSelected(t, update);
124 void TrackView::setDuration(int dur)
126 m_trackview->setDuration(dur);
127 m_ruler->setDuration(dur);
130 void TrackView::parseDocument(QDomDocument doc)
133 m_documentErrors.clear();
134 // kDebug() << "//// DOCUMENT: " << doc.toString();
135 /*QDomNode props = doc.elementsByTagName("properties").item(0);
136 if (!props.isNull()) {
137 cursorPos = props.toElement().attribute("timeline_position").toInt();
140 // parse project tracks
141 QDomElement tractor = doc.elementsByTagName("tractor").item(0).toElement();
142 QDomNodeList tracks = doc.elementsByTagName("track");
143 QDomNodeList playlists = doc.elementsByTagName("playlist");
145 m_projectTracks = tracks.count();
146 int trackduration = 0;
150 int pos = m_projectTracks - 1;
151 m_invalidProducers.clear();
152 QDomNodeList producers = doc.elementsByTagName("producer");
153 for (int i = 0; i < producers.count(); i++) {
154 // CHeck for invalid producers
155 QDomNode n = producers.item(i);
157 if (e.hasAttribute("in") == false && e.hasAttribute("out") == false) continue;
158 int in = e.attribute("in").toInt();
159 int out = e.attribute("out").toInt();
160 if (in > out || in == out) {
161 // invalid producer, remove it
162 QString id = e.attribute("id");
163 m_invalidProducers.append(id);
164 m_documentErrors.append(i18n("Invalid clip producer %1\n", id));
165 doc.documentElement().removeChild(producers.at(i));
170 for (int i = 0; i < m_projectTracks; i++) {
171 e = tracks.item(i).toElement();
172 QString playlist_name = e.attribute("producer");
173 if (playlist_name != "black_track" && playlist_name != "playlistmain") {
174 // find playlist related to this track
176 for (int j = 0; j < m_projectTracks; j++) {
177 p = playlists.item(j).toElement();
178 if (p.attribute("id") == playlist_name) break;
180 if (p.attribute("id") != playlist_name) { // then it didn't work.
181 kDebug() << "NO PLAYLIST FOUND FOR TRACK " + pos;
183 if (e.attribute("hide") == "video") {
184 m_doc->switchTrackVideo(i - 1, true);
185 } else if (e.attribute("hide") == "audio") {
186 m_doc->switchTrackAudio(i - 1, true);
187 } else if (e.attribute("hide") == "both") {
188 m_doc->switchTrackVideo(i - 1, true);
189 m_doc->switchTrackAudio(i - 1, true);
192 trackduration = slotAddProjectTrack(pos, p, m_doc->isTrackLocked(i - 1));
194 //kDebug() << " PRO DUR: " << trackduration << ", TRACK DUR: " << duration;
195 if (trackduration > duration) duration = trackduration;
197 // background black track
198 for (int j = 0; j < m_projectTracks; j++) {
199 p = playlists.item(j).toElement();
200 if (p.attribute("id") == playlist_name) break;
202 int black_clips = p.childNodes().count();
203 for (int i = 0; i < black_clips; i++)
204 m_doc->loadingProgressed();
205 qApp->processEvents();
211 QDomNodeList transitions = doc.elementsByTagName("transition");
213 //kDebug() << "//////////// TIMELINE FOUND: " << projectTransitions << " transitions";
214 for (int i = 0; i < transitions.count(); i++) {
215 e = transitions.item(i).toElement();
216 QDomNodeList transitionparams = e.childNodes();
217 bool transitionAdd = true;
220 bool isAutomatic = false;
221 bool forceTrack = false;
222 QString mlt_geometry;
224 for (int k = 0; k < transitionparams.count(); k++) {
225 p = transitionparams.item(k).toElement();
227 QString paramName = p.attribute("name");
228 // do not add audio mixing transitions
229 if (paramName == "internal_added" && p.text() == "237") {
230 transitionAdd = false;
231 //kDebug() << "// TRANSITRION " << i << " IS NOT VALID (INTERN ADDED)";
233 } else if (paramName == "a_track") a_track = p.text().toInt();
234 else if (paramName == "b_track") b_track = p.text().toInt();
235 else if (paramName == "mlt_service") mlt_service = p.text();
236 else if (paramName == "geometry") mlt_geometry = p.text();
237 else if (paramName == "automatic" && p.text() == "1") isAutomatic = true;
238 else if (paramName == "force_track" && p.text() == "1") forceTrack = true;
241 if (transitionAdd || mlt_service != "mix") {
242 // Transition should be added to the scene
243 ItemInfo transitionInfo;
244 QString transitionId;
245 if (mlt_service == "composite") {
246 // When adding composite transition, check if it is a wipe transition
247 if (mlt_geometry.count(';') == 1) {
248 mlt_geometry.remove(QChar('%'), Qt::CaseInsensitive);
249 mlt_geometry.replace(QChar('x'), QChar(','), Qt::CaseInsensitive);
250 QString start = mlt_geometry.section(';', 0, 0);
251 start = start.section(':', 0, 1);
252 start.replace(QChar(':'), QChar(','), Qt::CaseInsensitive);
253 QString end = mlt_geometry.section('=', 1, 1);
254 end = end.section(':', 0, 1);
255 end.replace(QChar(':'), QChar(','), Qt::CaseInsensitive);
256 start.append(',' + end);
257 QStringList numbers = start.split(',', QString::SkipEmptyParts);
258 bool isWipeTransition = true;
260 for (int i = 0; i < numbers.size(); ++i) {
261 checkNumber = qAbs(numbers.at(i).toInt());
262 if (checkNumber != 0 && checkNumber != 100) {
263 isWipeTransition = false;
267 if (isWipeTransition) transitionId = "wipe";
270 QDomElement base = MainWindow::transitions.getEffectByTag(mlt_service, transitionId).cloneNode().toElement();
272 for (int k = 0; k < transitionparams.count(); k++) {
273 p = transitionparams.item(k).toElement();
275 QString paramName = p.attribute("name");
276 QString paramValue = p.text();
278 QDomNodeList params = base.elementsByTagName("parameter");
279 if (paramName != "a_track" && paramName != "b_track") for (int i = 0; i < params.count(); i++) {
280 QDomElement e = params.item(i).toElement();
281 if (!e.isNull() && e.attribute("tag") == paramName) {
282 if (e.attribute("type") == "double") {
283 QString factor = e.attribute("factor", "1");
285 double val = paramValue.toDouble() * factor.toDouble();
286 paramValue = QString::number(val);
289 e.setAttribute("value", paramValue);
297 doc.appendChild(doc.importNode(base, true));
298 kDebug() << "/////// TRANSITION XML: "<< doc.toString();*/
300 transitionInfo.startPos = GenTime(e.attribute("in").toInt(), m_doc->fps());
301 transitionInfo.endPos = GenTime(e.attribute("out").toInt() + 1, m_doc->fps());
302 transitionInfo.track = m_projectTracks - 1 - b_track;
303 //kDebug() << "/////////////// +++++++++++ ADDING TRANSITION ON TRACK: " << b_track << ", TOTAL TRKA: " << m_projectTracks;
304 if (transitionInfo.startPos >= transitionInfo.endPos) {
305 // invalid transition, remove it.
306 m_documentErrors.append(i18n("Removed invalid transition: %1", e.attribute("id")) + '\n');
307 kDebug() << "///// REMOVED INVALID TRANSITION: " << e.attribute("id");
308 tractor.removeChild(transitions.item(i));
311 Transition *tr = new Transition(transitionInfo, a_track, m_doc->fps(), base, isAutomatic);
312 if (forceTrack) tr->setForcedTrack(true, a_track);
313 m_scene->addItem(tr);
314 if (b_track > 0 && m_doc->isTrackLocked(b_track - 1)) {
315 tr->setItemLocked(true);
322 QDomNodeList guides = doc.elementsByTagName("guide");
323 for (int i = 0; i < guides.count(); i++) {
324 e = guides.item(i).toElement();
325 const QString comment = e.attribute("comment");
326 const GenTime pos = GenTime(e.attribute("time").toDouble());
327 m_trackview->addGuide(pos, comment);
331 QDomNodeList groups = doc.elementsByTagName("group");
332 m_trackview->loadGroups(groups);
334 m_trackview->setDuration(duration);
335 kDebug() << "/////////// TOTAL PROJECT DURATION: " << duration;
336 slotRebuildTrackHeaders();
337 if (!m_documentErrors.isNull()) KMessageBox::sorry(this, m_documentErrors);
338 //m_trackview->setCursorPos(cursorPos);
339 //m_scrollBox->setGeometry(0, 0, 300 * zoomFactor(), m_scrollArea->height());
342 void TrackView::slotDeleteClip(const QString &clipId)
344 m_trackview->deleteClip(clipId);
347 void TrackView::setCursorPos(int pos)
349 m_trackview->setCursorPos(pos);
352 void TrackView::moveCursorPos(int pos)
354 m_trackview->setCursorPos(pos, false);
357 void TrackView::slotChangeZoom(int factor)
359 m_doc->setZoom(factor);
360 m_ruler->setPixelPerMark(factor);
361 m_scale = (double) FRAME_SIZE / m_ruler->comboScale[factor]; // m_ruler->comboScale[m_currentZoom] /
362 m_trackview->setScale(m_scale);
365 int TrackView::fitZoom() const
367 int zoom = (int)((duration() + 20 / m_scale) * FRAME_SIZE / m_trackview->width());
369 for (i = 0; i < 13; i++)
370 if (m_ruler->comboScale[i] > zoom) break;
374 KdenliveDoc *TrackView::document()
379 void TrackView::refresh()
381 m_trackview->viewport()->update();
384 void TrackView::slotRebuildTrackHeaders()
386 QList <TrackInfo> list = m_doc->tracksList();
387 QList<HeaderTrack *> widgets = findChildren<HeaderTrack *>();
388 for (int i = 0; i < widgets.count(); i++)
389 delete widgets.at(i);
390 int max = list.count();
391 for (int i = 0; i < max; i++) {
392 HeaderTrack *header = new HeaderTrack(i, list.at(max - i - 1), this);
393 connect(header, SIGNAL(switchTrackVideo(int)), m_trackview, SLOT(slotSwitchTrackVideo(int)));
394 connect(header, SIGNAL(switchTrackAudio(int)), m_trackview, SLOT(slotSwitchTrackAudio(int)));
395 connect(header, SIGNAL(switchTrackLock(int)), m_trackview, SLOT(slotSwitchTrackLock(int)));
397 connect(header, SIGNAL(deleteTrack(int)), this, SIGNAL(deleteTrack(int)));
398 connect(header, SIGNAL(insertTrack(int)), this, SIGNAL(insertTrack(int)));
399 connect(header, SIGNAL(changeTrack(int)), this, SIGNAL(changeTrack(int)));
400 m_headersLayout->addWidget(header);
402 view->headers_container->adjustSize();
406 int TrackView::slotAddProjectTrack(int ix, QDomElement xml, bool locked)
410 QDomNodeList children = xml.childNodes();
411 for (int nodeindex = 0; nodeindex < children.count(); nodeindex++) {
412 QDomNode n = children.item(nodeindex);
413 QDomElement elem = n.toElement();
414 if (elem.tagName() == "blank") {
415 position += elem.attribute("length").toInt();
416 } else if (elem.tagName() == "entry") {
417 m_doc->loadingProgressed();
418 qApp->processEvents();
420 int in = elem.attribute("in").toInt();
421 int out = elem.attribute("out").toInt();
422 if (in > out || in == out || m_invalidProducers.contains(elem.attribute("producer"))) {
423 m_documentErrors.append(i18n("Invalid clip removed from track %1 at %2\n", ix, position));
424 xml.removeChild(children.at(nodeindex));
428 QString idString = elem.attribute("producer");
429 QString id = idString;
431 if (idString.startsWith("slowmotion")) {
432 id = idString.section(':', 1, 1);
433 speed = idString.section(':', 2, 2).toDouble();
434 } else id = id.section('_', 0, 0);
435 DocClipBase *clip = m_doc->clipManager()->getClipById(id);
438 clipinfo.startPos = GenTime(position, m_doc->fps());
439 clipinfo.endPos = clipinfo.startPos + GenTime(out - in + 1, m_doc->fps());
440 clipinfo.cropStart = GenTime(in, m_doc->fps());
442 //kDebug() << "// INSERTING CLIP: " << in << "x" << out << ", track: " << ix << ", ID: " << id << ", SCALE: " << m_scale << ", FPS: " << m_doc->fps();
443 ClipItem *item = new ClipItem(clip, clipinfo, m_doc->fps(), speed, false);
444 if (idString.endsWith("_video")) item->setVideoOnly(true);
445 else if (idString.endsWith("_audio")) item->setAudioOnly(true);
446 m_scene->addItem(item);
447 if (locked) item->setItemLocked(true);
448 clip->addReference();
449 position += (out - in + 1);
451 // parse clip effects
452 QDomNodeList effects = elem.childNodes();
453 for (int ix = 0; ix < effects.count(); ix++) {
454 QDomElement effect = effects.at(ix).toElement();
455 if (effect.tagName() == "filter") {
456 // add effect to clip
460 QString ladspaEffectFile;
461 // Get effect tag & index
462 for (QDomNode n3 = effect.firstChild(); !n3.isNull(); n3 = n3.nextSibling()) {
463 // parse effect parameters
464 QDomElement effectparam = n3.toElement();
465 if (effectparam.attribute("name") == "tag") {
466 effecttag = effectparam.text();
467 } else if (effectparam.attribute("name") == "kdenlive_id") {
468 effectid = effectparam.text();
469 } else if (effectparam.attribute("name") == "kdenlive_ix") {
470 effectindex = effectparam.text();
471 } else if (effectparam.attribute("name") == "src") {
472 ladspaEffectFile = effectparam.text();
473 if (!QFile::exists(ladspaEffectFile)) {
474 // If the ladspa effect file is missing, recreate it
475 kDebug() << "// MISSING LADSPA FILE: " << ladspaEffectFile;
476 ladspaEffectFile = m_doc->getLadspaFile();
477 effectparam.firstChild().setNodeValue(ladspaEffectFile);
478 kDebug() << "// ... REPLACED WITH: " << ladspaEffectFile;
482 //kDebug() << "+ + CLIP EFF FND: " << effecttag << ", " << effectid << ", " << effectindex;
483 // get effect standard tags
484 QDomElement clipeffect = MainWindow::customEffects.getEffectByTag(QString(), effectid);
485 if (clipeffect.isNull()) clipeffect = MainWindow::videoEffects.getEffectByTag(effecttag, effectid);
486 if (clipeffect.isNull()) clipeffect = MainWindow::audioEffects.getEffectByTag(effecttag, effectid);
487 if (clipeffect.isNull()) {
488 kDebug() << "/// WARNING, EFFECT: " << effecttag << ": " << effectid << " not found, removing it from project";
489 m_documentErrors.append(i18n("Effect %1:%2 not found in MLT, it was removed from this project\n", effecttag, effectid));
490 elem.removeChild(effects.at(ix));
493 QDomElement currenteffect = clipeffect.cloneNode().toElement();
494 currenteffect.setAttribute("kdenlive_ix", effectindex);
495 QDomNodeList clipeffectparams = currenteffect.childNodes();
497 if (MainWindow::videoEffects.hasKeyFrames(currenteffect)) {
498 //kDebug() << " * * * * * * * * * * ** CLIP EFF WITH KFR FND * * * * * * * * * * *";
499 // effect is key-framable, read all effects to retrieve keyframes
503 QDomNodeList params = currenteffect.elementsByTagName("parameter");
504 for (int i = 0; i < params.count(); i++) {
505 QDomElement e = params.item(i).toElement();
506 if (e.attribute("type") == "keyframe") {
507 starttag = e.attribute("starttag", "start");
508 endtag = e.attribute("endtag", "end");
509 factor = e.attribute("factor", "1").toDouble();
514 int effectin = effect.attribute("in").toInt();
515 int effectout = effect.attribute("out").toInt();
516 double startvalue = 0;
518 for (QDomNode n3 = effect.firstChild(); !n3.isNull(); n3 = n3.nextSibling()) {
519 // parse effect parameters
520 QDomElement effectparam = n3.toElement();
521 if (effectparam.attribute("name") == starttag)
522 startvalue = effectparam.text().toDouble() * factor;
523 if (effectparam.attribute("name") == endtag)
524 endvalue = effectparam.text().toDouble() * factor;
526 // add first keyframe
527 keyframes.append(QString::number(effectin) + ':' + QString::number(startvalue) + ';' + QString::number(effectout) + ':' + QString::number(endvalue) + ';');
528 QDomNode lastParsedEffect;
530 QDomNode n2 = effects.at(ix);
531 bool continueParsing = true;
532 for (; !n2.isNull() && continueParsing; n2 = n2.nextSibling()) {
534 QDomElement kfreffect = n2.toElement();
535 int effectout = kfreffect.attribute("out").toInt();
537 for (QDomNode n4 = kfreffect.firstChild(); !n4.isNull(); n4 = n4.nextSibling()) {
538 // parse effect parameters
539 QDomElement subeffectparam = n4.toElement();
540 if (subeffectparam.attribute("name") == "kdenlive_ix" && subeffectparam.text() != effectindex) {
541 //We are not in the same effect, stop parsing
542 lastParsedEffect = n2.previousSibling();
544 continueParsing = false;
546 } else if (subeffectparam.attribute("name") == endtag) {
547 endvalue = subeffectparam.text().toDouble() * factor;
551 if (continueParsing) {
552 keyframes.append(QString::number(effectout) + ':' + QString::number(endvalue) + ';');
557 params = currenteffect.elementsByTagName("parameter");
558 for (int i = 0; i < params.count(); i++) {
559 QDomElement e = params.item(i).toElement();
560 if (e.attribute("type") == "keyframe") e.setAttribute("keyframes", keyframes);
562 if (!continueParsing) {
563 n2 = lastParsedEffect;
566 // Check if effect has in/out points
567 if (effect.hasAttribute("in")) {
568 EffectsList::setParameter(currenteffect, "in", effect.attribute("in"));
570 if (effect.hasAttribute("out")) {
571 EffectsList::setParameter(currenteffect, "out", effect.attribute("out"));
575 // adjust effect parameters
576 for (QDomNode n3 = effect.firstChild(); !n3.isNull(); n3 = n3.nextSibling()) {
577 // parse effect parameters
578 QDomElement effectparam = n3.toElement();
579 QString paramname = effectparam.attribute("name");
580 QString paramvalue = effectparam.text();
583 // try to find this parameter in the effect xml
585 for (int k = 0; k < clipeffectparams.count(); k++) {
586 e = clipeffectparams.item(k).toElement();
587 if (!e.isNull() && e.tagName() == "parameter" && e.attribute("name") == paramname) {
588 double factor = e.attribute("factor", "1").toDouble();
590 e.setAttribute("value", paramvalue.toDouble() * factor);
591 } else e.setAttribute("value", paramvalue);
596 if (effecttag == "ladspa") {
597 //QString ladspaEffectFile = EffectsList::parameter(effect, "src", "property");
599 if (!QFile::exists(ladspaEffectFile)) {
600 // If the ladspa effect file is missing, recreate it
601 initEffects::ladspaEffectFile(ladspaEffectFile, currenteffect.attribute("ladspaid").toInt(), m_trackview->getLadspaParams(currenteffect));
603 currenteffect.setAttribute("src", ladspaEffectFile);
605 item->addEffect(currenteffect, false);
606 item->effectsCounter();
611 // The clip in playlist was not listed in the kdenlive producers,
612 // something went wrong, repair required.
613 kWarning() << "CANNOT INSERT CLIP " << id;
614 int out = elem.attribute("out").toInt();
617 clipinfo.startPos = GenTime(position, m_doc->fps());
618 clipinfo.endPos = clipinfo.startPos + GenTime(out - in + 1, m_doc->fps());
619 clipinfo.cropStart = GenTime(in, m_doc->fps());
621 //kDebug() << "// INSERTING CLIP: " << in << "x" << out << ", track: " << ix << ", ID: " << id << ", SCALE: " << m_scale << ", FPS: " << m_doc->fps();
623 DocClipBase *missingClip = getMissingProducer(id);
625 // We cannot find the producer, something is really wrong, add
626 // placeholder color clip
627 QDomElement producerXml;
628 producerXml.setTagName("producer");
629 producerXml.setAttribute("resource", "0xff0000ff");
630 producerXml.setAttribute("mlt_service", "colour");
631 producerXml.setAttribute("length", "15000");
632 producerXml.setAttribute("id", id);
633 missingClip = new DocClipBase(m_doc->clipManager(), producerXml, id);
634 m_documentErrors.append(i18n("Boken clip producer %1", id) + '\n');
635 } else m_documentErrors.append(i18n("Replaced wrong clip producer %1 with %2", id, missingClip->getId()) + '\n');
636 ClipItem *item = new ClipItem(missingClip, clipinfo, m_doc->fps(), 1.0, false);
637 m_scene->addItem(item);
638 missingClip->addReference();
639 position += (out - in + 1);
641 m_doc->setModified(true);
643 //m_clipList.append(clip);
646 //m_trackDuration = position;
649 //documentTracks.insert(ix, track);
650 kDebug() << "************* ADD DOC TRACK " << ix << ", DURATION: " << position;
655 DocClipBase *TrackView::getMissingProducer(const QString id) const
657 QDomElement missingXml;
658 QDomDocument doc = m_doc->toXml();
659 QString docRoot = doc.documentElement().attribute("root");
660 if (!docRoot.endsWith('/')) docRoot.append('/');
661 QDomNodeList prods = doc.elementsByTagName("producer");
662 int maxprod = prods.count();
663 for (int i = 0; i < maxprod; i++) {
664 QDomNode m = prods.at(i);
665 QString prodId = m.toElement().attribute("id");
667 missingXml = m.toElement();
671 if (missingXml == QDomElement()) return NULL;
673 QDomNodeList params = missingXml.childNodes();
676 for (int j = 0; j < params.count(); j++) {
677 QDomElement e = params.item(j).toElement();
678 if (e.attribute("name") == "resource") {
679 resource = e.firstChild().nodeValue();
680 } else if (e.attribute("name") == "mlt_service") {
681 mlt_service = e.firstChild().nodeValue();
684 resource.prepend(docRoot);
685 DocClipBase *missingClip = NULL;
686 if (!resource.isEmpty())
687 missingClip = m_doc->clipManager()->getClipByResource(resource);
691 QGraphicsScene *TrackView::projectScene()
696 CustomTrackView *TrackView::projectView()
701 void TrackView::setEditMode(const QString & editMode)
703 m_editMode = editMode;
706 const QString & TrackView::editMode() const
711 void TrackView::slotChangeTrackLock(int ix, bool lock)
713 QList<HeaderTrack *> widgets = findChildren<HeaderTrack *>();
714 widgets.at(ix)->setLock(lock);
718 #include "trackview.moc"