kdeconnect-kde/core/compositefiletransferjob.h
Kai Uwe Broulik 8dae6772e0 Fix CompositeFileTransferJob speed calculation
The `QElapsedTimer` was never started. Clean it up somewhat and use a dedicated
250ms timer for reporting transferred bytes periodically (like KIO does it) and
1000ms for calculating speed so it's not as erratic.

Furthermore, report final numbers in `slotResult` rather than complicating
`slotProcessedAmount` for that.

Also, fix typo "send" -> "sent"
2021-01-31 23:50:14 +01:00

52 lines
1.2 KiB
C++

/**
* SPDX-FileCopyrightText: 2019 Nicolas Fella <nicolas.fella@gmx.de>
*
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
#ifndef COMPOSITEFILETRANSFERJOB_H
#define COMPOSITEFILETRANSFERJOB_H
#include "kdeconnectcore_export.h"
#include <KCompositeJob>
#include <QElapsedTimer>
class FileTransferJob;
class KDECONNECTCORE_EXPORT CompositeFileTransferJob
: public KCompositeJob
{
Q_OBJECT
public:
explicit CompositeFileTransferJob(const QString& deviceId);
void start() override;
bool isRunning() const;
bool addSubjob(KJob* job) override;
protected:
bool doKill() override;
private Q_SLOTS:
void slotProcessedAmount(KJob *job, KJob::Unit unit, qulonglong amount);
void slotResult(KJob *job) override;
void startNextSubJob();
private:
QString m_deviceId;
bool m_running;
int m_currentJobNum;
int m_totalJobs;
quint64 m_currentJobSentPayloadSize;
quint64 m_totalSentPayloadSize;
quint64 m_oldTotalSentPayloadSize; // for speed calculation
quint64 m_totalPayloadSize;
FileTransferJob *m_currentJob;
QElapsedTimer m_reportTimer;
QElapsedTimer m_speedTimer;
};
#endif //COMPOSITEFILETRANSFERJOB_H