-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfilecopythread.cpp
More file actions
68 lines (53 loc) · 1.23 KB
/
filecopythread.cpp
File metadata and controls
68 lines (53 loc) · 1.23 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
#include "filecopythread.h"
FileCopyThread::FileCopyThread(QObject *parent) :
QThread(parent)
{
}
FileCopyThread::FileCopyThread(
const QList<QUrl> &files, QString destination, QObject *parent) :
QThread(parent),
m_files(files),
m_destination(destination)
{
m_stop = false;
}
FileCopyThread::~FileCopyThread()
{
stop();
}
void FileCopyThread::run()
{
if (m_files.isEmpty())
return;
if (m_destination.isEmpty())
return;
m_stop = false;
QString path;
QString trackPath;
QString trackFileName;
QFileInfo fileInfo;
for(int i=0; i < m_files.count() && (m_stop == false); i++)
{
trackPath = m_files.at(i).toLocalFile();
fileInfo.setFile(trackPath);
trackFileName = fileInfo.fileName();
path = m_destination + "/" + trackFileName;
QFile::copy(trackPath, path);
emit copied(i+1);
}
if(m_stop == false)
emit copiedAll();
}
void FileCopyThread::setFileList(const QList<QUrl> &files)
{
m_files = files;
}
void FileCopyThread::setDestination(const QString &destination)
{
m_destination = destination;
}
void FileCopyThread::stop()
{
m_stop = true;
while(isRunning()) {}
}