]> git.sesse.net Git - kdenlive/blobdiff - src/docclipbase.cpp
* Correctly convert titles in existing projects to the new kdenlivetitle producer
[kdenlive] / src / docclipbase.cpp
index f22410f1d237f091fea6640e1f10407919507f5d..2669a878673f0f6db43592e300599f5d09f4b3cc 100644 (file)
@@ -245,6 +245,10 @@ bool DocClipBase::hasFileSize() const
     return true;
 }
 
+qulonglong DocClipBase::fileSize() const
+{
+    return m_properties.value("file_size").toULongLong();
+}
 
 // virtual
 QDomElement DocClipBase::toXML() const
@@ -292,7 +296,7 @@ QList < GenTime > DocClipBase::snapMarkers() const
     QList < GenTime > markers;
 
     for (int count = 0; count < m_snapMarkers.count(); ++count) {
-        markers.append(m_snapMarkers[count].time());
+        markers.append(m_snapMarkers.at(count).time());
     }
 
     return markers;
@@ -376,23 +380,23 @@ GenTime DocClipBase::findPreviousSnapMarker(const GenTime & currTime)
 {
     int it;
     for (it = 0; it < m_snapMarkers.count(); it++) {
-        if (m_snapMarkers[it].time() >= currTime)
+        if (m_snapMarkers.at(it).time() >= currTime)
             break;
     }
     if (it == 0) return GenTime();
-    else if (it == m_snapMarkers.count() - 1 && m_snapMarkers[it].time() < currTime)
-        return m_snapMarkers[it].time();
-    else return m_snapMarkers[it-1].time();
+    else if (it == m_snapMarkers.count() - 1 && m_snapMarkers.at(it).time() < currTime)
+        return m_snapMarkers.at(it).time();
+    else return m_snapMarkers.at(it -1).time();
 }
 
 GenTime DocClipBase::findNextSnapMarker(const GenTime & currTime)
 {
     int it;
     for (it = 0; it < m_snapMarkers.count(); it++) {
-        if (m_snapMarkers[it].time() > currTime)
+        if (m_snapMarkers.at(it).time() > currTime)
             break;
     }
-    if (it < m_snapMarkers.count() && m_snapMarkers[it].time() > currTime) return m_snapMarkers[it].time();
+    if (it < m_snapMarkers.count() && m_snapMarkers.at(it).time() > currTime) return m_snapMarkers.at(it).time();
     return duration();
 }
 
@@ -408,15 +412,34 @@ QString DocClipBase::markerComment(GenTime t)
     return QString();
 }
 
+void DocClipBase::clearProducers()
+{
+    m_baseTrackProducers.clear();
+}
+
 void DocClipBase::deleteProducers()
 {
+    kDebug() << "// CLIP KILL PRODS ct: " << m_baseTrackProducers.count();
+    if (m_thumbProd) m_thumbProd->clearProducer();
+    /*kDebug()<<"// CLIP KILL PRODS ct: "<<m_baseTrackProducers.count();
+    int max = m_baseTrackProducers.count();
+    for (int i = 0; i < max; i++) {
+        kDebug()<<"// CLIP KILL PROD "<<i;
+    Mlt::Producer *p = m_baseTrackProducers.takeAt(i);
+    if (p != NULL) {
+     delete p;
+     p = NULL;
+    }
+    m_baseTrackProducers.insert(i, NULL);
+    }*/
+
+    delete m_videoOnlyProducer;
+    m_videoOnlyProducer = NULL;
+
     qDeleteAll(m_baseTrackProducers);
     m_baseTrackProducers.clear();
-    if (m_thumbProd) m_thumbProd->clearProducer();
     qDeleteAll(m_audioTrackProducers);
     m_audioTrackProducers.clear();
-    delete m_videoOnlyProducer;
-    m_videoOnlyProducer = NULL;
 }
 
 void DocClipBase::setProducer(Mlt::Producer *producer, bool reset)
@@ -424,6 +447,7 @@ void DocClipBase::setProducer(Mlt::Producer *producer, bool reset)
     if (producer == NULL) return;
     if (reset) {
         // Clear all previous producers
+        kDebug() << "/+++++++++++++++   DELETE ALL PRODS " << producer->get("id");
         deleteProducers();
     }
     QString id = producer->get("id");
@@ -439,8 +463,7 @@ void DocClipBase::setProducer(Mlt::Producer *producer, bool reset)
             }
             if (m_audioTrackProducers.at(pos) == NULL) m_audioTrackProducers[pos] = producer;
             return;
-        }
-        if (id.endsWith("video")) {
+        } else if (id.endsWith("video")) {
             m_videoOnlyProducer = producer;
             return;
         }
@@ -711,6 +734,7 @@ QString DocClipBase::getClipHash() const
     QString hash;
     if (m_clipType == SLIDESHOW) hash = QCryptographicHash::hash(m_properties.value("resource").toAscii().data(), QCryptographicHash::Md5).toHex();
     else if (m_clipType == COLOR) hash = QCryptographicHash::hash(m_properties.value("colour").toAscii().data(), QCryptographicHash::Md5).toHex();
+    else if (m_clipType == TEXT) hash = QCryptographicHash::hash(QString("title" + getId() + m_properties.value("xmldata")).toUtf8().data(), QCryptographicHash::Md5).toHex();
     else hash = m_properties.value("file_hash");
     return hash;
 }
@@ -768,6 +792,7 @@ void DocClipBase::setProperty(const QString &key, const QString &value)
     } else if (key == "force_aspect_ratio") {
         if (value.isEmpty()) {
             m_properties.remove("force_aspect_ratio");
+            //TODO: find a was to remove the "force_aspect_ratio" property from producer, currently does not work
             setProducerProperty("force_aspect_ratio", 0);
         } else setProducerProperty("force_aspect_ratio", value.toDouble());
     } else if (key == "threads") {