Fix delete batch of empty file not update progress issue, related to bug#133380,133624.

This commit is contained in:
HeMeihong 2022-08-11 17:50:35 +08:00 committed by Yue-Lan
parent 8eb53a237e
commit 501258708b
2 changed files with 10 additions and 3 deletions

View File

@ -748,6 +748,7 @@ ProgressBar::ProgressBar(QWidget *parent) : QWidget(parent)
setMouseTracking(true); setMouseTracking(true);
m_is_stopping = false; m_is_stopping = false;
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
m_update_count = 0;
m_dest_uri = tr("starting ..."); m_dest_uri = tr("starting ...");
connect(this, &ProgressBar::cancelled, this, &ProgressBar::onCancelled); connect(this, &ProgressBar::cancelled, this, &ProgressBar::onCancelled);
connect(this, &ProgressBar::destroyed, this, [=] () {m_has_finished = true;}); connect(this, &ProgressBar::destroyed, this, [=] () {m_has_finished = true;});
@ -980,8 +981,8 @@ void ProgressBar::onFileOperationProgressedOne(const QString &uri, const QString
void ProgressBar::updateProgress(const QString &srcUri, const QString &destUri, const QString& fIcon, const quint64& current, const quint64& total) void ProgressBar::updateProgress(const QString &srcUri, const QString &destUri, const QString& fIcon, const quint64& current, const quint64& total)
{ {
if (current >= m_total_size) { if ((current > m_total_size && m_total_size>0) || m_update_count > m_total_count) {
qDebug() << "progress bar value error!"; qDebug() << "progress bar value error!:"<<current<<m_total_size;
return; return;
} }
@ -995,8 +996,13 @@ void ProgressBar::updateProgress(const QString &srcUri, const QString &destUri,
} }
double currentPercent = current * 1.0 / total; double currentPercent = current * 1.0 / total;
//fix bug#133624,133380, delete all empty files, not update progress bar
if (m_total_size <= 0){
m_update_count++;
currentPercent = m_update_count * 1.0 /m_total_count;
}
// qDebug() << "progress bar: " << currentPercent; qDebug() << "progress bar: " << currentPercent <<current<<total<<m_update_count<<m_total_count;
updateValue(currentPercent); updateValue(currentPercent);

View File

@ -197,6 +197,7 @@ private:
QString m_dest_uri; QString m_dest_uri;
int m_total_count = 0; int m_total_count = 0;
int m_current_count = 1; int m_current_count = 1;
int m_update_count = 0;
quint64 m_total_size = 0; quint64 m_total_size = 0;
qint32 m_current_size = 0; qint32 m_current_size = 0;