|
|
|
@ -51,15 +51,21 @@
@@ -51,15 +51,21 @@
|
|
|
|
|
#endif |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
TransferListDelegate::TransferListDelegate(QObject *parent) : QItemDelegate(parent) {} |
|
|
|
|
TransferListDelegate::TransferListDelegate(QObject *parent) |
|
|
|
|
: QItemDelegate(parent) |
|
|
|
|
{ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TransferListDelegate::~TransferListDelegate() {} |
|
|
|
|
TransferListDelegate::~TransferListDelegate() |
|
|
|
|
{ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const { |
|
|
|
|
void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const |
|
|
|
|
{ |
|
|
|
|
const bool hideValues = Preferences::instance()->getHideZeroValues(); |
|
|
|
|
QStyleOptionViewItemV2 opt = QItemDelegate::setOptions(index, option); |
|
|
|
|
painter->save(); |
|
|
|
|
switch(index.column()) { |
|
|
|
|
switch (index.column()) { |
|
|
|
|
case TorrentModel::TR_AMOUNT_DOWNLOADED: |
|
|
|
|
case TorrentModel::TR_AMOUNT_UPLOADED: |
|
|
|
|
case TorrentModel::TR_AMOUNT_DOWNLOADED_SESSION: |
|
|
|
@ -76,7 +82,6 @@ void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem
@@ -76,7 +82,6 @@ void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem
|
|
|
|
|
QItemDelegate::drawDisplay(painter, opt, option.rect, Utils::Misc::friendlyUnit(size)); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
case TorrentModel::TR_ETA: { |
|
|
|
|
QItemDelegate::drawBackground(painter, opt, index); |
|
|
|
|
opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter; |
|
|
|
@ -87,10 +92,9 @@ void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem
@@ -87,10 +92,9 @@ void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem
|
|
|
|
|
case TorrentModel::TR_PEERS: { |
|
|
|
|
QString display = QString::number(index.data().toLongLong()); |
|
|
|
|
qlonglong total = index.data(Qt::UserRole).toLongLong(); |
|
|
|
|
if (total > 0) { |
|
|
|
|
if (total > 0) |
|
|
|
|
// Scrape was successful, we have total values
|
|
|
|
|
display += " ("+QString::number(total)+")"; |
|
|
|
|
} |
|
|
|
|
display += " (" + QString::number(total) + ")"; |
|
|
|
|
QItemDelegate::drawBackground(painter, opt, index); |
|
|
|
|
opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter; |
|
|
|
|
QItemDelegate::drawDisplay(painter, opt, opt.rect, display); |
|
|
|
@ -99,7 +103,7 @@ void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem
@@ -99,7 +103,7 @@ void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem
|
|
|
|
|
case TorrentModel::TR_STATUS: { |
|
|
|
|
const int state = index.data().toInt(); |
|
|
|
|
QString display; |
|
|
|
|
switch(state) { |
|
|
|
|
switch (state) { |
|
|
|
|
case BitTorrent::TorrentState::Downloading: |
|
|
|
|
display = tr("Downloading"); |
|
|
|
|
break; |
|
|
|
@ -205,8 +209,9 @@ void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem
@@ -205,8 +209,9 @@ void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem
|
|
|
|
|
case TorrentModel::TR_PRIORITY: { |
|
|
|
|
const int priority = index.data().toInt(); |
|
|
|
|
opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter; |
|
|
|
|
if (priority > 0) |
|
|
|
|
if (priority > 0) { |
|
|
|
|
QItemDelegate::paint(painter, opt, index); |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
QItemDelegate::drawBackground(painter, opt, index); |
|
|
|
|
QItemDelegate::drawDisplay(painter, opt, opt.rect, "*"); |
|
|
|
@ -215,7 +220,7 @@ void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem
@@ -215,7 +220,7 @@ void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem
|
|
|
|
|
} |
|
|
|
|
case TorrentModel::TR_PROGRESS: { |
|
|
|
|
QStyleOptionProgressBarV2 newopt; |
|
|
|
|
qreal progress = index.data().toDouble()*100.; |
|
|
|
|
qreal progress = index.data().toDouble() * 100.; |
|
|
|
|
newopt.rect = opt.rect; |
|
|
|
|
newopt.text = ((progress == 100.0) ? QString("100%") : Utils::String::fromDouble(progress, 1) + "%"); |
|
|
|
|
newopt.progress = (int)progress; |
|
|
|
@ -260,23 +265,25 @@ void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem
@@ -260,23 +265,25 @@ void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem
|
|
|
|
|
painter->restore(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
QWidget* TransferListDelegate::createEditor(QWidget*, const QStyleOptionViewItem &, const QModelIndex &) const { |
|
|
|
|
QWidget* TransferListDelegate::createEditor(QWidget*, const QStyleOptionViewItem &, const QModelIndex &) const |
|
|
|
|
{ |
|
|
|
|
// No editor here
|
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
QSize TransferListDelegate::sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const { |
|
|
|
|
QSize TransferListDelegate::sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const |
|
|
|
|
{ |
|
|
|
|
QSize size = QItemDelegate::sizeHint(option, index); |
|
|
|
|
|
|
|
|
|
static int icon_height = -1; |
|
|
|
|
if (icon_height == -1) { |
|
|
|
|
static int iconHeight = -1; |
|
|
|
|
if (iconHeight == -1) { |
|
|
|
|
QIcon icon(":/icons/skin/downloading.png"); |
|
|
|
|
QList<QSize> ic_sizes(icon.availableSizes()); |
|
|
|
|
icon_height = ic_sizes[0].height(); |
|
|
|
|
QList<QSize> icSizes(icon.availableSizes()); |
|
|
|
|
iconHeight = icSizes[0].height(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (size.height() < icon_height) |
|
|
|
|
size.setHeight(icon_height); |
|
|
|
|
if (size.height() < iconHeight) |
|
|
|
|
size.setHeight(iconHeight); |
|
|
|
|
|
|
|
|
|
return size; |
|
|
|
|
} |
|
|
|
|