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) :
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 layout->setContentsMargins(m_trackview->frameWidth(), 0, 0, 0);
59 layout->setSpacing(0);
60 m_view.ruler_frame->setLayout(layout);
61 layout->addWidget(m_ruler);
64 QHBoxLayout *sizeLayout = new QHBoxLayout;
65 sizeLayout->setContentsMargins(0, 0, 0, 0);
66 sizeLayout->setSpacing(0);
67 m_view.size_frame->setLayout(sizeLayout);
69 QString style1 = "QToolButton {border-style: none;margin: 0px 3px;padding: 0px;} QToolButton:pressed:hover { background-color: rgba(224, 224, 0, 100); border-style: inset; border:1px solid #cc6666;border-radius: 3px;} QToolButton:hover { background-color: rgba(255, 255, 255, 100); border-style: inset; border:1px solid #cc6666;border-radius: 3px;}";
71 QToolButton *butSmall = new QToolButton(this);
72 butSmall->setIcon(KIcon("kdenlive-zoom-small"));
73 butSmall->setToolTip(i18n("Smaller tracks"));
74 connect(butSmall, SIGNAL(clicked()), this, SLOT(slotVerticalZoomDown()));
75 sizeLayout->addWidget(butSmall);
77 QToolButton *butLarge = new QToolButton(this);
78 butLarge->setIcon(KIcon("kdenlive-zoom-large"));
79 butLarge->setToolTip(i18n("Bigger tracks"));
80 connect(butLarge, SIGNAL(clicked()), this, SLOT(slotVerticalZoomUp()));
81 sizeLayout->addWidget(butLarge);
82 m_view.size_frame->setStyleSheet(style1);
85 QHBoxLayout *tracksLayout = new QHBoxLayout;
86 tracksLayout->setContentsMargins(0, 0, 0, 0);
87 tracksLayout->setSpacing(0);
88 m_view.tracks_frame->setLayout(tracksLayout);
90 m_view.headers_area->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
91 m_view.headers_area->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
93 m_headersLayout = new QVBoxLayout;
94 m_headersLayout->setContentsMargins(0, m_trackview->frameWidth(), 0, 0);
95 m_headersLayout->setSpacing(0);
96 m_view.headers_container->setLayout(m_headersLayout);
98 connect(m_view.headers_area->verticalScrollBar(), SIGNAL(valueChanged(int)), m_trackview->verticalScrollBar(), SLOT(setValue(int)));
100 tracksLayout->addWidget(m_trackview);
102 connect(m_trackview->verticalScrollBar(), SIGNAL(valueChanged(int)), m_view.headers_area->verticalScrollBar(), SLOT(setValue(int)));
103 connect(m_trackview, SIGNAL(trackHeightChanged()), this, SLOT(slotRebuildTrackHeaders()));
105 parseDocument(m_doc->toXml());
106 m_doc->setSceneList();
107 connect(m_trackview, SIGNAL(cursorMoved(int, int)), m_ruler, SLOT(slotCursorMoved(int, int)));
108 connect(m_trackview->horizontalScrollBar(), SIGNAL(valueChanged(int)), m_ruler, SLOT(slotMoveRuler(int)));
109 connect(m_trackview, SIGNAL(mousePosition(int)), this, SIGNAL(mousePosition(int)));
110 connect(m_trackview, SIGNAL(doTrackLock(int, bool)), this, SLOT(slotChangeTrackLock(int, bool)));
112 slotChangeZoom(m_doc->zoom());
113 slotSetZone(m_doc->zone());
116 TrackView::~TrackView()
122 int TrackView::duration() const
124 return m_trackview->duration();
127 int TrackView::tracksNumber() const
129 return m_projectTracks - 1;
132 int TrackView::inPoint() const
134 return m_ruler->inPoint();
137 int TrackView::outPoint() const
139 return m_ruler->outPoint();
142 void TrackView::slotSetZone(QPoint p)
147 void TrackView::setDuration(int dur)
149 m_trackview->setDuration(dur);
150 m_ruler->setDuration(dur);
153 void TrackView::parseDocument(QDomDocument doc)
156 m_documentErrors.clear();
158 //kDebug() << "//// DOCUMENT: " << doc.toString();
159 /*QDomNode props = doc.elementsByTagName("properties").item(0);
160 if (!props.isNull()) {
161 cursorPos = props.toElement().attribute("timeline_position").toInt();
164 // parse project tracks
165 QDomElement tractor = doc.elementsByTagName("tractor").item(0).toElement();
166 QDomNodeList tracks = doc.elementsByTagName("track");
167 QDomNodeList playlists = doc.elementsByTagName("playlist");
169 m_projectTracks = tracks.count();
170 int trackduration = 0;
174 int pos = m_projectTracks - 1;
175 m_invalidProducers.clear();
176 QDomNodeList producers = doc.elementsByTagName("producer");
177 for (int i = 0; i < producers.count(); i++) {
178 // Check for invalid producers
179 QDomNode n = producers.item(i);
183 // Check for invalid markup
184 QDomNodeList params = e.elementsByTagName("property");
185 for (int j = 0; j < params.count(); j++) {
186 QDomElement p = params.item(j).toElement();
187 if (p.attribute("name") == "markup") {
188 QString val = p.text().toUtf8().data();
189 kDebug()<<"//FOUND MARKUP, VAL: "<<val;
190 //e.setAttribute("value", value);
191 n.removeChild(params.item(j));
197 if (e.hasAttribute("in") == false && e.hasAttribute("out") == false) continue;
198 int in = e.attribute("in").toInt();
199 int out = e.attribute("out").toInt();
200 if (in > out || in == out) {
201 // invalid producer, remove it
202 QString id = e.attribute("id");
203 m_invalidProducers.append(id);
204 m_documentErrors.append(i18n("Invalid clip producer %1\n", id));
205 doc.documentElement().removeChild(producers.at(i));
210 for (int i = 0; i < m_projectTracks; i++) {
211 e = tracks.item(i).toElement();
212 QString playlist_name = e.attribute("producer");
213 if (playlist_name != "black_track" && playlist_name != "playlistmain") {
214 // find playlist related to this 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 if (p.attribute("id") != playlist_name) { // then it didn't work.
221 kDebug() << "NO PLAYLIST FOUND FOR TRACK " + pos;
223 if (e.attribute("hide") == "video") {
224 m_doc->switchTrackVideo(i - 1, true);
225 } else if (e.attribute("hide") == "audio") {
226 m_doc->switchTrackAudio(i - 1, true);
227 } else if (e.attribute("hide") == "both") {
228 m_doc->switchTrackVideo(i - 1, true);
229 m_doc->switchTrackAudio(i - 1, true);
232 trackduration = slotAddProjectTrack(pos, p, m_doc->isTrackLocked(i - 1));
234 //kDebug() << " PRO DUR: " << trackduration << ", TRACK DUR: " << duration;
235 if (trackduration > duration) duration = trackduration;
237 // background black track
238 for (int j = 0; j < m_projectTracks; j++) {
239 p = playlists.item(j).toElement();
240 if (p.attribute("id") == playlist_name) break;
242 int black_clips = p.childNodes().count();
243 for (int i = 0; i < black_clips; i++)
244 m_doc->loadingProgressed();
245 qApp->processEvents();
251 QDomNodeList transitions = doc.elementsByTagName("transition");
253 //kDebug() << "//////////// TIMELINE FOUND: " << projectTransitions << " transitions";
254 for (int i = 0; i < transitions.count(); i++) {
255 e = transitions.item(i).toElement();
256 QDomNodeList transitionparams = e.childNodes();
257 bool transitionAdd = true;
260 bool isAutomatic = false;
261 bool forceTrack = false;
262 QString mlt_geometry;
264 QString transitionId;
265 for (int k = 0; k < transitionparams.count(); k++) {
266 p = transitionparams.item(k).toElement();
268 QString paramName = p.attribute("name");
269 // do not add audio mixing transitions
270 if (paramName == "internal_added" && p.text() == "237") {
271 transitionAdd = false;
272 //kDebug() << "// TRANSITRION " << i << " IS NOT VALID (INTERN ADDED)";
274 } else if (paramName == "a_track") a_track = p.text().toInt();
275 else if (paramName == "b_track") b_track = p.text().toInt();
276 else if (paramName == "mlt_service") mlt_service = p.text();
277 else if (paramName == "kdenlive_id") transitionId = p.text();
278 else if (paramName == "geometry") mlt_geometry = p.text();
279 else if (paramName == "automatic" && p.text() == "1") isAutomatic = true;
280 else if (paramName == "force_track" && p.text() == "1") forceTrack = true;
283 if (transitionAdd || mlt_service != "mix") {
284 // Transition should be added to the scene
285 ItemInfo transitionInfo;
286 if (mlt_service == "composite" && transitionId.isEmpty()) {
287 // When adding composite transition, check if it is a wipe transition
288 if (mlt_geometry.count(';') == 1) {
289 mlt_geometry.remove(QChar('%'), Qt::CaseInsensitive);
290 mlt_geometry.replace(QChar('x'), QChar(','), Qt::CaseInsensitive);
291 QString start = mlt_geometry.section(';', 0, 0);
292 start = start.section(':', 0, 1);
293 start.replace(QChar(':'), QChar(','), Qt::CaseInsensitive);
294 QString end = mlt_geometry.section('=', 1, 1);
295 end = end.section(':', 0, 1);
296 end.replace(QChar(':'), QChar(','), Qt::CaseInsensitive);
297 start.append(',' + end);
298 QStringList numbers = start.split(',', QString::SkipEmptyParts);
299 bool isWipeTransition = true;
301 for (int i = 0; i < numbers.size(); ++i) {
302 checkNumber = qAbs(numbers.at(i).toInt());
303 if (checkNumber != 0 && checkNumber != 100) {
304 isWipeTransition = false;
308 if (isWipeTransition) transitionId = "slide";
311 QDomElement base = MainWindow::transitions.getEffectByTag(mlt_service, transitionId).cloneNode().toElement();
313 for (int k = 0; k < transitionparams.count(); k++) {
314 p = transitionparams.item(k).toElement();
316 QString paramName = p.attribute("name");
317 QString paramValue = p.text();
319 QDomNodeList params = base.elementsByTagName("parameter");
320 if (paramName != "a_track" && paramName != "b_track") for (int i = 0; i < params.count(); i++) {
321 QDomElement e = params.item(i).toElement();
322 if (!e.isNull() && e.attribute("tag") == paramName) {
323 if (e.attribute("type") == "double") {
324 QString factor = e.attribute("factor", "1");
326 double val = paramValue.toDouble() * factor.toDouble();
327 paramValue = QString::number(val);
330 e.setAttribute("value", paramValue);
338 doc.appendChild(doc.importNode(base, true));
339 kDebug() << "/////// TRANSITION XML: "<< doc.toString();*/
341 transitionInfo.startPos = GenTime(e.attribute("in").toInt(), m_doc->fps());
342 transitionInfo.endPos = GenTime(e.attribute("out").toInt() + 1, m_doc->fps());
343 transitionInfo.track = m_projectTracks - 1 - b_track;
344 //kDebug() << "/////////////// +++++++++++ ADDING TRANSITION ON TRACK: " << b_track << ", TOTAL TRKA: " << m_projectTracks;
345 if (transitionInfo.startPos >= transitionInfo.endPos) {
346 // invalid transition, remove it.
347 m_documentErrors.append(i18n("Removed invalid transition: %1", e.attribute("id")) + '\n');
348 kDebug() << "///// REMOVED INVALID TRANSITION: " << e.attribute("id");
349 tractor.removeChild(transitions.item(i));
352 Transition *tr = new Transition(transitionInfo, a_track, m_doc->fps(), base, isAutomatic);
353 if (forceTrack) tr->setForcedTrack(true, a_track);
354 m_scene->addItem(tr);
355 if (b_track > 0 && m_doc->isTrackLocked(b_track - 1)) {
356 tr->setItemLocked(true);
363 QDomNodeList guides = doc.elementsByTagName("guide");
364 for (int i = 0; i < guides.count(); i++) {
365 e = guides.item(i).toElement();
366 const QString comment = e.attribute("comment");
367 const GenTime pos = GenTime(e.attribute("time").toDouble());
368 m_trackview->addGuide(pos, comment);
372 QDomNodeList groups = doc.elementsByTagName("group");
373 m_trackview->loadGroups(groups);
374 m_trackview->setDuration(duration);
375 kDebug() << "/////////// TOTAL PROJECT DURATION: " << duration;
377 // Remove Kdenlive extra info from xml doc before sending it to MLT
378 QDomElement mlt = doc.firstChildElement("mlt");
379 QDomElement infoXml = mlt.firstChildElement("kdenlivedoc");
380 mlt.removeChild(infoXml);
382 slotRebuildTrackHeaders();
383 if (!m_documentErrors.isNull()) KMessageBox::sorry(this, m_documentErrors);
384 //m_trackview->setCursorPos(cursorPos);
385 //m_scrollBox->setGeometry(0, 0, 300 * zoomFactor(), m_scrollArea->height());
388 void TrackView::slotDeleteClip(const QString &clipId)
390 m_trackview->deleteClip(clipId);
393 void TrackView::setCursorPos(int pos)
395 m_trackview->setCursorPos(pos);
398 void TrackView::moveCursorPos(int pos)
400 m_trackview->setCursorPos(pos, false);
403 void TrackView::slotChangeZoom(int factor)
405 m_doc->setZoom(factor);
406 m_ruler->setPixelPerMark(factor);
407 m_scale = (double) FRAME_SIZE / m_ruler->comboScale[factor]; // m_ruler->comboScale[m_currentZoom] /
408 m_trackview->setScale(m_scale, m_scene->scale().y());
411 int TrackView::fitZoom() const
413 int zoom = (int)((duration() + 20 / m_scale) * FRAME_SIZE / m_trackview->width());
415 for (i = 0; i < 13; i++)
416 if (m_ruler->comboScale[i] > zoom) break;
420 KdenliveDoc *TrackView::document()
425 void TrackView::refresh()
427 m_trackview->viewport()->update();
430 void TrackView::slotRebuildTrackHeaders()
432 QList <TrackInfo> list = m_doc->tracksList();
434 while ((child = m_headersLayout->takeAt(0)) != 0) {
435 if (child->widget()) delete child->widget();
438 int max = list.count();
439 int height = KdenliveSettings::trackheight() * m_scene->scale().y();
440 for (int i = 0; i < max; i++) {
441 HeaderTrack *header = new HeaderTrack(i, list.at(max - i - 1), height, this);
442 connect(header, SIGNAL(switchTrackVideo(int)), m_trackview, SLOT(slotSwitchTrackVideo(int)));
443 connect(header, SIGNAL(switchTrackAudio(int)), m_trackview, SLOT(slotSwitchTrackAudio(int)));
444 connect(header, SIGNAL(switchTrackLock(int)), m_trackview, SLOT(slotSwitchTrackLock(int)));
446 connect(header, SIGNAL(deleteTrack(int)), this, SIGNAL(deleteTrack(int)));
447 connect(header, SIGNAL(insertTrack(int)), this, SIGNAL(insertTrack(int)));
448 connect(header, SIGNAL(changeTrack(int)), this, SIGNAL(changeTrack(int)));
449 m_headersLayout->addWidget(header);
454 void TrackView::adjustTrackHeaders()
456 int height = KdenliveSettings::trackheight() * m_scene->scale().y();
458 for (int i = 0; i < m_headersLayout->count(); i++) {
459 child = m_headersLayout->itemAt(i);
460 if (child->widget())(static_cast <HeaderTrack *>(child->widget()))->adjustSize(height);
464 int TrackView::slotAddProjectTrack(int ix, QDomElement xml, bool locked)
468 QDomNodeList children = xml.childNodes();
469 for (int nodeindex = 0; nodeindex < children.count(); nodeindex++) {
470 QDomNode n = children.item(nodeindex);
471 QDomElement elem = n.toElement();
472 if (elem.tagName() == "blank") {
473 position += elem.attribute("length").toInt();
474 } else if (elem.tagName() == "entry") {
475 m_doc->loadingProgressed();
476 qApp->processEvents();
478 int in = elem.attribute("in").toInt();
479 int out = elem.attribute("out").toInt();
480 if (in > out || in == out || m_invalidProducers.contains(elem.attribute("producer"))) {
481 m_documentErrors.append(i18n("Invalid clip removed from track %1 at %2\n", ix, position));
482 xml.removeChild(children.at(nodeindex));
486 QString idString = elem.attribute("producer");
487 QString id = idString;
489 if (idString.startsWith("slowmotion")) {
490 id = idString.section(':', 1, 1);
491 speed = idString.section(':', 2, 2).toDouble();
492 } else id = id.section('_', 0, 0);
493 DocClipBase *clip = m_doc->clipManager()->getClipById(id);
495 // The clip in playlist was not listed in the kdenlive producers,
496 // something went wrong, repair required.
497 kWarning() << "CANNOT INSERT CLIP " << id;
499 clip = getMissingProducer(id);
501 // We cannot find the producer, something is really wrong, add
502 // placeholder color clip
504 QDomElement producerXml = doc.createElement("producer");
505 doc.appendChild(producerXml);
506 producerXml.setAttribute("colour", "0xff0000ff");
507 producerXml.setAttribute("mlt_service", "colour");
508 producerXml.setAttribute("length", "15000");
509 producerXml.setAttribute("name", "INVALID");
510 producerXml.setAttribute("type", COLOR);
511 producerXml.setAttribute("id", id);
512 clip = new DocClipBase(m_doc->clipManager(), doc.documentElement(), id);
513 xml.insertBefore(producerXml, QDomNode());
514 m_doc->clipManager()->addClip(clip);
516 m_documentErrors.append(i18n("Broken clip producer %1", id) + '\n');
518 // Found correct producer
519 m_documentErrors.append(i18n("Replaced wrong clip producer %1 with %2", id, clip->getId()) + '\n');
520 elem.setAttribute("producer", clip->getId());
522 m_doc->setModified(true);
527 clipinfo.startPos = GenTime(position, m_doc->fps());
528 clipinfo.endPos = clipinfo.startPos + GenTime(out - in + 1, m_doc->fps());
529 clipinfo.cropStart = GenTime(in, m_doc->fps());
531 //kDebug() << "// INSERTING CLIP: " << in << "x" << out << ", track: " << ix << ", ID: " << id << ", SCALE: " << m_scale << ", FPS: " << m_doc->fps();
532 ClipItem *item = new ClipItem(clip, clipinfo, m_doc->fps(), speed, false);
533 if (idString.endsWith("_video")) item->setVideoOnly(true);
534 else if (idString.endsWith("_audio")) item->setAudioOnly(true);
535 m_scene->addItem(item);
536 if (locked) item->setItemLocked(true);
537 clip->addReference();
538 position += (out - in + 1);
540 // parse clip effects
541 QDomNodeList effects = elem.childNodes();
542 for (int ix = 0; ix < effects.count(); ix++) {
543 QDomElement effect = effects.at(ix).toElement();
544 if (effect.tagName() == "filter") {
545 // add effect to clip
549 QString ladspaEffectFile;
550 // Get effect tag & index
551 for (QDomNode n3 = effect.firstChild(); !n3.isNull(); n3 = n3.nextSibling()) {
552 // parse effect parameters
553 QDomElement effectparam = n3.toElement();
554 if (effectparam.attribute("name") == "tag") {
555 effecttag = effectparam.text();
556 } else if (effectparam.attribute("name") == "kdenlive_id") {
557 effectid = effectparam.text();
558 } else if (effectparam.attribute("name") == "kdenlive_ix") {
559 effectindex = effectparam.text();
560 } else if (effectparam.attribute("name") == "src") {
561 ladspaEffectFile = effectparam.text();
562 if (!QFile::exists(ladspaEffectFile)) {
563 // If the ladspa effect file is missing, recreate it
564 kDebug() << "// MISSING LADSPA FILE: " << ladspaEffectFile;
565 ladspaEffectFile = m_doc->getLadspaFile();
566 effectparam.firstChild().setNodeValue(ladspaEffectFile);
567 kDebug() << "// ... REPLACED WITH: " << ladspaEffectFile;
571 //kDebug() << "+ + CLIP EFF FND: " << effecttag << ", " << effectid << ", " << effectindex;
572 // get effect standard tags
573 QDomElement clipeffect = MainWindow::customEffects.getEffectByTag(QString(), effectid);
574 if (clipeffect.isNull()) clipeffect = MainWindow::videoEffects.getEffectByTag(effecttag, effectid);
575 if (clipeffect.isNull()) clipeffect = MainWindow::audioEffects.getEffectByTag(effecttag, effectid);
576 if (clipeffect.isNull()) {
577 kDebug() << "/// WARNING, EFFECT: " << effecttag << ": " << effectid << " not found, removing it from project";
578 m_documentErrors.append(i18n("Effect %1:%2 not found in MLT, it was removed from this project\n", effecttag, effectid));
579 elem.removeChild(effects.at(ix));
582 QDomElement currenteffect = clipeffect.cloneNode().toElement();
583 currenteffect.setAttribute("kdenlive_ix", effectindex);
584 QDomNodeList clipeffectparams = currenteffect.childNodes();
586 if (MainWindow::videoEffects.hasKeyFrames(currenteffect)) {
587 //kDebug() << " * * * * * * * * * * ** CLIP EFF WITH KFR FND * * * * * * * * * * *";
588 // effect is key-framable, read all effects to retrieve keyframes
592 QDomNodeList params = currenteffect.elementsByTagName("parameter");
593 for (int i = 0; i < params.count(); i++) {
594 QDomElement e = params.item(i).toElement();
595 if (e.attribute("type") == "keyframe") {
596 starttag = e.attribute("starttag", "start");
597 endtag = e.attribute("endtag", "end");
598 factor = e.attribute("factor", "1").toDouble();
603 int effectin = effect.attribute("in").toInt();
604 int effectout = effect.attribute("out").toInt();
605 double startvalue = 0;
607 for (QDomNode n3 = effect.firstChild(); !n3.isNull(); n3 = n3.nextSibling()) {
608 // parse effect parameters
609 QDomElement effectparam = n3.toElement();
610 if (effectparam.attribute("name") == starttag)
611 startvalue = effectparam.text().toDouble() * factor;
612 if (effectparam.attribute("name") == endtag)
613 endvalue = effectparam.text().toDouble() * factor;
615 // add first keyframe
616 keyframes.append(QString::number(effectin) + ':' + QString::number(startvalue) + ';' + QString::number(effectout) + ':' + QString::number(endvalue) + ';');
617 QDomNode lastParsedEffect;
619 QDomNode n2 = effects.at(ix);
620 bool continueParsing = true;
621 for (; !n2.isNull() && continueParsing; n2 = n2.nextSibling()) {
623 QDomElement kfreffect = n2.toElement();
624 int effectout = kfreffect.attribute("out").toInt();
626 for (QDomNode n4 = kfreffect.firstChild(); !n4.isNull(); n4 = n4.nextSibling()) {
627 // parse effect parameters
628 QDomElement subeffectparam = n4.toElement();
629 if (subeffectparam.attribute("name") == "kdenlive_ix" && subeffectparam.text() != effectindex) {
630 //We are not in the same effect, stop parsing
631 lastParsedEffect = n2.previousSibling();
633 continueParsing = false;
635 } else if (subeffectparam.attribute("name") == endtag) {
636 endvalue = subeffectparam.text().toDouble() * factor;
640 if (continueParsing) {
641 keyframes.append(QString::number(effectout) + ':' + QString::number(endvalue) + ';');
646 params = currenteffect.elementsByTagName("parameter");
647 for (int i = 0; i < params.count(); i++) {
648 QDomElement e = params.item(i).toElement();
649 if (e.attribute("type") == "keyframe") e.setAttribute("keyframes", keyframes);
651 if (!continueParsing) {
652 n2 = lastParsedEffect;
655 // Check if effect has in/out points
656 if (effect.hasAttribute("in")) {
657 EffectsList::setParameter(currenteffect, "in", effect.attribute("in"));
659 if (effect.hasAttribute("out")) {
660 EffectsList::setParameter(currenteffect, "out", effect.attribute("out"));
664 // adjust effect parameters
665 for (QDomNode n3 = effect.firstChild(); !n3.isNull(); n3 = n3.nextSibling()) {
666 // parse effect parameters
667 QDomElement effectparam = n3.toElement();
668 QString paramname = effectparam.attribute("name");
669 QString paramvalue = effectparam.text();
672 // try to find this parameter in the effect xml
674 for (int k = 0; k < clipeffectparams.count(); k++) {
675 e = clipeffectparams.item(k).toElement();
676 if (!e.isNull() && e.tagName() == "parameter" && e.attribute("name") == paramname) {
677 double factor = e.attribute("factor", "1").toDouble();
679 e.setAttribute("value", paramvalue.toDouble() * factor);
680 } else e.setAttribute("value", paramvalue);
685 if (effecttag == "ladspa") {
686 //QString ladspaEffectFile = EffectsList::parameter(effect, "src", "property");
688 if (!QFile::exists(ladspaEffectFile)) {
689 // If the ladspa effect file is missing, recreate it
690 initEffects::ladspaEffectFile(ladspaEffectFile, currenteffect.attribute("ladspaid").toInt(), m_trackview->getLadspaParams(currenteffect));
692 currenteffect.setAttribute("src", ladspaEffectFile);
694 item->addEffect(currenteffect, false);
695 item->effectsCounter();
700 //m_clipList.append(clip);
703 //m_trackDuration = position;
706 //documentTracks.insert(ix, track);
707 kDebug() << "************* ADD DOC TRACK " << ix << ", DURATION: " << position;
712 DocClipBase *TrackView::getMissingProducer(const QString id) const
714 QDomElement missingXml;
715 QDomDocument doc = m_doc->toXml();
716 QString docRoot = doc.documentElement().attribute("root");
717 if (!docRoot.endsWith('/')) docRoot.append('/');
718 QDomNodeList prods = doc.elementsByTagName("producer");
719 int maxprod = prods.count();
720 for (int i = 0; i < maxprod; i++) {
721 QDomNode m = prods.at(i);
722 QString prodId = m.toElement().attribute("id");
724 missingXml = m.toElement();
728 if (missingXml == QDomElement()) return NULL;
730 QDomNodeList params = missingXml.childNodes();
732 for (int j = 0; j < params.count(); j++) {
733 QDomElement e = params.item(j).toElement();
734 if (e.attribute("name") == "resource") {
735 resource = e.firstChild().nodeValue();
739 // prepend MLT XML document root if no path in clip resource and not a color clip
740 if (!resource.contains('/') && !resource.startsWith("0x")) resource.prepend(docRoot);
741 DocClipBase *missingClip = NULL;
742 if (!resource.isEmpty())
743 missingClip = m_doc->clipManager()->getClipByResource(resource);
747 QGraphicsScene *TrackView::projectScene()
752 CustomTrackView *TrackView::projectView()
757 void TrackView::setEditMode(const QString & editMode)
759 m_editMode = editMode;
762 const QString & TrackView::editMode() const
767 void TrackView::slotChangeTrackLock(int ix, bool lock)
769 QList<HeaderTrack *> widgets = findChildren<HeaderTrack *>();
770 widgets.at(ix)->setLock(lock);
773 void TrackView::slotVerticalZoomDown()
775 if (m_verticalZoom == 0) return;
777 if (m_verticalZoom == 0) m_trackview->setScale(m_scene->scale().x(), 0.5);
778 else m_trackview->setScale(m_scene->scale().x(), 1);
779 adjustTrackHeaders();
780 /*KdenliveSettings::setTrackheight(KdenliveSettings::trackheight() / 2);
781 m_trackview->checkTrackHeight(false);*/
784 void TrackView::slotVerticalZoomUp()
786 if (m_verticalZoom == 2) return;
788 /*KdenliveSettings::setTrackheight(KdenliveSettings::trackheight() * 2);
789 m_trackview->checkTrackHeight(false);*/
790 if (m_verticalZoom == 2) m_trackview->setScale(m_scene->scale().x(), 2);
791 else m_trackview->setScale(m_scene->scale().x(), 1);
792 adjustTrackHeaders();
795 #include "trackview.moc"