mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-22 08:27:24 -06:00
Simplify progress bar painting
This commit is contained in:
@@ -33,7 +33,7 @@
|
||||
#include "transferlistmodel.h"
|
||||
|
||||
TransferListDelegate::TransferListDelegate(QObject *parent)
|
||||
: ProgressBarDelegate {TransferListModel::TR_PROGRESS, TransferListModel::UnderlyingDataRole, parent}
|
||||
: QStyledItemDelegate {parent}
|
||||
{
|
||||
}
|
||||
|
||||
@@ -61,3 +61,20 @@ QSize TransferListDelegate::sizeHint(const QStyleOptionViewItem &option, const Q
|
||||
size.setHeight(std::max(nameColHeight, size.height()));
|
||||
return size;
|
||||
}
|
||||
|
||||
void TransferListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||
{
|
||||
switch (index.column())
|
||||
{
|
||||
case TransferListModel::TR_PROGRESS:
|
||||
{
|
||||
const int progress = static_cast<int>(index.data(TransferListModel::UnderlyingDataRole).toReal());
|
||||
|
||||
m_progressBarPainter.paint(painter, option, index.data().toString(), progress);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
QStyledItemDelegate::paint(painter, option, index);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user