Skip to content

Commit

Permalink
v1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
fffaraz committed Nov 18, 2018
1 parent 8ee4c82 commit 27d8dab
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@
<item>
<widget class="QLabel" name="lblAbout">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:11pt; font-weight:600;&quot;&gt;QtHashSum&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot; font-size:9pt;&quot;&gt;1.1.0&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/fffaraz/QtHashSum&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#007af4;&quot;&gt;https://github.com/fffaraz/QtHashSum&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:11pt; font-weight:600;&quot;&gt;QtHashSum&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot; font-size:9pt;&quot;&gt;1.2.0&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/fffaraz/QtHashSum&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#007af4;&quot;&gt;https://github.com/fffaraz/QtHashSum&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
Expand Down
47 changes: 28 additions & 19 deletions src/progressdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,57 +58,66 @@ void ProgressDialog::timer_timeout()
{
qDebug() << "All jobs done" << elapsedtimer.elapsed();
timer.stop();

QString result;
result.append("Checksums generated by QtHashSum 1.1.0\n");
result.append("https://github.com/fffaraz/QtHashSum\n");
result.append(QDateTime::currentDateTime().toString() + "\n");

QString files;
qint64 totalsize = 0;
QMap<QString, int> hashmap;
QHash<QString, qint64> hashsize;
QMap<QString, int> hashmap; // hash -> count
QHash<QString, qint64> hashsize; // hash -> size
QMultiHash<QString, QString> hashpath; // hash -> file path
for(int i = 0; i < jobs.size(); ++i)
{
qint64 size = jobs[i]->size;
QString hash = jobs[i]->hash;

totalsize += size;
files.append(jobs[i]->methodStr() + " " + hash + " " + QString::number(size) + " " +jobs[i]->name() + "\n");

files.append(jobs[i]->methodStr() + " " + hash + " " + QString::number(size) + " " + jobs[i]->name() + "\n");

hashmap[hash] = hashmap[hash] + 1;
hashpath.insertMulti(hash, jobs[i]->name());

if(!hashsize.contains(hash)) hashsize.insert(hash, size);
else if(hashsize.value(hash) != size) qDebug() << "ERROR: same hash different size" << hash;

delete jobs[i];
}
result.append(QString::number(jobs.size()) + " files hashed, " + QString::number(totalsize / 1048576) + " MB total\n");

QString duplicates;
int num_duplicates = 0;
qint64 wasted = 0;
for(QMap<QString, int>::const_iterator itr = hashmap.constBegin(); itr != hashmap.constEnd(); ++itr)
for(int flag = 0; flag < 2; ++flag)
{
qint64 size = hashsize[itr.key()] / 1048576;
if(itr.value() > 1 && size > 0)
for(QMap<QString, int>::const_iterator itr = hashmap.constBegin(); itr != hashmap.constEnd(); ++itr)
{
num_duplicates++;
wasted += (itr.value() - 1) * hashsize[itr.key()];
duplicates.append(QString::number(itr.value()) + " " + QString::number(size) + " " + itr.key() + "\n");
}
}
for(QMap<QString, int>::const_iterator itr = hashmap.constBegin(); itr != hashmap.constEnd(); ++itr)
{
qint64 size = hashsize[itr.key()] / 1048576;
if(itr.value() > 1 && size < 1)
{
num_duplicates++;
wasted += (itr.value() - 1) * hashsize[itr.key()];
duplicates.append(QString::number(itr.value()) + " " + QString::number(size) + " " + itr.key() + "\n");
qint64 size = hashsize[itr.key()] / 1048576;
if(itr.value() > 1 && ((size > 0 && flag == 0) || (size < 1 && flag == 1)))
{
num_duplicates++;
wasted += (itr.value() - 1) * hashsize[itr.key()];
duplicates.append(QString::number(itr.value()) + " " + QString::number(size) + " " + itr.key() + "\n");
QList<QString> list = hashpath.values(itr.key());
foreach(QString name, list) duplicates.append("\t" + name + "\n");
}
}
}

if(num_duplicates > 0)
{
result.append(QString::number(num_duplicates) + " duplicates found, " + QString::number(wasted / 1048576) + " MB wasted\n");
duplicates.append("\n");
}

qDebug() << "Result ready" << elapsedtimer.elapsed();

ResultDialog *rd = new ResultDialog(result + "\n" + duplicates + files);
rd->show();

this->deleteLater();
}
}

0 comments on commit 27d8dab

Please sign in to comment.