mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-03-09 20:01:08 +00:00
- Performance improvement, property tabs are updated only when displayed
This commit is contained in:
parent
c5c09b09ee
commit
d9cb73634d
@ -86,6 +86,7 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, TransferListWidget *transfer
|
|||||||
connect(transferList, SIGNAL(currentTorrentChanged(QTorrentHandle&)), this, SLOT(loadTorrentInfos(QTorrentHandle &)));
|
connect(transferList, SIGNAL(currentTorrentChanged(QTorrentHandle&)), this, SLOT(loadTorrentInfos(QTorrentHandle &)));
|
||||||
connect(incrementalDownload, SIGNAL(stateChanged(int)), this, SLOT(setIncrementalDownload(int)));
|
connect(incrementalDownload, SIGNAL(stateChanged(int)), this, SLOT(setIncrementalDownload(int)));
|
||||||
connect(PropDelegate, SIGNAL(filteredFilesChanged()), this, SLOT(filteredFilesChanged()));
|
connect(PropDelegate, SIGNAL(filteredFilesChanged()), this, SLOT(filteredFilesChanged()));
|
||||||
|
connect(stackedProperties, SIGNAL(currentChanged(int)), this, SLOT(loadDynamicData()));
|
||||||
|
|
||||||
// Downloaded pieces progress bar
|
// Downloaded pieces progress bar
|
||||||
progressBar = new RealProgressBar(this);
|
progressBar = new RealProgressBar(this);
|
||||||
@ -274,42 +275,50 @@ void PropertiesWidget::loadDynamicData() {
|
|||||||
if(!h.is_valid()) return;
|
if(!h.is_valid()) return;
|
||||||
try {
|
try {
|
||||||
// Transfer infos
|
// Transfer infos
|
||||||
wasted->setText(misc::friendlyUnit(h.total_failed_bytes()+h.total_redundant_bytes()));
|
if(stackedProperties->currentIndex() == MAIN_TAB) {
|
||||||
upTotal->setText(misc::friendlyUnit(h.all_time_upload()) + " ("+misc::friendlyUnit(h.total_payload_upload())+" "+tr("this session")+")");
|
wasted->setText(misc::friendlyUnit(h.total_failed_bytes()+h.total_redundant_bytes()));
|
||||||
dlTotal->setText(misc::friendlyUnit(h.all_time_download()) + " ("+misc::friendlyUnit(h.total_payload_download())+" "+tr("this session")+")");
|
upTotal->setText(misc::friendlyUnit(h.all_time_upload()) + " ("+misc::friendlyUnit(h.total_payload_upload())+" "+tr("this session")+")");
|
||||||
lbl_uplimit->setText(misc::friendlyUnit(h.upload_limit()));
|
dlTotal->setText(misc::friendlyUnit(h.all_time_download()) + " ("+misc::friendlyUnit(h.total_payload_download())+" "+tr("this session")+")");
|
||||||
lbl_dllimit->setText(misc::friendlyUnit(h.download_limit()));
|
lbl_uplimit->setText(misc::friendlyUnit(h.upload_limit()));
|
||||||
QString elapsed_txt = misc::userFriendlyDuration(h.active_time());
|
lbl_dllimit->setText(misc::friendlyUnit(h.download_limit()));
|
||||||
if(h.is_seed()) {
|
QString elapsed_txt = misc::userFriendlyDuration(h.active_time());
|
||||||
elapsed_txt += " ("+tr("Seeding for %1", "e.g. Seeding for 3m10s").arg(misc::userFriendlyDuration(h.seeding_time()))+")";
|
if(h.is_seed()) {
|
||||||
}
|
elapsed_txt += " ("+tr("Seeding for %1", "e.g. Seeding for 3m10s").arg(misc::userFriendlyDuration(h.seeding_time()))+")";
|
||||||
lbl_elapsed->setText(elapsed_txt);
|
|
||||||
lbl_connections->setText(QString::number(h.num_connections())+" ("+tr("%1 max", "e.g. 10 max").arg(QString::number(h.connections_limit()))+")");
|
|
||||||
// Load peers
|
|
||||||
peersList->loadPeers(h);
|
|
||||||
// Update ratio info
|
|
||||||
float ratio;
|
|
||||||
if(h.total_payload_download() == 0){
|
|
||||||
if(h.total_payload_upload() == 0)
|
|
||||||
ratio = 1.;
|
|
||||||
else
|
|
||||||
ratio = 10.; // Max ratio
|
|
||||||
}else{
|
|
||||||
ratio = (double)h.total_payload_upload()/(double)h.total_payload_download();
|
|
||||||
if(ratio > 10.){
|
|
||||||
ratio = 10.;
|
|
||||||
}
|
}
|
||||||
|
lbl_elapsed->setText(elapsed_txt);
|
||||||
|
lbl_connections->setText(QString::number(h.num_connections())+" ("+tr("%1 max", "e.g. 10 max").arg(QString::number(h.connections_limit()))+")");
|
||||||
|
// Update ratio info
|
||||||
|
float ratio;
|
||||||
|
if(h.total_payload_download() == 0){
|
||||||
|
if(h.total_payload_upload() == 0)
|
||||||
|
ratio = 1.;
|
||||||
|
else
|
||||||
|
ratio = 10.; // Max ratio
|
||||||
|
}else{
|
||||||
|
ratio = (double)h.total_payload_upload()/(double)h.total_payload_download();
|
||||||
|
if(ratio > 10.){
|
||||||
|
ratio = 10.;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
shareRatio->setText(QString(QByteArray::number(ratio, 'f', 1)));
|
||||||
|
// Downloaded pieces
|
||||||
|
if(progressBarUpdater)
|
||||||
|
progressBarUpdater->refresh();
|
||||||
|
// Progress
|
||||||
|
progress_lbl->setText(QString::number(h.progress()*100., 'f', 1)+"%");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(stackedProperties->currentIndex() == PEERS_TAB) {
|
||||||
|
// Load peers
|
||||||
|
peersList->loadPeers(h);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(stackedProperties->currentIndex() == FILES_TAB) {
|
||||||
|
// Files progress
|
||||||
|
std::vector<size_type> fp;
|
||||||
|
h.file_progress(fp);
|
||||||
|
PropListModel->updateFilesProgress(fp);
|
||||||
}
|
}
|
||||||
shareRatio->setText(QString(QByteArray::number(ratio, 'f', 1)));
|
|
||||||
// Downloaded pieces
|
|
||||||
if(progressBarUpdater)
|
|
||||||
progressBarUpdater->refresh();
|
|
||||||
// Progress
|
|
||||||
progress_lbl->setText(QString::number(h.progress()*100., 'f', 1)+"%");
|
|
||||||
// Files progress
|
|
||||||
std::vector<size_type> fp;
|
|
||||||
h.file_progress(fp);
|
|
||||||
PropListModel->updateFilesProgress(fp);
|
|
||||||
} catch(invalid_handle e) {}
|
} catch(invalid_handle e) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user