+void DocClipBase::getFileHash(const QString url)
+{
+ if (m_clipType == SLIDESHOW) return;
+ QFile file(url);
+ if (file.open(QIODevice::ReadOnly)) { // write size and hash only if resource points to a file
+ QByteArray fileData;
+ QByteArray fileHash;
+ //kDebug() << "SETTING HASH of" << value;
+ m_properties.insert("file_size", QString::number(file.size()));
+ /*
+ * 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();
+ fileHash = QCryptographicHash::hash(fileData, QCryptographicHash::Md5);
+ m_properties.insert("file_hash", QString(fileHash.toHex()));
+ }
+}
+
+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 hash = m_properties.value("file_hash");
+ 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"));
+}
+
+void DocClipBase::setProperty(const QString &key, const QString &value)
+{