-
Notifications
You must be signed in to change notification settings - Fork 1
/
workerdialog.h
86 lines (59 loc) · 1.49 KB
/
workerdialog.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#ifndef WORKERDIALOG_H
#define WORKERDIALOG_H
#include <QDialog>
#include <QThreadPool>
#include <QMutexLocker>
#include "mainwindow.h"
namespace Ui {
class WorkerDialog;
}
class ExportWork : public QObject, public QRunnable
{
Q_OBJECT
public:
ExportWork(MainWindow *window, size_t idx, const std::string &file, int *priority) : QRunnable(), window(window), idx(idx), file(file), current_priority(priority){ }
void run();
public slots:
void onCancel();
signals:
void workFinished();
void errorSignal();
private:
MainWindow *window;
size_t idx;
std::string file;
bool cancel = false;
int *current_priority;
};
class WorkerDialog : public QDialog
{
Q_OBJECT
public slots:
void onWorkFinished();
void reject() override;
void onError();
void onSetWorkSize(int size);
public:
explicit WorkerDialog(QWidget *parent = nullptr);
~WorkerDialog();
int exec() override;
void setExport(RdbFile *rdb, const std::vector<uint32_t> &hashes, const std::string &dir);
void setExportAll(RdbFile *rdb, const std::string &dir);
signals:
void cancelSignal();
private slots:
void on_cancelButton_clicked();
void on_priorityComboBox_activated(int index);
private:
Ui::WorkerDialog *ui;
MainWindow *window;
RdbFile *rdb;
std::vector<size_t> files_idx;
std::string out_dir;
QMutex mutex;
int jobs_finished = 0;
int max_jobs;
int priority=0;
void DoExport();
};
#endif // WORKERDIALOG_H