]> Some of my projects - anidbudpclient.git/commitdiff
- Fix compile errors and progress calculation.
authorAPTX <mail@example.com>
Sun, 6 Sep 2009 13:37:10 +0000 (15:37 +0200)
committerAPTX <mail@example.com>
Sun, 6 Sep 2009 13:37:10 +0000 (15:37 +0200)
hash.cpp

index f569ab542f6e292139a86bbf19814a875bf07423..dd4693d306799675061b5f6519e60c782eba85de 100644 (file)
--- 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()