-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHashCalculator.hpp
More file actions
41 lines (32 loc) · 929 Bytes
/
HashCalculator.hpp
File metadata and controls
41 lines (32 loc) · 929 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#pragma once
#include <QObject>
#include <QThread>
#include <QCryptographicHash>
class HashCalculator : public QThread
{
Q_OBJECT
public:
enum class ErrorType : char
{
Open = 'o',
Empty = 'e',
Read = 'r'
};
HashCalculator(QObject* parent);
~HashCalculator();
void setDirectory(const QString& directory);
void setAlgorithm(QCryptographicHash::Algorithm algorithm);
void setWildcards(const QString& wildcards);
signals:
void processing(const QString& filePath, qint64 bytesRead, qint64 bytesLeft);
void duplicateFound(const QString& hashString, const QString& filePath);
void failure(const QString& filePath, ErrorType error);
private:
bool keepRunning() const;
QByteArray calculateHash(const QString& filePath);
void run() override;
QString _directory;
QStringList _wildcards;
QCryptographicHash::Algorithm _algorithm = QCryptographicHash::Sha256;
};
Q_DECLARE_METATYPE(HashCalculator::ErrorType)