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 view.ruler_frame->setLayout(layout);
60 layout->getContentsMargins(&left_margin, 0, &right_margin, 0);
61 layout->setContentsMargins(left_margin, 0, right_margin, 0);
62 layout->addWidget(m_ruler);
64 QHBoxLayout *tracksLayout = new QHBoxLayout;
65 tracksLayout->setContentsMargins(0, 0, 0, 0);
66 view.tracks_frame->setLayout(tracksLayout);
68 view.headers_area->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
69 view.headers_area->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
71 m_headersLayout = new QVBoxLayout;
72 m_headersLayout->setContentsMargins(0, 0, 0, 0);
73 m_headersLayout->setSpacing(0);
74 view.headers_container->setLayout(m_headersLayout);
76 connect(view.headers_area->verticalScrollBar(), SIGNAL(valueChanged(int)), m_trackview->verticalScrollBar(), SLOT(setValue(int)));
78 tracksLayout->addWidget(m_trackview);
80 connect(m_trackview->verticalScrollBar(), SIGNAL(valueChanged(int)), view.headers_area->verticalScrollBar(), SLOT(setValue(int)));
81 connect(m_trackview, SIGNAL(trackHeightChanged()), this, SLOT(slotRebuildTrackHeaders()));
83 parseDocument(m_doc->toXml());
84 m_doc->setSceneList();
85 connect(m_trackview, SIGNAL(cursorMoved(int, int)), m_ruler, SLOT(slotCursorMoved(int, int)));
86 connect(m_trackview->horizontalScrollBar(), SIGNAL(valueChanged(int)), m_ruler, SLOT(slotMoveRuler(int)));
87 connect(m_trackview, SIGNAL(mousePosition(int)), this, SIGNAL(mousePosition(int)));
88 connect(m_trackview, SIGNAL(transitionItemSelected(Transition*, bool)), this, SLOT(slotTransitionItemSelected(Transition*, bool)));
89 connect(m_trackview, SIGNAL(doTrackLock(int, bool)), this, SLOT(slotChangeTrackLock(int, bool)));
91 slotChangeZoom(m_doc->zoom());
92 slotSetZone(m_doc->zone());
96 int TrackView::duration() const
98 return m_trackview->duration();
101 int TrackView::tracksNumber() const
103 return m_projectTracks - 1;
106 int TrackView::inPoint() const
108 return m_ruler->inPoint();
111 int TrackView::outPoint() const
113 return m_ruler->outPoint();
116 void TrackView::slotSetZone(QPoint p)
121 void TrackView::slotTransitionItemSelected(Transition *t, bool update)
123 emit transitionItemSelected(t, update);
126 void TrackView::setDuration(int dur)
128 m_trackview->setDuration(dur);
129 m_ruler->setDuration(dur);
132 void TrackView::parseDocument(QDomDocument doc)
135 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);
162 // Check for invalid markup
163 QDomNodeList params = e.elementsByTagName("property");
164 for (int j = 0; j < params.count(); j++) {
165 QDomElement p = params.item(j).toElement();
166 if (p.attribute("name") == "markup") {
167 QString val = p.text().toUtf8().data();
168 kDebug()<<"//FOUND MARKUP, VAL: "<<val;
169 //e.setAttribute("value", value);
170 n.removeChild(params.item(j));
176 if (e.hasAttribute("in") == false && e.hasAttribute("out") == false) continue;
177 int in = e.attribute("in").toInt();
178 int out = e.attribute("out").toInt();
179 if (in > out || in == out) {
180 // invalid producer, remove it
181 QString id = e.attribute("id");
182 m_invalidProducers.append(id);
183 m_documentErrors.append(i18n("Invalid clip producer %1\n", id));
184 doc.documentElement().removeChild(producers.at(i));
189 for (int i = 0; i < m_projectTracks; i++) {
190 e = tracks.item(i).toElement();
191 QString playlist_name = e.attribute("producer");
192 if (playlist_name != "black_track" && playlist_name != "playlistmain") {
193 // find playlist related to this track
195 for (int j = 0; j < m_projectTracks; j++) {
196 p = playlists.item(j).toElement();
197 if (p.attribute("id") == playlist_name) break;
199 if (p.attribute("id") != playlist_name) { // then it didn't work.
200 kDebug() << "NO PLAYLIST FOUND FOR TRACK " + pos;
202 if (e.attribute("hide") == "video") {
203 m_doc->switchTrackVideo(i - 1, true);
204 } else if (e.attribute("hide") == "audio") {
205 m_doc->switchTrackAudio(i - 1, true);
206 } else if (e.attribute("hide") == "both") {
207 m_doc->switchTrackVideo(i - 1, true);
208 m_doc->switchTrackAudio(i - 1, true);
211 trackduration = slotAddProjectTrack(pos, p, m_doc->isTrackLocked(i - 1));
213 //kDebug() << " PRO DUR: " << trackduration << ", TRACK DUR: " << duration;
214 if (trackduration > duration) duration = trackduration;
216 // background black track
217 for (int j = 0; j < m_projectTracks; j++) {
218 p = playlists.item(j).toElement();
219 if (p.attribute("id") == playlist_name) break;
221 int black_clips = p.childNodes().count();
222 for (int i = 0; i < black_clips; i++)
223 m_doc->loadingProgressed();
224 qApp->processEvents();
230 QDomNodeList transitions = doc.elementsByTagName("transition");
232 //kDebug() << "//////////// TIMELINE FOUND: " << projectTransitions << " transitions";
233 for (int i = 0; i < transitions.count(); i++) {
234 e = transitions.item(i).toElement();
235 QDomNodeList transitionparams = e.childNodes();
236 bool transitionAdd = true;
239 bool isAutomatic = false;
240 bool forceTrack = false;
241 QString mlt_geometry;
243 for (int k = 0; k < transitionparams.count(); k++) {
244 p = transitionparams.item(k).toElement();
246 QString paramName = p.attribute("name");
247 // do not add audio mixing transitions
248 if (paramName == "internal_added" && p.text() == "237") {
249 transitionAdd = false;
250 //kDebug() << "// TRANSITRION " << i << " IS NOT VALID (INTERN ADDED)";
252 } else if (paramName == "a_track") a_track = p.text().toInt();
253 else if (paramName == "b_track") b_track = p.text().toInt();
254 else if (paramName == "mlt_service") mlt_service = p.text();
255 else if (paramName == "geometry") mlt_geometry = p.text();
256 else if (paramName == "automatic" && p.text() == "1") isAutomatic = true;
257 else if (paramName == "force_track" && p.text() == "1") forceTrack = true;
260 if (transitionAdd || mlt_service != "mix") {
261 // Transition should be added to the scene
262 ItemInfo transitionInfo;
263 QString transitionId;
264 if (mlt_service == "composite") {
265 // When adding composite transition, check if it is a wipe transition
266 if (mlt_geometry.count(';') == 1) {
267 mlt_geometry.remove(QChar('%'), Qt::CaseInsensitive);
268 mlt_geometry.replace(QChar('x'), QChar(','), Qt::CaseInsensitive);
269 QString start = mlt_geometry.section(';', 0, 0);
270 start = start.section(':', 0, 1);
271 start.replace(QChar(':'), QChar(','), Qt::CaseInsensitive);
272 QString end = mlt_geometry.section('=', 1, 1);
273 end = end.section(':', 0, 1);
274 end.replace(QChar(':'), QChar(','), Qt::CaseInsensitive);
275 start.append(',' + end);
276 QStringList numbers = start.split(',', QString::SkipEmptyParts);
277 bool isWipeTransition = true;
279 for (int i = 0; i < numbers.size(); ++i) {
280 checkNumber = qAbs(numbers.at(i).toInt());
281 if (checkNumber != 0 && checkNumber != 100) {
282 isWipeTransition = false;
286 if (isWipeTransition) transitionId = "wipe";
289 QDomElement base = MainWindow::transitions.getEffectByTag(mlt_service, transitionId).cloneNode().toElement();
291 for (int k = 0; k < transitionparams.count(); k++) {
292 p = transitionparams.item(k).toElement();
294 QString paramName = p.attribute("name");
295 QString paramValue = p.text();
297 QDomNodeList params = base.elementsByTagName("parameter");
298 if (paramName != "a_track" && paramName != "b_track") for (int i = 0; i < params.count(); i++) {
299 QDomElement e = params.item(i).toElement();
300 if (!e.isNull() && e.attribute("tag") == paramName) {
301 if (e.attribute("type") == "double") {
302 QString factor = e.attribute("factor", "1");
304 double val = paramValue.toDouble() * factor.toDouble();
305 paramValue = QString::number(val);
308 e.setAttribute("value", paramValue);
316 doc.appendChild(doc.importNode(base, true));
317 kDebug() << "/////// TRANSITION XML: "<< doc.toString();*/
319 transitionInfo.startPos = GenTime(e.attribute("in").toInt(), m_doc->fps());
320 transitionInfo.endPos = GenTime(e.attribute("out").toInt() + 1, m_doc->fps());
321 transitionInfo.track = m_projectTracks - 1 - b_track;
322 //kDebug() << "/////////////// +++++++++++ ADDING TRANSITION ON TRACK: " << b_track << ", TOTAL TRKA: " << m_projectTracks;
323 if (transitionInfo.startPos >= transitionInfo.endPos) {
324 // invalid transition, remove it.
325 m_documentErrors.append(i18n("Removed invalid transition: %1", e.attribute("id")) + '\n');
326 kDebug() << "///// REMOVED INVALID TRANSITION: " << e.attribute("id");
327 tractor.removeChild(transitions.item(i));
330 Transition *tr = new Transition(transitionInfo, a_track, m_doc->fps(), base, isAutomatic);
331 if (forceTrack) tr->setForcedTrack(true, a_track);
332 m_scene->addItem(tr);
333 if (b_track > 0 && m_doc->isTrackLocked(b_track - 1)) {
334 tr->setItemLocked(true);
341 QDomNodeList guides = doc.elementsByTagName("guide");
342 for (int i = 0; i < guides.count(); i++) {
343 e = guides.item(i).toElement();
344 const QString comment = e.attribute("comment");
345 const GenTime pos = GenTime(e.attribute("time").toDouble());
346 m_trackview->addGuide(pos, comment);
350 QDomNodeList groups = doc.elementsByTagName("group");
351 m_trackview->loadGroups(groups);
353 m_trackview->setDuration(duration);
354 kDebug() << "/////////// TOTAL PROJECT DURATION: " << duration;
355 slotRebuildTrackHeaders();
356 if (!m_documentErrors.isNull()) KMessageBox::sorry(this, m_documentErrors);
357 //m_trackview->setCursorPos(cursorPos);
358 //m_scrollBox->setGeometry(0, 0, 300 * zoomFactor(), m_scrollArea->height());
361 void TrackView::slotDeleteClip(const QString &clipId)
363 m_trackview->deleteClip(clipId);
366 void TrackView::setCursorPos(int pos)
368 m_trackview->setCursorPos(pos);
371 void TrackView::moveCursorPos(int pos)
373 m_trackview->setCursorPos(pos, false);
376 void TrackView::slotChangeZoom(int factor)
378 m_doc->setZoom(factor);
379 m_ruler->setPixelPerMark(factor);
380 m_scale = (double) FRAME_SIZE / m_ruler->comboScale[factor]; // m_ruler->comboScale[m_currentZoom] /
381 m_trackview->setScale(m_scale);
384 int TrackView::fitZoom() const
386 int zoom = (int)((duration() + 20 / m_scale) * FRAME_SIZE / m_trackview->width());
388 for (i = 0; i < 13; i++)
389 if (m_ruler->comboScale[i] > zoom) break;
393 KdenliveDoc *TrackView::document()
398 void TrackView::refresh()
400 m_trackview->viewport()->update();
403 void TrackView::slotRebuildTrackHeaders()
405 QList <TrackInfo> list = m_doc->tracksList();
406 QList<HeaderTrack *> widgets = findChildren<HeaderTrack *>();
407 for (int i = 0; i < widgets.count(); i++)
408 delete widgets.at(i);
409 int max = list.count();
410 for (int i = 0; i < max; i++) {
411 HeaderTrack *header = new HeaderTrack(i, list.at(max - i - 1), this);
412 connect(header, SIGNAL(switchTrackVideo(int)), m_trackview, SLOT(slotSwitchTrackVideo(int)));
413 connect(header, SIGNAL(switchTrackAudio(int)), m_trackview, SLOT(slotSwitchTrackAudio(int)));
414 connect(header, SIGNAL(switchTrackLock(int)), m_trackview, SLOT(slotSwitchTrackLock(int)));
416 connect(header, SIGNAL(deleteTrack(int)), this, SIGNAL(deleteTrack(int)));
417 connect(header, SIGNAL(insertTrack(int)), this, SIGNAL(insertTrack(int)));
418 connect(header, SIGNAL(changeTrack(int)), this, SIGNAL(changeTrack(int)));
419 m_headersLayout->addWidget(header);
421 view.headers_container->adjustSize();
425 int TrackView::slotAddProjectTrack(int ix, QDomElement xml, bool locked)
429 QDomNodeList children = xml.childNodes();
430 for (int nodeindex = 0; nodeindex < children.count(); nodeindex++) {
431 QDomNode n = children.item(nodeindex);
432 QDomElement elem = n.toElement();
433 if (elem.tagName() == "blank") {
434 position += elem.attribute("length").toInt();
435 } else if (elem.tagName() == "entry") {
436 m_doc->loadingProgressed();
437 qApp->processEvents();
439 int in = elem.attribute("in").toInt();
440 int out = elem.attribute("out").toInt();
441 if (in > out || in == out || m_invalidProducers.contains(elem.attribute("producer"))) {
442 m_documentErrors.append(i18n("Invalid clip removed from track %1 at %2\n", ix, position));
443 xml.removeChild(children.at(nodeindex));
447 QString idString = elem.attribute("producer");
448 QString id = idString;
450 if (idString.startsWith("slowmotion")) {
451 id = idString.section(':', 1, 1);
452 speed = idString.section(':', 2, 2).toDouble();
453 } else id = id.section('_', 0, 0);
454 DocClipBase *clip = m_doc->clipManager()->getClipById(id);
456 // The clip in playlist was not listed in the kdenlive producers,
457 // something went wrong, repair required.
458 kWarning() << "CANNOT INSERT CLIP " << id;
460 clip = getMissingProducer(id);
462 // We cannot find the producer, something is really wrong, add
463 // placeholder color clip
465 QDomElement producerXml = doc.createElement("producer");
466 doc.appendChild(producerXml);
467 producerXml.setAttribute("colour", "0xff0000ff");
468 producerXml.setAttribute("mlt_service", "colour");
469 producerXml.setAttribute("length", "15000");
470 producerXml.setAttribute("name", "INVALID");
471 producerXml.setAttribute("type", COLOR);
472 producerXml.setAttribute("id", id);
473 clip = new DocClipBase(m_doc->clipManager(), doc.documentElement(), id);
474 xml.insertBefore(producerXml, QDomNode());
475 m_doc->clipManager()->addClip(clip);
477 m_documentErrors.append(i18n("Broken clip producer %1", id) + '\n');
479 // Found correct producer
480 m_documentErrors.append(i18n("Replaced wrong clip producer %1 with %2", id, clip->getId()) + '\n');
481 elem.setAttribute("producer", clip->getId());
483 m_doc->setModified(true);
488 clipinfo.startPos = GenTime(position, m_doc->fps());
489 clipinfo.endPos = clipinfo.startPos + GenTime(out - in + 1, m_doc->fps());
490 clipinfo.cropStart = GenTime(in, m_doc->fps());
492 //kDebug() << "// INSERTING CLIP: " << in << "x" << out << ", track: " << ix << ", ID: " << id << ", SCALE: " << m_scale << ", FPS: " << m_doc->fps();
493 ClipItem *item = new ClipItem(clip, clipinfo, m_doc->fps(), speed, false);
494 if (idString.endsWith("_video")) item->setVideoOnly(true);
495 else if (idString.endsWith("_audio")) item->setAudioOnly(true);
496 m_scene->addItem(item);
497 if (locked) item->setItemLocked(true);
498 clip->addReference();
499 position += (out - in + 1);
501 // parse clip effects
502 QDomNodeList effects = elem.childNodes();
503 for (int ix = 0; ix < effects.count(); ix++) {
504 QDomElement effect = effects.at(ix).toElement();
505 if (effect.tagName() == "filter") {
506 // add effect to clip
510 QString ladspaEffectFile;
511 // Get effect tag & index
512 for (QDomNode n3 = effect.firstChild(); !n3.isNull(); n3 = n3.nextSibling()) {
513 // parse effect parameters
514 QDomElement effectparam = n3.toElement();
515 if (effectparam.attribute("name") == "tag") {
516 effecttag = effectparam.text();
517 } else if (effectparam.attribute("name") == "kdenlive_id") {
518 effectid = effectparam.text();
519 } else if (effectparam.attribute("name") == "kdenlive_ix") {
520 effectindex = effectparam.text();
521 } else if (effectparam.attribute("name") == "src") {
522 ladspaEffectFile = effectparam.text();
523 if (!QFile::exists(ladspaEffectFile)) {
524 // If the ladspa effect file is missing, recreate it
525 kDebug() << "// MISSING LADSPA FILE: " << ladspaEffectFile;
526 ladspaEffectFile = m_doc->getLadspaFile();
527 effectparam.firstChild().setNodeValue(ladspaEffectFile);
528 kDebug() << "// ... REPLACED WITH: " << ladspaEffectFile;
532 //kDebug() << "+ + CLIP EFF FND: " << effecttag << ", " << effectid << ", " << effectindex;
533 // get effect standard tags
534 QDomElement clipeffect = MainWindow::customEffects.getEffectByTag(QString(), effectid);
535 if (clipeffect.isNull()) clipeffect = MainWindow::videoEffects.getEffectByTag(effecttag, effectid);
536 if (clipeffect.isNull()) clipeffect = MainWindow::audioEffects.getEffectByTag(effecttag, effectid);
537 if (clipeffect.isNull()) {
538 kDebug() << "/// WARNING, EFFECT: " << effecttag << ": " << effectid << " not found, removing it from project";
539 m_documentErrors.append(i18n("Effect %1:%2 not found in MLT, it was removed from this project\n", effecttag, effectid));
540 elem.removeChild(effects.at(ix));
543 QDomElement currenteffect = clipeffect.cloneNode().toElement();
544 currenteffect.setAttribute("kdenlive_ix", effectindex);
545 QDomNodeList clipeffectparams = currenteffect.childNodes();
547 if (MainWindow::videoEffects.hasKeyFrames(currenteffect)) {
548 //kDebug() << " * * * * * * * * * * ** CLIP EFF WITH KFR FND * * * * * * * * * * *";
549 // effect is key-framable, read all effects to retrieve keyframes
553 QDomNodeList params = currenteffect.elementsByTagName("parameter");
554 for (int i = 0; i < params.count(); i++) {
555 QDomElement e = params.item(i).toElement();
556 if (e.attribute("type") == "keyframe") {
557 starttag = e.attribute("starttag", "start");
558 endtag = e.attribute("endtag", "end");
559 factor = e.attribute("factor", "1").toDouble();
564 int effectin = effect.attribute("in").toInt();
565 int effectout = effect.attribute("out").toInt();
566 double startvalue = 0;
568 for (QDomNode n3 = effect.firstChild(); !n3.isNull(); n3 = n3.nextSibling()) {
569 // parse effect parameters
570 QDomElement effectparam = n3.toElement();
571 if (effectparam.attribute("name") == starttag)
572 startvalue = effectparam.text().toDouble() * factor;
573 if (effectparam.attribute("name") == endtag)
574 endvalue = effectparam.text().toDouble() * factor;
576 // add first keyframe
577 keyframes.append(QString::number(effectin) + ':' + QString::number(startvalue) + ';' + QString::number(effectout) + ':' + QString::number(endvalue) + ';');
578 QDomNode lastParsedEffect;
580 QDomNode n2 = effects.at(ix);
581 bool continueParsing = true;
582 for (; !n2.isNull() && continueParsing; n2 = n2.nextSibling()) {
584 QDomElement kfreffect = n2.toElement();
585 int effectout = kfreffect.attribute("out").toInt();
587 for (QDomNode n4 = kfreffect.firstChild(); !n4.isNull(); n4 = n4.nextSibling()) {
588 // parse effect parameters
589 QDomElement subeffectparam = n4.toElement();
590 if (subeffectparam.attribute("name") == "kdenlive_ix" && subeffectparam.text() != effectindex) {
591 //We are not in the same effect, stop parsing
592 lastParsedEffect = n2.previousSibling();
594 continueParsing = false;
596 } else if (subeffectparam.attribute("name") == endtag) {
597 endvalue = subeffectparam.text().toDouble() * factor;
601 if (continueParsing) {
602 keyframes.append(QString::number(effectout) + ':' + QString::number(endvalue) + ';');
607 params = currenteffect.elementsByTagName("parameter");
608 for (int i = 0; i < params.count(); i++) {
609 QDomElement e = params.item(i).toElement();
610 if (e.attribute("type") == "keyframe") e.setAttribute("keyframes", keyframes);
612 if (!continueParsing) {
613 n2 = lastParsedEffect;
616 // Check if effect has in/out points
617 if (effect.hasAttribute("in")) {
618 EffectsList::setParameter(currenteffect, "in", effect.attribute("in"));
620 if (effect.hasAttribute("out")) {
621 EffectsList::setParameter(currenteffect, "out", effect.attribute("out"));
625 // adjust effect parameters
626 for (QDomNode n3 = effect.firstChild(); !n3.isNull(); n3 = n3.nextSibling()) {
627 // parse effect parameters
628 QDomElement effectparam = n3.toElement();
629 QString paramname = effectparam.attribute("name");
630 QString paramvalue = effectparam.text();
633 // try to find this parameter in the effect xml
635 for (int k = 0; k < clipeffectparams.count(); k++) {
636 e = clipeffectparams.item(k).toElement();
637 if (!e.isNull() && e.tagName() == "parameter" && e.attribute("name") == paramname) {
638 double factor = e.attribute("factor", "1").toDouble();
640 e.setAttribute("value", paramvalue.toDouble() * factor);
641 } else e.setAttribute("value", paramvalue);
646 if (effecttag == "ladspa") {
647 //QString ladspaEffectFile = EffectsList::parameter(effect, "src", "property");
649 if (!QFile::exists(ladspaEffectFile)) {
650 // If the ladspa effect file is missing, recreate it
651 initEffects::ladspaEffectFile(ladspaEffectFile, currenteffect.attribute("ladspaid").toInt(), m_trackview->getLadspaParams(currenteffect));
653 currenteffect.setAttribute("src", ladspaEffectFile);
655 item->addEffect(currenteffect, false);
656 item->effectsCounter();
661 //m_clipList.append(clip);
664 //m_trackDuration = position;
667 //documentTracks.insert(ix, track);
668 kDebug() << "************* ADD DOC TRACK " << ix << ", DURATION: " << position;
673 DocClipBase *TrackView::getMissingProducer(const QString id) const
675 QDomElement missingXml;
676 QDomDocument doc = m_doc->toXml();
677 QString docRoot = doc.documentElement().attribute("root");
678 if (!docRoot.endsWith('/')) docRoot.append('/');
679 QDomNodeList prods = doc.elementsByTagName("producer");
680 int maxprod = prods.count();
681 for (int i = 0; i < maxprod; i++) {
682 QDomNode m = prods.at(i);
683 QString prodId = m.toElement().attribute("id");
685 missingXml = m.toElement();
689 if (missingXml == QDomElement()) return NULL;
691 QDomNodeList params = missingXml.childNodes();
693 for (int j = 0; j < params.count(); j++) {
694 QDomElement e = params.item(j).toElement();
695 if (e.attribute("name") == "resource") {
696 resource = e.firstChild().nodeValue();
700 // prepend westley document root if no path in clip resource and not a color clip
701 if (!resource.contains('/') && !resource.startsWith("0x")) resource.prepend(docRoot);
702 DocClipBase *missingClip = NULL;
703 if (!resource.isEmpty())
704 missingClip = m_doc->clipManager()->getClipByResource(resource);
708 QGraphicsScene *TrackView::projectScene()
713 CustomTrackView *TrackView::projectView()
718 void TrackView::setEditMode(const QString & editMode)
720 m_editMode = editMode;
723 const QString & TrackView::editMode() const
728 void TrackView::slotChangeTrackLock(int ix, bool lock)
730 QList<HeaderTrack *> widgets = findChildren<HeaderTrack *>();
731 widgets.at(ix)->setLock(lock);
735 #include "trackview.moc"