|
|
|
@ -47,12 +47,12 @@
@@ -47,12 +47,12 @@
|
|
|
|
|
#include "propertieswidget.h" |
|
|
|
|
#include "torrentcontentmodelitem.h" |
|
|
|
|
|
|
|
|
|
namespace { |
|
|
|
|
namespace |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
QPalette progressBarDisabledPalette() |
|
|
|
|
{ |
|
|
|
|
auto getPalette = []() |
|
|
|
|
{ |
|
|
|
|
auto getPalette = []() { |
|
|
|
|
QProgressBar bar; |
|
|
|
|
bar.setEnabled(false); |
|
|
|
|
QStyleOptionProgressBar opt; |
|
|
|
@ -64,8 +64,8 @@ namespace {
@@ -64,8 +64,8 @@ namespace {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
PropListDelegate::PropListDelegate(PropertiesWidget *properties, QObject *parent) |
|
|
|
|
: QItemDelegate(parent) |
|
|
|
|
PropListDelegate::PropListDelegate(PropertiesWidget *properties) |
|
|
|
|
: QItemDelegate(properties) |
|
|
|
|
, m_properties(properties) |
|
|
|
|
{ |
|
|
|
|
} |
|
|
|
@ -74,23 +74,22 @@ void PropListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti
@@ -74,23 +74,22 @@ void PropListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti
|
|
|
|
|
{ |
|
|
|
|
painter->save(); |
|
|
|
|
QStyleOptionViewItem opt = QItemDelegate::setOptions(index, option); |
|
|
|
|
QItemDelegate::drawBackground(painter, opt, index); |
|
|
|
|
|
|
|
|
|
switch (index.column()) { |
|
|
|
|
case PCSIZE: |
|
|
|
|
QItemDelegate::drawBackground(painter, opt, index); |
|
|
|
|
QItemDelegate::drawDisplay(painter, opt, option.rect, Utils::Misc::friendlyUnit(index.data().toLongLong())); |
|
|
|
|
break; |
|
|
|
|
case REMAINING: |
|
|
|
|
QItemDelegate::drawBackground(painter, opt, index); |
|
|
|
|
QItemDelegate::drawDisplay(painter, opt, option.rect, Utils::Misc::friendlyUnit(index.data().toLongLong())); |
|
|
|
|
break; |
|
|
|
|
case PROGRESS: |
|
|
|
|
if (index.data().toDouble() >= 0) { |
|
|
|
|
case PROGRESS: { |
|
|
|
|
if (index.data().toDouble() < 0) |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
QStyleOptionProgressBar newopt; |
|
|
|
|
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; |
|
|
|
|
newopt.progress = int(progress); |
|
|
|
|
newopt.maximum = 100; |
|
|
|
|
newopt.minimum = 0; |
|
|
|
|
newopt.textVisible = true; |
|
|
|
@ -98,23 +97,19 @@ void PropListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti
@@ -98,23 +97,19 @@ void PropListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti
|
|
|
|
|
newopt.state &= ~QStyle::State_Enabled; |
|
|
|
|
newopt.palette = progressBarDisabledPalette(); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
else { |
|
|
|
|
newopt.state |= QStyle::State_Enabled; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#ifndef Q_OS_WIN |
|
|
|
|
QApplication::style()->drawControl(QStyle::CE_ProgressBar, &newopt, painter); |
|
|
|
|
#else |
|
|
|
|
// XXX: To avoid having the progress text on the right of the bar
|
|
|
|
|
QProxyStyle st("fusion"); |
|
|
|
|
st.drawControl(QStyle::CE_ProgressBar, &newopt, painter, 0); |
|
|
|
|
QProxyStyle("fusion").drawControl(QStyle::CE_ProgressBar, &newopt, painter, 0); |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
// Do not display anything if the file is disabled (progress == 0)
|
|
|
|
|
QItemDelegate::drawBackground(painter, opt, index); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case PRIORITY: { |
|
|
|
|
QItemDelegate::drawBackground(painter, opt, index); |
|
|
|
|
QString text = ""; |
|
|
|
|
switch (index.data().toInt()) { |
|
|
|
|
case prio::MIXED: |
|
|
|
|