-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainwindow.h
59 lines (49 loc) · 1.36 KB
/
mainwindow.h
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <vector>
#include <QMainWindow>
#include <memory>
#include <QProgressDialog>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private:
struct Id {
QString name;
size_t size;
uint64_t crc;
bool crc_done;
};
struct Element {
Id id;
std::vector<std::unique_ptr<Element>> content;
unsigned short depth;
bool is_dir;
};
Ui::MainWindow *ui;
QProgressDialog *progressDialog=nullptr;
std::vector<std::unique_ptr<Element>> db; // roots of the tree
size_t count;
int max_folder_depth;
using DirEntry=std::pair<Element *,bool>; // bool=done
std::vector<DirEntry> dirs_entry; // dirs only, sorted by depth (top dir first)
using Duplicates=std::vector<Element *>;
std::vector<Duplicates> dirs_duplicate;
bool addFolderToDb(std::vector<std::unique_ptr<Element> > &dbi, QString s, int depth);
bool addFileToDb(std::vector<std::unique_ptr<Element> > &dbi, QString s, int depth);
bool equal(Element &d0,Element &d1) const;
void addDirsEntry(Element &e, std::vector<std::vector<Element *> > &v) const;
bool crc64(Element &e) const;
private slots:
void addInputFolder();
void removeFolder();
void findDuplicate();
void showResult(int r,int c);
};
#endif // MAINWINDOW_H