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) :
46 view = new Ui::TimeLine_UI();
49 m_scene = new CustomTrackScene(doc);
50 m_trackview = new CustomTrackView(doc, m_scene, parent);
51 m_trackview->scale(1, 1);
52 m_trackview->setAlignment(Qt::AlignLeft | Qt::AlignTop);
53 //m_scene->addRect(QRectF(0, 0, 100, 100), QPen(), QBrush(Qt::red));
55 m_ruler = new CustomRuler(doc->timecode(), m_trackview);
56 connect(m_ruler, SIGNAL(zoneMoved(int, int)), this, SIGNAL(zoneMoved(int, int)));
57 QHBoxLayout *layout = new QHBoxLayout;
58 view->ruler_frame->setLayout(layout);
61 layout->getContentsMargins(&left_margin, 0, &right_margin, 0);
62 layout->setContentsMargins(left_margin, 0, right_margin, 0);
63 layout->addWidget(m_ruler);
65 QHBoxLayout *tracksLayout = new QHBoxLayout;
66 tracksLayout->setContentsMargins(0, 0, 0, 0);
67 view->tracks_frame->setLayout(tracksLayout);
69 view->headers_area->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
70 view->headers_area->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
72 m_headersLayout = new QVBoxLayout;
73 m_headersLayout->setContentsMargins(0, 0, 0, 0);
74 m_headersLayout->setSpacing(0);
75 view->headers_container->setLayout(m_headersLayout);
77 connect(view->headers_area->verticalScrollBar(), SIGNAL(valueChanged(int)), m_trackview->verticalScrollBar(), SLOT(setValue(int)));
79 tracksLayout->addWidget(m_trackview);
81 connect(m_trackview->verticalScrollBar(), SIGNAL(valueChanged(int)), view->headers_area->verticalScrollBar(), SLOT(setValue(int)));
82 connect(m_trackview, SIGNAL(trackHeightChanged()), this, SLOT(slotRebuildTrackHeaders()));
84 parseDocument(m_doc->toXml());
85 m_doc->setSceneList();
86 connect(m_trackview, SIGNAL(cursorMoved(int, int)), m_ruler, SLOT(slotCursorMoved(int, int)));
87 connect(m_trackview->horizontalScrollBar(), SIGNAL(valueChanged(int)), m_ruler, SLOT(slotMoveRuler(int)));
88 connect(m_trackview, SIGNAL(mousePosition(int)), this, SIGNAL(mousePosition(int)));
89 connect(m_trackview, SIGNAL(transitionItemSelected(Transition*, bool)), this, SLOT(slotTransitionItemSelected(Transition*, bool)));
90 connect(m_trackview, SIGNAL(doTrackLock(int, bool)), this, SLOT(slotChangeTrackLock(int, bool)));
92 slotChangeZoom(m_doc->zoom());
93 slotSetZone(m_doc->zone());
97 int TrackView::duration() const
99 return m_trackview->duration();
102 int TrackView::tracksNumber() const
104 return m_projectTracks - 1;
107 int TrackView::inPoint() const
109 return m_ruler->inPoint();
112 int TrackView::outPoint() const
114 return m_ruler->outPoint();
117 void TrackView::slotSetZone(QPoint p)
122 void TrackView::slotTransitionItemSelected(Transition *t, bool update)
124 emit transitionItemSelected(t, update);
127 void TrackView::setDuration(int dur)
129 m_trackview->setDuration(dur);
130 m_ruler->setDuration(dur);
133 void TrackView::parseDocument(QDomDocument doc)
136 m_documentErrors.clear();
137 // kDebug() << "//// DOCUMENT: " << doc.toString();
138 /*QDomNode props = doc.elementsByTagName("properties").item(0);
139 if (!props.isNull()) {
140 cursorPos = props.toElement().attribute("timeline_position").toInt();
143 // parse project tracks
144 QDomElement tractor = doc.elementsByTagName("tractor").item(0).toElement();
145 QDomNodeList tracks = doc.elementsByTagName("track");
146 QDomNodeList playlists = doc.elementsByTagName("playlist");
148 m_projectTracks = tracks.count();
149 int trackduration = 0;
153 int pos = m_projectTracks - 1;
154 m_invalidProducers.clear();
155 QDomNodeList producers = doc.elementsByTagName("producer");
156 for (int i = 0; i < producers.count(); i++) {
157 // CHeck for invalid producers
158 QDomNode n = producers.item(i);
160 if (e.hasAttribute("in") == false && e.hasAttribute("out") == false) continue;
161 int in = e.attribute("in").toInt();
162 int out = e.attribute("out").toInt();
163 if (in > out || in == out) {
164 // invalid producer, remove it
165 QString id = e.attribute("id");
166 m_invalidProducers.append(id);
167 m_documentErrors.append(i18n("Invalid clip producer %1\n", id));
168 doc.documentElement().removeChild(producers.at(i));
173 for (int i = 0; i < m_projectTracks; i++) {
174 e = tracks.item(i).toElement();
175 QString playlist_name = e.attribute("producer");
176 if (playlist_name != "black_track" && playlist_name != "playlistmain") {
177 // find playlist related to this track
179 for (int j = 0; j < m_projectTracks; j++) {
180 p = playlists.item(j).toElement();
181 if (p.attribute("id") == playlist_name) break;
183 if (p.attribute("id") != playlist_name) { // then it didn't work.
184 kDebug() << "NO PLAYLIST FOUND FOR TRACK " + pos;
186 if (e.attribute("hide") == "video") {
187 m_doc->switchTrackVideo(i - 1, true);
188 } else if (e.attribute("hide") == "audio") {
189 m_doc->switchTrackAudio(i - 1, true);
190 } else if (e.attribute("hide") == "both") {
191 m_doc->switchTrackVideo(i - 1, true);
192 m_doc->switchTrackAudio(i - 1, true);
195 trackduration = slotAddProjectTrack(pos, p, m_doc->isTrackLocked(i - 1));
197 //kDebug() << " PRO DUR: " << trackduration << ", TRACK DUR: " << duration;
198 if (trackduration > duration) duration = trackduration;
200 // background black track
201 for (int j = 0; j < m_projectTracks; j++) {
202 p = playlists.item(j).toElement();
203 if (p.attribute("id") == playlist_name) break;
205 int black_clips = p.childNodes().count();
206 for (int i = 0; i < black_clips; i++)
207 m_doc->loadingProgressed();
208 qApp->processEvents();
214 QDomNodeList transitions = doc.elementsByTagName("transition");
216 //kDebug() << "//////////// TIMELINE FOUND: " << projectTransitions << " transitions";
217 for (int i = 0; i < transitions.count(); i++) {
218 e = transitions.item(i).toElement();
219 QDomNodeList transitionparams = e.childNodes();
220 bool transitionAdd = true;
223 bool isAutomatic = false;
224 bool forceTrack = false;
225 QString mlt_geometry;
227 for (int k = 0; k < transitionparams.count(); k++) {
228 p = transitionparams.item(k).toElement();
230 QString paramName = p.attribute("name");
231 // do not add audio mixing transitions
232 if (paramName == "internal_added" && p.text() == "237") {
233 transitionAdd = false;
234 //kDebug() << "// TRANSITRION " << i << " IS NOT VALID (INTERN ADDED)";
236 } else if (paramName == "a_track") a_track = p.text().toInt();
237 else if (paramName == "b_track") b_track = p.text().toInt();
238 else if (paramName == "mlt_service") mlt_service = p.text();
239 else if (paramName == "geometry") mlt_geometry = p.text();
240 else if (paramName == "automatic" && p.text() == "1") isAutomatic = true;
241 else if (paramName == "force_track" && p.text() == "1") forceTrack = true;
244 if (transitionAdd || mlt_service != "mix") {
245 // Transition should be added to the scene
246 ItemInfo transitionInfo;
247 QString transitionId;
248 if (mlt_service == "composite") {
249 // When adding composite transition, check if it is a wipe transition
250 if (mlt_geometry.count(';') == 1) {
251 mlt_geometry.remove(QChar('%'), Qt::CaseInsensitive);
252 mlt_geometry.replace(QChar('x'), QChar(','), Qt::CaseInsensitive);
253 QString start = mlt_geometry.section(';', 0, 0);
254 start = start.section(':', 0, 1);
255 start.replace(QChar(':'), QChar(','), Qt::CaseInsensitive);
256 QString end = mlt_geometry.section('=', 1, 1);
257 end = end.section(':', 0, 1);
258 end.replace(QChar(':'), QChar(','), Qt::CaseInsensitive);
259 start.append(',' + end);
260 QStringList numbers = start.split(',', QString::SkipEmptyParts);
261 bool isWipeTransition = true;
263 for (int i = 0; i < numbers.size(); ++i) {
264 checkNumber = qAbs(numbers.at(i).toInt());
265 if (checkNumber != 0 && checkNumber != 100) {
266 isWipeTransition = false;
270 if (isWipeTransition) transitionId = "wipe";
273 QDomElement base = MainWindow::transitions.getEffectByTag(mlt_service, transitionId).cloneNode().toElement();
275 for (int k = 0; k < transitionparams.count(); k++) {
276 p = transitionparams.item(k).toElement();
278 QString paramName = p.attribute("name");
279 QString paramValue = p.text();
281 QDomNodeList params = base.elementsByTagName("parameter");
282 if (paramName != "a_track" && paramName != "b_track") for (int i = 0; i < params.count(); i++) {
283 QDomElement e = params.item(i).toElement();
284 if (!e.isNull() && e.attribute("tag") == paramName) {
285 if (e.attribute("type") == "double") {
286 QString factor = e.attribute("factor", "1");
288 double val = paramValue.toDouble() * factor.toDouble();
289 paramValue = QString::number(val);
292 e.setAttribute("value", paramValue);
300 doc.appendChild(doc.importNode(base, true));
301 kDebug() << "/////// TRANSITION XML: "<< doc.toString();*/
303 transitionInfo.startPos = GenTime(e.attribute("in").toInt(), m_doc->fps());
304 transitionInfo.endPos = GenTime(e.attribute("out").toInt() + 1, m_doc->fps());
305 transitionInfo.track = m_projectTracks - 1 - b_track;
306 //kDebug() << "/////////////// +++++++++++ ADDING TRANSITION ON TRACK: " << b_track << ", TOTAL TRKA: " << m_projectTracks;
307 if (transitionInfo.startPos >= transitionInfo.endPos) {
308 // invalid transition, remove it.
309 m_documentErrors.append(i18n("Removed invalid transition: %1", e.attribute("id")) + '\n');
310 kDebug() << "///// REMOVED INVALID TRANSITION: " << e.attribute("id");
311 tractor.removeChild(transitions.item(i));
314 Transition *tr = new Transition(transitionInfo, a_track, m_doc->fps(), base, isAutomatic);
315 if (forceTrack) tr->setForcedTrack(true, a_track);
316 m_scene->addItem(tr);
317 if (b_track > 0 && m_doc->isTrackLocked(b_track - 1)) {
318 tr->setItemLocked(true);
325 QDomNodeList guides = doc.elementsByTagName("guide");
326 for (int i = 0; i < guides.count(); i++) {
327 e = guides.item(i).toElement();
328 const QString comment = e.attribute("comment");
329 const GenTime pos = GenTime(e.attribute("time").toDouble());
330 m_trackview->addGuide(pos, comment);
334 QDomNodeList groups = doc.elementsByTagName("group");
335 m_trackview->loadGroups(groups);
337 m_trackview->setDuration(duration);
338 kDebug() << "/////////// TOTAL PROJECT DURATION: " << duration;
339 slotRebuildTrackHeaders();
340 if (!m_documentErrors.isNull()) KMessageBox::sorry(this, m_documentErrors);
341 //m_trackview->setCursorPos(cursorPos);
342 //m_scrollBox->setGeometry(0, 0, 300 * zoomFactor(), m_scrollArea->height());
345 void TrackView::slotDeleteClip(const QString &clipId)
347 m_trackview->deleteClip(clipId);
350 void TrackView::setCursorPos(int pos)
352 m_trackview->setCursorPos(pos);
355 void TrackView::moveCursorPos(int pos)
357 m_trackview->setCursorPos(pos, false);
360 void TrackView::slotChangeZoom(int factor)
362 m_doc->setZoom(factor);
363 m_ruler->setPixelPerMark(factor);
364 m_scale = (double) FRAME_SIZE / m_ruler->comboScale[factor]; // m_ruler->comboScale[m_currentZoom] /
365 m_trackview->setScale(m_scale);
368 int TrackView::fitZoom() const
370 int zoom = (int)((duration() + 20 / m_scale) * FRAME_SIZE / m_trackview->width());
372 for (i = 0; i < 13; i++)
373 if (m_ruler->comboScale[i] > zoom) break;
377 KdenliveDoc *TrackView::document()
382 void TrackView::refresh()
384 m_trackview->viewport()->update();
387 void TrackView::slotRebuildTrackHeaders()
389 QList <TrackInfo> list = m_doc->tracksList();
390 QList<HeaderTrack *> widgets = findChildren<HeaderTrack *>();
391 for (int i = 0; i < widgets.count(); i++)
392 delete widgets.at(i);
393 int max = list.count();
394 for (int i = 0; i < max; i++) {
395 HeaderTrack *header = new HeaderTrack(i, list.at(max - i - 1), this);
396 connect(header, SIGNAL(switchTrackVideo(int)), m_trackview, SLOT(slotSwitchTrackVideo(int)));
397 connect(header, SIGNAL(switchTrackAudio(int)), m_trackview, SLOT(slotSwitchTrackAudio(int)));
398 connect(header, SIGNAL(switchTrackLock(int)), m_trackview, SLOT(slotSwitchTrackLock(int)));
400 connect(header, SIGNAL(deleteTrack(int)), this, SIGNAL(deleteTrack(int)));
401 connect(header, SIGNAL(insertTrack(int)), this, SIGNAL(insertTrack(int)));
402 connect(header, SIGNAL(changeTrack(int)), this, SIGNAL(changeTrack(int)));
403 m_headersLayout->addWidget(header);
405 view->headers_container->adjustSize();
409 int TrackView::slotAddProjectTrack(int ix, QDomElement xml, bool locked)
413 QDomNodeList children = xml.childNodes();
414 for (int nodeindex = 0; nodeindex < children.count(); nodeindex++) {
415 QDomNode n = children.item(nodeindex);
416 QDomElement elem = n.toElement();
417 if (elem.tagName() == "blank") {
418 position += elem.attribute("length").toInt();
419 } else if (elem.tagName() == "entry") {
420 m_doc->loadingProgressed();
421 qApp->processEvents();
423 int in = elem.attribute("in").toInt();
424 int out = elem.attribute("out").toInt();
425 if (in > out || in == out || m_invalidProducers.contains(elem.attribute("producer"))) {
426 m_documentErrors.append(i18n("Invalid clip removed from track %1 at %2\n", ix, position));
427 xml.removeChild(children.at(nodeindex));
431 QString idString = elem.attribute("producer");
432 QString id = idString;
434 if (idString.startsWith("slowmotion")) {
435 id = idString.section(':', 1, 1);
436 speed = idString.section(':', 2, 2).toDouble();
437 } else id = id.section('_', 0, 0);
438 DocClipBase *clip = m_doc->clipManager()->getClipById(id);
441 clipinfo.startPos = GenTime(position, m_doc->fps());
442 clipinfo.endPos = clipinfo.startPos + GenTime(out - in + 1, m_doc->fps());
443 clipinfo.cropStart = GenTime(in, m_doc->fps());
445 //kDebug() << "// INSERTING CLIP: " << in << "x" << out << ", track: " << ix << ", ID: " << id << ", SCALE: " << m_scale << ", FPS: " << m_doc->fps();
446 ClipItem *item = new ClipItem(clip, clipinfo, m_doc->fps(), speed, false);
447 if (idString.endsWith("_video")) item->setVideoOnly(true);
448 else if (idString.endsWith("_audio")) item->setAudioOnly(true);
449 m_scene->addItem(item);
450 if (locked) item->setItemLocked(true);
451 clip->addReference();
452 position += (out - in + 1);
454 // parse clip effects
455 QDomNodeList effects = elem.childNodes();
456 for (int ix = 0; ix < effects.count(); ix++) {
457 QDomElement effect = effects.at(ix).toElement();
458 if (effect.tagName() == "filter") {
459 // add effect to clip
463 QString ladspaEffectFile;
464 // Get effect tag & index
465 for (QDomNode n3 = effect.firstChild(); !n3.isNull(); n3 = n3.nextSibling()) {
466 // parse effect parameters
467 QDomElement effectparam = n3.toElement();
468 if (effectparam.attribute("name") == "tag") {
469 effecttag = effectparam.text();
470 } else if (effectparam.attribute("name") == "kdenlive_id") {
471 effectid = effectparam.text();
472 } else if (effectparam.attribute("name") == "kdenlive_ix") {
473 effectindex = effectparam.text();
474 } else if (effectparam.attribute("name") == "src") {
475 ladspaEffectFile = effectparam.text();
476 if (!QFile::exists(ladspaEffectFile)) {
477 // If the ladspa effect file is missing, recreate it
478 kDebug() << "// MISSING LADSPA FILE: " << ladspaEffectFile;
479 ladspaEffectFile = m_doc->getLadspaFile();
480 effectparam.firstChild().setNodeValue(ladspaEffectFile);
481 kDebug() << "// ... REPLACED WITH: " << ladspaEffectFile;
485 //kDebug() << "+ + CLIP EFF FND: " << effecttag << ", " << effectid << ", " << effectindex;
486 // get effect standard tags
487 QDomElement clipeffect = MainWindow::customEffects.getEffectByTag(QString(), effectid);
488 if (clipeffect.isNull()) clipeffect = MainWindow::videoEffects.getEffectByTag(effecttag, effectid);
489 if (clipeffect.isNull()) clipeffect = MainWindow::audioEffects.getEffectByTag(effecttag, effectid);
490 if (clipeffect.isNull()) {
491 kDebug() << "/// WARNING, EFFECT: " << effecttag << ": " << effectid << " not found, removing it from project";
492 m_documentErrors.append(i18n("Effect %1:%2 not found in MLT, it was removed from this project\n", effecttag, effectid));
493 elem.removeChild(effects.at(ix));
496 QDomElement currenteffect = clipeffect.cloneNode().toElement();
497 currenteffect.setAttribute("kdenlive_ix", effectindex);
498 QDomNodeList clipeffectparams = currenteffect.childNodes();
500 if (MainWindow::videoEffects.hasKeyFrames(currenteffect)) {
501 //kDebug() << " * * * * * * * * * * ** CLIP EFF WITH KFR FND * * * * * * * * * * *";
502 // effect is key-framable, read all effects to retrieve keyframes
506 QDomNodeList params = currenteffect.elementsByTagName("parameter");
507 for (int i = 0; i < params.count(); i++) {
508 QDomElement e = params.item(i).toElement();
509 if (e.attribute("type") == "keyframe") {
510 starttag = e.attribute("starttag", "start");
511 endtag = e.attribute("endtag", "end");
512 factor = e.attribute("factor", "1").toDouble();
517 int effectin = effect.attribute("in").toInt();
518 int effectout = effect.attribute("out").toInt();
519 double startvalue = 0;
521 for (QDomNode n3 = effect.firstChild(); !n3.isNull(); n3 = n3.nextSibling()) {
522 // parse effect parameters
523 QDomElement effectparam = n3.toElement();
524 if (effectparam.attribute("name") == starttag)
525 startvalue = effectparam.text().toDouble() * factor;
526 if (effectparam.attribute("name") == endtag)
527 endvalue = effectparam.text().toDouble() * factor;
529 // add first keyframe
530 keyframes.append(QString::number(effectin) + ':' + QString::number(startvalue) + ';' + QString::number(effectout) + ':' + QString::number(endvalue) + ';');
531 QDomNode lastParsedEffect;
533 QDomNode n2 = effects.at(ix);
534 bool continueParsing = true;
535 for (; !n2.isNull() && continueParsing; n2 = n2.nextSibling()) {
537 QDomElement kfreffect = n2.toElement();
538 int effectout = kfreffect.attribute("out").toInt();
540 for (QDomNode n4 = kfreffect.firstChild(); !n4.isNull(); n4 = n4.nextSibling()) {
541 // parse effect parameters
542 QDomElement subeffectparam = n4.toElement();
543 if (subeffectparam.attribute("name") == "kdenlive_ix" && subeffectparam.text() != effectindex) {
544 //We are not in the same effect, stop parsing
545 lastParsedEffect = n2.previousSibling();
547 continueParsing = false;
549 } else if (subeffectparam.attribute("name") == endtag) {
550 endvalue = subeffectparam.text().toDouble() * factor;
554 if (continueParsing) {
555 keyframes.append(QString::number(effectout) + ':' + QString::number(endvalue) + ';');
560 params = currenteffect.elementsByTagName("parameter");
561 for (int i = 0; i < params.count(); i++) {
562 QDomElement e = params.item(i).toElement();
563 if (e.attribute("type") == "keyframe") e.setAttribute("keyframes", keyframes);
565 if (!continueParsing) {
566 n2 = lastParsedEffect;
569 // Check if effect has in/out points
570 if (effect.hasAttribute("in")) {
571 EffectsList::setParameter(currenteffect, "in", effect.attribute("in"));
573 if (effect.hasAttribute("out")) {
574 EffectsList::setParameter(currenteffect, "out", effect.attribute("out"));
578 // adjust effect parameters
579 for (QDomNode n3 = effect.firstChild(); !n3.isNull(); n3 = n3.nextSibling()) {
580 // parse effect parameters
581 QDomElement effectparam = n3.toElement();
582 QString paramname = effectparam.attribute("name");
583 QString paramvalue = effectparam.text();
586 // try to find this parameter in the effect xml
588 for (int k = 0; k < clipeffectparams.count(); k++) {
589 e = clipeffectparams.item(k).toElement();
590 if (!e.isNull() && e.tagName() == "parameter" && e.attribute("name") == paramname) {
591 double factor = e.attribute("factor", "1").toDouble();
593 e.setAttribute("value", paramvalue.toDouble() * factor);
594 } else e.setAttribute("value", paramvalue);
599 if (effecttag == "ladspa") {
600 //QString ladspaEffectFile = EffectsList::parameter(effect, "src", "property");
602 if (!QFile::exists(ladspaEffectFile)) {
603 // If the ladspa effect file is missing, recreate it
604 initEffects::ladspaEffectFile(ladspaEffectFile, currenteffect.attribute("ladspaid").toInt(), m_trackview->getLadspaParams(currenteffect));
606 currenteffect.setAttribute("src", ladspaEffectFile);
608 item->addEffect(currenteffect, false);
609 item->effectsCounter();
614 // The clip in playlist was not listed in the kdenlive producers,
615 // something went wrong, repair required.
616 kWarning() << "CANNOT INSERT CLIP " << id;
617 int out = elem.attribute("out").toInt();
620 clipinfo.startPos = GenTime(position, m_doc->fps());
621 clipinfo.endPos = clipinfo.startPos + GenTime(out - in + 1, m_doc->fps());
622 clipinfo.cropStart = GenTime(in, m_doc->fps());
624 //kDebug() << "// INSERTING CLIP: " << in << "x" << out << ", track: " << ix << ", ID: " << id << ", SCALE: " << m_scale << ", FPS: " << m_doc->fps();
626 DocClipBase *missingClip = getMissingProducer(id);
628 // We cannot find the producer, something is really wrong, add
629 // placeholder color clip
630 QDomElement producerXml;
631 producerXml.setTagName("producer");
632 producerXml.setAttribute("resource", "0xff0000ff");
633 producerXml.setAttribute("mlt_service", "colour");
634 producerXml.setAttribute("length", "15000");
635 producerXml.setAttribute("id", id);
636 missingClip = new DocClipBase(m_doc->clipManager(), producerXml, id);
637 m_documentErrors.append(i18n("Boken clip producer %1", id) + '\n');
638 } else m_documentErrors.append(i18n("Replaced wrong clip producer %1 with %2", id, missingClip->getId()) + '\n');
639 ClipItem *item = new ClipItem(missingClip, clipinfo, m_doc->fps(), 1.0, false);
640 m_scene->addItem(item);
641 missingClip->addReference();
642 position += (out - in + 1);
644 m_doc->setModified(true);
646 //m_clipList.append(clip);
649 //m_trackDuration = position;
652 //documentTracks.insert(ix, track);
653 kDebug() << "************* ADD DOC TRACK " << ix << ", DURATION: " << position;
658 DocClipBase *TrackView::getMissingProducer(const QString id) const
660 QDomElement missingXml;
661 QDomDocument doc = m_doc->toXml();
662 QString docRoot = doc.documentElement().attribute("root");
663 if (!docRoot.endsWith('/')) docRoot.append('/');
664 QDomNodeList prods = doc.elementsByTagName("producer");
665 int maxprod = prods.count();
666 for (int i = 0; i < maxprod; i++) {
667 QDomNode m = prods.at(i);
668 QString prodId = m.toElement().attribute("id");
670 missingXml = m.toElement();
674 if (missingXml == QDomElement()) return NULL;
676 QDomNodeList params = missingXml.childNodes();
679 for (int j = 0; j < params.count(); j++) {
680 QDomElement e = params.item(j).toElement();
681 if (e.attribute("name") == "resource") {
682 resource = e.firstChild().nodeValue();
683 } else if (e.attribute("name") == "mlt_service") {
684 mlt_service = e.firstChild().nodeValue();
687 resource.prepend(docRoot);
688 DocClipBase *missingClip = NULL;
689 if (!resource.isEmpty())
690 missingClip = m_doc->clipManager()->getClipByResource(resource);
694 QGraphicsScene *TrackView::projectScene()
699 CustomTrackView *TrackView::projectView()
704 void TrackView::setEditMode(const QString & editMode)
706 m_editMode = editMode;
709 const QString & TrackView::editMode() const
714 void TrackView::slotChangeTrackLock(int ix, bool lock)
716 QList<HeaderTrack *> widgets = findChildren<HeaderTrack *>();
717 widgets.at(ix)->setLock(lock);
721 #include "trackview.moc"