-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloadpathworker.cpp
More file actions
48 lines (41 loc) · 1.19 KB
/
Copy pathloadpathworker.cpp
File metadata and controls
48 lines (41 loc) · 1.19 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
#include "loadpathworker.h"
#include "adclistreader.h"
LoadPathWorker::LoadPathWorker(QIODevice *inputIo,
ShowListing::DirFileTree *treewidget,
qint64 *pWrittenTracker,
QReadWriteLock *lock,
QTreeWidgetItem **ppInsertedItem)
: runningReader(0)
{
io = inputIo;
tree = treewidget;
pWritten = pWrittenTracker;
this->lock = lock;
this->ppInsertedItem = ppInsertedItem;
}
void LoadPathWorker::run()
{
ShowListing::AdcListReader reader(tree);
QString message;
QObject::connect(&reader, SIGNAL(broadcastProgress(qint64)),
this, SLOT(slotBroadcastProgressReceived(qint64)));
runningReader = &reader;
int rc = reader.read(io, ppInsertedItem);
runningReader = 0;
if (rc != 0) {
message = reader.errorString();
}
emit signalWorkFinished(rc, message);
}
void LoadPathWorker::slotBroadcastProgressReceived(qint64 pos)
{
lock->lockForWrite();
*pWritten = pos;
lock->unlock();
}
void LoadPathWorker::postCancelRequest()
{
if (runningReader) {
runningReader->cancelProcessing();
}
}