mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-30 00:14:57 +00:00
Do not report any progress for disabled files (Closes #56731485)
This commit is contained in:
parent
39e1ebaa9b
commit
4ca665eb0c
@ -74,26 +74,31 @@ public:
|
|||||||
QItemDelegate::drawDisplay(painter, opt, option.rect, misc::friendlyUnit(index.data().toLongLong()));
|
QItemDelegate::drawDisplay(painter, opt, option.rect, misc::friendlyUnit(index.data().toLongLong()));
|
||||||
break;
|
break;
|
||||||
case PROGRESS:{
|
case PROGRESS:{
|
||||||
QStyleOptionProgressBarV2 newopt;
|
if (index.data().toDouble() >= 0) {
|
||||||
qreal progress = index.data().toDouble()*100.;
|
QStyleOptionProgressBarV2 newopt;
|
||||||
newopt.rect = opt.rect;
|
qreal progress = index.data().toDouble()*100.;
|
||||||
// We don't want to display 100% unless
|
newopt.rect = opt.rect;
|
||||||
// the torrent is really complete
|
// We don't want to display 100% unless
|
||||||
if(progress > 99.94 && progress < 100.)
|
// the torrent is really complete
|
||||||
progress = 99.9;
|
if(progress > 99.94 && progress < 100.)
|
||||||
newopt.text = QString(QByteArray::number(progress, 'f', 1))+QString::fromUtf8("%");
|
progress = 99.9;
|
||||||
newopt.progress = (int)progress;
|
newopt.text = QString(QByteArray::number(progress, 'f', 1))+QString::fromUtf8("%");
|
||||||
newopt.maximum = 100;
|
newopt.progress = (int)progress;
|
||||||
newopt.minimum = 0;
|
newopt.maximum = 100;
|
||||||
newopt.state |= QStyle::State_Enabled;
|
newopt.minimum = 0;
|
||||||
newopt.textVisible = true;
|
newopt.state |= QStyle::State_Enabled;
|
||||||
|
newopt.textVisible = true;
|
||||||
#ifndef Q_WS_WIN
|
#ifndef Q_WS_WIN
|
||||||
QApplication::style()->drawControl(QStyle::CE_ProgressBar, &newopt, painter);
|
QApplication::style()->drawControl(QStyle::CE_ProgressBar, &newopt, painter);
|
||||||
#else
|
#else
|
||||||
// XXX: To avoid having the progress text on the right of the bar
|
// XXX: To avoid having the progress text on the right of the bar
|
||||||
QPlastiqueStyle st;
|
QPlastiqueStyle st;
|
||||||
st.drawControl(QStyle::CE_ProgressBar, &newopt, painter, 0);
|
st.drawControl(QStyle::CE_ProgressBar, &newopt, painter, 0);
|
||||||
#endif
|
#endif
|
||||||
|
} else {
|
||||||
|
// Do not display anything if the file is disabled (progress == -1)
|
||||||
|
QItemDelegate::drawBackground(painter, opt, index);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PRIORITY: {
|
case PRIORITY: {
|
||||||
|
@ -194,7 +194,7 @@ public:
|
|||||||
|
|
||||||
qreal getProgress() const {
|
qreal getProgress() const {
|
||||||
if(getPriority() == 0)
|
if(getPriority() == 0)
|
||||||
return 0.;
|
return -1;
|
||||||
qulonglong size = getSize();
|
qulonglong size = getSize();
|
||||||
if(size > 0)
|
if(size > 0)
|
||||||
return total_done/(float)getSize();
|
return total_done/(float)getSize();
|
||||||
@ -313,6 +313,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
QVariant data(int column) const {
|
QVariant data(int column) const {
|
||||||
|
if(column == COL_PROGRESS)
|
||||||
|
return getProgress();
|
||||||
return itemData.value(column);
|
return itemData.value(column);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user