]> git.sesse.net Git - kdenlive/blob - src/trackview.cpp
Fix LADSPA effects, should work now:
[kdenlive] / src / trackview.cpp
1 /***************************************************************************
2  *   Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org)        *
3  *                                                                         *
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.                                   *
8  *                                                                         *
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.                          *
13  *                                                                         *
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  ***************************************************************************/
19
20
21 #include <QScrollBar>
22
23 #include <KDebug>
24 #include <KMessageBox>
25
26 #include "definitions.h"
27 #include "headertrack.h"
28 #include "trackview.h"
29 #include "clipitem.h"
30 #include "transition.h"
31 #include "kdenlivesettings.h"
32 #include "clipmanager.h"
33 #include "customruler.h"
34 #include "kdenlivedoc.h"
35 #include "mainwindow.h"
36 #include "customtrackview.h"
37 #include "initeffects.h"
38
39 TrackView::TrackView(KdenliveDoc *doc, QWidget *parent)
40         : QWidget(parent), m_doc(doc), m_scale(1.0), m_projectTracks(0) {
41
42     view = new Ui::TimeLine_UI();
43     view->setupUi(this);
44
45     m_scene = new CustomTrackScene(doc);
46     m_trackview = new CustomTrackView(doc, m_scene, parent);
47     m_trackview->scale(1, 1);
48     m_trackview->setAlignment(Qt::AlignLeft | Qt::AlignTop);
49     //m_scene->addRect(QRectF(0, 0, 100, 100), QPen(), QBrush(Qt::red));
50
51     m_ruler = new CustomRuler(doc->timecode(), m_trackview);
52     connect(m_ruler, SIGNAL(zoneMoved(int, int)), this, SIGNAL(zoneMoved(int, int)));
53     QHBoxLayout *layout = new QHBoxLayout;
54     view->ruler_frame->setLayout(layout);
55     int left_margin;
56     int right_margin;
57     layout->getContentsMargins(&left_margin, 0, &right_margin, 0);
58     layout->setContentsMargins(left_margin, 0, right_margin, 0);
59     layout->addWidget(m_ruler);
60
61     QHBoxLayout *tracksLayout = new QHBoxLayout;
62     tracksLayout->setContentsMargins(0, 0, 0, 0);
63     view->tracks_frame->setLayout(tracksLayout);
64
65     view->headers_area->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
66     view->headers_area->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
67
68     m_headersLayout = new QVBoxLayout;
69     m_headersLayout->setContentsMargins(0, 0, 0, 0);
70     m_headersLayout->setSpacing(0);
71     view->headers_container->setLayout(m_headersLayout);
72
73     connect(view->headers_area->verticalScrollBar(), SIGNAL(valueChanged(int)), m_trackview->verticalScrollBar(), SLOT(setValue(int)));
74
75     tracksLayout->addWidget(m_trackview);
76
77     connect(m_trackview->verticalScrollBar(), SIGNAL(valueChanged(int)), view->headers_area->verticalScrollBar(), SLOT(setValue(int)));
78     connect(m_trackview, SIGNAL(trackHeightChanged()), this, SLOT(slotRebuildTrackHeaders()));
79
80     parseDocument(m_doc->toXml());
81
82     connect(m_trackview, SIGNAL(cursorMoved(int, int)), m_ruler, SLOT(slotCursorMoved(int, int)));
83     connect(m_trackview->horizontalScrollBar(), SIGNAL(valueChanged(int)), m_ruler, SLOT(slotMoveRuler(int)));
84     connect(m_trackview, SIGNAL(mousePosition(int)), this, SIGNAL(mousePosition(int)));
85     connect(m_trackview, SIGNAL(transitionItemSelected(Transition*, bool)), this, SLOT(slotTransitionItemSelected(Transition*, bool)));
86     slotChangeZoom(m_doc->zoom());
87 }
88
89
90 int TrackView::duration() const {
91     return m_trackview->duration();
92 }
93
94 int TrackView::tracksNumber() const {
95     return m_projectTracks - 1;
96 }
97
98 int TrackView::inPoint() const {
99     return m_ruler->inPoint();
100 }
101
102 int TrackView::outPoint() const {
103     return m_ruler->outPoint();
104 }
105
106 void TrackView::slotSetZone(QPoint p) {
107     m_ruler->setZone(p);
108 }
109
110 void TrackView::slotTransitionItemSelected(Transition *t, bool update) {
111     emit transitionItemSelected(t, update);
112 }
113
114 void TrackView::setDuration(int dur) {
115     m_trackview->setDuration(dur);
116     m_ruler->setDuration(dur);
117 }
118
119 void TrackView::parseDocument(QDomDocument doc) {
120     int cursorPos = 0;
121     m_documentErrors = QString();
122     // kDebug() << "//// DOCUMENT: " << doc.toString();
123     /*QDomNode props = doc.elementsByTagName("properties").item(0);
124     if (!props.isNull()) {
125         cursorPos = props.toElement().attribute("timeline_position").toInt();
126     }*/
127
128     // parse project tracks
129     QDomNodeList tracks = doc.elementsByTagName("track");
130     QDomNodeList playlists = doc.elementsByTagName("playlist");
131     int duration = 300;
132     m_projectTracks = tracks.count();
133     int trackduration = 0;
134     QDomElement e;
135     QDomElement p;
136
137     int pos = m_projectTracks - 1;
138
139
140     for (int i = 0; i < m_projectTracks; i++) {
141         e = tracks.item(i).toElement();
142         QString playlist_name = e.attribute("producer");
143         if (playlist_name != "black_track" && playlist_name != "playlistmain") {
144             // find playlist related to this track
145             p = QDomElement();
146             for (int j = 0; j < m_projectTracks; j++) {
147                 p = playlists.item(j).toElement();
148                 if (p.attribute("id") == playlist_name) break;
149             }
150             if (e.attribute("hide") == "video") {
151                 m_doc->switchTrackVideo(i - 1, true);
152             } else if (e.attribute("hide") == "audio") {
153                 m_doc->switchTrackAudio(i - 1, true);
154             } else if (e.attribute("hide") == "both") {
155                 m_doc->switchTrackVideo(i - 1, true);
156                 m_doc->switchTrackAudio(i - 1, true);
157             }
158             trackduration = slotAddProjectTrack(pos, p);
159             pos--;
160             //kDebug() << " PRO DUR: " << trackduration << ", TRACK DUR: " << duration;
161             if (trackduration > duration) duration = trackduration;
162         } else {
163             // background black track
164             for (int j = 0; j < m_projectTracks; j++) {
165                 p = playlists.item(j).toElement();
166                 if (p.attribute("id") == playlist_name) break;
167             }
168             int black_clips = p.childNodes().count();
169             for (int i = 0; i < black_clips; i++)
170                 m_doc->loadingProgressed();
171             qApp->processEvents();
172             pos--;
173         }
174     }
175
176     // parse transitions
177     QDomNodeList transitions = doc.elementsByTagName("transition");
178     int projectTransitions = transitions.count();
179     //kDebug() << "//////////// TIMELINE FOUND: " << projectTransitions << " transitions";
180     for (int i = 0; i < projectTransitions; i++) {
181         e = transitions.item(i).toElement();
182         QDomNodeList transitionparams = e.childNodes();
183         bool transitionAdd = true;
184         int a_track = 0;
185         int b_track = 0;
186         bool isAutomatic = false;
187         bool forceTrack = false;
188         QString mlt_geometry;
189         QString mlt_service;
190         for (int k = 0; k < transitionparams.count(); k++) {
191             p = transitionparams.item(k).toElement();
192             if (!p.isNull()) {
193                 QString paramName = p.attribute("name");
194                 // do not add audio mixing transitions
195                 if (paramName == "internal_added" && p.text() == "237") {
196                     transitionAdd = false;
197                     //kDebug() << "//  TRANSITRION " << i << " IS NOT VALID (INTERN ADDED)";
198                     //break;
199                 } else if (paramName == "a_track") a_track = p.text().toInt();
200                 else if (paramName == "b_track") b_track = p.text().toInt();
201                 else if (paramName == "mlt_service") mlt_service = p.text();
202                 else if (paramName == "geometry") mlt_geometry = p.text();
203                 else if (paramName == "automatic" && p.text() == "1") isAutomatic = true;
204                 else if (paramName == "force_track" && p.text() == "1") forceTrack = true;
205             }
206         }
207         if (transitionAdd || mlt_service != "mix") {
208             // Transition should be added to the scene
209             ItemInfo transitionInfo;
210             QString transitionId;
211             if (mlt_service == "composite") {
212                 // When adding composite transition, check if it is a wipe transition
213                 if (mlt_geometry == "0%,0%:100%x100%") transitionId = "alphatransparency";
214                 else if (mlt_geometry.count(';') == 1) {
215                     mlt_geometry.remove(QChar('%'), Qt::CaseInsensitive);
216                     mlt_geometry.replace(QChar('x'), QChar(','), Qt::CaseInsensitive);
217                     QString start = mlt_geometry.section(';', 0, 0);
218                     start = start.section(':', 0, 1);
219                     start.replace(QChar(':'), QChar(','), Qt::CaseInsensitive);
220                     QString end = mlt_geometry.section('=', 1, 1);
221                     end = end.section(':', 0, 1);
222                     end.replace(QChar(':'), QChar(','), Qt::CaseInsensitive);
223                     start.append(',' + end);
224                     QStringList numbers = start.split(',', QString::SkipEmptyParts);
225                     bool isWipeTransition = true;
226                     int checkNumber;
227                     for (int i = 0; i < numbers.size(); ++i) {
228                         checkNumber = qAbs(numbers.at(i).toInt());
229                         if (checkNumber != 0 && checkNumber != 100) {
230                             isWipeTransition = false;
231                             break;
232                         }
233                     }
234                     if (isWipeTransition) transitionId = "wipe";
235                 }
236             }
237             QDomElement base = MainWindow::transitions.getEffectByTag(mlt_service, transitionId).cloneNode().toElement();
238
239             for (int k = 0; k < transitionparams.count(); k++) {
240                 p = transitionparams.item(k).toElement();
241                 if (!p.isNull()) {
242                     QString paramName = p.attribute("name");
243                     QString paramValue = p.text();
244
245                     QDomNodeList params = base.elementsByTagName("parameter");
246                     if (paramName != "a_track" && paramName != "b_track") for (int i = 0; i < params.count(); i++) {
247                             QDomElement e = params.item(i).toElement();
248                             if (!e.isNull() && e.attribute("tag") == paramName) {
249                                 if (e.attribute("type") == "double") {
250                                     QString factor = e.attribute("factor", "1");
251                                     if (factor != "1") {
252                                         double val = paramValue.toDouble() * factor.toDouble();
253                                         paramValue = QString::number(val);
254                                     }
255                                 }
256                                 e.setAttribute("value", paramValue);
257                                 break;
258                             }
259                         }
260                 }
261             }
262
263             /*QDomDocument doc;
264             doc.appendChild(doc.importNode(base, true));
265             kDebug() << "///////  TRANSITION XML: "<< doc.toString();*/
266
267             transitionInfo.startPos = GenTime(e.attribute("in").toInt(), m_doc->fps());
268             transitionInfo.endPos = GenTime(e.attribute("out").toInt() + 1, m_doc->fps());
269             transitionInfo.track = m_projectTracks - 1 - b_track;
270             //kDebug() << "///////////////   +++++++++++  ADDING TRANSITION ON TRACK: " << b_track << ", TOTAL TRKA: " << m_projectTracks;
271             Transition *tr = new Transition(transitionInfo, a_track, m_doc->fps(), base, isAutomatic);
272             if (forceTrack) tr->setForcedTrack(true, a_track);
273             m_scene->addItem(tr);
274         }
275     }
276
277     // Add guides
278     QDomNodeList guides = doc.elementsByTagName("guide");
279     for (int i = 0; i < guides.count(); i++) {
280         e = guides.item(i).toElement();
281         const QString comment = e.attribute("comment");
282         const GenTime pos = GenTime(e.attribute("time").toDouble());
283         m_trackview->addGuide(pos, comment);
284     }
285
286     m_trackview->setDuration(duration);
287     kDebug() << "///////////  TOTAL PROJECT DURATION: " << duration;
288     slotRebuildTrackHeaders();
289     if (!m_documentErrors.isNull()) KMessageBox::sorry(this, m_documentErrors);
290     //m_trackview->setCursorPos(cursorPos);
291     //m_scrollBox->setGeometry(0, 0, 300 * zoomFactor(), m_scrollArea->height());
292 }
293
294 void TrackView::slotDeleteClip(const QString &clipId) {
295     m_trackview->deleteClip(clipId);
296 }
297
298 void TrackView::setCursorPos(int pos) {
299     m_trackview->setCursorPos(pos);
300 }
301
302 void TrackView::moveCursorPos(int pos) {
303     m_trackview->setCursorPos(pos, false);
304 }
305
306 void TrackView::slotChangeZoom(int factor) {
307     m_doc->setZoom(factor);
308     m_ruler->setPixelPerMark(factor);
309     m_scale = (double) FRAME_SIZE / m_ruler->comboScale[factor]; // m_ruler->comboScale[m_currentZoom] /
310     m_trackview->setScale(m_scale);
311 }
312
313 int TrackView::fitZoom() const {
314     int zoom = (int)((duration() + 20 / m_scale) * FRAME_SIZE / m_trackview->width());
315     int i;
316     for (i = 0; i < 13; i++)
317         if (m_ruler->comboScale[i] > zoom) break;
318     return i;
319 }
320
321 const double TrackView::zoomFactor() const {
322     return m_scale;
323 }
324
325 const int TrackView::mapLocalToValue(int x) const {
326     return (int)(x * zoomFactor());
327 }
328
329 KdenliveDoc *TrackView::document() {
330     return m_doc;
331 }
332
333 void TrackView::refresh() {
334     m_trackview->viewport()->update();
335 }
336
337 void TrackView::slotRebuildTrackHeaders() {
338     QList <TrackInfo> list = m_doc->tracksList();
339     QList<HeaderTrack *> widgets = this->findChildren<HeaderTrack *>();
340     for (int i = 0; i < widgets.count(); i++)
341         delete widgets.at(i);
342     int max = list.count();
343     for (int i = 0; i < max; i++) {
344         HeaderTrack *header = new HeaderTrack(i, list.at(max - i - 1), this);
345         connect(header, SIGNAL(switchTrackVideo(int)), m_trackview, SLOT(slotSwitchTrackVideo(int)));
346         connect(header, SIGNAL(switchTrackAudio(int)), m_trackview, SLOT(slotSwitchTrackAudio(int)));
347
348         connect(header, SIGNAL(deleteTrack(int)), this, SIGNAL(deleteTrack(int)));
349         connect(header, SIGNAL(insertTrack(int)), this, SIGNAL(insertTrack(int)));
350         connect(header, SIGNAL(changeTrack(int)), this, SIGNAL(changeTrack(int)));
351         m_headersLayout->addWidget(header);
352     }
353     view->headers_container->adjustSize();
354 }
355
356
357 int TrackView::slotAddProjectTrack(int ix, QDomElement xml) {
358     int trackTop = KdenliveSettings::trackheight() * ix;
359     // parse track
360     int position = 0;
361     for (QDomNode n = xml.firstChild(); !n.isNull(); n = n.nextSibling()) {
362         QDomElement elem = n.toElement();
363         if (elem.tagName() == "blank") {
364             position += elem.attribute("length").toInt();
365         } else if (elem.tagName() == "entry") {
366             m_doc->loadingProgressed();
367             qApp->processEvents();
368             // Found a clip
369             int in = elem.attribute("in").toInt();
370             QString idString = elem.attribute("producer");
371             QString id = idString;
372             bool hasSpeedAttribute = false;
373             double speed;
374             if (idString.startsWith("slowmotion")) {
375                 hasSpeedAttribute = true;
376                 id = idString.section(":", 1, 1);
377                 speed = idString.section(":", 2, 2).toDouble();
378             } else id = id.section('_', 0, 0);
379             DocClipBase *clip = m_doc->clipManager()->getClipById(id);
380             if (clip != NULL) {
381                 int out = elem.attribute("out").toInt();
382
383                 ItemInfo clipinfo;
384                 clipinfo.startPos = GenTime(position, m_doc->fps());
385                 clipinfo.endPos = clipinfo.startPos + GenTime(out - in + 1, m_doc->fps());
386                 clipinfo.cropStart = GenTime(in, m_doc->fps());
387                 clipinfo.track = ix;
388                 //kDebug() << "// INSERTING CLIP: " << in << "x" << out << ", track: " << ix << ", ID: " << id << ", SCALE: " << m_scale << ", FPS: " << m_doc->fps();
389                 ClipItem *item = new ClipItem(clip, clipinfo, m_doc->fps(), false);
390                 if (hasSpeedAttribute) item->setSpeed(speed);
391                 m_scene->addItem(item);
392                 clip->addReference();
393                 position += (out - in + 1);
394
395                 // parse clip effects
396                 QDomNodeList effects = elem.childNodes();
397                 for (int ix = 0; ix < effects.count(); ix++) {
398                     QDomElement effect = effects.at(ix).toElement();
399                     if (effect.tagName() == "filter") {
400                         // add effect to clip
401                         QString effecttag;
402                         QString effectid;
403                         QString effectindex;
404                         QString ladspaEffectFile;
405                         // Get effect tag & index
406                         for (QDomNode n3 = effect.firstChild(); !n3.isNull(); n3 = n3.nextSibling()) {
407                             // parse effect parameters
408                             QDomElement effectparam = n3.toElement();
409                             if (effectparam.attribute("name") == "tag") {
410                                 effecttag = effectparam.text();
411                             } else if (effectparam.attribute("name") == "kdenlive_id") {
412                                 effectid = effectparam.text();
413                             } else if (effectparam.attribute("name") == "kdenlive_ix") {
414                                 effectindex = effectparam.text();
415                             } else if (effectparam.attribute("name") == "src") {
416                                 ladspaEffectFile = effectparam.text();
417                                 if (!QFile::exists(ladspaEffectFile)) {
418                                     // If the ladspa effect file is missing, recreate it
419                                     kDebug() << "// MISSING LADSPA FILE: " << ladspaEffectFile;
420                                     ladspaEffectFile = m_doc->getLadspaFile();
421                                     effectparam.firstChild().setNodeValue(ladspaEffectFile);
422                                     kDebug() << "// ... REPLACED WITH: " << ladspaEffectFile;
423                                 }
424                             }
425                         }
426                         //kDebug() << "+ + CLIP EFF FND: " << effecttag << ", " << effectid << ", " << effectindex;
427                         // get effect standard tags
428                         QDomElement clipeffect = MainWindow::customEffects.getEffectByTag(QString(), effectid);
429                         if (clipeffect.isNull()) clipeffect = MainWindow::videoEffects.getEffectByTag(effecttag, effectid);
430                         if (clipeffect.isNull()) clipeffect = MainWindow::audioEffects.getEffectByTag(effecttag, effectid);
431                         if (clipeffect.isNull()) {
432                             kDebug() << "///  WARNING, EFFECT: " << effecttag << ": " << effectid << " not found, removing it from project";
433                             m_documentErrors.append(i18n("Effect %1:%2 not found in MLT, it was removed from this project\n", effecttag, effectid));
434                             elem.removeChild(effects.at(ix));
435                             ix--;
436                         } else {
437                             QDomElement currenteffect = clipeffect.cloneNode().toElement();
438                             currenteffect.setAttribute("kdenlive_ix", effectindex);
439                             QDomNodeList clipeffectparams = currenteffect.childNodes();
440
441                             if (MainWindow::videoEffects.hasKeyFrames(currenteffect)) {
442                                 //kDebug() << " * * * * * * * * * * ** CLIP EFF WITH KFR FND  * * * * * * * * * * *";
443                                 // effect is key-framable, read all effects to retrieve keyframes
444                                 double factor;
445                                 QString starttag;
446                                 QString endtag;
447                                 QDomNodeList params = currenteffect.elementsByTagName("parameter");
448                                 for (int i = 0; i < params.count(); i++) {
449                                     QDomElement e = params.item(i).toElement();
450                                     if (e.attribute("type") == "keyframe") {
451                                         starttag = e.attribute("starttag", "start");
452                                         endtag = e.attribute("endtag", "end");
453                                         factor = e.attribute("factor", "1").toDouble();
454                                         break;
455                                     }
456                                 }
457                                 QString keyframes;
458                                 int effectin = effect.attribute("in").toInt();
459                                 int effectout = effect.attribute("out").toInt();
460                                 double startvalue;
461                                 double endvalue;
462                                 for (QDomNode n3 = effect.firstChild(); !n3.isNull(); n3 = n3.nextSibling()) {
463                                     // parse effect parameters
464                                     QDomElement effectparam = n3.toElement();
465                                     if (effectparam.attribute("name") == starttag)
466                                         startvalue = effectparam.text().toDouble() * factor;
467                                     if (effectparam.attribute("name") == endtag)
468                                         endvalue = effectparam.text().toDouble() * factor;
469                                 }
470                                 // add first keyframe
471                                 keyframes.append(QString::number(effectin) + ":" + QString::number(startvalue) + ";" + QString::number(effectout) + ":" + QString::number(endvalue) + ";");
472                                 QDomNode lastParsedEffect;
473                                 ix++;
474                                 QDomNode n2 = effects.at(ix);
475                                 bool continueParsing = true;
476                                 for (; !n2.isNull() && continueParsing; n2 = n2.nextSibling()) {
477                                     // parse all effects
478                                     QDomElement kfreffect = n2.toElement();
479                                     int effectout = kfreffect.attribute("out").toInt();
480
481                                     for (QDomNode n4 = kfreffect.firstChild(); !n4.isNull(); n4 = n4.nextSibling()) {
482                                         // parse effect parameters
483                                         QDomElement subeffectparam = n4.toElement();
484                                         if (subeffectparam.attribute("name") == "kdenlive_ix" && subeffectparam.text() != effectindex) {
485                                             //We are not in the same effect, stop parsing
486                                             lastParsedEffect = n2.previousSibling();
487                                             ix--;
488                                             continueParsing = false;
489                                             break;
490                                         } else if (subeffectparam.attribute("name") == endtag) {
491                                             endvalue = subeffectparam.text().toDouble() * factor;
492                                             break;
493                                         }
494                                     }
495                                     if (continueParsing) {
496                                         keyframes.append(QString::number(effectout) + ":" + QString::number(endvalue) + ";");
497                                         ix++;
498                                     }
499                                 }
500
501                                 params = currenteffect.elementsByTagName("parameter");
502                                 for (int i = 0; i < params.count(); i++) {
503                                     QDomElement e = params.item(i).toElement();
504                                     if (e.attribute("type") == "keyframe") e.setAttribute("keyframes", keyframes);
505                                 }
506                                 if (!continueParsing) {
507                                     n2 = lastParsedEffect;
508                                 }
509                             } else {
510                                 // Check if effect has in/out points
511                                 if (effect.hasAttribute("in")) {
512                                     EffectsList::setParameter(currenteffect, "in",  effect.attribute("in"));
513                                 }
514                                 if (effect.hasAttribute("out")) {
515                                     EffectsList::setParameter(currenteffect, "out",  effect.attribute("out"));
516                                 }
517                             }
518
519                             // adjust effect parameters
520                             for (QDomNode n3 = effect.firstChild(); !n3.isNull(); n3 = n3.nextSibling()) {
521                                 // parse effect parameters
522                                 QDomElement effectparam = n3.toElement();
523                                 QString paramname = effectparam.attribute("name");
524                                 QString paramvalue = effectparam.text();
525
526
527                                 // try to find this parameter in the effect xml
528                                 QDomElement e;
529                                 for (int k = 0; k < clipeffectparams.count(); k++) {
530                                     e = clipeffectparams.item(k).toElement();
531                                     if (!e.isNull() && e.tagName() == "parameter" && e.attribute("name") == paramname) {
532                                         double factor = e.attribute("factor", "1").toDouble();
533                                         if (factor != 1) {
534                                             e.setAttribute("value", paramvalue.toDouble() * factor);
535                                         } else e.setAttribute("value", paramvalue);
536                                         break;
537                                     }
538                                 }
539                             }
540                             if (effecttag == "ladspa") {
541                                 //QString ladspaEffectFile = EffectsList::parameter(effect, "src", "property");
542
543                                 if (!QFile::exists(ladspaEffectFile)) {
544                                     // If the ladspa effect file is missing, recreate it
545                                     initEffects::ladspaEffectFile(ladspaEffectFile, currenteffect.attribute("ladspaid").toInt(), m_trackview->getLadspaParams(currenteffect));
546                                 }
547                                 currenteffect.setAttribute("src", ladspaEffectFile);
548                             }
549                             item->addEffect(currenteffect, false);
550                             item->effectsCounter();
551                         }
552                     }
553                 }
554             } else kWarning() << "CANNOT INSERT CLIP " << id;
555             //m_clipList.append(clip);
556         }
557     }
558     //m_trackDuration = position;
559
560
561     //documentTracks.insert(ix, track);
562     kDebug() << "*************  ADD DOC TRACK " << ix << ", DURATION: " << position;
563     return position;
564     //track->show();
565 }
566
567 QGraphicsScene *TrackView::projectScene() {
568     return m_scene;
569 }
570
571 CustomTrackView *TrackView::projectView() {
572     return m_trackview;
573 }
574
575 void TrackView::setEditMode(const QString & editMode) {
576     m_editMode = editMode;
577 }
578
579 const QString & TrackView::editMode() const {
580     return m_editMode;
581 }
582
583
584
585 #include "trackview.moc"