mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-20 07:27:22 -06:00
- Fixed a bug in last commit in qBittorrentPath()
- Optimized float to string conversions
This commit is contained in:
@@ -49,7 +49,6 @@ class FinishedListDelegate: public QItemDelegate {
|
||||
~FinishedListDelegate(){}
|
||||
|
||||
void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const{
|
||||
char tmp[MAX_CHAR_TMP];
|
||||
QStyleOptionViewItemV2 opt = QItemDelegate::setOptions(index, option);
|
||||
switch(index.column()){
|
||||
case F_SIZE:
|
||||
@@ -58,25 +57,21 @@ class FinishedListDelegate: public QItemDelegate {
|
||||
break;
|
||||
case F_UPSPEED:{
|
||||
QItemDelegate::drawBackground(painter, opt, index);
|
||||
float speed = index.data().toDouble();
|
||||
snprintf(tmp, MAX_CHAR_TMP, "%.1f", speed/1024.);
|
||||
QItemDelegate::drawDisplay(painter, opt, opt.rect, QString::fromUtf8(tmp)+QString::fromUtf8(" ")+tr("KiB/s"));
|
||||
double speed = index.data().toDouble();
|
||||
QItemDelegate::drawDisplay(painter, opt, opt.rect, QString(QByteArray::number(speed/1024., 'f', 1))+QString::fromUtf8(" ")+tr("KiB/s"));
|
||||
break;
|
||||
}
|
||||
case F_RATIO:{
|
||||
QItemDelegate::drawBackground(painter, opt, index);
|
||||
float ratio = index.data().toDouble();
|
||||
snprintf(tmp, MAX_CHAR_TMP, "%.1f", ratio);
|
||||
QItemDelegate::drawDisplay(painter, opt, opt.rect, QString::fromUtf8(tmp));
|
||||
double ratio = index.data().toDouble();
|
||||
QItemDelegate::drawDisplay(painter, opt, opt.rect, QString(QByteArray::number(ratio, 'f', 1)));
|
||||
break;
|
||||
}
|
||||
case F_PROGRESS:{
|
||||
QStyleOptionProgressBarV2 newopt;
|
||||
float progress;
|
||||
progress = index.data().toDouble()*100.;
|
||||
snprintf(tmp, MAX_CHAR_TMP, "%.1f", progress);
|
||||
double progress = index.data().toDouble()*100.;
|
||||
newopt.rect = opt.rect;
|
||||
newopt.text = QString::fromUtf8(tmp)+QString::fromUtf8("%");
|
||||
newopt.text = QString(QByteArray::number(progress, 'f', 1))+QString::fromUtf8("%");
|
||||
newopt.progress = (int)progress;
|
||||
newopt.maximum = 100;
|
||||
newopt.minimum = 0;
|
||||
|
||||
Reference in New Issue
Block a user