KNewStuff

filecopyworker.cpp
1 /*
2  SPDX-FileCopyrightText: 2016 Dan Leinir Turthra Jensen <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.1-or-later
5 */
6 
7 #include "filecopyworker.h"
8 
9 #include <QFile>
10 
11 using namespace KNSCore;
12 
13 class FileCopyWorker::Private {
14 public:
15  Private() {}
16  QFile source;
17  QFile destination;
18 };
19 
20 FileCopyWorker::FileCopyWorker(const QUrl& source, const QUrl& destination, QObject* parent)
21  : QThread(parent)
22  , d(new Private)
23 {
24  d->source.setFileName(source.toLocalFile());
25  d->destination.setFileName(destination.toLocalFile());
26 }
27 
28 FileCopyWorker::~FileCopyWorker()
29 {
30  delete d;
31 }
32 
33 void FileCopyWorker::run()
34 {
35  qint64 totalSize = d->source.size();
36 
37  for (qint64 i = 0; i < totalSize; i += 1024) {
38  d->destination.write(d->source.read(1024));
39  d->source.seek(i);
40  d->destination.seek(i);
41 
42  emit progress(i, totalSize / 1024);
43  }
44  emit completed();
45 }
Contains the core functionality for handling interaction with NewStuff providers. ...
QString toLocalFile() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Tue Aug 11 2020 22:43:23 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.