mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-02-08 12:54:27 +00:00
Code optimization
This commit is contained in:
parent
1562088bc8
commit
f6172f8c77
@ -176,7 +176,7 @@ public slots:
|
|||||||
|
|
||||||
void refreshStatusBar() {
|
void refreshStatusBar() {
|
||||||
// Update connection status
|
// Update connection status
|
||||||
session_status sessionStatus = BTSession->getSessionStatus();
|
const session_status sessionStatus = BTSession->getSessionStatus();
|
||||||
if(!BTSession->getSession()->is_listening()) {
|
if(!BTSession->getSession()->is_listening()) {
|
||||||
connecStatusLblIcon->setPixmap(QPixmap(QString::fromUtf8(":/Icons/skin/disconnected.png")));
|
connecStatusLblIcon->setPixmap(QPixmap(QString::fromUtf8(":/Icons/skin/disconnected.png")));
|
||||||
connecStatusLblIcon->setToolTip(QString::fromUtf8("<b>")+tr("Connection Status:")+QString::fromUtf8("</b><br>")+tr("Offline. This usually means that qBittorrent failed to listen on the selected port for incoming connections."));
|
connecStatusLblIcon->setToolTip(QString::fromUtf8("<b>")+tr("Connection Status:")+QString::fromUtf8("</b><br>")+tr("Offline. This usually means that qBittorrent failed to listen on the selected port for incoming connections."));
|
||||||
|
@ -74,7 +74,7 @@ public:
|
|||||||
}
|
}
|
||||||
case TR_SEEDS:
|
case TR_SEEDS:
|
||||||
case TR_PEERS: {
|
case TR_PEERS: {
|
||||||
qulonglong tot_val = index.data().toULongLong();
|
const qulonglong tot_val = index.data().toULongLong();
|
||||||
QString display = QString::number((qulonglong)tot_val/1000000);
|
QString display = QString::number((qulonglong)tot_val/1000000);
|
||||||
if(tot_val%2 == 0) {
|
if(tot_val%2 == 0) {
|
||||||
// Scrape was successful, we have total values
|
// Scrape was successful, we have total values
|
||||||
@ -86,8 +86,8 @@ public:
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TR_STATUS: {
|
case TR_STATUS: {
|
||||||
int state = index.data().toInt();
|
const 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");
|
||||||
@ -110,6 +110,9 @@ public:
|
|||||||
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");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
display = "";
|
||||||
}
|
}
|
||||||
QItemDelegate::drawBackground(painter, opt, index);
|
QItemDelegate::drawBackground(painter, opt, index);
|
||||||
QItemDelegate::drawDisplay(painter, opt, opt.rect, display);
|
QItemDelegate::drawDisplay(painter, opt, opt.rect, display);
|
||||||
@ -118,7 +121,7 @@ public:
|
|||||||
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();
|
const 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;
|
||||||
@ -126,7 +129,7 @@ public:
|
|||||||
case TR_UPLIMIT:
|
case TR_UPLIMIT:
|
||||||
case TR_DLLIMIT:{
|
case TR_DLLIMIT:{
|
||||||
QItemDelegate::drawBackground(painter, opt, index);
|
QItemDelegate::drawBackground(painter, opt, index);
|
||||||
qlonglong limit = index.data().toLongLong();
|
const qlonglong limit = index.data().toLongLong();
|
||||||
opt.displayAlignment = Qt::AlignRight;
|
opt.displayAlignment = Qt::AlignRight;
|
||||||
if(limit > 0)
|
if(limit > 0)
|
||||||
QItemDelegate::drawDisplay(painter, opt, opt.rect, QString::number(limit/1024., 'f', 1) + " " + tr("KiB/s", "KiB/second (.i.e per second)"));
|
QItemDelegate::drawDisplay(painter, opt, opt.rect, QString::number(limit/1024., 'f', 1) + " " + tr("KiB/s", "KiB/second (.i.e per second)"));
|
||||||
@ -142,7 +145,7 @@ public:
|
|||||||
case TR_RATIO:{
|
case TR_RATIO:{
|
||||||
QItemDelegate::drawBackground(painter, opt, index);
|
QItemDelegate::drawBackground(painter, opt, index);
|
||||||
opt.displayAlignment = Qt::AlignRight;
|
opt.displayAlignment = Qt::AlignRight;
|
||||||
double ratio = index.data().toDouble();
|
const double ratio = index.data().toDouble();
|
||||||
if(ratio > 100.)
|
if(ratio > 100.)
|
||||||
QItemDelegate::drawDisplay(painter, opt, opt.rect, QString::fromUtf8("∞"));
|
QItemDelegate::drawDisplay(painter, opt, opt.rect, QString::fromUtf8("∞"));
|
||||||
else
|
else
|
||||||
@ -150,7 +153,7 @@ public:
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TR_PRIORITY: {
|
case TR_PRIORITY: {
|
||||||
int priority = index.data().toInt();
|
const int priority = index.data().toInt();
|
||||||
if(priority >= 0) {
|
if(priority >= 0) {
|
||||||
opt.displayAlignment = Qt::AlignRight;
|
opt.displayAlignment = Qt::AlignRight;
|
||||||
QItemDelegate::paint(painter, opt, index);
|
QItemDelegate::paint(painter, opt, index);
|
||||||
@ -163,7 +166,7 @@ public:
|
|||||||
}
|
}
|
||||||
case TR_PROGRESS:{
|
case TR_PROGRESS:{
|
||||||
QStyleOptionProgressBarV2 newopt;
|
QStyleOptionProgressBarV2 newopt;
|
||||||
double progress = index.data().toDouble()*100.;
|
const double progress = index.data().toDouble()*100.;
|
||||||
newopt.rect = opt.rect;
|
newopt.rect = opt.rect;
|
||||||
newopt.text = QString::number(progress, 'f', 1)+"%";
|
newopt.text = QString::number(progress, 'f', 1)+"%";
|
||||||
newopt.progress = (int)progress;
|
newopt.progress = (int)progress;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user