]> git.sesse.net Git - kdenlive/blobdiff - src/trackview.cpp
Pre-select the first parameter on effects with not other parameter selected to be...
[kdenlive] / src / trackview.cpp
index 0e8a8c1857a34ac05f0c98ce3c9b4e2e837c9148..e4255c33751ed03bd08bfa3774ee0381ecd2dcbd 100644 (file)
@@ -117,7 +117,7 @@ TrackView::TrackView(KdenliveDoc *doc, bool *ok, QWidget *parent) :
     connect(m_trackview, SIGNAL(doTrackLock(int, bool)), this, SLOT(slotChangeTrackLock(int, bool)));
 
     slotChangeZoom(m_doc->zoom().x(), m_doc->zoom().y());
-    slotSetZone(m_doc->zone());
+    slotSetZone(m_doc->zone(), false);
 }
 
 TrackView::~TrackView()
@@ -173,9 +173,10 @@ int TrackView::outPoint() const
     return m_ruler->outPoint();
 }
 
-void TrackView::slotSetZone(QPoint p)
+void TrackView::slotSetZone(QPoint p, bool updateDocumentProperties)
 {
     m_ruler->setZone(p);
+    if (updateDocumentProperties) m_doc->setZone(p.x(), p.y());
 }
 
 void TrackView::setDuration(int dur)
@@ -196,8 +197,9 @@ void TrackView::parseDocument(QDomDocument doc)
     }*/
 
     // parse project tracks
-    QDomElement tractor = doc.elementsByTagName("tractor").item(0).toElement();
-    QDomNodeList tracks = doc.elementsByTagName("track");
+    QDomElement mlt = doc.firstChildElement("mlt");
+    QDomElement tractor = mlt.firstChildElement("tractor");
+    QDomNodeList tracks = tractor.elementsByTagName("track");
     QDomNodeList playlists = doc.elementsByTagName("playlist");
     int duration = 300;
     m_projectTracks = tracks.count();
@@ -231,7 +233,7 @@ void TrackView::parseDocument(QDomDocument doc)
         if (e.hasAttribute("in") == false && e.hasAttribute("out") == false) continue;
         int in = e.attribute("in").toInt();
         int out = e.attribute("out").toInt();
-        if (in > out || in == out) {
+        if (in >= out) {
             // invalid producer, remove it
             QString id = e.attribute("id");
             m_invalidProducers.append(id);
@@ -284,7 +286,7 @@ void TrackView::parseDocument(QDomDocument doc)
     }
 
     // parse transitions
-    QDomNodeList transitions = doc.elementsByTagName("transition");
+    QDomNodeList transitions = tractor.elementsByTagName("transition");
 
     //kDebug() << "//////////// TIMELINE FOUND: " << projectTransitions << " transitions";
     for (int i = 0; i < transitions.count(); i++) {
@@ -422,8 +424,11 @@ void TrackView::parseDocument(QDomDocument doc)
         }
     }
 
+
+    QDomElement infoXml = mlt.firstChildElement("kdenlivedoc");
+
     // Add guides
-    QDomNodeList guides = doc.elementsByTagName("guide");
+    QDomNodeList guides = infoXml.elementsByTagName("guide");
     for (int i = 0; i < guides.count(); i++) {
         e = guides.item(i).toElement();
         const QString comment = e.attribute("comment");
@@ -432,14 +437,12 @@ void TrackView::parseDocument(QDomDocument doc)
     }
 
     // Rebuild groups
-    QDomNodeList groups = doc.elementsByTagName("group");
+    QDomNodeList groups = infoXml.elementsByTagName("group");
     m_trackview->loadGroups(groups);
     m_trackview->setDuration(duration);
     kDebug() << "///////////  TOTAL PROJECT DURATION: " << duration;
 
     // Remove Kdenlive extra info from xml doc before sending it to MLT
-    QDomElement mlt = doc.firstChildElement("mlt");
-    QDomElement infoXml = mlt.firstChildElement("kdenlivedoc");
     mlt.removeChild(infoXml);
 
     slotRebuildTrackHeaders();
@@ -762,7 +765,7 @@ void TrackView::slotAddProjectEffects(QDomNodeList effects, QDomElement parentNo
                 }
                 // add first keyframe
                 if (effectout <= effectin) {
-                    // there is only one keyframe
+                    // there is only one keyframe
                     keyframes.append(QString::number(effectin) + ':' + QString::number(startvalue) + ';');
                 } else keyframes.append(QString::number(effectin) + ':' + QString::number(startvalue) + ';' + QString::number(effectout) + ':' + QString::number(endvalue) + ';');
                 QDomNode lastParsedEffect;
@@ -833,8 +836,8 @@ void TrackView::slotAddProjectEffects(QDomNodeList effects, QDomElement parentNo
                             if (e.attribute("type") == "simplekeyframe") {
                                 QStringList kfrs = paramvalue.split(";");
                                 for (int l = 0; l < kfrs.count(); l++) {
-                                    QString fr = kfrs.at(l).section("=", 0, 0);
-                                    double val = kfrs.at(l).section("=", 1, 1).toDouble();
+                                    QString fr = kfrs.at(l).section('=', 0, 0);
+                                    double val = kfrs.at(l).section('=', 1, 1).toDouble();
                                     kfrs[l] = fr + ":" + QString::number((int)(val * fact));
                                 }
                                 e.setAttribute("keyframes", kfrs.join(";"));
@@ -854,11 +857,10 @@ void TrackView::slotAddProjectEffects(QDomNodeList effects, QDomElement parentNo
                 currenteffect.setAttribute("src", ladspaEffectFile);
             }
             if (disableeffect) currenteffect.setAttribute("disable", "1");
-            if (clip) clip->addEffect(currenteffect, false);
-            else {
-                kDebug() << "<< TRACK: " << trackIndex << ", adding effect";;
+            if (clip)
+                clip->addEffect(currenteffect, false);
+            else
                 m_doc->addTrackEffect(trackIndex, currenteffect);
-            }
         }
     }
 }
@@ -991,7 +993,7 @@ void TrackView::slotShowTrackEffects(int ix)
 void TrackView::slotUpdateTrackEffectState(int ix)
 {
     QList<HeaderTrack *> widgets = findChildren<HeaderTrack *>();
-    if (ix >= widgets.count()) {
+    if (ix < 0 || ix >= widgets.count()) {
         kDebug() << "ERROR, Trying to access a non existant track: " << ix;
         return;
     }