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