]> git.sesse.net Git - kdenlive/blobdiff - src/docclipbase.cpp
Clean up timecode handling, improves:
[kdenlive] / src / docclipbase.cpp
index 0df8adb20c70ae6b6f155d7352e94f9b062f9847..f22410f1d237f091fea6640e1f10407919507f5d 100644 (file)
@@ -92,11 +92,14 @@ DocClipBase::DocClipBase(ClipManager *clipManager, QDomElement xml, const QStrin
 
 DocClipBase::~DocClipBase()
 {
+    kDebug() << "CLIP " << m_id << " DELETED******************************";
     delete m_thumbProd;
     if (m_audioTimer) {
         m_audioTimer->stop();
         delete m_audioTimer;
     }
+    /*kDebug() <<" * * *CNT "<<m_baseTrackProducers.count();
+    if (m_baseTrackProducers.count() > 0) kDebug()<<"YOYO: "<<m_baseTrackProducers.at(0)->get_out()<<", CUT: "<<m_baseTrackProducers.at(0)->is_cut();*/
     qDeleteAll(m_baseTrackProducers);
     m_baseTrackProducers.clear();
     qDeleteAll(m_audioTrackProducers);
@@ -255,7 +258,7 @@ QDomElement DocClipBase::toXML() const
         if (!i.value().isEmpty()) clip.setAttribute(i.key(), i.value());
     }
     doc.appendChild(clip);
-    //kDebug()<<"/// CLIP XML: "<<doc.toString();
+    //kDebug() << "/// CLIP XML: " << doc.toString();
     return doc.documentElement();
 }
 
@@ -700,7 +703,6 @@ void DocClipBase::getFileHash(const QString url)
         file.close();
         fileHash = QCryptographicHash::hash(fileData, QCryptographicHash::Md5);
         m_properties.insert("file_hash", QString(fileHash.toHex()));
-        //kDebug() << file.fileName() << file.size() << fileHash.toHex();
     }
 }
 
@@ -713,6 +715,29 @@ QString DocClipBase::getClipHash() const
     return hash;
 }
 
+// static
+QString DocClipBase::getHash(const QString &path)
+{
+    QFile file(path);
+    if (file.open(QIODevice::ReadOnly)) { // write size and hash only if resource points to a file
+        QByteArray fileData;
+        QByteArray fileHash;
+        /*
+               * 1 MB = 1 second per 450 files (or faster)
+               * 10 MB = 9 seconds per 450 files (or faster)
+               */
+        if (file.size() > 1000000*2) {
+            fileData = file.read(1000000);
+            if (file.seek(file.size() - 1000000))
+                fileData.append(file.readAll());
+        } else
+            fileData = file.readAll();
+        file.close();
+        return QCryptographicHash::hash(fileData, QCryptographicHash::Md5).toHex();
+    }
+    return QString();
+}
+
 void DocClipBase::refreshThumbUrl()
 {
     if (m_thumbProd) m_thumbProd->updateThumbUrl(m_properties.value("file_hash"));
@@ -730,7 +755,15 @@ void DocClipBase::setProperty(const QString &key, const QString &value)
         char *tmp = (char *) qstrdup(value.toUtf8().data());
         setProducerProperty("colour", tmp);
         delete[] tmp;
+    } else if (key == "templatetext") {
+        char *tmp = (char *) qstrdup(value.toUtf8().data());
+        setProducerProperty("templatetext", tmp);
+        delete[] tmp;
+        setProducerProperty("force_reload", 1);
     } else if (key == "xmldata") {
+        char *tmp = (char *) qstrdup(value.toUtf8().data());
+        setProducerProperty("xmldata", tmp);
+        delete[] tmp;
         setProducerProperty("force_reload", 1);
     } else if (key == "force_aspect_ratio") {
         if (value.isEmpty()) {