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) {
42 view = new Ui::TimeLine_UI();
45 m_scene = new CustomTrackScene(doc);
46 m_trackview = new CustomTrackView(doc, m_scene, parent);
47 m_trackview->scale(1, 1);
48 m_trackview->setAlignment(Qt::AlignLeft | Qt::AlignTop);
49 //m_scene->addRect(QRectF(0, 0, 100, 100), QPen(), QBrush(Qt::red));
51 m_ruler = new CustomRuler(doc->timecode(), m_trackview);
52 connect(m_ruler, SIGNAL(zoneMoved(int, int)), this, SIGNAL(zoneMoved(int, int)));
53 QHBoxLayout *layout = new QHBoxLayout;
54 view->ruler_frame->setLayout(layout);
57 layout->getContentsMargins(&left_margin, 0, &right_margin, 0);
58 layout->setContentsMargins(left_margin, 0, right_margin, 0);
59 layout->addWidget(m_ruler);
61 QHBoxLayout *tracksLayout = new QHBoxLayout;
62 tracksLayout->setContentsMargins(0, 0, 0, 0);
63 view->tracks_frame->setLayout(tracksLayout);
65 view->headers_area->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
66 view->headers_area->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
68 m_headersLayout = new QVBoxLayout;
69 m_headersLayout->setContentsMargins(0, 0, 0, 0);
70 m_headersLayout->setSpacing(0);
71 view->headers_container->setLayout(m_headersLayout);
73 connect(view->headers_area->verticalScrollBar(), SIGNAL(valueChanged(int)), m_trackview->verticalScrollBar(), SLOT(setValue(int)));
75 tracksLayout->addWidget(m_trackview);
77 connect(m_trackview->verticalScrollBar(), SIGNAL(valueChanged(int)), view->headers_area->verticalScrollBar(), SLOT(setValue(int)));
78 connect(m_trackview, SIGNAL(trackHeightChanged()), this, SLOT(slotRebuildTrackHeaders()));
80 parseDocument(m_doc->toXml());
81 m_doc->setSceneList();
82 connect(m_trackview, SIGNAL(cursorMoved(int, int)), m_ruler, SLOT(slotCursorMoved(int, int)));
83 connect(m_trackview->horizontalScrollBar(), SIGNAL(valueChanged(int)), m_ruler, SLOT(slotMoveRuler(int)));
84 connect(m_trackview, SIGNAL(mousePosition(int)), this, SIGNAL(mousePosition(int)));
85 connect(m_trackview, SIGNAL(transitionItemSelected(Transition*, bool)), this, SLOT(slotTransitionItemSelected(Transition*, bool)));
86 connect(m_trackview, SIGNAL(doTrackLock(int, bool)), this, SLOT(slotChangeTrackLock(int, bool)));
88 slotChangeZoom(m_doc->zoom());
89 slotSetZone(m_doc->zone());
93 int TrackView::duration() const {
94 return m_trackview->duration();
97 int TrackView::tracksNumber() const {
98 return m_projectTracks - 1;
101 int TrackView::inPoint() const {
102 return m_ruler->inPoint();
105 int TrackView::outPoint() const {
106 return m_ruler->outPoint();
109 void TrackView::slotSetZone(QPoint p) {
113 void TrackView::slotTransitionItemSelected(Transition *t, bool update) {
114 emit transitionItemSelected(t, update);
117 void TrackView::setDuration(int dur) {
118 m_trackview->setDuration(dur);
119 m_ruler->setDuration(dur);
122 void TrackView::parseDocument(QDomDocument doc) {
124 m_documentErrors.clear();
125 // kDebug() << "//// DOCUMENT: " << doc.toString();
126 /*QDomNode props = doc.elementsByTagName("properties").item(0);
127 if (!props.isNull()) {
128 cursorPos = props.toElement().attribute("timeline_position").toInt();
131 // parse project tracks
132 QDomElement tractor = doc.elementsByTagName("tractor").item(0).toElement();
133 QDomNodeList tracks = doc.elementsByTagName("track");
134 QDomNodeList playlists = doc.elementsByTagName("playlist");
136 m_projectTracks = tracks.count();
137 int trackduration = 0;
141 int pos = m_projectTracks - 1;
142 m_invalidProducers.clear();
143 QDomNodeList producers = doc.elementsByTagName("producer");
144 for (int i = 0; i < producers.count(); i++) {
145 // CHeck for invalid producers
146 QDomNode n = producers.item(i);
148 int in = e.attribute("in").toInt();
149 int out = e.attribute("out").toInt();
150 if (in > out || in == out) {
151 // invalid producer, remove it
152 QString id = e.attribute("id");
153 m_invalidProducers.append(id);
154 m_documentErrors.append(i18n("Invalid clip producer %1\n", id));
155 doc.documentElement().removeChild(producers.at(i));
160 for (int i = 0; i < m_projectTracks; i++) {
161 e = tracks.item(i).toElement();
162 QString playlist_name = e.attribute("producer");
163 if (playlist_name != "black_track" && playlist_name != "playlistmain") {
164 // find playlist related to this track
166 for (int j = 0; j < m_projectTracks; j++) {
167 p = playlists.item(j).toElement();
168 if (p.attribute("id") == playlist_name) break;
170 if (p.attribute("id") != playlist_name) { // then it didn't work.
171 kDebug() << "NO PLAYLIST FOUND FOR TRACK " + pos;
173 if (e.attribute("hide") == "video") {
174 m_doc->switchTrackVideo(i - 1, true);
175 } else if (e.attribute("hide") == "audio") {
176 m_doc->switchTrackAudio(i - 1, true);
177 } else if (e.attribute("hide") == "both") {
178 m_doc->switchTrackVideo(i - 1, true);
179 m_doc->switchTrackAudio(i - 1, true);
181 trackduration = slotAddProjectTrack(pos, p, m_doc->isTrackLocked(i - 1));
183 //kDebug() << " PRO DUR: " << trackduration << ", TRACK DUR: " << duration;
184 if (trackduration > duration) duration = trackduration;
186 // background black track
187 for (int j = 0; j < m_projectTracks; j++) {
188 p = playlists.item(j).toElement();
189 if (p.attribute("id") == playlist_name) break;
191 int black_clips = p.childNodes().count();
192 for (int i = 0; i < black_clips; i++)
193 m_doc->loadingProgressed();
194 qApp->processEvents();
200 QDomNodeList transitions = doc.elementsByTagName("transition");
202 //kDebug() << "//////////// TIMELINE FOUND: " << projectTransitions << " transitions";
203 for (int i = 0; i < transitions.count(); i++) {
204 e = transitions.item(i).toElement();
205 QDomNodeList transitionparams = e.childNodes();
206 bool transitionAdd = true;
209 bool isAutomatic = false;
210 bool forceTrack = false;
211 QString mlt_geometry;
213 for (int k = 0; k < transitionparams.count(); k++) {
214 p = transitionparams.item(k).toElement();
216 QString paramName = p.attribute("name");
217 // do not add audio mixing transitions
218 if (paramName == "internal_added" && p.text() == "237") {
219 transitionAdd = false;
220 //kDebug() << "// TRANSITRION " << i << " IS NOT VALID (INTERN ADDED)";
222 } else if (paramName == "a_track") a_track = p.text().toInt();
223 else if (paramName == "b_track") b_track = p.text().toInt();
224 else if (paramName == "mlt_service") mlt_service = p.text();
225 else if (paramName == "geometry") mlt_geometry = p.text();
226 else if (paramName == "automatic" && p.text() == "1") isAutomatic = true;
227 else if (paramName == "force_track" && p.text() == "1") forceTrack = true;
230 if (transitionAdd || mlt_service != "mix") {
231 // Transition should be added to the scene
232 ItemInfo transitionInfo;
233 QString transitionId;
234 if (mlt_service == "composite") {
235 // When adding composite transition, check if it is a wipe transition
236 if (mlt_geometry.count(';') == 1) {
237 mlt_geometry.remove(QChar('%'), Qt::CaseInsensitive);
238 mlt_geometry.replace(QChar('x'), QChar(','), Qt::CaseInsensitive);
239 QString start = mlt_geometry.section(';', 0, 0);
240 start = start.section(':', 0, 1);
241 start.replace(QChar(':'), QChar(','), Qt::CaseInsensitive);
242 QString end = mlt_geometry.section('=', 1, 1);
243 end = end.section(':', 0, 1);
244 end.replace(QChar(':'), QChar(','), Qt::CaseInsensitive);
245 start.append(',' + end);
246 QStringList numbers = start.split(',', QString::SkipEmptyParts);
247 bool isWipeTransition = true;
249 for (int i = 0; i < numbers.size(); ++i) {
250 checkNumber = qAbs(numbers.at(i).toInt());
251 if (checkNumber != 0 && checkNumber != 100) {
252 isWipeTransition = false;
256 if (isWipeTransition) transitionId = "wipe";
259 QDomElement base = MainWindow::transitions.getEffectByTag(mlt_service, transitionId).cloneNode().toElement();
261 for (int k = 0; k < transitionparams.count(); k++) {
262 p = transitionparams.item(k).toElement();
264 QString paramName = p.attribute("name");
265 QString paramValue = p.text();
267 QDomNodeList params = base.elementsByTagName("parameter");
268 if (paramName != "a_track" && paramName != "b_track") for (int i = 0; i < params.count(); i++) {
269 QDomElement e = params.item(i).toElement();
270 if (!e.isNull() && e.attribute("tag") == paramName) {
271 if (e.attribute("type") == "double") {
272 QString factor = e.attribute("factor", "1");
274 double val = paramValue.toDouble() * factor.toDouble();
275 paramValue = QString::number(val);
278 e.setAttribute("value", paramValue);
286 doc.appendChild(doc.importNode(base, true));
287 kDebug() << "/////// TRANSITION XML: "<< doc.toString();*/
289 transitionInfo.startPos = GenTime(e.attribute("in").toInt(), m_doc->fps());
290 transitionInfo.endPos = GenTime(e.attribute("out").toInt() + 1, m_doc->fps());
291 transitionInfo.track = m_projectTracks - 1 - b_track;
292 //kDebug() << "/////////////// +++++++++++ ADDING TRANSITION ON TRACK: " << b_track << ", TOTAL TRKA: " << m_projectTracks;
293 if (transitionInfo.startPos >= transitionInfo.endPos) {
294 // invalid transition, remove it.
295 m_documentErrors.append(i18n("Removed invalid transition: %1", e.attribute("id")) + '\n');
296 kDebug() << "///// REMOVED INVALID TRANSITION: " << e.attribute("id");
297 tractor.removeChild(transitions.item(i));
300 Transition *tr = new Transition(transitionInfo, a_track, m_doc->fps(), base, isAutomatic);
301 if (forceTrack) tr->setForcedTrack(true, a_track);
302 m_scene->addItem(tr);
303 if (m_doc->isTrackLocked(b_track - 1)) {
304 tr->setItemLocked(true);
311 QDomNodeList guides = doc.elementsByTagName("guide");
312 for (int i = 0; i < guides.count(); i++) {
313 e = guides.item(i).toElement();
314 const QString comment = e.attribute("comment");
315 const GenTime pos = GenTime(e.attribute("time").toDouble());
316 m_trackview->addGuide(pos, comment);
319 m_trackview->setDuration(duration);
320 kDebug() << "/////////// TOTAL PROJECT DURATION: " << duration;
321 slotRebuildTrackHeaders();
322 if (!m_documentErrors.isNull()) KMessageBox::sorry(this, m_documentErrors);
323 //m_trackview->setCursorPos(cursorPos);
324 //m_scrollBox->setGeometry(0, 0, 300 * zoomFactor(), m_scrollArea->height());
327 void TrackView::slotDeleteClip(const QString &clipId) {
328 m_trackview->deleteClip(clipId);
331 void TrackView::setCursorPos(int pos) {
332 m_trackview->setCursorPos(pos);
335 void TrackView::moveCursorPos(int pos) {
336 m_trackview->setCursorPos(pos, false);
339 void TrackView::slotChangeZoom(int factor) {
340 m_doc->setZoom(factor);
341 m_ruler->setPixelPerMark(factor);
342 m_scale = (double) FRAME_SIZE / m_ruler->comboScale[factor]; // m_ruler->comboScale[m_currentZoom] /
343 m_trackview->setScale(m_scale);
346 int TrackView::fitZoom() const {
347 int zoom = (int)((duration() + 20 / m_scale) * FRAME_SIZE / m_trackview->width());
349 for (i = 0; i < 13; i++)
350 if (m_ruler->comboScale[i] > zoom) break;
354 KdenliveDoc *TrackView::document() {
358 void TrackView::refresh() {
359 m_trackview->viewport()->update();
362 void TrackView::slotRebuildTrackHeaders() {
363 QList <TrackInfo> list = m_doc->tracksList();
364 QList<HeaderTrack *> widgets = this->findChildren<HeaderTrack *>();
365 for (int i = 0; i < widgets.count(); i++)
366 delete widgets.at(i);
367 int max = list.count();
368 for (int i = 0; i < max; i++) {
369 HeaderTrack *header = new HeaderTrack(i, list.at(max - i - 1), this);
370 connect(header, SIGNAL(switchTrackVideo(int)), m_trackview, SLOT(slotSwitchTrackVideo(int)));
371 connect(header, SIGNAL(switchTrackAudio(int)), m_trackview, SLOT(slotSwitchTrackAudio(int)));
372 connect(header, SIGNAL(switchTrackLock(int)), m_trackview, SLOT(slotSwitchTrackLock(int)));
374 connect(header, SIGNAL(deleteTrack(int)), this, SIGNAL(deleteTrack(int)));
375 connect(header, SIGNAL(insertTrack(int)), this, SIGNAL(insertTrack(int)));
376 connect(header, SIGNAL(changeTrack(int)), this, SIGNAL(changeTrack(int)));
377 m_headersLayout->addWidget(header);
379 view->headers_container->adjustSize();
383 int TrackView::slotAddProjectTrack(int ix, QDomElement xml, bool locked) {
386 QDomNodeList children = xml.childNodes();
387 for (int nodeindex = 0; nodeindex < children.count(); nodeindex++) {
388 QDomNode n = children.item(nodeindex);
389 QDomElement elem = n.toElement();
390 if (elem.tagName() == "blank") {
391 position += elem.attribute("length").toInt();
392 } else if (elem.tagName() == "entry") {
393 m_doc->loadingProgressed();
394 qApp->processEvents();
396 int in = elem.attribute("in").toInt();
397 int out = elem.attribute("out").toInt();
398 if (in > out || in == out || m_invalidProducers.contains(elem.attribute("producer"))) {
399 m_documentErrors.append(i18n("Invalid clip removed from track %1 at %2\n", ix, position));
400 xml.removeChild(children.at(nodeindex));
404 QString idString = elem.attribute("producer");
405 QString id = idString;
407 if (idString.startsWith("slowmotion")) {
408 id = idString.section(':', 1, 1);
409 speed = idString.section(':', 2, 2).toDouble();
410 } else id = id.section('_', 0, 0);
411 DocClipBase *clip = m_doc->clipManager()->getClipById(id);
414 clipinfo.startPos = GenTime(position, m_doc->fps());
415 clipinfo.endPos = clipinfo.startPos + GenTime(out - in + 1, m_doc->fps());
416 clipinfo.cropStart = GenTime(in, m_doc->fps());
418 //kDebug() << "// INSERTING CLIP: " << in << "x" << out << ", track: " << ix << ", ID: " << id << ", SCALE: " << m_scale << ", FPS: " << m_doc->fps();
419 ClipItem *item = new ClipItem(clip, clipinfo, m_doc->fps(), speed, false);
420 m_scene->addItem(item);
421 if (locked) item->setItemLocked(true);
422 clip->addReference();
423 position += (out - in + 1);
425 // parse clip effects
426 QDomNodeList effects = elem.childNodes();
427 for (int ix = 0; ix < effects.count(); ix++) {
428 QDomElement effect = effects.at(ix).toElement();
429 if (effect.tagName() == "filter") {
430 // add effect to clip
434 QString ladspaEffectFile;
435 // Get effect tag & index
436 for (QDomNode n3 = effect.firstChild(); !n3.isNull(); n3 = n3.nextSibling()) {
437 // parse effect parameters
438 QDomElement effectparam = n3.toElement();
439 if (effectparam.attribute("name") == "tag") {
440 effecttag = effectparam.text();
441 } else if (effectparam.attribute("name") == "kdenlive_id") {
442 effectid = effectparam.text();
443 } else if (effectparam.attribute("name") == "kdenlive_ix") {
444 effectindex = effectparam.text();
445 } else if (effectparam.attribute("name") == "src") {
446 ladspaEffectFile = effectparam.text();
447 if (!QFile::exists(ladspaEffectFile)) {
448 // If the ladspa effect file is missing, recreate it
449 kDebug() << "// MISSING LADSPA FILE: " << ladspaEffectFile;
450 ladspaEffectFile = m_doc->getLadspaFile();
451 effectparam.firstChild().setNodeValue(ladspaEffectFile);
452 kDebug() << "// ... REPLACED WITH: " << ladspaEffectFile;
456 //kDebug() << "+ + CLIP EFF FND: " << effecttag << ", " << effectid << ", " << effectindex;
457 // get effect standard tags
458 QDomElement clipeffect = MainWindow::customEffects.getEffectByTag(QString(), effectid);
459 if (clipeffect.isNull()) clipeffect = MainWindow::videoEffects.getEffectByTag(effecttag, effectid);
460 if (clipeffect.isNull()) clipeffect = MainWindow::audioEffects.getEffectByTag(effecttag, effectid);
461 if (clipeffect.isNull()) {
462 kDebug() << "/// WARNING, EFFECT: " << effecttag << ": " << effectid << " not found, removing it from project";
463 m_documentErrors.append(i18n("Effect %1:%2 not found in MLT, it was removed from this project\n", effecttag, effectid));
464 elem.removeChild(effects.at(ix));
467 QDomElement currenteffect = clipeffect.cloneNode().toElement();
468 currenteffect.setAttribute("kdenlive_ix", effectindex);
469 QDomNodeList clipeffectparams = currenteffect.childNodes();
471 if (MainWindow::videoEffects.hasKeyFrames(currenteffect)) {
472 //kDebug() << " * * * * * * * * * * ** CLIP EFF WITH KFR FND * * * * * * * * * * *";
473 // effect is key-framable, read all effects to retrieve keyframes
477 QDomNodeList params = currenteffect.elementsByTagName("parameter");
478 for (int i = 0; i < params.count(); i++) {
479 QDomElement e = params.item(i).toElement();
480 if (e.attribute("type") == "keyframe") {
481 starttag = e.attribute("starttag", "start");
482 endtag = e.attribute("endtag", "end");
483 factor = e.attribute("factor", "1").toDouble();
488 int effectin = effect.attribute("in").toInt();
489 int effectout = effect.attribute("out").toInt();
490 double startvalue = 0;
492 for (QDomNode n3 = effect.firstChild(); !n3.isNull(); n3 = n3.nextSibling()) {
493 // parse effect parameters
494 QDomElement effectparam = n3.toElement();
495 if (effectparam.attribute("name") == starttag)
496 startvalue = effectparam.text().toDouble() * factor;
497 if (effectparam.attribute("name") == endtag)
498 endvalue = effectparam.text().toDouble() * factor;
500 // add first keyframe
501 keyframes.append(QString::number(effectin) + ':' + QString::number(startvalue) + ';' + QString::number(effectout) + ':' + QString::number(endvalue) + ';');
502 QDomNode lastParsedEffect;
504 QDomNode n2 = effects.at(ix);
505 bool continueParsing = true;
506 for (; !n2.isNull() && continueParsing; n2 = n2.nextSibling()) {
508 QDomElement kfreffect = n2.toElement();
509 int effectout = kfreffect.attribute("out").toInt();
511 for (QDomNode n4 = kfreffect.firstChild(); !n4.isNull(); n4 = n4.nextSibling()) {
512 // parse effect parameters
513 QDomElement subeffectparam = n4.toElement();
514 if (subeffectparam.attribute("name") == "kdenlive_ix" && subeffectparam.text() != effectindex) {
515 //We are not in the same effect, stop parsing
516 lastParsedEffect = n2.previousSibling();
518 continueParsing = false;
520 } else if (subeffectparam.attribute("name") == endtag) {
521 endvalue = subeffectparam.text().toDouble() * factor;
525 if (continueParsing) {
526 keyframes.append(QString::number(effectout) + ':' + QString::number(endvalue) + ';');
531 params = currenteffect.elementsByTagName("parameter");
532 for (int i = 0; i < params.count(); i++) {
533 QDomElement e = params.item(i).toElement();
534 if (e.attribute("type") == "keyframe") e.setAttribute("keyframes", keyframes);
536 if (!continueParsing) {
537 n2 = lastParsedEffect;
540 // Check if effect has in/out points
541 if (effect.hasAttribute("in")) {
542 EffectsList::setParameter(currenteffect, "in", effect.attribute("in"));
544 if (effect.hasAttribute("out")) {
545 EffectsList::setParameter(currenteffect, "out", effect.attribute("out"));
549 // adjust effect parameters
550 for (QDomNode n3 = effect.firstChild(); !n3.isNull(); n3 = n3.nextSibling()) {
551 // parse effect parameters
552 QDomElement effectparam = n3.toElement();
553 QString paramname = effectparam.attribute("name");
554 QString paramvalue = effectparam.text();
557 // try to find this parameter in the effect xml
559 for (int k = 0; k < clipeffectparams.count(); k++) {
560 e = clipeffectparams.item(k).toElement();
561 if (!e.isNull() && e.tagName() == "parameter" && e.attribute("name") == paramname) {
562 double factor = e.attribute("factor", "1").toDouble();
564 e.setAttribute("value", paramvalue.toDouble() * factor);
565 } else e.setAttribute("value", paramvalue);
570 if (effecttag == "ladspa") {
571 //QString ladspaEffectFile = EffectsList::parameter(effect, "src", "property");
573 if (!QFile::exists(ladspaEffectFile)) {
574 // If the ladspa effect file is missing, recreate it
575 initEffects::ladspaEffectFile(ladspaEffectFile, currenteffect.attribute("ladspaid").toInt(), m_trackview->getLadspaParams(currenteffect));
577 currenteffect.setAttribute("src", ladspaEffectFile);
579 item->addEffect(currenteffect, false);
580 item->effectsCounter();
585 // The clip in playlist was not listed in the kdenlive producers,
586 // something went wrong, repair required.
587 kWarning() << "CANNOT INSERT CLIP " << id;
588 int out = elem.attribute("out").toInt();
591 clipinfo.startPos = GenTime(position, m_doc->fps());
592 clipinfo.endPos = clipinfo.startPos + GenTime(out - in + 1, m_doc->fps());
593 clipinfo.cropStart = GenTime(in, m_doc->fps());
595 //kDebug() << "// INSERTING CLIP: " << in << "x" << out << ", track: " << ix << ", ID: " << id << ", SCALE: " << m_scale << ", FPS: " << m_doc->fps();
597 DocClipBase *missingClip = getMissingProducer(id);
599 // We cannot find the producer, something is really wrong, add
600 // placeholder color clip
601 QDomElement producerXml;
602 producerXml.setTagName("producer");
603 producerXml.setAttribute("resource", "0xff0000ff");
604 producerXml.setAttribute("mlt_service", "colour");
605 producerXml.setAttribute("length", "15000");
606 producerXml.setAttribute("id", id);
607 missingClip = new DocClipBase(m_doc->clipManager(), producerXml, id);
608 m_documentErrors.append(i18n("Boken clip producer %1", id) + '\n');
609 } else m_documentErrors.append(i18n("Replaced wrong clip producer %1 with %2", id, missingClip->getId()) + '\n');
610 ClipItem *item = new ClipItem(missingClip, clipinfo, m_doc->fps(), 1.0, false);
611 m_scene->addItem(item);
612 missingClip->addReference();
613 position += (out - in + 1);
615 m_doc->setModified(true);
617 //m_clipList.append(clip);
620 //m_trackDuration = position;
623 //documentTracks.insert(ix, track);
624 kDebug() << "************* ADD DOC TRACK " << ix << ", DURATION: " << position;
629 DocClipBase *TrackView::getMissingProducer(const QString id) const {
630 QDomElement missingXml = QDomElement();
631 QDomDocument doc = m_doc->toXml();
632 QString docRoot = doc.documentElement().attribute("root");
633 if (!docRoot.endsWith('/')) docRoot.append('/');
634 QDomNodeList prods = doc.elementsByTagName("producer");
635 int maxprod = prods.count();
636 for (int i = 0; i < maxprod; i++) {
637 QDomNode m = prods.at(i);
638 QString prodId = m.toElement().attribute("id");
640 missingXml = m.toElement();
644 if (missingXml == QDomElement()) return NULL;
646 QDomNodeList params = missingXml.childNodes();
649 for (int j = 0; j < params.count(); j++) {
650 QDomElement e = params.item(j).toElement();
651 if (e.attribute("name") == "resource") {
652 resource = e.firstChild().nodeValue();
653 } else if (e.attribute("name") == "mlt_service") {
654 mlt_service = e.firstChild().nodeValue();
657 resource.prepend(docRoot);
658 DocClipBase *missingClip = NULL;
659 if (!resource.isEmpty())
660 missingClip = m_doc->clipManager()->getClipByResource(resource);
664 QGraphicsScene *TrackView::projectScene() {
668 CustomTrackView *TrackView::projectView() {
672 void TrackView::setEditMode(const QString & editMode) {
673 m_editMode = editMode;
676 const QString & TrackView::editMode() const {
680 void TrackView::slotChangeTrackLock(int ix, bool lock) {
681 QList<HeaderTrack *> widgets = this->findChildren<HeaderTrack *>();
682 widgets.at(ix)->setLock(lock);
686 #include "trackview.moc"