From 10a8921bbcd9802ad2425e8cee1e5ca70fb0b241 Mon Sep 17 00:00:00 2001 From: Arno Date: Wed, 13 Jun 2018 09:27:59 +0200 Subject: Speed up file copy Hmm, as it turns out QFile does a much better, e.g. faster, job than my open-coded file copy with a progress dialog. I always wondered why it only did 150-170Mbit. I thought that it was just the calculation, but now I have 400 Mbit, and it still stalls at 150 Mbit. QFile::copy maxes out the line, so get rid of the ProgressDialog and show a status message instead. Copy can be canceled by the context menu, but FileCopier will always finish the current file, because I don't want to lock and unlock the CancelMutex during copy. Besides, QFile::copy doesn't admit that :) --- progressdialog.cpp | 40 ---------------------------------------- 1 file changed, 40 deletions(-) delete mode 100644 progressdialog.cpp (limited to 'progressdialog.cpp') diff --git a/progressdialog.cpp b/progressdialog.cpp deleted file mode 100644 index 0690d65..0000000 --- a/progressdialog.cpp +++ /dev/null @@ -1,40 +0,0 @@ -#include -#include -#include - -#include "progressdialog.h" - -ProgressDialog::ProgressDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f){ - mSrc = new QLabel; - mDst = new QLabel; - mProgress = new QProgressBar; - mSum = new QLabel(tr("Wait for it...")); - QPushButton *cancelBtn = new QPushButton(tr("Cancel")); - connect(cancelBtn, &QPushButton::clicked, this, &ProgressDialog::cancelled); - QHBoxLayout *btnLayout = new QHBoxLayout; - btnLayout->addStretch(); - btnLayout->addWidget(cancelBtn); - btnLayout->addStretch(); - QVBoxLayout *mainLayout = new QVBoxLayout; - mainLayout->addWidget(mSrc); - mainLayout->addWidget(mDst); - mainLayout->addWidget(mProgress); - mainLayout->addWidget(mSum); - mainLayout->addLayout(btnLayout); - setMaximumWidth(400); - setMinimumWidth(400); - setLayout(mainLayout); -} - -void ProgressDialog::setLabelText(const QString &src, const QString &dst){ - QFontMetrics fm(mSrc->font()); - int width = mSrc->width() - 4; - QString srcElided = fm.elidedText(src, Qt::ElideRight, width); - mSrc->setText(srcElided); - QString dstElided = fm.elidedText(dst, Qt::ElideRight, width); - mDst->setText(dstElided); -} - -void ProgressDialog::setValue(int val){ - mProgress->setValue(val); -} -- cgit v1.2.3-70-g09d2