|
|
@ -42,7 +42,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
// Defines for download list list columns
|
|
|
|
// Defines for download list list columns
|
|
|
|
enum TorrentState {STATE_DOWNLOADING, STATE_STALLED_DL, STATE_STALLED_UP, STATE_SEEDING, STATE_PAUSED_DL, STATE_PAUSED_UP, STATE_QUEUED_DL, STATE_QUEUED_UP, STATE_CHECKING_UP, STATE_CHECKING_DL, STATE_INVALID}; |
|
|
|
enum TorrentState {STATE_DOWNLOADING, STATE_STALLED_DL, STATE_STALLED_UP, STATE_SEEDING, STATE_PAUSED_DL, STATE_PAUSED_UP, STATE_QUEUED_DL, STATE_QUEUED_UP, STATE_CHECKING_UP, STATE_CHECKING_DL, STATE_INVALID}; |
|
|
|
enum Column {TR_NAME, TR_PRIORITY, TR_SIZE, TR_PROGRESS, TR_STATUS, TR_SEEDS, TR_PEERS, TR_DLSPEED, TR_UPSPEED, TR_ETA, TR_RATIO, TR_LABEL, TR_HASH}; |
|
|
|
enum Column {TR_NAME, TR_PRIORITY, TR_SIZE, TR_PROGRESS, TR_STATUS, TR_SEEDS, TR_PEERS, TR_DLSPEED, TR_UPSPEED, TR_ETA, TR_RATIO, TR_LABEL, TR_ADD_DATE, TR_SEED_DATE, TR_HASH}; |
|
|
|
|
|
|
|
|
|
|
|
class TransferListDelegate: public QItemDelegate { |
|
|
|
class TransferListDelegate: public QItemDelegate { |
|
|
|
Q_OBJECT |
|
|
|
Q_OBJECT |
|
|
@ -83,78 +83,83 @@ public: |
|
|
|
int state = index.data().toInt(); |
|
|
|
int state = index.data().toInt(); |
|
|
|
QString display = ""; |
|
|
|
QString display = ""; |
|
|
|
switch(state) { |
|
|
|
switch(state) { |
|
|
|
case STATE_DOWNLOADING: |
|
|
|
case STATE_DOWNLOADING: |
|
|
|
display = tr("Downloading"); |
|
|
|
display = tr("Downloading"); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case STATE_PAUSED_DL: |
|
|
|
case STATE_PAUSED_DL: |
|
|
|
case STATE_PAUSED_UP: |
|
|
|
case STATE_PAUSED_UP: |
|
|
|
display = tr("Paused"); |
|
|
|
display = tr("Paused"); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case STATE_QUEUED_DL: |
|
|
|
case STATE_QUEUED_DL: |
|
|
|
case STATE_QUEUED_UP: |
|
|
|
case STATE_QUEUED_UP: |
|
|
|
display = tr("Queued", "i.e. torrent is queued"); |
|
|
|
display = tr("Queued", "i.e. torrent is queued"); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case STATE_SEEDING: |
|
|
|
case STATE_SEEDING: |
|
|
|
case STATE_STALLED_UP: |
|
|
|
case STATE_STALLED_UP: |
|
|
|
display = tr("Seeding", "Torrent is complete and in upload-only mode"); |
|
|
|
display = tr("Seeding", "Torrent is complete and in upload-only mode"); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case STATE_STALLED_DL: |
|
|
|
case STATE_STALLED_DL: |
|
|
|
display = tr("Stalled", "Torrent is waiting for download to begin"); |
|
|
|
display = tr("Stalled", "Torrent is waiting for download to begin"); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case STATE_CHECKING_DL: |
|
|
|
case STATE_CHECKING_DL: |
|
|
|
case STATE_CHECKING_UP: |
|
|
|
case STATE_CHECKING_UP: |
|
|
|
display = tr("Checking", "Torrent local data is being checked"); |
|
|
|
display = tr("Checking", "Torrent local data is being checked"); |
|
|
|
} |
|
|
|
} |
|
|
|
QItemDelegate::drawBackground(painter, opt, index); |
|
|
|
QItemDelegate::drawBackground(painter, opt, index); |
|
|
|
QItemDelegate::drawDisplay(painter, opt, opt.rect, display); |
|
|
|
QItemDelegate::drawDisplay(painter, opt, opt.rect, display); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
case TR_UPSPEED: |
|
|
|
case TR_UPSPEED: |
|
|
|
case TR_DLSPEED:{ |
|
|
|
case TR_DLSPEED:{ |
|
|
|
QItemDelegate::drawBackground(painter, opt, index); |
|
|
|
QItemDelegate::drawBackground(painter, opt, index); |
|
|
|
qulonglong speed = index.data().toULongLong(); |
|
|
|
qulonglong speed = index.data().toULongLong(); |
|
|
|
opt.displayAlignment = Qt::AlignRight; |
|
|
|
opt.displayAlignment = Qt::AlignRight; |
|
|
|
QItemDelegate::drawDisplay(painter, opt, opt.rect, misc::friendlyUnit(speed)+tr("/s", "/second (.i.e per second)")); |
|
|
|
QItemDelegate::drawDisplay(painter, opt, opt.rect, misc::friendlyUnit(speed)+tr("/s", "/second (.i.e per second)")); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
case TR_RATIO:{ |
|
|
|
case TR_ADD_DATE: |
|
|
|
QItemDelegate::drawBackground(painter, opt, index); |
|
|
|
case TR_SEED_DATE: |
|
|
|
opt.displayAlignment = Qt::AlignRight; |
|
|
|
QItemDelegate::drawBackground(painter, opt, index); |
|
|
|
double ratio = index.data().toDouble(); |
|
|
|
QItemDelegate::drawDisplay(painter, opt, opt.rect, index.data().toDateTime().toLocalTime().toString(Qt::DefaultLocaleShortDate)); |
|
|
|
if(ratio > 100.) |
|
|
|
break; |
|
|
|
QItemDelegate::drawDisplay(painter, opt, opt.rect, QString::fromUtf8("∞")); |
|
|
|
case TR_RATIO:{ |
|
|
|
else |
|
|
|
QItemDelegate::drawBackground(painter, opt, index); |
|
|
|
QItemDelegate::drawDisplay(painter, opt, opt.rect, QString::number(ratio, 'f', 1)); |
|
|
|
opt.displayAlignment = Qt::AlignRight; |
|
|
|
break; |
|
|
|
double ratio = index.data().toDouble(); |
|
|
|
} |
|
|
|
if(ratio > 100.) |
|
|
|
case TR_PRIORITY: { |
|
|
|
QItemDelegate::drawDisplay(painter, opt, opt.rect, QString::fromUtf8("∞")); |
|
|
|
int priority = index.data().toInt(); |
|
|
|
else |
|
|
|
if(priority >= 0) { |
|
|
|
QItemDelegate::drawDisplay(painter, opt, opt.rect, QString::number(ratio, 'f', 1)); |
|
|
|
opt.displayAlignment = Qt::AlignRight; |
|
|
|
break; |
|
|
|
QItemDelegate::paint(painter, opt, index); |
|
|
|
} |
|
|
|
} else { |
|
|
|
case TR_PRIORITY: { |
|
|
|
QItemDelegate::drawBackground(painter, opt, index); |
|
|
|
int priority = index.data().toInt(); |
|
|
|
opt.displayAlignment = Qt::AlignRight; |
|
|
|
if(priority >= 0) { |
|
|
|
QItemDelegate::drawDisplay(painter, opt, opt.rect, "*"); |
|
|
|
opt.displayAlignment = Qt::AlignRight; |
|
|
|
} |
|
|
|
QItemDelegate::paint(painter, opt, index); |
|
|
|
break; |
|
|
|
} else { |
|
|
|
} |
|
|
|
QItemDelegate::drawBackground(painter, opt, index); |
|
|
|
case TR_PROGRESS:{ |
|
|
|
opt.displayAlignment = Qt::AlignRight; |
|
|
|
QStyleOptionProgressBarV2 newopt; |
|
|
|
QItemDelegate::drawDisplay(painter, opt, opt.rect, "*"); |
|
|
|
double progress = index.data().toDouble()*100.; |
|
|
|
|
|
|
|
newopt.rect = opt.rect; |
|
|
|
|
|
|
|
newopt.text = QString::number(progress, 'f', 1)+"%"; |
|
|
|
|
|
|
|
newopt.progress = (int)progress; |
|
|
|
|
|
|
|
newopt.maximum = 100; |
|
|
|
|
|
|
|
newopt.minimum = 0; |
|
|
|
|
|
|
|
newopt.state |= QStyle::State_Enabled; |
|
|
|
|
|
|
|
newopt.textVisible = true; |
|
|
|
|
|
|
|
QApplication::style()->drawControl(QStyle::CE_ProgressBar, &newopt, painter); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
QItemDelegate::paint(painter, option, index); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
case TR_PROGRESS:{ |
|
|
|
|
|
|
|
QStyleOptionProgressBarV2 newopt; |
|
|
|
|
|
|
|
double progress = index.data().toDouble()*100.; |
|
|
|
|
|
|
|
newopt.rect = opt.rect; |
|
|
|
|
|
|
|
newopt.text = QString::number(progress, 'f', 1)+"%"; |
|
|
|
|
|
|
|
newopt.progress = (int)progress; |
|
|
|
|
|
|
|
newopt.maximum = 100; |
|
|
|
|
|
|
|
newopt.minimum = 0; |
|
|
|
|
|
|
|
newopt.state |= QStyle::State_Enabled; |
|
|
|
|
|
|
|
newopt.textVisible = true; |
|
|
|
|
|
|
|
QApplication::style()->drawControl(QStyle::CE_ProgressBar, &newopt, painter); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
QItemDelegate::paint(painter, option, index); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
QWidget* createEditor(QWidget*, const QStyleOptionViewItem &, const QModelIndex &) const { |
|
|
|
QWidget* createEditor(QWidget*, const QStyleOptionViewItem &, const QModelIndex &) const { |
|
|
|