+// 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();
+}
+