-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogresswriterobject.cpp
More file actions
77 lines (60 loc) · 1.65 KB
/
progresswriterobject.cpp
File metadata and controls
77 lines (60 loc) · 1.65 KB
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
#include "progresswriterobject.h"
#include "progresswriterworker.h"
ProgressWriterObject::ProgressWriterObject(QObject *parent)
: QObject{parent}
{
workerThread.setObjectName("progressWriterThread");
}
float ProgressWriterObject::current()
{
return m_current;
}
int ProgressWriterObject::currentStep()
{
return m_step;
}
int ProgressWriterObject::totalStep()
{
return m_total_step;
}
void ProgressWriterObject::setCurrent(float current)
{
m_current = current;
}
void ProgressWriterObject::setTotalStep(int total)
{
m_total_step = total;
}
void ProgressWriterObject::setCurrentStep(int current)
{
m_current = current;
}
void ProgressWriterObject::initJob(progress_writer_handler handler, QString file_name)
{
m_handler = handler;
m_fifo_name = file_name;
}
void ProgressWriterObject::initJob(std::function<void (ProgressWriterObject *)> handler, const QString file_name)
{
//@todo : Not implemented yet!
}
void ProgressWriterObject::prepareJob()
{
ProgressWriterWorker *worker = new ProgressWriterWorker;
worker->setInputFileName(m_fifo_name);
if (m_handler != nullptr)
{
worker->setHandler(m_handler);
}
worker->moveToThread(&workerThread);
connect(this, &ProgressWriterObject::startJob, worker, &ProgressWriterWorker::startJob);
connect(this, &ProgressWriterObject::endJob, worker, &ProgressWriterWorker::endJob);
//connect(worker,&ProgressWriterObject::jobEnded, this, &ProgressWriterObject:jobEndHandler );
workerThread.start();
}
ProgressWriterObject::~ProgressWriterObject()
{
emit this->endJob();
workerThread.wait();
qDebug()<<"end of writing process"<<endl;
}