]> git.sesse.net Git - kdenlive/blobdiff - src/trackview.cpp
Properly disable bitrate combobox
[kdenlive] / src / trackview.cpp
index c75cd06a1ebbc6a76509c30a56d9a96924f6a23d..edabf94a03fced8d39eb86c7bc07e9d115349ffa 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()) {
@@ -715,8 +718,12 @@ void TrackView::slotAddProjectEffects(QDomNodeList effects, QDomElement parentNo
         //kDebug() << "+ + CLIP EFF FND: " << effecttag << ", " << effectid << ", " << effectindex;
         // get effect standard tags
         QDomElement clipeffect = MainWindow::customEffects.getEffectByTag(QString(), effectid);
-        if (clipeffect.isNull()) clipeffect = MainWindow::videoEffects.getEffectByTag(effecttag, effectid);
-        if (clipeffect.isNull()) clipeffect = MainWindow::audioEffects.getEffectByTag(effecttag, effectid);
+        if (clipeffect.isNull()) {
+            clipeffect = MainWindow::videoEffects.getEffectByTag(effecttag, effectid);
+        }
+        if (clipeffect.isNull()) {
+            clipeffect = MainWindow::audioEffects.getEffectByTag(effecttag, effectid);
+        }
         if (clipeffect.isNull()) {
             kDebug() << "///  WARNING, EFFECT: " << effecttag << ": " << effectid << " not found, removing it from project";
             m_documentErrors.append(i18n("Effect %1:%2 not found in MLT, it was removed from this project\n", effecttag, effectid));
@@ -763,7 +770,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;
@@ -825,27 +832,33 @@ void TrackView::slotAddProjectEffects(QDomNodeList effects, QDomElement parentNo
                 for (int k = 0; k < clipeffectparams.count(); k++) {
                     e = clipeffectparams.item(k).toElement();
                     if (!e.isNull() && e.tagName() == "parameter" && e.attribute("name") == paramname) {
-                        if (e.attribute("factor", "1") != "1") {
-                            QString factor = e.attribute("factor", "1");
-                            double fact;
-                            if (factor.startsWith('%')) {
-                                fact = ProfilesDialog::getStringEval(m_doc->mltProfile(), factor);
-                            } else fact = factor.toDouble();
-                            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();
-                                    kfrs[l] = fr + ":" + QString::number((int)(val * fact));
-                                }
-                                e.setAttribute("keyframes", kfrs.join(";"));
-                            } else e.setAttribute("value", paramvalue.toDouble() * fact);
-                        } else e.setAttribute("value", paramvalue);
+                        QString factor = e.attribute("factor", "1");
+                        double fact;
+                        if (factor.startsWith('%')) {
+                            fact = ProfilesDialog::getStringEval(m_doc->mltProfile(), factor);
+                        } else {
+                            fact = factor.toDouble();
+                        }
+                        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();
+                                kfrs[l] = fr + ":" + QString::number((int)(val * fact));
+                            }
+                            e.setAttribute("keyframes", kfrs.join(";"));
+                        } else {
+                            bool ok;
+                            e.setAttribute("value", paramvalue.toDouble(&ok) * fact);
+                            if (!ok)
+                                e.setAttribute("value", paramvalue);
+                        }
                         break;
                     }
                 }
             }
-            if (effecttag == "ladspa") {
+            // Old LADSPA filter, deprecated
+            /*if (effecttag == "ladspa") {
                 //QString ladspaEffectFile = EffectsList::parameter(effect, "src", "property");
 
                 if (!QFile::exists(ladspaEffectFile)) {
@@ -853,13 +866,13 @@ void TrackView::slotAddProjectEffects(QDomNodeList effects, QDomElement parentNo
                     initEffects::ladspaEffectFile(ladspaEffectFile, currenteffect.attribute("ladspaid").toInt(), m_trackview->getLadspaParams(currenteffect));
                 }
                 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);
-            }
         }
     }
 }