Simplify progress bar painting

This commit is contained in:
Chocobo1
2021-03-10 15:52:30 +08:00
parent 6139d0d65a
commit a78929dadf
13 changed files with 110 additions and 132 deletions

View File

@@ -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;
}
}