mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-16 02:03:07 -07:00
Add functionality to new data fields, cleanups
This commit is contained in:
parent
64665146e1
commit
6bc42cfd1a
1 changed files with 106 additions and 68 deletions
|
@ -205,7 +205,7 @@ void PropertiesWidget::clear() {
|
||||||
qDebug("Clearing torrent properties");
|
qDebug("Clearing torrent properties");
|
||||||
save_path->clear();
|
save_path->clear();
|
||||||
lbl_creationDate->clear();
|
lbl_creationDate->clear();
|
||||||
pieceSize_lbl->clear();
|
label_total_pieces_val->clear();
|
||||||
hash_lbl->clear();
|
hash_lbl->clear();
|
||||||
comment_text->clear();
|
comment_text->clear();
|
||||||
progress_lbl->clear();
|
progress_lbl->clear();
|
||||||
|
@ -226,8 +226,16 @@ void PropertiesWidget::clear() {
|
||||||
listWebSeeds->clear();
|
listWebSeeds->clear();
|
||||||
m_contentFilerLine->clear();
|
m_contentFilerLine->clear();
|
||||||
PropListModel->model()->clear();
|
PropListModel->model()->clear();
|
||||||
showPiecesAvailability(false);
|
label_eta_val->clear();
|
||||||
showPiecesDownloaded(false);
|
label_seeds_val->clear();
|
||||||
|
label_peers_val->clear();
|
||||||
|
label_dl_speed_val->clear();
|
||||||
|
label_upload_speed_val->clear();
|
||||||
|
label_total_size_val->clear();
|
||||||
|
label_completed_on_val->clear();
|
||||||
|
label_last_complete_val->clear();
|
||||||
|
label_created_by_val->clear();
|
||||||
|
label_added_on_val->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
BitTorrent::TorrentHandle *PropertiesWidget::getCurrentTorrent() const
|
BitTorrent::TorrentHandle *PropertiesWidget::getCurrentTorrent() const
|
||||||
|
@ -267,16 +275,22 @@ void PropertiesWidget::loadTorrentInfos(BitTorrent::TorrentHandle *const torrent
|
||||||
PropListModel->model()->clear();
|
PropListModel->model()->clear();
|
||||||
if (m_torrent->hasMetadata()) {
|
if (m_torrent->hasMetadata()) {
|
||||||
// Creation date
|
// Creation date
|
||||||
lbl_creationDate->setText(m_torrent->creationDate().toString());
|
lbl_creationDate->setText(m_torrent->creationDate().toString(Qt::DefaultLocaleShortDate));
|
||||||
// Piece size
|
|
||||||
pieceSize_lbl->setText(Utils::Misc::friendlyUnit(m_torrent->pieceLength()));
|
label_total_size_val->setText(Utils::Misc::friendlyUnit(m_torrent->totalSize()));
|
||||||
|
|
||||||
// Comment
|
// Comment
|
||||||
comment_text->setHtml(Utils::Misc::parseHtmlLinks(m_torrent->comment()));
|
comment_text->setHtml(Utils::Misc::parseHtmlLinks(m_torrent->comment()));
|
||||||
|
|
||||||
// URL seeds
|
// URL seeds
|
||||||
loadUrlSeeds();
|
loadUrlSeeds();
|
||||||
|
|
||||||
|
label_created_by_val->setText(m_torrent->creator());
|
||||||
|
|
||||||
// List files in torrent
|
// List files in torrent
|
||||||
PropListModel->model()->setupModelData(m_torrent->info());
|
PropListModel->model()->setupModelData(m_torrent->info());
|
||||||
filesList->setExpanded(PropListModel->index(0, 0), true);
|
filesList->setExpanded(PropListModel->index(0, 0), true);
|
||||||
|
|
||||||
// Load file priorities
|
// Load file priorities
|
||||||
PropListModel->model()->updateFilesPriorities(m_torrent->filePriorities());
|
PropListModel->model()->updateFilesPriorities(m_torrent->filePriorities());
|
||||||
}
|
}
|
||||||
|
@ -318,7 +332,7 @@ void PropertiesWidget::saveSettings() {
|
||||||
sizes = slideSizes;
|
sizes = slideSizes;
|
||||||
qDebug("Sizes: %d", sizes.size());
|
qDebug("Sizes: %d", sizes.size());
|
||||||
if (sizes.size() == 2) {
|
if (sizes.size() == 2) {
|
||||||
pref->setPropSplitterSizes(QString::number(sizes.first())+','+QString::number(sizes.last()));
|
pref->setPropSplitterSizes(QString::number(sizes.first()) + ',' + QString::number(sizes.last()));
|
||||||
}
|
}
|
||||||
pref->setPropFileListState(filesList->header()->saveState());
|
pref->setPropFileListState(filesList->header()->saveState());
|
||||||
// Remember current tab
|
// Remember current tab
|
||||||
|
@ -336,59 +350,79 @@ void PropertiesWidget::loadDynamicData() {
|
||||||
if (!m_torrent || (main_window->getCurrentTabWidget() != transferList) || (state != VISIBLE)) return;
|
if (!m_torrent || (main_window->getCurrentTabWidget() != transferList) || (state != VISIBLE)) return;
|
||||||
|
|
||||||
// Transfer infos
|
// Transfer infos
|
||||||
if (stackedProperties->currentIndex() == PropTabBar::MAIN_TAB) {
|
switch(stackedProperties->currentIndex()) {
|
||||||
|
case PropTabBar::MAIN_TAB: {
|
||||||
wasted->setText(Utils::Misc::friendlyUnit(m_torrent->wastedSize()));
|
wasted->setText(Utils::Misc::friendlyUnit(m_torrent->wastedSize()));
|
||||||
upTotal->setText(Utils::Misc::friendlyUnit(m_torrent->totalUpload()) + " ("+Utils::Misc::friendlyUnit(m_torrent->totalPayloadUpload())+" "+tr("this session")+")");
|
upTotal->setText(Utils::Misc::friendlyUnit(m_torrent->totalUpload()) + " ("+Utils::Misc::friendlyUnit(m_torrent->totalPayloadUpload())+" "+tr("this session")+")");
|
||||||
dlTotal->setText(Utils::Misc::friendlyUnit(m_torrent->totalDownload()) + " ("+Utils::Misc::friendlyUnit(m_torrent->totalPayloadDownload())+" "+tr("this session")+")");
|
dlTotal->setText(Utils::Misc::friendlyUnit(m_torrent->totalDownload()) + " ("+Utils::Misc::friendlyUnit(m_torrent->totalPayloadDownload())+" "+tr("this session")+")");
|
||||||
lbl_uplimit->setText(m_torrent->uploadLimit() <= 0 ? QString::fromUtf8("∞") : Utils::Misc::friendlyUnit(m_torrent->uploadLimit())+tr("/s", "/second (i.e. per second)"));
|
lbl_uplimit->setText(m_torrent->uploadLimit() <= 0 ? QString::fromUtf8("∞") : Utils::Misc::friendlyUnit(m_torrent->uploadLimit())+tr("/s", "/second (i.e. per second)"));
|
||||||
lbl_dllimit->setText(m_torrent->downloadLimit() <= 0 ? QString::fromUtf8("∞") : Utils::Misc::friendlyUnit(m_torrent->downloadLimit())+tr("/s", "/second (i.e. per second)"));
|
lbl_dllimit->setText(m_torrent->downloadLimit() <= 0 ? QString::fromUtf8("∞") : Utils::Misc::friendlyUnit(m_torrent->downloadLimit())+tr("/s", "/second (i.e. per second)"));
|
||||||
QString elapsed_txt = Utils::Misc::userFriendlyDuration(m_torrent->activeTime());
|
QString elapsed_txt = Utils::Misc::userFriendlyDuration(m_torrent->activeTime());
|
||||||
if (m_torrent->isSeed()) {
|
if (m_torrent->isSeed())
|
||||||
elapsed_txt += " ("+tr("Seeded for %1", "e.g. Seeded for 3m10s").arg(Utils::Misc::userFriendlyDuration(m_torrent->seedingTime()))+")";
|
elapsed_txt += " ("+tr("Seeded for %1", "e.g. Seeded for 3m10s").arg(Utils::Misc::userFriendlyDuration(m_torrent->seedingTime()))+")";
|
||||||
}
|
|
||||||
lbl_elapsed->setText(elapsed_txt);
|
lbl_elapsed->setText(elapsed_txt);
|
||||||
if (m_torrent->connectionsLimit() > 0)
|
|
||||||
lbl_connections->setText(QString::number(m_torrent->connectionsCount())+" ("+tr("%1 max", "e.g. 10 max").arg(QString::number(m_torrent->connectionsLimit()))+")");
|
lbl_connections->setText(QString::number(m_torrent->connectionsCount()));
|
||||||
else
|
label_eta_val->setText(Utils::Misc::userFriendlyDuration(m_torrent->eta()));
|
||||||
lbl_connections->setText(QString::number(m_torrent->connectionsLimit()));
|
|
||||||
// Update next announce time
|
// Update next announce time
|
||||||
reannounce_lbl->setText(Utils::Misc::userFriendlyDuration(m_torrent->nextAnnounce()));
|
reannounce_lbl->setText(Utils::Misc::userFriendlyDuration(m_torrent->nextAnnounce()));
|
||||||
|
|
||||||
// Update ratio info
|
// Update ratio info
|
||||||
const qreal ratio = m_torrent->realRatio();
|
const qreal ratio = m_torrent->realRatio();
|
||||||
shareRatio->setText(ratio > BitTorrent::TorrentHandle::MAX_RATIO ? QString::fromUtf8("∞") : Utils::String::fromDouble(ratio, 2));
|
shareRatio->setText(ratio > BitTorrent::TorrentHandle::MAX_RATIO ? QString::fromUtf8("∞") : Utils::String::fromDouble(ratio, 2));
|
||||||
if (!m_torrent->isSeed() && m_torrent->hasMetadata()) {
|
|
||||||
showPiecesDownloaded(true);
|
label_seeds_val->setText(QString::number(m_torrent->seedsCount()) + " " + tr("(%1 total)","e.g. (10 total)").arg(QString::number(m_torrent->totalSeedsCount())));
|
||||||
// Downloaded pieces
|
label_peers_val->setText(QString::number(m_torrent->leechsCount()) + " " + tr("(%1 total)","e.g. (10 total)").arg(QString::number(m_torrent->totalLeechersCount())));
|
||||||
downloaded_pieces->setProgress(m_torrent->pieces(), m_torrent->downloadingPieces());
|
|
||||||
|
label_dl_speed_val->setText(Utils::Misc::friendlyUnit(m_torrent->downloadPayloadRate()) + tr("/s", "/second (i.e. per second)") + " "
|
||||||
|
+ tr("(%1/s avg.)","e.g. (100KiB/s avg.)").arg(Utils::Misc::friendlyUnit(m_torrent->totalDownload() / (1 + m_torrent->activeTime() - m_torrent->finishedTime()))));
|
||||||
|
label_upload_speed_val->setText(Utils::Misc::friendlyUnit(m_torrent->uploadPayloadRate()) + tr("/s", "/second (i.e. per second)") + " "
|
||||||
|
+ tr("(%1/s avg.)", "e.g. (100KiB/s avg.)").arg(Utils::Misc::friendlyUnit(m_torrent->totalUpload() / (1 + m_torrent->activeTime()))));
|
||||||
|
|
||||||
|
label_last_complete_val->setText(m_torrent->lastSeenComplete().isValid() ? m_torrent->lastSeenComplete().toString(Qt::DefaultLocaleShortDate) : tr("Never"));
|
||||||
|
label_completed_on_val->setText(m_torrent->completedTime().isValid() ? m_torrent->completedTime().toString(Qt::DefaultLocaleShortDate) : "");
|
||||||
|
label_added_on_val->setText(m_torrent->addedTime().toString(Qt::DefaultLocaleShortDate));
|
||||||
|
|
||||||
|
if (m_torrent->hasMetadata()) {
|
||||||
|
label_total_pieces_val->setText(tr("%1 x %2 (have %3)", "(torrent pieces) eg 152 x 4MB (have 25)").arg(m_torrent->piecesCount()).arg(Utils::Misc::friendlyUnit(m_torrent->pieceLength())).arg(m_torrent->piecesHave()));
|
||||||
|
|
||||||
|
if (!m_torrent->isSeed() && !m_torrent->isPaused() && !m_torrent->isQueued() && !m_torrent->isChecking()) {
|
||||||
// Pieces availability
|
// Pieces availability
|
||||||
if (!m_torrent->isPaused() && !m_torrent->isQueued() && !m_torrent->isChecking()) {
|
|
||||||
showPiecesAvailability(true);
|
showPiecesAvailability(true);
|
||||||
pieces_availability->setAvailability(m_torrent->pieceAvailability());
|
pieces_availability->setAvailability(m_torrent->pieceAvailability());
|
||||||
avail_average_lbl->setText(Utils::String::fromDouble(m_torrent->distributedCopies(), 3));
|
avail_average_lbl->setText(Utils::String::fromDouble(m_torrent->distributedCopies(), 3));
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
showPiecesAvailability(false);
|
showPiecesAvailability(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Progress
|
// Progress
|
||||||
qreal progress = m_torrent->progress() * 100.;
|
qreal progress = m_torrent->progress() * 100.;
|
||||||
progress_lbl->setText(Utils::String::fromDouble(progress, 1)+"%");
|
progress_lbl->setText(Utils::String::fromDouble(progress, 1)+"%");
|
||||||
} else {
|
downloaded_pieces->setProgress(m_torrent->pieces(), m_torrent->downloadingPieces());
|
||||||
showPiecesAvailability(false);
|
|
||||||
showPiecesDownloaded(false);
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
showPiecesAvailability(false);
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (stackedProperties->currentIndex() == PropTabBar::TRACKERS_TAB) {
|
|
||||||
|
case PropTabBar::TRACKERS_TAB: {
|
||||||
// Trackers
|
// Trackers
|
||||||
trackerList->loadTrackers();
|
trackerList->loadTrackers();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (stackedProperties->currentIndex() == PropTabBar::PEERS_TAB) {
|
|
||||||
|
case PropTabBar::PEERS_TAB: {
|
||||||
// Load peers
|
// Load peers
|
||||||
peersList->loadPeers(m_torrent);
|
peersList->loadPeers(m_torrent);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (stackedProperties->currentIndex() == PropTabBar::FILES_TAB) {
|
|
||||||
|
case PropTabBar::FILES_TAB: {
|
||||||
// Files progress
|
// Files progress
|
||||||
if (m_torrent->hasMetadata()) {
|
if (m_torrent->hasMetadata()) {
|
||||||
qDebug("Updating priorities in files tab");
|
qDebug("Updating priorities in files tab");
|
||||||
|
@ -401,6 +435,10 @@ void PropertiesWidget::loadDynamicData() {
|
||||||
filesList->setUpdatesEnabled(true);
|
filesList->setUpdatesEnabled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PropertiesWidget::loadUrlSeeds() {
|
void PropertiesWidget::loadUrlSeeds() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue