]> git.sesse.net Git - kdenlive/blobdiff - src/trackview.cpp
Fix small display issue in render widget
[kdenlive] / src / trackview.cpp
index 5333eb0e325bc04aaede201fa2d73e99815d09a4..cdfd02fd6ad09b39111bd644ed80e49261640113 100644 (file)
 #include <QInputDialog>
 
 TrackView::TrackView(KdenliveDoc *doc, bool *ok, QWidget *parent) :
-        QWidget(parent),
-        m_scale(1.0),
-        m_projectTracks(0),
-        m_doc(doc),
-        m_verticalZoom(1)
+    QWidget(parent),
+    m_scale(1.0),
+    m_projectTracks(0),
+    m_doc(doc),
+    m_verticalZoom(1)
 {
 
     setupUi(this);
@@ -197,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();
@@ -232,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);
@@ -285,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++) {
@@ -423,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");
@@ -433,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();
@@ -677,15 +679,16 @@ int TrackView::slotAddProjectTrack(int ix, QDomElement xml, bool locked)
 
 void TrackView::slotAddProjectEffects(QDomNodeList effects, QDomElement parentNode, ClipItem *clip, int trackIndex)
 {
+    int effectNb = 0;
     for (int ix = 0; ix < effects.count(); ix++) {
         bool disableeffect = false;
         QDomElement effect = effects.at(ix).toElement();
         if (effect.tagName() != "filter") continue;
-
+        effectNb++;
         // add effect to clip
         QString effecttag;
         QString effectid;
-        QString effectindex = QString::number(ix + 1);
+        QString effectindex = QString::number(effectNb);
         QString ladspaEffectFile;
         // Get effect tag & index
         for (QDomNode n3 = effect.firstChild(); !n3.isNull(); n3 = n3.nextSibling()) {
@@ -763,7 +766,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;
@@ -834,8 +837,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(";"));
@@ -855,11 +858,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);
-            }
         }
     }
 }
@@ -992,7 +994,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;
     }