From: APTX Date: Sun, 6 Sep 2009 13:37:10 +0000 (+0200) Subject: - Fix compile errors and progress calculation. X-Git-Url: https://gitweb.aptx.org/?a=commitdiff_plain;h=f387f10707bf8bb7a4d15f00573577080ecec3a3;p=anidbudpclient.git - Fix compile errors and progress calculation. --- diff --git a/hash.cpp b/hash.cpp index f569ab5..dd4693d 100644 --- a/hash.cpp +++ b/hash.cpp @@ -11,6 +11,8 @@ Hash::Hash(QObject *parent) : QObject(parent) buffer = 0; hashing = false; setUp(); + totalFileSize = 0; + hashedFileSize = 0; } Hash::~Hash() @@ -18,7 +20,7 @@ Hash::~Hash() tearDown(); } -static Hash *Hash::instance() +Hash *Hash::instance() { if (!m_instance) m_instance = new Hash(); @@ -26,7 +28,7 @@ static Hash *Hash::instance() return m_instance; } -static void Hash::destroy() +void Hash::destroy() { delete m_instance; m_instance = 0; @@ -55,6 +57,7 @@ qDebug() << "Hash::endHashing"; emit fileHashed(f, hash); qDebug() << "File:" << f.fileName() << "Hash:" << hash << "Time:" << fileElapsed; + hashedFileSize += f.size(); if (!fileQueue.isEmpty()) { @@ -73,9 +76,11 @@ qDebug() << "Total time:" << totalElapsed; void Hash::reportProgress(qint64 read, qint64 total) { - emit fileProgress((read * 100) / total); - hashedFileSize += fileQueue.first().size() - read; - emit progress((hashedFileSize * 100) / totalFileSize); + int filePercent = (read * 100) / total; + emit fileProgress(filePercent); + + int totalPercent = ((hashedFileSize + read) * 100) / totalFileSize; + emit progress(totalPercent); } void Hash::startHashing()