]> git.sesse.net Git - kdenlive/blob - src/trackview.cpp
Cleanup track actions, add "Select all clips in a track" and "Select all clips in...
[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 "trackview.h"
22 #include "headertrack.h"
23 #include "clipitem.h"
24 #include "transition.h"
25 #include "kdenlivesettings.h"
26 #include "clipmanager.h"
27 #include "customruler.h"
28 #include "kdenlivedoc.h"
29 #include "mainwindow.h"
30 #include "customtrackview.h"
31 #include "initeffects.h"
32 #include "profilesdialog.h"
33 #include "commands/configtrackscommand.h"
34
35 #include <KDebug>
36 #include <KMessageBox>
37 #include <KIO/NetAccess>
38
39 #include <QScrollBar>
40 #include <QInputDialog>
41
42 TrackView::TrackView(KdenliveDoc *doc, QList <QAction*> actions, bool *ok, QWidget *parent) :
43     QWidget(parent),
44     m_scale(1.0),
45     m_projectTracks(0),
46     m_doc(doc),
47     m_verticalZoom(1)
48 {
49     m_trackActions << actions;
50     setupUi(this);
51 //    ruler_frame->setMaximumHeight();
52 //    size_frame->setMaximumHeight();
53     m_scene = new CustomTrackScene(doc);
54     m_trackview = new CustomTrackView(doc, m_scene, parent);
55     m_trackview->scale(1, 1);
56     m_trackview->setAlignment(Qt::AlignLeft | Qt::AlignTop);
57
58     m_ruler = new CustomRuler(doc->timecode(), m_trackview);
59     connect(m_ruler, SIGNAL(zoneMoved(int, int)), this, SIGNAL(zoneMoved(int, int)));
60     connect(m_ruler, SIGNAL(adjustZoom(int)), this, SIGNAL(setZoom(int)));
61     QHBoxLayout *layout = new QHBoxLayout;
62     layout->setContentsMargins(m_trackview->frameWidth(), 0, 0, 0);
63     layout->setSpacing(0);
64     ruler_frame->setLayout(layout);
65     layout->addWidget(m_ruler);
66
67     QHBoxLayout *sizeLayout = new QHBoxLayout;
68     sizeLayout->setContentsMargins(0, 0, 0, 0);
69     sizeLayout->setSpacing(0);
70     size_frame->setLayout(sizeLayout);
71
72     QToolButton *butSmall = new QToolButton(this);
73     butSmall->setIcon(KIcon("kdenlive-zoom-small"));
74     butSmall->setToolTip(i18n("Smaller tracks"));
75     butSmall->setAutoRaise(true);
76     connect(butSmall, SIGNAL(clicked()), this, SLOT(slotVerticalZoomDown()));
77     sizeLayout->addWidget(butSmall);
78
79     QToolButton *butLarge = new QToolButton(this);
80     butLarge->setIcon(KIcon("kdenlive-zoom-large"));
81     butLarge->setToolTip(i18n("Bigger tracks"));
82     butLarge->setAutoRaise(true);
83     connect(butLarge, SIGNAL(clicked()), this, SLOT(slotVerticalZoomUp()));
84     sizeLayout->addWidget(butLarge);
85
86     QHBoxLayout *tracksLayout = new QHBoxLayout;
87     tracksLayout->setContentsMargins(0, 0, 0, 0);
88     tracksLayout->setSpacing(0);
89     tracks_frame->setLayout(tracksLayout);
90
91     headers_area->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
92     headers_area->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
93     headers_area->setFixedWidth(70);
94
95     QVBoxLayout *headersLayout = new QVBoxLayout;
96     headersLayout->setContentsMargins(0, m_trackview->frameWidth(), 0, 0);
97     headersLayout->setSpacing(0);
98     headers_container->setLayout(headersLayout);
99     connect(headers_area->verticalScrollBar(), SIGNAL(valueChanged(int)), m_trackview->verticalScrollBar(), SLOT(setValue(int)));
100
101     tracksLayout->addWidget(m_trackview);
102     connect(m_trackview->verticalScrollBar(), SIGNAL(valueChanged(int)), headers_area->verticalScrollBar(), SLOT(setValue(int)));
103     connect(m_trackview, SIGNAL(trackHeightChanged()), this, SLOT(slotRebuildTrackHeaders()));
104     connect(m_trackview, SIGNAL(tracksChanged()), this, SLOT(slotReloadTracks()));
105     connect(m_trackview, SIGNAL(updateTrackHeaders()), this, SLOT(slotRepaintTracks()));
106     connect(m_trackview, SIGNAL(showTrackEffects(int, TrackInfo)), this, SIGNAL(showTrackEffects(int, TrackInfo)));
107     connect(m_trackview, SIGNAL(updateTrackEffectState(int)), this, SLOT(slotUpdateTrackEffectState(int)));
108
109
110     parseDocument(m_doc->toXml());
111     if (m_doc->setSceneList() == -1) *ok = false;
112     else *ok = true;
113     connect(m_trackview, SIGNAL(cursorMoved(int, int)), m_ruler, SLOT(slotCursorMoved(int, int)));
114     connect(m_trackview->horizontalScrollBar(), SIGNAL(valueChanged(int)), m_ruler, SLOT(slotMoveRuler(int)));
115     connect(m_trackview->horizontalScrollBar(), SIGNAL(rangeChanged(int, int)), this, SLOT(slotUpdateVerticalScroll(int, int)));
116     connect(m_trackview, SIGNAL(mousePosition(int)), this, SIGNAL(mousePosition(int)));
117     connect(m_trackview, SIGNAL(doTrackLock(int, bool)), this, SLOT(slotChangeTrackLock(int, bool)));
118
119     slotChangeZoom(m_doc->zoom().x(), m_doc->zoom().y());
120     slotSetZone(m_doc->zone(), false);
121 }
122
123 TrackView::~TrackView()
124 {
125     delete m_ruler;
126     delete m_trackview;
127     delete m_scene;
128 }
129
130 //virtual
131 void TrackView::keyPressEvent(QKeyEvent * event)
132 {
133     if (event->key() == Qt::Key_Up) {
134         m_trackview->slotTrackUp();
135         event->accept();
136     } else if (event->key() == Qt::Key_Down) {
137         m_trackview->slotTrackDown();
138         event->accept();
139     } else QWidget::keyPressEvent(event);
140 }
141
142 int TrackView::duration() const
143 {
144     return m_trackview->duration();
145 }
146
147 int TrackView::tracksNumber() const
148 {
149     return m_projectTracks - 1;
150 }
151
152 bool TrackView::checkProjectAudio() const
153 {
154     bool hasAudio = false;
155     const QList <TrackInfo> list = m_doc->tracksList();
156     int max = list.count();
157     for (int i = 0; i < max; i++) {
158         TrackInfo info = list.at(max - i - 1);
159         if (!info.isMute && m_trackview->hasAudio(i)) {
160             hasAudio = true;
161             break;
162         }
163     }
164     return hasAudio;
165 }
166
167 int TrackView::inPoint() const
168 {
169     return m_ruler->inPoint();
170 }
171
172 int TrackView::outPoint() const
173 {
174     return m_ruler->outPoint();
175 }
176
177 void TrackView::slotSetZone(QPoint p, bool updateDocumentProperties)
178 {
179     m_ruler->setZone(p);
180     if (updateDocumentProperties) m_doc->setZone(p.x(), p.y());
181 }
182
183 void TrackView::setDuration(int dur)
184 {
185     m_trackview->setDuration(dur);
186     m_ruler->setDuration(dur);
187 }
188
189 void TrackView::parseDocument(QDomDocument doc)
190 {
191     //int cursorPos = 0;
192     m_documentErrors.clear();
193     m_replacementProducerIds.clear();
194
195     // parse project tracks
196     QDomElement mlt = doc.firstChildElement("mlt");
197     QDomElement tractor = mlt.firstChildElement("tractor");
198     QDomNodeList tracks = tractor.elementsByTagName("track");
199     QDomNodeList playlists = doc.elementsByTagName("playlist");
200     int duration = 300;
201     m_projectTracks = tracks.count();
202     int trackduration = 0;
203     QDomElement e;
204     QDomElement p;
205
206     int pos = m_projectTracks - 1;
207     m_invalidProducers.clear();
208     QDomNodeList producers = doc.elementsByTagName("producer");
209     for (int i = 0; i < producers.count(); i++) {
210         // Check for invalid producers
211         QDomNode n = producers.item(i);
212         e = n.toElement();
213
214         if (e.hasAttribute("in") == false && e.hasAttribute("out") == false) continue;
215         int in = e.attribute("in").toInt();
216         int out = e.attribute("out").toInt();
217         if (in >= out) {
218             // invalid producer, remove it
219             QString id = e.attribute("id");
220             m_invalidProducers.append(id);
221             m_documentErrors.append(i18n("Invalid clip producer %1\n", id));
222             doc.documentElement().removeChild(producers.at(i));
223             i--;
224         }
225     }
226
227     int trackIndex = 0;
228     for (int i = 0; i < m_projectTracks; i++) {
229         e = tracks.item(i).toElement();
230         QString playlist_name = e.attribute("producer");
231         if (playlist_name != "black_track" && playlist_name != "playlistmain") {
232             // find playlist related to this track
233             p = QDomElement();
234             for (int j = 0; j < m_projectTracks; j++) {
235                 p = playlists.item(j).toElement();
236                 if (p.attribute("id") == playlist_name) {
237                     // playlist found, check track effects
238                     QDomNodeList trackEffects = p.childNodes();
239                     slotAddProjectEffects(trackEffects, p, NULL, trackIndex++);
240                     break;
241                 }
242             }
243             if (p.attribute("id") != playlist_name) { // then it didn't work.
244                 kDebug() << "NO PLAYLIST FOUND FOR TRACK " + pos;
245             }
246             if (e.attribute("hide") == "video") {
247                 m_doc->switchTrackVideo(i - 1, true);
248             } else if (e.attribute("hide") == "audio") {
249                 m_doc->switchTrackAudio(i - 1, true);
250             } else if (e.attribute("hide") == "both") {
251                 m_doc->switchTrackVideo(i - 1, true);
252                 m_doc->switchTrackAudio(i - 1, true);
253             }
254
255             trackduration = slotAddProjectTrack(pos, p, m_doc->isTrackLocked(i - 1), producers);
256             pos--;
257             //kDebug() << " PRO DUR: " << trackduration << ", TRACK DUR: " << duration;
258             if (trackduration > duration) duration = trackduration;
259         } else {
260             // background black track
261             for (int j = 0; j < m_projectTracks; j++) {
262                 p = playlists.item(j).toElement();
263                 if (p.attribute("id") == playlist_name) break;
264             }
265             pos--;
266         }
267     }
268
269     // parse transitions
270     QDomNodeList transitions = tractor.elementsByTagName("transition");
271
272     //kDebug() << "//////////// TIMELINE FOUND: " << projectTransitions << " transitions";
273     for (int i = 0; i < transitions.count(); i++) {
274         e = transitions.item(i).toElement();
275         QDomNodeList transitionparams = e.childNodes();
276         bool transitionAdd = true;
277         int a_track = 0;
278         int b_track = 0;
279         bool isAutomatic = false;
280         bool forceTrack = false;
281         QString mlt_geometry;
282         QString mlt_service;
283         QString transitionId;
284         for (int k = 0; k < transitionparams.count(); k++) {
285             p = transitionparams.item(k).toElement();
286             if (!p.isNull()) {
287                 QString paramName = p.attribute("name");
288                 // do not add audio mixing transitions
289                 if (paramName == "internal_added" && p.text() == "237") {
290                     transitionAdd = false;
291                     //kDebug() << "//  TRANSITRION " << i << " IS NOT VALID (INTERN ADDED)";
292                     //break;
293                 } else if (paramName == "a_track") {
294                     a_track = qMax(0, p.text().toInt());
295                     a_track = qMin(m_projectTracks - 1, a_track);
296                     if (a_track != p.text().toInt()) {
297                         // the transition track was out of bounds
298                         m_documentErrors.append(i18n("Transition %1 had an invalid track: %2 > %3", e.attribute("id"), p.text().toInt(), a_track) + '\n');
299                         EffectsList::setProperty(e, "a_track", QString::number(a_track));
300                     }
301                 } else if (paramName == "b_track") {
302                     b_track = qMax(0, p.text().toInt());
303                     b_track = qMin(m_projectTracks - 1, b_track);
304                     if (b_track != p.text().toInt()) {
305                         // the transition track was out of bounds
306                         m_documentErrors.append(i18n("Transition %1 had an invalid track: %2 > %3", e.attribute("id"), p.text().toInt(), b_track) + '\n');
307                         EffectsList::setProperty(e, "b_track", QString::number(b_track));
308                     }
309                 } else if (paramName == "mlt_service") mlt_service = p.text();
310                 else if (paramName == "kdenlive_id") transitionId = p.text();
311                 else if (paramName == "geometry") mlt_geometry = p.text();
312                 else if (paramName == "automatic" && p.text() == "1") isAutomatic = true;
313                 else if (paramName == "force_track" && p.text() == "1") forceTrack = true;
314             }
315         }
316         if (a_track == b_track || b_track == 0) {
317             // invalid transition, remove it
318             m_documentErrors.append(i18n("Removed invalid transition: %1", e.attribute("id")) + '\n');
319             tractor.removeChild(transitions.item(i));
320             i--;
321             continue;
322         }
323         if (transitionAdd || mlt_service != "mix") {
324             // Transition should be added to the scene
325             ItemInfo transitionInfo;
326             if (mlt_service == "composite" && transitionId.isEmpty()) {
327                 // When adding composite transition, check if it is a wipe transition
328                 if (mlt_geometry.count(';') == 1) {
329                     mlt_geometry.remove(QChar('%'), Qt::CaseInsensitive);
330                     mlt_geometry.replace(QChar('x'), QChar(':'), Qt::CaseInsensitive);
331                     mlt_geometry.replace(QChar(','), QChar(':'), Qt::CaseInsensitive);
332                     mlt_geometry.replace(QChar('/'), QChar(':'), Qt::CaseInsensitive);
333                     
334                     QString start = mlt_geometry.section('=', 0, 0).section(':', 0, -2) + ':';
335                     start.append(mlt_geometry.section('=', 1, 1).section(':', 0, -2));
336                     QStringList numbers = start.split(':', QString::SkipEmptyParts);
337                     bool isWipeTransition = true;
338                     int checkNumber;
339                     for (int i = 0; i < numbers.size(); ++i) {
340                         checkNumber = qAbs(numbers.at(i).toInt());
341                         if (checkNumber != 0 && checkNumber != 100) {
342                             isWipeTransition = false;
343                             break;
344                         }
345                     }
346                     if (isWipeTransition) transitionId = "slide";
347                 }
348             }
349
350             QDomElement base = MainWindow::transitions.getEffectByTag(mlt_service, transitionId).cloneNode().toElement();
351
352             if (!base.isNull()) for (int k = 0; k < transitionparams.count(); k++) {
353                     p = transitionparams.item(k).toElement();
354                     if (!p.isNull()) {
355                         QString paramName = p.attribute("name");
356                         QString paramValue = p.text();
357
358                         QDomNodeList params = base.elementsByTagName("parameter");
359                         if (paramName != "a_track" && paramName != "b_track") for (int i = 0; i < params.count(); i++) {
360                                 QDomElement e = params.item(i).toElement();
361                                 if (!e.isNull() && e.attribute("tag") == paramName) {
362                                     if (e.attribute("type") == "double") {
363                                         QString factor = e.attribute("factor", "1");
364                                         double offset = e.attribute("offset", "0").toDouble();
365                                         if (factor != "1" || offset != 0) {
366                                             double fact;
367                                             if (factor.contains('%')) {
368                                                 fact = ProfilesDialog::getStringEval(m_doc->mltProfile(), factor);
369                                             } else {
370                                                 fact = factor.toDouble();
371                                             }
372                                             paramValue = QLocale().toString(offset + paramValue.toDouble() * fact);
373                                         }
374                                     }
375                                     e.setAttribute("value", paramValue);
376                                     break;
377                                 }
378                             }
379                     }
380                 }
381
382             /*QDomDocument doc;
383             doc.appendChild(doc.importNode(base, true));
384             kDebug() << "///////  TRANSITION XML: "<< doc.toString();*/
385
386             transitionInfo.startPos = GenTime(e.attribute("in").toInt(), m_doc->fps());
387             transitionInfo.endPos = GenTime(e.attribute("out").toInt() + 1, m_doc->fps());
388             transitionInfo.track = m_projectTracks - 1 - b_track;
389
390             //kDebug() << "///////////////   +++++++++++  ADDING TRANSITION ON TRACK: " << b_track << ", TOTAL TRKA: " << m_projectTracks;
391             if (transitionInfo.startPos >= transitionInfo.endPos || base.isNull()) {
392                 // invalid transition, remove it.
393                 m_documentErrors.append(i18n("Removed invalid transition: (%1, %2, %3)", e.attribute("id"), mlt_service, transitionId) + '\n');
394                 kDebug() << "///// REMOVED INVALID TRANSITION: " << e.attribute("id");
395                 tractor.removeChild(transitions.item(i));
396                 i--;
397             } else if (m_trackview->canBePastedTo(transitionInfo, TRANSITIONWIDGET)) {
398                 Transition *tr = new Transition(transitionInfo, a_track, m_doc->fps(), base, isAutomatic);
399                 if (forceTrack) tr->setForcedTrack(true, a_track);
400                 m_scene->addItem(tr);
401                 if (b_track > 0 && m_doc->isTrackLocked(b_track - 1)) {
402                     tr->setItemLocked(true);
403                 }
404             }
405             else {
406                 m_documentErrors.append(i18n("Removed overlapping transition: (%1, %2, %3)", e.attribute("id"), mlt_service, transitionId) + '\n');
407                 tractor.removeChild(transitions.item(i));
408                 i--;
409             }
410         }
411     }
412     QDomElement infoXml = mlt.firstChildElement("kdenlivedoc");
413
414     // Add guides
415     QDomNodeList guides = infoXml.elementsByTagName("guide");
416     for (int i = 0; i < guides.count(); i++) {
417         e = guides.item(i).toElement();
418         const QString comment = e.attribute("comment");
419         const GenTime pos = GenTime(e.attribute("time").toDouble());
420         m_trackview->addGuide(pos, comment);
421     }
422
423     // Rebuild groups
424     QDomNodeList groups = infoXml.elementsByTagName("group");
425     m_trackview->loadGroups(groups);
426     m_trackview->setDuration(duration);
427     kDebug() << "///////////  TOTAL PROJECT DURATION: " << duration;
428
429     // Remove Kdenlive extra info from xml doc before sending it to MLT
430     mlt.removeChild(infoXml);
431
432     slotRebuildTrackHeaders();
433     if (!m_documentErrors.isNull()) KMessageBox::sorry(this, m_documentErrors);
434     if (infoXml.hasAttribute("upgraded") || infoXml.hasAttribute("modified")) {
435         // Our document was upgraded, create a backup copy just in case
436         QString baseFile = m_doc->url().path().section(".kdenlive", 0, 0);
437         int ct = 0;
438         QString backupFile = baseFile + "_backup" + QString::number(ct) + ".kdenlive";
439         while (QFile::exists(backupFile)) {
440             ct++;
441             backupFile = baseFile + "_backup" + QString::number(ct) + ".kdenlive";
442         }
443         QString message;
444         if (infoXml.hasAttribute("upgraded"))
445             message = i18n("Your project file was upgraded to the latest Kdenlive document version.\nTo make sure you don't lose data, a backup copy called %1 was created.", backupFile);
446         else
447             message = i18n("Your project file was modified by Kdenlive.\nTo make sure you don't lose data, a backup copy called %1 was created.", backupFile);
448         if (KIO::NetAccess::file_copy(m_doc->url(), KUrl(backupFile), this))
449             KMessageBox::information(this, message);
450         else
451             KMessageBox::information(this, i18n("Your project file was upgraded to the latest Kdenlive document version, but it was not possible to create a backup copy.", backupFile));
452     }
453     //m_trackview->setCursorPos(cursorPos);
454     //m_scrollBox->setGeometry(0, 0, 300 * zoomFactor(), m_scrollArea->height());
455 }
456
457 void TrackView::slotDeleteClip(const QString &clipId)
458 {
459     m_trackview->deleteClip(clipId);
460 }
461
462 void TrackView::setCursorPos(int pos)
463 {
464     m_trackview->setCursorPos(pos);
465 }
466
467 void TrackView::moveCursorPos(int pos)
468 {
469     m_trackview->setCursorPos(pos, false);
470 }
471
472 void TrackView::slotChangeZoom(int horizontal, int vertical)
473 {
474     m_ruler->setPixelPerMark(horizontal);
475     m_scale = (double) m_trackview->getFrameWidth() / m_ruler->comboScale[horizontal];
476
477     if (vertical == -1) {
478         // user called zoom
479         m_doc->setZoom(horizontal, m_verticalZoom);
480         m_trackview->setScale(m_scale, m_scene->scale().y());
481     } else {
482         m_verticalZoom = vertical;
483         if (m_verticalZoom == 0)
484             m_trackview->setScale(m_scale, 0.5);
485         else
486             m_trackview->setScale(m_scale, m_verticalZoom);
487         adjustTrackHeaders();
488     }
489 }
490
491 int TrackView::fitZoom() const
492 {
493     int zoom = (int)((duration() + 20 / m_scale) * m_trackview->getFrameWidth() / m_trackview->width());
494     int i;
495     for (i = 0; i < 13; i++)
496         if (m_ruler->comboScale[i] > zoom) break;
497     return i;
498 }
499
500 KdenliveDoc *TrackView::document()
501 {
502     return m_doc;
503 }
504
505 void TrackView::refresh()
506 {
507     m_trackview->viewport()->update();
508 }
509
510 void TrackView::slotRepaintTracks()
511 {
512     QList<HeaderTrack *> widgets = findChildren<HeaderTrack *>();
513     for (int i = 0; i < widgets.count(); i++) {
514         if (widgets.at(i)) widgets.at(i)->setSelectedIndex(m_trackview->selectedTrack());
515     }
516 }
517
518 void TrackView::slotReloadTracks()
519 {
520     slotRebuildTrackHeaders();
521     emit updateTracksInfo();
522 }
523
524 void TrackView::slotRebuildTrackHeaders()
525 {
526     const QList <TrackInfo> list = m_doc->tracksList();
527     QLayoutItem *child;
528     while ((child = headers_container->layout()->takeAt(0)) != 0) {
529         QWidget *wid = child->widget();
530         delete child;
531         if (wid) wid->deleteLater();
532     }
533     int max = list.count();
534     int height = KdenliveSettings::trackheight() * m_scene->scale().y() - 1;
535     HeaderTrack *header = NULL;
536     QFrame *frame = NULL;
537
538     QPalette p = palette();
539     KColorScheme scheme(p.currentColorGroup(), KColorScheme::View, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
540     QColor norm = scheme.shade(scheme.background(KColorScheme::ActiveBackground).color(), KColorScheme::MidShade);
541     p.setColor(QPalette::Button, norm);
542
543     QColor col = scheme.background().color();
544     QColor col2 = scheme.foreground().color();
545     headers_container->setStyleSheet(QString("QLineEdit { background-color: transparent;color: rgb(%4, %5, %6);} QLineEdit:hover{ background-color: rgb(%1, %2, %3);} QLineEdit:focus { background-color: rgb(%1, %2, %3);}").arg(col.red()).arg(col.green()).arg(col.blue()).arg(col2.red()).arg(col2.green()).arg(col2.blue()));
546     
547     for (int i = 0; i < max; i++) {
548         frame = new QFrame(headers_container);
549         frame->setFrameStyle(QFrame::HLine);
550         frame->setFixedHeight(1);
551         headers_container->layout()->addWidget(frame);
552         TrackInfo info = list.at(max - i - 1);
553         header = new HeaderTrack(i, info, height, m_trackActions, headers_container);
554         header->setPalette(p);
555         header->setSelectedIndex(m_trackview->selectedTrack());
556         connect(header, SIGNAL(switchTrackVideo(int)), m_trackview, SLOT(slotSwitchTrackVideo(int)));
557         connect(header, SIGNAL(switchTrackAudio(int)), m_trackview, SLOT(slotSwitchTrackAudio(int)));
558         connect(header, SIGNAL(switchTrackLock(int)), m_trackview, SLOT(slotSwitchTrackLock(int)));
559         connect(header, SIGNAL(selectTrack(int)), m_trackview, SLOT(slotSelectTrack(int)));
560         connect(header, SIGNAL(renameTrack(int, QString)), this, SLOT(slotRenameTrack(int, QString)));
561         connect(header, SIGNAL(configTrack(int)), this, SIGNAL(configTrack(int)));
562         connect(header, SIGNAL(addTrackInfo(const QDomElement, int)), m_trackview, SLOT(slotAddTrackEffect(const QDomElement, int)));
563         connect(header, SIGNAL(showTrackEffects(int)), this, SLOT(slotShowTrackEffects(int)));
564         headers_container->layout()->addWidget(header);
565     }
566     frame = new QFrame(this);
567     frame->setFrameStyle(QFrame::HLine);
568     frame->setFixedHeight(1);
569     headers_container->layout()->addWidget(frame);
570 }
571
572
573 void TrackView::adjustTrackHeaders()
574 {
575     int height = KdenliveSettings::trackheight() * m_scene->scale().y() - 1;
576     QList<HeaderTrack *> widgets = findChildren<HeaderTrack *>();
577     for (int i = 0; i < widgets.count(); i++) {
578         if (widgets.at(i)) widgets.at(i)->adjustSize(height);
579     }
580 }
581
582 int TrackView::slotAddProjectTrack(int ix, QDomElement xml, bool locked, QDomNodeList producers)
583 {
584     // parse track
585     int position = 0;
586     QMap <QString, QString> producerReplacementIds;
587     int frame_width = m_trackview->getFrameWidth();
588     QDomNodeList children = xml.childNodes();
589     for (int nodeindex = 0; nodeindex < children.count(); nodeindex++) {
590         QDomNode n = children.item(nodeindex);
591         QDomElement elem = n.toElement();
592         if (elem.tagName() == "blank") {
593             position += elem.attribute("length").toInt();
594         } else if (elem.tagName() == "entry") {
595             // Found a clip
596             int in = elem.attribute("in").toInt();
597             int out = elem.attribute("out").toInt();
598             if (in > out || /*in == out ||*/ m_invalidProducers.contains(elem.attribute("producer"))) {
599                 m_documentErrors.append(i18n("Invalid clip removed from track %1 at %2\n", ix, position));
600                 xml.removeChild(children.at(nodeindex));
601                 nodeindex--;
602                 continue;
603             }
604             QString idString = elem.attribute("producer");
605             if (producerReplacementIds.contains(idString)) {
606                 // replace id
607                 elem.setAttribute("producer", producerReplacementIds.value(idString));
608                 idString = elem.attribute("producer");
609             }
610             QString id = idString;
611             double speed = 1.0;
612             int strobe = 1;
613             if (idString.startsWith("slowmotion")) {
614                 QLocale locale;
615                 id = idString.section(':', 1, 1);
616                 speed = locale.toDouble(idString.section(':', 2, 2));
617                 strobe = idString.section(':', 3, 3).toInt();
618                 if (strobe == 0) strobe = 1;
619             }
620             id = id.section('_', 0, 0);
621             DocClipBase *clip = m_doc->clipManager()->getClipById(id);
622             if (clip == NULL) {
623                 // The clip in playlist was not listed in the kdenlive producers,
624                 // something went wrong, repair required.
625                 kWarning() << "CANNOT INSERT CLIP " << id;
626                 QString docRoot = m_doc->toXml().documentElement().attribute("root");
627                 if (!docRoot.endsWith('/')) docRoot.append('/');
628                 clip = getMissingProducer(idString);
629                 if (clip) {
630                     // We found the original producer in Kdenlive's producers
631                     // Found correct producer
632                     m_documentErrors.append(i18n("Replaced wrong clip producer %1 with %2", id, clip->getId()) + '\n');
633                     QString prodId = clip->getId();
634                     if (clip->clipType() == PLAYLIST || clip->clipType() == AV || clip->clipType() == AUDIO) {
635                         // We need producer for the track
636                         prodId.append("_" + QString::number(ix));
637                     }
638                     elem.setAttribute("producer", prodId);
639                     producerReplacementIds.insert(idString, prodId);
640                     // now adjust the mlt producer
641                     bool found = false;
642                     for (int i = 0; i < producers.count(); i++) {
643                         QDomElement prod = producers.at(i).toElement();
644                         if (prod.attribute("id") == prodId) {
645                             // ok, producer already exists
646                             found = true;
647                             break;
648                         }
649                     }
650                     if (!found) {
651                         for (int i = 0; i < producers.count(); i++) {
652                             QDomElement prod = producers.at(i).toElement();
653                             if (prod.attribute("id") == idString) {
654                                 prod.setAttribute("id", prodId);
655                                 m_replacementProducerIds.insert(idString, prodId);
656                                 found = true;
657                                 break;
658                             }
659                         }
660                     }
661                     if (!found) {
662                         // We didn't find the producer for this track, find producer for another track and duplicate
663                         for (int i = 0; i < producers.count(); i++) {
664                             QDomElement prod = producers.at(i).toElement();
665                             QString mltProdId = prod.attribute("id");
666                             if (mltProdId == prodId || mltProdId.startsWith(prodId + "_")) {
667                                 // Found parent producer, clone it
668                                 QDomElement clone = prod.cloneNode().toElement();
669                                 clone.setAttribute("id", prodId);
670                                 m_doc->toXml().documentElement().insertBefore(clone, xml);
671                                 break;
672                             }
673                         }
674                     }                    
675                 }
676                 else {
677                     // We cannot find the producer, something is really wrong, add
678                     // placeholder color clip
679                     QDomDocument doc;
680                     QDomElement producerXml = doc.createElement("producer");
681                     doc.appendChild(producerXml);
682                     bool foundMltProd = false;
683                     for (int i = 0; i < producers.count(); i++) {
684                         QDomElement prod = producers.at(i).toElement();
685                         if (prod.attribute("id") == id) {
686                             QString service = EffectsList::property(prod, "mlt_service");
687                             QString type = EffectsList::property(prod, "mlt_type");
688                             QString resource = EffectsList::property(prod, "resource");
689                             if (!resource.startsWith('/') && service != "colour") {
690                                 resource.prepend(docRoot);
691                                 kDebug()<<"******************\nADJUSTED 1\n*************************";
692                             }
693                             QString length = EffectsList::property(prod, "length");
694                             producerXml.setAttribute("mlt_service", service);
695                             producerXml.setAttribute("mlt_type", type);
696                             producerXml.setAttribute("resource", resource);
697                             producerXml.setAttribute("duration", length);
698                             if (service == "colour") producerXml.setAttribute("type", COLOR);
699                             else if (service == "qimage" || service == "pixbuf") producerXml.setAttribute("type", IMAGE);
700                             else if (service == "kdenlivetitle") producerXml.setAttribute("type", TEXT);
701                             else producerXml.setAttribute("type", AV);
702                             clip = new DocClipBase(m_doc->clipManager(), doc.documentElement(), id);
703                             m_doc->clipManager()->addClip(clip);
704                             m_documentErrors.append(i18n("Broken clip producer %1, recreated base clip: %2", id, resource) + '\n');
705                             foundMltProd = true;
706                             break;
707                         }
708                     }
709                     if (!foundMltProd) {
710                         // Cannot recover, replace with blank
711                         int duration = elem.attribute("out").toInt() - elem.attribute("in").toInt();
712                         elem.setAttribute("length", duration);
713                         elem.setTagName("blank");
714                         m_documentErrors.append(i18n("Broken clip producer %1, removed from project", id) + '\n');
715                     }
716                 }
717                 m_doc->setModified(true);
718             }
719
720             if (clip != NULL) {
721                 ItemInfo clipinfo;
722                 clipinfo.startPos = GenTime(position, m_doc->fps());
723                 clipinfo.endPos = clipinfo.startPos + GenTime(out - in + 1, m_doc->fps());
724                 clipinfo.cropStart = GenTime(in, m_doc->fps());
725                 clipinfo.cropDuration = clipinfo.endPos - clipinfo.startPos;
726
727                 clipinfo.track = ix;
728                 //kDebug() << "// INSERTING CLIP: " << in << "x" << out << ", track: " << ix << ", ID: " << id << ", SCALE: " << m_scale << ", FPS: " << m_doc->fps();
729                 ClipItem *item = new ClipItem(clip, clipinfo, m_doc->fps(), speed, strobe, frame_width, false);
730                 if (idString.endsWith("_video")) item->setVideoOnly(true);
731                 else if (idString.endsWith("_audio")) item->setAudioOnly(true);
732                 m_scene->addItem(item);
733                 if (locked) item->setItemLocked(true);
734                 clip->addReference();
735                 position += (out - in + 1);
736                 if (speed != 1.0 || strobe > 1) {
737                     QDomElement speedeffect = MainWindow::videoEffects.getEffectByTag(QString(), "speed").cloneNode().toElement();
738                     EffectsList::setParameter(speedeffect, "speed", QString::number((int)(100 * speed + 0.5)));
739                     EffectsList::setParameter(speedeffect, "strobe", QString::number(strobe));
740                     item->addEffect(speedeffect, false);
741                     item->effectsCounter();
742                 }
743
744                 // parse clip effects
745                 QDomNodeList effects = elem.elementsByTagName("filter");
746                 slotAddProjectEffects(effects, elem, item, -1);
747             }
748         }
749     }
750     kDebug() << "*************  ADD DOC TRACK " << ix << ", DURATION: " << position;
751     return position;
752 }
753
754 void TrackView::slotAddProjectEffects(QDomNodeList effects, QDomElement parentNode, ClipItem *clip, int trackIndex)
755 {
756     int effectNb = 0;
757     QLocale locale;
758     for (int ix = 0; ix < effects.count(); ix++) {
759         bool disableeffect = false;
760         QDomElement effect = effects.at(ix).toElement();
761         if (effect.tagName() != "filter") continue;
762         effectNb++;
763         // add effect to clip
764         QString effecttag;
765         QString effectid;
766         QString effectindex = QString::number(effectNb);
767         // Get effect tag & index
768         for (QDomNode n3 = effect.firstChild(); !n3.isNull(); n3 = n3.nextSibling()) {
769             // parse effect parameters
770             QDomElement effectparam = n3.toElement();
771             if (effectparam.attribute("name") == "tag") {
772                 effecttag = effectparam.text();
773             } else if (effectparam.attribute("name") == "kdenlive_id") {
774                 effectid = effectparam.text();
775             } else if (effectparam.attribute("name") == "disable" && effectparam.text().toInt() == 1) {
776                 // Fix effects index
777                 disableeffect = true;
778             } else if (effectparam.attribute("name") == "kdenlive_ix") {
779                 // Fix effects index
780                 effectparam.firstChild().setNodeValue(effectindex);
781             }
782         }
783         //kDebug() << "+ + CLIP EFF FND: " << effecttag << ", " << effectid << ", " << effectindex;
784         // get effect standard tags
785         QDomElement clipeffect = MainWindow::customEffects.getEffectByTag(QString(), effectid);
786         if (clipeffect.isNull()) {
787             clipeffect = MainWindow::videoEffects.getEffectByTag(effecttag, effectid);
788         }
789         if (clipeffect.isNull()) {
790             clipeffect = MainWindow::audioEffects.getEffectByTag(effecttag, effectid);
791         }
792         if (clipeffect.isNull()) {
793             kDebug() << "///  WARNING, EFFECT: " << effecttag << ": " << effectid << " not found, removing it from project";
794             m_documentErrors.append(i18n("Effect %1:%2 not found in MLT, it was removed from this project\n", effecttag, effectid));
795             if (parentNode.removeChild(effects.at(ix)).isNull()) kDebug() << "///  PROBLEM REMOVING EFFECT: " << effecttag;
796             ix--;
797         } else {
798             QDomElement currenteffect = clipeffect.cloneNode().toElement();
799             currenteffect.setAttribute("kdenlive_ix", effectindex);
800             QDomNodeList clipeffectparams = currenteffect.childNodes();
801
802             if (MainWindow::videoEffects.hasKeyFrames(currenteffect)) {
803                 //kDebug() << " * * * * * * * * * * ** CLIP EFF WITH KFR FND  * * * * * * * * * * *";
804                 // effect is key-framable, read all effects to retrieve keyframes
805                 QString factor;
806                 QString starttag;
807                 QString endtag;
808                 double offset = 0;
809                 QDomNodeList params = currenteffect.elementsByTagName("parameter");
810                 for (int i = 0; i < params.count(); i++) {
811                     QDomElement e = params.item(i).toElement();
812                     if (e.attribute("type") == "keyframe") {
813                         starttag = e.attribute("starttag", "start");
814                         endtag = e.attribute("endtag", "end");
815                         factor = e.attribute("factor", "1");
816                         offset = e.attribute("offset", "0").toDouble();
817                         break;
818                     }
819                 }
820                 QString keyframes;
821                 int effectin = effect.attribute("in").toInt();
822                 int effectout = effect.attribute("out").toInt();
823                 double startvalue = 0;
824                 double endvalue = 0;
825                 double fact;
826                 if (factor.contains('%')) {
827                     fact = ProfilesDialog::getStringEval(m_doc->mltProfile(), factor);
828                 } else {
829                     fact = factor.toDouble();
830                 }
831                 for (QDomNode n3 = effect.firstChild(); !n3.isNull(); n3 = n3.nextSibling()) {
832                     // parse effect parameters
833                     QDomElement effectparam = n3.toElement();
834                     if (effectparam.attribute("name") == starttag)
835                         startvalue = offset + effectparam.text().toDouble() * fact;
836                     if (effectparam.attribute("name") == endtag)
837                         endvalue = offset + effectparam.text().toDouble() * fact;
838                 }
839                 // add first keyframe
840                 if (effectout <= effectin) {
841                     // there is only one keyframe
842                     keyframes.append(QString::number(effectin) + ':' + locale.toString(startvalue) + ';');
843                 } else keyframes.append(QString::number(effectin) + ':' + locale.toString(startvalue) + ';' + QString::number(effectout) + ':' + QString::number(endvalue) + ';');
844                 QDomNode lastParsedEffect;
845                 ix++;
846                 QDomNode n2 = effects.at(ix);
847                 bool continueParsing = true;
848                 for (; !n2.isNull() && continueParsing; n2 = n2.nextSibling()) {
849                     // parse all effects
850                     QDomElement kfreffect = n2.toElement();
851                     int effectout = kfreffect.attribute("out").toInt();
852
853                     for (QDomNode n4 = kfreffect.firstChild(); !n4.isNull(); n4 = n4.nextSibling()) {
854                         // parse effect parameters
855                         QDomElement subeffectparam = n4.toElement();
856                         if (subeffectparam.attribute("name") == "kdenlive_ix" && subeffectparam.text() != effectindex) {
857                             //We are not in the same effect, stop parsing
858                             lastParsedEffect = n2.previousSibling();
859                             ix--;
860                             continueParsing = false;
861                             break;
862                         } else if (subeffectparam.attribute("name") == endtag) {
863                             endvalue = offset + subeffectparam.text().toDouble() * fact;
864                             break;
865                         }
866                     }
867                     if (continueParsing) {
868                         keyframes.append(QString::number(effectout) + ':' + locale.toString(endvalue) + ';');
869                         ix++;
870                     }
871                 }
872
873                 params = currenteffect.elementsByTagName("parameter");
874                 for (int i = 0; i < params.count(); i++) {
875                     QDomElement e = params.item(i).toElement();
876                     if (e.attribute("type") == "keyframe") e.setAttribute("keyframes", keyframes);
877                 }
878                 if (!continueParsing) {
879                     n2 = lastParsedEffect;
880                 }
881             } else {
882                 // Check if effect has in/out points
883                 if (effect.hasAttribute("in")) {
884                     EffectsList::setParameter(currenteffect, "in",  effect.attribute("in"));
885                 }
886                 if (effect.hasAttribute("out")) {
887                     EffectsList::setParameter(currenteffect, "out",  effect.attribute("out"));
888                 }
889             }
890
891             // adjust effect parameters
892             for (QDomNode n3 = effect.firstChild(); !n3.isNull(); n3 = n3.nextSibling()) {
893                 // parse effect parameters
894                 QDomElement effectparam = n3.toElement();
895                 QString paramname = effectparam.attribute("name");
896                 QString paramvalue = effectparam.text();
897
898                 // try to find this parameter in the effect xml
899                 QDomElement e;
900                 for (int k = 0; k < clipeffectparams.count(); k++) {
901                     e = clipeffectparams.item(k).toElement();
902                     if (!e.isNull() && e.tagName() == "parameter" && e.attribute("name") == paramname) {
903                         QString type = e.attribute("type");
904                         QString factor = e.attribute("factor", "1");
905                         double fact;
906                         if (factor.contains('%')) {
907                             fact = ProfilesDialog::getStringEval(m_doc->mltProfile(), factor);
908                         } else {
909                             fact = factor.toDouble();
910                         }
911                         double offset = e.attribute("offset", "0").toDouble();
912                         if (type == "simplekeyframe") {
913                             QStringList kfrs = paramvalue.split(";");
914                             for (int l = 0; l < kfrs.count(); l++) {
915                                 QString fr = kfrs.at(l).section('=', 0, 0);
916                                 double val = locale.toDouble(kfrs.at(l).section('=', 1, 1));
917                                 //kfrs[l] = fr + ":" + locale.toString((int)(val * fact));
918                                 kfrs[l] = fr + ":" + QString::number((int) (offset + val * fact));
919                             }
920                             e.setAttribute("keyframes", kfrs.join(";"));
921                         } else if (type == "double" || type == "constant") {
922                             bool ok;
923                             e.setAttribute("value", offset + locale.toDouble(paramvalue, &ok) * fact);
924                             if (!ok)
925                                 e.setAttribute("value", paramvalue);
926                         } else {
927                             e.setAttribute("value", paramvalue);
928                         }
929                         break;
930                     }
931                 }
932             }
933             
934             if (disableeffect) currenteffect.setAttribute("disable", "1");
935             if (clip)
936                 clip->addEffect(currenteffect, false);
937             else
938                 m_doc->addTrackEffect(trackIndex, currenteffect);
939         }
940     }
941 }
942
943
944 DocClipBase *TrackView::getMissingProducer(const QString id) const
945 {
946     QDomElement missingXml;
947     QDomDocument doc = m_doc->toXml();
948     QString docRoot = doc.documentElement().attribute("root");
949     if (!docRoot.endsWith('/')) docRoot.append('/');
950     QDomNodeList prods = doc.elementsByTagName("producer");
951     int maxprod = prods.count();
952     bool slowmotionClip = false;
953     for (int i = 0; i < maxprod; i++) {
954         QDomNode m = prods.at(i);
955         QString prodId = m.toElement().attribute("id");
956         if (prodId.startsWith("slowmotion")) {
957             slowmotionClip = true;
958             prodId = prodId.section(':', 1, 1);
959         }
960         prodId = prodId.section('_', 0, 0);
961         if (prodId == id) {
962             missingXml =  m.toElement();
963             break;
964         }
965     }
966     if (missingXml == QDomElement()) {
967         // Check if producer id was replaced in another track
968         if (m_replacementProducerIds.contains(id)) {
969             QString newId = m_replacementProducerIds.value(id);
970             slowmotionClip = false;
971             for (int i = 0; i < maxprod; i++) {
972                 QDomNode m = prods.at(i);
973                 QString prodId = m.toElement().attribute("id");
974                 if (prodId.startsWith("slowmotion")) {
975                     slowmotionClip = true;
976                     prodId = prodId.section(':', 1, 1);
977                 }
978                 prodId = prodId.section('_', 0, 0);
979                 if (prodId == id) {
980                     missingXml =  m.toElement();
981                     break;
982                 }
983             }       
984         }
985     }
986     if (missingXml == QDomElement()) return NULL;
987     QString resource = EffectsList::property(missingXml, "resource");
988     QString service = EffectsList::property(missingXml, "mlt_service");
989
990     if (slowmotionClip) resource = resource.section('?', 0, 0);
991     // prepend MLT XML document root if no path in clip resource and not a color clip
992     if (!resource.startsWith('/') && service != "colour") {
993         resource.prepend(docRoot);
994         kDebug()<<"******************\nADJUSTED 2\n*************************";
995     }
996     DocClipBase *missingClip = NULL;
997     if (!resource.isEmpty()) {
998         QList <DocClipBase *> list = m_doc->clipManager()->getClipByResource(resource);
999         if (!list.isEmpty()) missingClip = list.at(0);
1000     }
1001     return missingClip;
1002 }
1003
1004 QGraphicsScene *TrackView::projectScene()
1005 {
1006     return m_scene;
1007 }
1008
1009 CustomTrackView *TrackView::projectView()
1010 {
1011     return m_trackview;
1012 }
1013
1014 void TrackView::setEditMode(const QString & editMode)
1015 {
1016     m_editMode = editMode;
1017 }
1018
1019 const QString & TrackView::editMode() const
1020 {
1021     return m_editMode;
1022 }
1023
1024 void TrackView::slotChangeTrackLock(int ix, bool lock)
1025 {
1026     QList<HeaderTrack *> widgets = findChildren<HeaderTrack *>();
1027     widgets.at(ix)->setLock(lock);
1028 }
1029
1030
1031 void TrackView::slotVerticalZoomDown()
1032 {
1033     if (m_verticalZoom == 0) return;
1034     m_verticalZoom--;
1035     m_doc->setZoom(m_doc->zoom().x(), m_verticalZoom);
1036     if (m_verticalZoom == 0)
1037         m_trackview->setScale(m_scene->scale().x(), 0.5);
1038     else
1039         m_trackview->setScale(m_scene->scale().x(), 1);
1040     adjustTrackHeaders();
1041     m_trackview->verticalScrollBar()->setValue(headers_area->verticalScrollBar()->value());
1042 }
1043
1044 void TrackView::slotVerticalZoomUp()
1045 {
1046     if (m_verticalZoom == 2) return;
1047     m_verticalZoom++;
1048     m_doc->setZoom(m_doc->zoom().x(), m_verticalZoom);
1049     if (m_verticalZoom == 2)
1050         m_trackview->setScale(m_scene->scale().x(), 2);
1051     else
1052         m_trackview->setScale(m_scene->scale().x(), 1);
1053     adjustTrackHeaders();
1054     m_trackview->verticalScrollBar()->setValue(headers_area->verticalScrollBar()->value());
1055 }
1056
1057 void TrackView::updateProjectFps()
1058 {
1059     m_ruler->updateProjectFps(m_doc->timecode());
1060     m_trackview->updateProjectFps();
1061 }
1062
1063 void TrackView::slotRenameTrack(int ix, QString name)
1064 {
1065     int tracknumber = m_doc->tracksCount() - ix;
1066     QList <TrackInfo> tracks = m_doc->tracksList();
1067     tracks[tracknumber - 1].trackName = name;
1068     ConfigTracksCommand *configTracks = new ConfigTracksCommand(m_trackview, m_doc->tracksList(), tracks);
1069     m_doc->commandStack()->push(configTracks);
1070     m_doc->setModified(true);
1071 }
1072
1073 void TrackView::slotUpdateVerticalScroll(int /*min*/, int max)
1074 {
1075     int height = 0;
1076     if (max > 0) height = m_trackview->horizontalScrollBar()->height() - 1;
1077     headers_container->layout()->setContentsMargins(0, m_trackview->frameWidth(), 0, height);
1078 }
1079
1080 void TrackView::updateRuler()
1081 {
1082     m_ruler->update();
1083 }
1084
1085 void TrackView::slotShowTrackEffects(int ix)
1086 {
1087     m_trackview->clearSelection();
1088     emit showTrackEffects(m_doc->tracksCount() - ix, m_doc->trackInfoAt(m_doc->tracksCount() - ix - 1));
1089 }
1090
1091 void TrackView::slotUpdateTrackEffectState(int ix)
1092 {
1093     QList<HeaderTrack *> widgets = findChildren<HeaderTrack *>();
1094     if (ix < 0 || ix >= widgets.count()) {
1095         kDebug() << "ERROR, Trying to access a non existant track: " << ix;
1096         return;
1097     }
1098     widgets.at(m_doc->tracksCount() - ix - 1)->updateEffectLabel(m_doc->trackInfoAt(ix).effectsList.effectNames());
1099 }
1100
1101 void TrackView::slotSaveTimelinePreview(const QString path)
1102 {
1103     QImage img(width(), height(), QImage::Format_ARGB32_Premultiplied);
1104     img.fill(palette().base().color().rgb());
1105     QPainter painter(&img);
1106     render(&painter);
1107     painter.end();
1108     img = img.scaledToWidth(600, Qt::SmoothTransformation);
1109     img.save(path);
1110 }
1111
1112 void TrackView::updateProfile()
1113 {
1114     m_ruler->updateFrameSize();
1115     m_trackview->updateSceneFrameWidth();
1116     slotChangeZoom(m_doc->zoom().x(), m_doc->zoom().y());
1117     slotSetZone(m_doc->zone(), false);
1118 }
1119
1120 void TrackView::checkTrackHeight()
1121 {
1122     if (m_trackview->checkTrackHeight()) {
1123         m_doc->clipManager()->clearCache();
1124         m_ruler->updateFrameSize();
1125         m_trackview->updateSceneFrameWidth();
1126         slotChangeZoom(m_doc->zoom().x(), m_doc->zoom().y());
1127         slotSetZone(m_doc->zone(), false);
1128     }
1129 }
1130
1131 #include "trackview.moc"
1132
1133
1134