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) :
48 m_scene = new CustomTrackScene(doc);
49 m_trackview = new CustomTrackView(doc, m_scene, parent);
50 m_trackview->scale(1, 1);
51 m_trackview->setAlignment(Qt::AlignLeft | Qt::AlignTop);
52 //m_scene->addRect(QRectF(0, 0, 100, 100), QPen(), QBrush(Qt::red));
54 m_ruler = new CustomRuler(doc->timecode(), m_trackview);
55 connect(m_ruler, SIGNAL(zoneMoved(int, int)), this, SIGNAL(zoneMoved(int, int)));
56 QHBoxLayout *layout = new QHBoxLayout;
57 layout->setContentsMargins(m_trackview->frameWidth(), 0, 0, 0);
58 layout->setSpacing(0);
59 m_view.ruler_frame->setLayout(layout);
60 layout->addWidget(m_ruler);
62 QHBoxLayout *tracksLayout = new QHBoxLayout;
63 tracksLayout->setContentsMargins(0, 0, 0, 0);
64 tracksLayout->setSpacing(0);
65 m_view.tracks_frame->setLayout(tracksLayout);
67 m_view.headers_area->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
68 m_view.headers_area->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
70 m_headersLayout = new QVBoxLayout;
71 m_headersLayout->setContentsMargins(0, m_trackview->frameWidth(), 0, 0);
72 m_headersLayout->setSpacing(0);
73 m_view.headers_container->setLayout(m_headersLayout);
75 connect(m_view.headers_area->verticalScrollBar(), SIGNAL(valueChanged(int)), m_trackview->verticalScrollBar(), SLOT(setValue(int)));
77 tracksLayout->addWidget(m_trackview);
79 connect(m_trackview->verticalScrollBar(), SIGNAL(valueChanged(int)), m_view.headers_area->verticalScrollBar(), SLOT(setValue(int)));
80 connect(m_trackview, SIGNAL(trackHeightChanged()), this, SLOT(slotRebuildTrackHeaders()));
82 parseDocument(m_doc->toXml());
83 m_doc->setSceneList();
84 connect(m_trackview, SIGNAL(cursorMoved(int, int)), m_ruler, SLOT(slotCursorMoved(int, int)));
85 connect(m_trackview->horizontalScrollBar(), SIGNAL(valueChanged(int)), m_ruler, SLOT(slotMoveRuler(int)));
86 connect(m_trackview, SIGNAL(mousePosition(int)), this, SIGNAL(mousePosition(int)));
87 connect(m_trackview, SIGNAL(transitionItemSelected(Transition*, bool)), this, SLOT(slotTransitionItemSelected(Transition*, bool)));
88 connect(m_trackview, SIGNAL(doTrackLock(int, bool)), this, SLOT(slotChangeTrackLock(int, bool)));
90 slotChangeZoom(m_doc->zoom());
91 slotSetZone(m_doc->zone());
95 int TrackView::duration() const
97 return m_trackview->duration();
100 int TrackView::tracksNumber() const
102 return m_projectTracks - 1;
105 int TrackView::inPoint() const
107 return m_ruler->inPoint();
110 int TrackView::outPoint() const
112 return m_ruler->outPoint();
115 void TrackView::slotSetZone(QPoint p)
120 void TrackView::slotTransitionItemSelected(Transition *t, bool update)
122 emit transitionItemSelected(t, update);
125 void TrackView::setDuration(int dur)
127 m_trackview->setDuration(dur);
128 m_ruler->setDuration(dur);
131 void TrackView::parseDocument(QDomDocument doc)
134 m_documentErrors.clear();
136 //kDebug() << "//// DOCUMENT: " << doc.toString();
137 /*QDomNode props = doc.elementsByTagName("properties").item(0);
138 if (!props.isNull()) {
139 cursorPos = props.toElement().attribute("timeline_position").toInt();
142 // parse project tracks
143 QDomElement tractor = doc.elementsByTagName("tractor").item(0).toElement();
144 QDomNodeList tracks = doc.elementsByTagName("track");
145 QDomNodeList playlists = doc.elementsByTagName("playlist");
147 m_projectTracks = tracks.count();
148 int trackduration = 0;
152 int pos = m_projectTracks - 1;
153 m_invalidProducers.clear();
154 QDomNodeList producers = doc.elementsByTagName("producer");
155 for (int i = 0; i < producers.count(); i++) {
156 // Check for invalid producers
157 QDomNode n = producers.item(i);
161 // Check for invalid markup
162 QDomNodeList params = e.elementsByTagName("property");
163 for (int j = 0; j < params.count(); j++) {
164 QDomElement p = params.item(j).toElement();
165 if (p.attribute("name") == "markup") {
166 QString val = p.text().toUtf8().data();
167 kDebug()<<"//FOUND MARKUP, VAL: "<<val;
168 //e.setAttribute("value", value);
169 n.removeChild(params.item(j));
175 if (e.hasAttribute("in") == false && e.hasAttribute("out") == false) continue;
176 int in = e.attribute("in").toInt();
177 int out = e.attribute("out").toInt();
178 if (in > out || in == out) {
179 // invalid producer, remove it
180 QString id = e.attribute("id");
181 m_invalidProducers.append(id);
182 m_documentErrors.append(i18n("Invalid clip producer %1\n", id));
183 doc.documentElement().removeChild(producers.at(i));
188 for (int i = 0; i < m_projectTracks; i++) {
189 e = tracks.item(i).toElement();
190 QString playlist_name = e.attribute("producer");
191 if (playlist_name != "black_track" && playlist_name != "playlistmain") {
192 // find playlist related to this track
194 for (int j = 0; j < m_projectTracks; j++) {
195 p = playlists.item(j).toElement();
196 if (p.attribute("id") == playlist_name) break;
198 if (p.attribute("id") != playlist_name) { // then it didn't work.
199 kDebug() << "NO PLAYLIST FOUND FOR TRACK " + pos;
201 if (e.attribute("hide") == "video") {
202 m_doc->switchTrackVideo(i - 1, true);
203 } else if (e.attribute("hide") == "audio") {
204 m_doc->switchTrackAudio(i - 1, true);
205 } else if (e.attribute("hide") == "both") {
206 m_doc->switchTrackVideo(i - 1, true);
207 m_doc->switchTrackAudio(i - 1, true);
210 trackduration = slotAddProjectTrack(pos, p, m_doc->isTrackLocked(i - 1));
212 //kDebug() << " PRO DUR: " << trackduration << ", TRACK DUR: " << duration;
213 if (trackduration > duration) duration = trackduration;
215 // background black track
216 for (int j = 0; j < m_projectTracks; j++) {
217 p = playlists.item(j).toElement();
218 if (p.attribute("id") == playlist_name) break;
220 int black_clips = p.childNodes().count();
221 for (int i = 0; i < black_clips; i++)
222 m_doc->loadingProgressed();
223 qApp->processEvents();
229 QDomNodeList transitions = doc.elementsByTagName("transition");
231 //kDebug() << "//////////// TIMELINE FOUND: " << projectTransitions << " transitions";
232 for (int i = 0; i < transitions.count(); i++) {
233 e = transitions.item(i).toElement();
234 QDomNodeList transitionparams = e.childNodes();
235 bool transitionAdd = true;
238 bool isAutomatic = false;
239 bool forceTrack = false;
240 QString mlt_geometry;
242 for (int k = 0; k < transitionparams.count(); k++) {
243 p = transitionparams.item(k).toElement();
245 QString paramName = p.attribute("name");
246 // do not add audio mixing transitions
247 if (paramName == "internal_added" && p.text() == "237") {
248 transitionAdd = false;
249 //kDebug() << "// TRANSITRION " << i << " IS NOT VALID (INTERN ADDED)";
251 } else if (paramName == "a_track") a_track = p.text().toInt();
252 else if (paramName == "b_track") b_track = p.text().toInt();
253 else if (paramName == "mlt_service") mlt_service = p.text();
254 else if (paramName == "geometry") mlt_geometry = p.text();
255 else if (paramName == "automatic" && p.text() == "1") isAutomatic = true;
256 else if (paramName == "force_track" && p.text() == "1") forceTrack = true;
259 if (transitionAdd || mlt_service != "mix") {
260 // Transition should be added to the scene
261 ItemInfo transitionInfo;
262 QString transitionId;
263 if (mlt_service == "composite") {
264 // When adding composite transition, check if it is a wipe transition
265 if (mlt_geometry.count(';') == 1) {
266 mlt_geometry.remove(QChar('%'), Qt::CaseInsensitive);
267 mlt_geometry.replace(QChar('x'), QChar(','), Qt::CaseInsensitive);
268 QString start = mlt_geometry.section(';', 0, 0);
269 start = start.section(':', 0, 1);
270 start.replace(QChar(':'), QChar(','), Qt::CaseInsensitive);
271 QString end = mlt_geometry.section('=', 1, 1);
272 end = end.section(':', 0, 1);
273 end.replace(QChar(':'), QChar(','), Qt::CaseInsensitive);
274 start.append(',' + end);
275 QStringList numbers = start.split(',', QString::SkipEmptyParts);
276 bool isWipeTransition = true;
278 for (int i = 0; i < numbers.size(); ++i) {
279 checkNumber = qAbs(numbers.at(i).toInt());
280 if (checkNumber != 0 && checkNumber != 100) {
281 isWipeTransition = false;
285 if (isWipeTransition) transitionId = "wipe";
288 QDomElement base = MainWindow::transitions.getEffectByTag(mlt_service, transitionId).cloneNode().toElement();
290 for (int k = 0; k < transitionparams.count(); k++) {
291 p = transitionparams.item(k).toElement();
293 QString paramName = p.attribute("name");
294 QString paramValue = p.text();
296 QDomNodeList params = base.elementsByTagName("parameter");
297 if (paramName != "a_track" && paramName != "b_track") for (int i = 0; i < params.count(); i++) {
298 QDomElement e = params.item(i).toElement();
299 if (!e.isNull() && e.attribute("tag") == paramName) {
300 if (e.attribute("type") == "double") {
301 QString factor = e.attribute("factor", "1");
303 double val = paramValue.toDouble() * factor.toDouble();
304 paramValue = QString::number(val);
307 e.setAttribute("value", paramValue);
315 doc.appendChild(doc.importNode(base, true));
316 kDebug() << "/////// TRANSITION XML: "<< doc.toString();*/
318 transitionInfo.startPos = GenTime(e.attribute("in").toInt(), m_doc->fps());
319 transitionInfo.endPos = GenTime(e.attribute("out").toInt() + 1, m_doc->fps());
320 transitionInfo.track = m_projectTracks - 1 - b_track;
321 //kDebug() << "/////////////// +++++++++++ ADDING TRANSITION ON TRACK: " << b_track << ", TOTAL TRKA: " << m_projectTracks;
322 if (transitionInfo.startPos >= transitionInfo.endPos) {
323 // invalid transition, remove it.
324 m_documentErrors.append(i18n("Removed invalid transition: %1", e.attribute("id")) + '\n');
325 kDebug() << "///// REMOVED INVALID TRANSITION: " << e.attribute("id");
326 tractor.removeChild(transitions.item(i));
329 Transition *tr = new Transition(transitionInfo, a_track, m_doc->fps(), base, isAutomatic);
330 if (forceTrack) tr->setForcedTrack(true, a_track);
331 m_scene->addItem(tr);
332 if (b_track > 0 && m_doc->isTrackLocked(b_track - 1)) {
333 tr->setItemLocked(true);
340 QDomNodeList guides = doc.elementsByTagName("guide");
341 for (int i = 0; i < guides.count(); i++) {
342 e = guides.item(i).toElement();
343 const QString comment = e.attribute("comment");
344 const GenTime pos = GenTime(e.attribute("time").toDouble());
345 m_trackview->addGuide(pos, comment);
349 QDomNodeList groups = doc.elementsByTagName("group");
350 m_trackview->loadGroups(groups);
352 m_trackview->setDuration(duration);
353 kDebug() << "/////////// TOTAL PROJECT DURATION: " << duration;
354 slotRebuildTrackHeaders();
355 if (!m_documentErrors.isNull()) KMessageBox::sorry(this, m_documentErrors);
356 //m_trackview->setCursorPos(cursorPos);
357 //m_scrollBox->setGeometry(0, 0, 300 * zoomFactor(), m_scrollArea->height());
360 void TrackView::slotDeleteClip(const QString &clipId)
362 m_trackview->deleteClip(clipId);
365 void TrackView::setCursorPos(int pos)
367 m_trackview->setCursorPos(pos);
370 void TrackView::moveCursorPos(int pos)
372 m_trackview->setCursorPos(pos, false);
375 void TrackView::slotChangeZoom(int factor)
377 m_doc->setZoom(factor);
378 m_ruler->setPixelPerMark(factor);
379 m_scale = (double) FRAME_SIZE / m_ruler->comboScale[factor]; // m_ruler->comboScale[m_currentZoom] /
380 m_trackview->setScale(m_scale);
383 int TrackView::fitZoom() const
385 int zoom = (int)((duration() + 20 / m_scale) * FRAME_SIZE / m_trackview->width());
387 for (i = 0; i < 13; i++)
388 if (m_ruler->comboScale[i] > zoom) break;
392 KdenliveDoc *TrackView::document()
397 void TrackView::refresh()
399 m_trackview->viewport()->update();
402 void TrackView::slotRebuildTrackHeaders()
404 QList <TrackInfo> list = m_doc->tracksList();
405 QList<HeaderTrack *> widgets = findChildren<HeaderTrack *>();
407 int max = list.count();
408 for (int i = 0; i < max; i++) {
409 HeaderTrack *header = new HeaderTrack(i, list.at(max - i - 1), this);
410 connect(header, SIGNAL(switchTrackVideo(int)), m_trackview, SLOT(slotSwitchTrackVideo(int)));
411 connect(header, SIGNAL(switchTrackAudio(int)), m_trackview, SLOT(slotSwitchTrackAudio(int)));
412 connect(header, SIGNAL(switchTrackLock(int)), m_trackview, SLOT(slotSwitchTrackLock(int)));
414 connect(header, SIGNAL(deleteTrack(int)), this, SIGNAL(deleteTrack(int)));
415 connect(header, SIGNAL(insertTrack(int)), this, SIGNAL(insertTrack(int)));
416 connect(header, SIGNAL(changeTrack(int)), this, SIGNAL(changeTrack(int)));
417 m_headersLayout->addWidget(header);
419 m_view.headers_container->adjustSize();
423 int TrackView::slotAddProjectTrack(int ix, QDomElement xml, bool locked)
427 QDomNodeList children = xml.childNodes();
428 for (int nodeindex = 0; nodeindex < children.count(); nodeindex++) {
429 QDomNode n = children.item(nodeindex);
430 QDomElement elem = n.toElement();
431 if (elem.tagName() == "blank") {
432 position += elem.attribute("length").toInt();
433 } else if (elem.tagName() == "entry") {
434 m_doc->loadingProgressed();
435 qApp->processEvents();
437 int in = elem.attribute("in").toInt();
438 int out = elem.attribute("out").toInt();
439 if (in > out || in == out || m_invalidProducers.contains(elem.attribute("producer"))) {
440 m_documentErrors.append(i18n("Invalid clip removed from track %1 at %2\n", ix, position));
441 xml.removeChild(children.at(nodeindex));
445 QString idString = elem.attribute("producer");
446 QString id = idString;
448 if (idString.startsWith("slowmotion")) {
449 id = idString.section(':', 1, 1);
450 speed = idString.section(':', 2, 2).toDouble();
451 } else id = id.section('_', 0, 0);
452 DocClipBase *clip = m_doc->clipManager()->getClipById(id);
454 // The clip in playlist was not listed in the kdenlive producers,
455 // something went wrong, repair required.
456 kWarning() << "CANNOT INSERT CLIP " << id;
458 clip = getMissingProducer(id);
460 // We cannot find the producer, something is really wrong, add
461 // placeholder color clip
463 QDomElement producerXml = doc.createElement("producer");
464 doc.appendChild(producerXml);
465 producerXml.setAttribute("colour", "0xff0000ff");
466 producerXml.setAttribute("mlt_service", "colour");
467 producerXml.setAttribute("length", "15000");
468 producerXml.setAttribute("name", "INVALID");
469 producerXml.setAttribute("type", COLOR);
470 producerXml.setAttribute("id", id);
471 clip = new DocClipBase(m_doc->clipManager(), doc.documentElement(), id);
472 xml.insertBefore(producerXml, QDomNode());
473 m_doc->clipManager()->addClip(clip);
475 m_documentErrors.append(i18n("Broken clip producer %1", id) + '\n');
477 // Found correct producer
478 m_documentErrors.append(i18n("Replaced wrong clip producer %1 with %2", id, clip->getId()) + '\n');
479 elem.setAttribute("producer", clip->getId());
481 m_doc->setModified(true);
486 clipinfo.startPos = GenTime(position, m_doc->fps());
487 clipinfo.endPos = clipinfo.startPos + GenTime(out - in + 1, m_doc->fps());
488 clipinfo.cropStart = GenTime(in, m_doc->fps());
490 //kDebug() << "// INSERTING CLIP: " << in << "x" << out << ", track: " << ix << ", ID: " << id << ", SCALE: " << m_scale << ", FPS: " << m_doc->fps();
491 ClipItem *item = new ClipItem(clip, clipinfo, m_doc->fps(), speed, false);
492 if (idString.endsWith("_video")) item->setVideoOnly(true);
493 else if (idString.endsWith("_audio")) item->setAudioOnly(true);
494 m_scene->addItem(item);
495 if (locked) item->setItemLocked(true);
496 clip->addReference();
497 position += (out - in + 1);
499 // parse clip effects
500 QDomNodeList effects = elem.childNodes();
501 for (int ix = 0; ix < effects.count(); ix++) {
502 QDomElement effect = effects.at(ix).toElement();
503 if (effect.tagName() == "filter") {
504 // add effect to clip
508 QString ladspaEffectFile;
509 // Get effect tag & index
510 for (QDomNode n3 = effect.firstChild(); !n3.isNull(); n3 = n3.nextSibling()) {
511 // parse effect parameters
512 QDomElement effectparam = n3.toElement();
513 if (effectparam.attribute("name") == "tag") {
514 effecttag = effectparam.text();
515 } else if (effectparam.attribute("name") == "kdenlive_id") {
516 effectid = effectparam.text();
517 } else if (effectparam.attribute("name") == "kdenlive_ix") {
518 effectindex = effectparam.text();
519 } else if (effectparam.attribute("name") == "src") {
520 ladspaEffectFile = effectparam.text();
521 if (!QFile::exists(ladspaEffectFile)) {
522 // If the ladspa effect file is missing, recreate it
523 kDebug() << "// MISSING LADSPA FILE: " << ladspaEffectFile;
524 ladspaEffectFile = m_doc->getLadspaFile();
525 effectparam.firstChild().setNodeValue(ladspaEffectFile);
526 kDebug() << "// ... REPLACED WITH: " << ladspaEffectFile;
530 //kDebug() << "+ + CLIP EFF FND: " << effecttag << ", " << effectid << ", " << effectindex;
531 // get effect standard tags
532 QDomElement clipeffect = MainWindow::customEffects.getEffectByTag(QString(), effectid);
533 if (clipeffect.isNull()) clipeffect = MainWindow::videoEffects.getEffectByTag(effecttag, effectid);
534 if (clipeffect.isNull()) clipeffect = MainWindow::audioEffects.getEffectByTag(effecttag, effectid);
535 if (clipeffect.isNull()) {
536 kDebug() << "/// WARNING, EFFECT: " << effecttag << ": " << effectid << " not found, removing it from project";
537 m_documentErrors.append(i18n("Effect %1:%2 not found in MLT, it was removed from this project\n", effecttag, effectid));
538 elem.removeChild(effects.at(ix));
541 QDomElement currenteffect = clipeffect.cloneNode().toElement();
542 currenteffect.setAttribute("kdenlive_ix", effectindex);
543 QDomNodeList clipeffectparams = currenteffect.childNodes();
545 if (MainWindow::videoEffects.hasKeyFrames(currenteffect)) {
546 //kDebug() << " * * * * * * * * * * ** CLIP EFF WITH KFR FND * * * * * * * * * * *";
547 // effect is key-framable, read all effects to retrieve keyframes
551 QDomNodeList params = currenteffect.elementsByTagName("parameter");
552 for (int i = 0; i < params.count(); i++) {
553 QDomElement e = params.item(i).toElement();
554 if (e.attribute("type") == "keyframe") {
555 starttag = e.attribute("starttag", "start");
556 endtag = e.attribute("endtag", "end");
557 factor = e.attribute("factor", "1").toDouble();
562 int effectin = effect.attribute("in").toInt();
563 int effectout = effect.attribute("out").toInt();
564 double startvalue = 0;
566 for (QDomNode n3 = effect.firstChild(); !n3.isNull(); n3 = n3.nextSibling()) {
567 // parse effect parameters
568 QDomElement effectparam = n3.toElement();
569 if (effectparam.attribute("name") == starttag)
570 startvalue = effectparam.text().toDouble() * factor;
571 if (effectparam.attribute("name") == endtag)
572 endvalue = effectparam.text().toDouble() * factor;
574 // add first keyframe
575 keyframes.append(QString::number(effectin) + ':' + QString::number(startvalue) + ';' + QString::number(effectout) + ':' + QString::number(endvalue) + ';');
576 QDomNode lastParsedEffect;
578 QDomNode n2 = effects.at(ix);
579 bool continueParsing = true;
580 for (; !n2.isNull() && continueParsing; n2 = n2.nextSibling()) {
582 QDomElement kfreffect = n2.toElement();
583 int effectout = kfreffect.attribute("out").toInt();
585 for (QDomNode n4 = kfreffect.firstChild(); !n4.isNull(); n4 = n4.nextSibling()) {
586 // parse effect parameters
587 QDomElement subeffectparam = n4.toElement();
588 if (subeffectparam.attribute("name") == "kdenlive_ix" && subeffectparam.text() != effectindex) {
589 //We are not in the same effect, stop parsing
590 lastParsedEffect = n2.previousSibling();
592 continueParsing = false;
594 } else if (subeffectparam.attribute("name") == endtag) {
595 endvalue = subeffectparam.text().toDouble() * factor;
599 if (continueParsing) {
600 keyframes.append(QString::number(effectout) + ':' + QString::number(endvalue) + ';');
605 params = currenteffect.elementsByTagName("parameter");
606 for (int i = 0; i < params.count(); i++) {
607 QDomElement e = params.item(i).toElement();
608 if (e.attribute("type") == "keyframe") e.setAttribute("keyframes", keyframes);
610 if (!continueParsing) {
611 n2 = lastParsedEffect;
614 // Check if effect has in/out points
615 if (effect.hasAttribute("in")) {
616 EffectsList::setParameter(currenteffect, "in", effect.attribute("in"));
618 if (effect.hasAttribute("out")) {
619 EffectsList::setParameter(currenteffect, "out", effect.attribute("out"));
623 // adjust effect parameters
624 for (QDomNode n3 = effect.firstChild(); !n3.isNull(); n3 = n3.nextSibling()) {
625 // parse effect parameters
626 QDomElement effectparam = n3.toElement();
627 QString paramname = effectparam.attribute("name");
628 QString paramvalue = effectparam.text();
631 // try to find this parameter in the effect xml
633 for (int k = 0; k < clipeffectparams.count(); k++) {
634 e = clipeffectparams.item(k).toElement();
635 if (!e.isNull() && e.tagName() == "parameter" && e.attribute("name") == paramname) {
636 double factor = e.attribute("factor", "1").toDouble();
638 e.setAttribute("value", paramvalue.toDouble() * factor);
639 } else e.setAttribute("value", paramvalue);
644 if (effecttag == "ladspa") {
645 //QString ladspaEffectFile = EffectsList::parameter(effect, "src", "property");
647 if (!QFile::exists(ladspaEffectFile)) {
648 // If the ladspa effect file is missing, recreate it
649 initEffects::ladspaEffectFile(ladspaEffectFile, currenteffect.attribute("ladspaid").toInt(), m_trackview->getLadspaParams(currenteffect));
651 currenteffect.setAttribute("src", ladspaEffectFile);
653 item->addEffect(currenteffect, false);
654 item->effectsCounter();
659 //m_clipList.append(clip);
662 //m_trackDuration = position;
665 //documentTracks.insert(ix, track);
666 kDebug() << "************* ADD DOC TRACK " << ix << ", DURATION: " << position;
671 DocClipBase *TrackView::getMissingProducer(const QString id) const
673 QDomElement missingXml;
674 QDomDocument doc = m_doc->toXml();
675 QString docRoot = doc.documentElement().attribute("root");
676 if (!docRoot.endsWith('/')) docRoot.append('/');
677 QDomNodeList prods = doc.elementsByTagName("producer");
678 int maxprod = prods.count();
679 for (int i = 0; i < maxprod; i++) {
680 QDomNode m = prods.at(i);
681 QString prodId = m.toElement().attribute("id");
683 missingXml = m.toElement();
687 if (missingXml == QDomElement()) return NULL;
689 QDomNodeList params = missingXml.childNodes();
691 for (int j = 0; j < params.count(); j++) {
692 QDomElement e = params.item(j).toElement();
693 if (e.attribute("name") == "resource") {
694 resource = e.firstChild().nodeValue();
698 // prepend MLT XML document root if no path in clip resource and not a color clip
699 if (!resource.contains('/') && !resource.startsWith("0x")) resource.prepend(docRoot);
700 DocClipBase *missingClip = NULL;
701 if (!resource.isEmpty())
702 missingClip = m_doc->clipManager()->getClipByResource(resource);
706 QGraphicsScene *TrackView::projectScene()
711 CustomTrackView *TrackView::projectView()
716 void TrackView::setEditMode(const QString & editMode)
718 m_editMode = editMode;
721 const QString & TrackView::editMode() const
726 void TrackView::slotChangeTrackLock(int ix, bool lock)
728 QList<HeaderTrack *> widgets = findChildren<HeaderTrack *>();
729 widgets.at(ix)->setLock(lock);
733 #include "trackview.moc"