]> git.sesse.net Git - kdenlive/blobdiff - src/trackview.cpp
Implement track locking:
[kdenlive] / src / trackview.cpp
index 7d59cf3892f3ba374c92b56f086d217abe0e79e4..0e88dd3c81a636dc94ce44f4bfd1dbc0dd1f74b9 100644 (file)
@@ -83,6 +83,8 @@ TrackView::TrackView(KdenliveDoc *doc, QWidget *parent)
     connect(m_trackview->horizontalScrollBar(), SIGNAL(valueChanged(int)), m_ruler, SLOT(slotMoveRuler(int)));
     connect(m_trackview, SIGNAL(mousePosition(int)), this, SIGNAL(mousePosition(int)));
     connect(m_trackview, SIGNAL(transitionItemSelected(Transition*, bool)), this, SLOT(slotTransitionItemSelected(Transition*, bool)));
+    connect(m_trackview, SIGNAL(doTrackLock(int, bool)), this, SLOT(slotChangeTrackLock(int, bool)));
+
     slotChangeZoom(m_doc->zoom());
     slotSetZone(m_doc->zone());
 }
@@ -149,6 +151,9 @@ void TrackView::parseDocument(QDomDocument doc) {
                 p = playlists.item(j).toElement();
                 if (p.attribute("id") == playlist_name) break;
             }
+            if (p.attribute("id") != playlist_name) { // then it didn't work.
+                kDebug() << "NO PLAYLIST FOUND FOR TRACK " + pos;
+            }
             if (e.attribute("hide") == "video") {
                 m_doc->switchTrackVideo(i - 1, true);
             } else if (e.attribute("hide") == "audio") {
@@ -354,6 +359,7 @@ void TrackView::slotRebuildTrackHeaders() {
         HeaderTrack *header = new HeaderTrack(i, list.at(max - i - 1), this);
         connect(header, SIGNAL(switchTrackVideo(int)), m_trackview, SLOT(slotSwitchTrackVideo(int)));
         connect(header, SIGNAL(switchTrackAudio(int)), m_trackview, SLOT(slotSwitchTrackAudio(int)));
+        connect(header, SIGNAL(switchTrackLock(int)), m_trackview, SLOT(slotSwitchTrackLock(int)));
 
         connect(header, SIGNAL(deleteTrack(int)), this, SIGNAL(deleteTrack(int)));
         connect(header, SIGNAL(insertTrack(int)), this, SIGNAL(insertTrack(int)));
@@ -377,6 +383,11 @@ int TrackView::slotAddProjectTrack(int ix, QDomElement xml) {
             qApp->processEvents();
             // Found a clip
             int in = elem.attribute("in").toInt();
+            int out = elem.attribute("out").toInt();
+            if (in > out || in == out) {
+                m_documentErrors.append(i18n("Invalid clip removed from track %1 at %2\n", ix, position));
+                continue;
+            }
             QString idString = elem.attribute("producer");
             QString id = idString;
             double speed = 1.0;
@@ -386,8 +397,6 @@ int TrackView::slotAddProjectTrack(int ix, QDomElement xml) {
             } else id = id.section('_', 0, 0);
             DocClipBase *clip = m_doc->clipManager()->getClipById(id);
             if (clip != NULL) {
-                int out = elem.attribute("out").toInt();
-
                 ItemInfo clipinfo;
                 clipinfo.startPos = GenTime(position, m_doc->fps());
                 clipinfo.endPos = clipinfo.startPos + GenTime(out - in + 1, m_doc->fps());
@@ -561,7 +570,7 @@ int TrackView::slotAddProjectTrack(int ix, QDomElement xml) {
             } else {
                 // The clip in playlist was not listed in the kdenlive producers,
                 // something went wrong, repair required.
-                kWarning() << "CANNOT INSERT CLIP " << id;
+                kWarning() << "CANNOT INSERT CLIP " << id;
                 int out = elem.attribute("out").toInt();
 
                 ItemInfo clipinfo;
@@ -598,7 +607,7 @@ int TrackView::slotAddProjectTrack(int ix, QDomElement xml) {
 
 
     //documentTracks.insert(ix, track);
-    kDebug() << "*************  ADD DOC TRACK " << ix << ", DURATION: " << position;
+    kDebug() << "*************  ADD DOC TRACK " << ix << ", DURATION: " << position;
     return position;
     //track->show();
 }
@@ -654,6 +663,10 @@ const QString & TrackView::editMode() const {
     return m_editMode;
 }
 
+void TrackView::slotChangeTrackLock(int ix, bool lock) {
+    QList<HeaderTrack *> widgets = this->findChildren<HeaderTrack *>();
+    widgets.at(ix)->setLock(lock);
+}
 
 
 #include "trackview.moc"