diff --git a/src/core/bittorrent/torrenthandle.cpp b/src/core/bittorrent/torrenthandle.cpp index 14c8e6ccb..cc8f4b18d 100644 --- a/src/core/bittorrent/torrenthandle.cpp +++ b/src/core/bittorrent/torrenthandle.cpp @@ -496,6 +496,11 @@ int TorrentHandle::piecesCount() const return m_torrentInfo.piecesCount(); } +int TorrentHandle::piecesHave() const +{ + return m_nativeStatus.num_pieces; +} + qreal TorrentHandle::progress() const { if (!m_nativeStatus.total_wanted) @@ -846,6 +851,11 @@ int TorrentHandle::activeTime() const return m_nativeStatus.active_time; } +int TorrentHandle::finishedTime() const +{ + return m_nativeStatus.finished_time; +} + int TorrentHandle::seedingTime() const { return m_nativeStatus.seeding_time; @@ -908,6 +918,21 @@ int TorrentHandle::leechsCount() const return (m_nativeStatus.num_peers - m_nativeStatus.num_seeds); } +int TorrentHandle::totalSeedsCount() const +{ + return m_nativeStatus.list_seeds; +} + +int TorrentHandle::totalPeersCount() const +{ + return m_nativeStatus.list_peers; +} + +int TorrentHandle::totalLeechersCount() const +{ + return (m_nativeStatus.list_peers - m_nativeStatus.list_seeds); +} + int TorrentHandle::completeCount() const { return m_nativeStatus.num_complete; diff --git a/src/core/bittorrent/torrenthandle.h b/src/core/bittorrent/torrenthandle.h index eb17fa3ed..1b4663d15 100644 --- a/src/core/bittorrent/torrenthandle.h +++ b/src/core/bittorrent/torrenthandle.h @@ -183,6 +183,7 @@ namespace BitTorrent QString savePathParsed() const; int filesCount() const; int piecesCount() const; + int piecesHave() const; qreal progress() const; QString label() const; QDateTime addedTime() const; @@ -224,12 +225,16 @@ namespace BitTorrent qlonglong totalDownload() const; qlonglong totalUpload() const; int activeTime() const; + int finishedTime() const; int seedingTime() const; qulonglong eta() const; QVector filesProgress() const; int seedsCount() const; int peersCount() const; int leechsCount() const; + int totalSeedsCount() const; + int totalPeersCount() const; + int totalLeechersCount() const; int completeCount() const; int incompleteCount() const; QDateTime lastSeenComplete() const; diff --git a/src/gui/properties/propertieswidget.cpp b/src/gui/properties/propertieswidget.cpp index 4f6d0efb5..d4eab984c 100644 --- a/src/gui/properties/propertieswidget.cpp +++ b/src/gui/properties/propertieswidget.cpp @@ -205,7 +205,7 @@ void PropertiesWidget::clear() { qDebug("Clearing torrent properties"); save_path->clear(); lbl_creationDate->clear(); - pieceSize_lbl->clear(); + label_total_pieces_val->clear(); hash_lbl->clear(); comment_text->clear(); progress_lbl->clear(); @@ -226,8 +226,16 @@ void PropertiesWidget::clear() { listWebSeeds->clear(); m_contentFilerLine->clear(); PropListModel->model()->clear(); - showPiecesAvailability(false); - showPiecesDownloaded(false); + label_eta_val->clear(); + 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 @@ -267,16 +275,22 @@ void PropertiesWidget::loadTorrentInfos(BitTorrent::TorrentHandle *const torrent PropListModel->model()->clear(); if (m_torrent->hasMetadata()) { // Creation date - lbl_creationDate->setText(m_torrent->creationDate().toString()); - // Piece size - pieceSize_lbl->setText(Utils::Misc::friendlyUnit(m_torrent->pieceLength())); + lbl_creationDate->setText(m_torrent->creationDate().toString(Qt::DefaultLocaleShortDate)); + + label_total_size_val->setText(Utils::Misc::friendlyUnit(m_torrent->totalSize())); + // Comment comment_text->setHtml(Utils::Misc::parseHtmlLinks(m_torrent->comment())); + // URL seeds loadUrlSeeds(); + + label_created_by_val->setText(m_torrent->creator()); + // List files in torrent PropListModel->model()->setupModelData(m_torrent->info()); filesList->setExpanded(PropListModel->index(0, 0), true); + // Load file priorities PropListModel->model()->updateFilesPriorities(m_torrent->filePriorities()); } @@ -318,7 +332,7 @@ void PropertiesWidget::saveSettings() { sizes = slideSizes; qDebug("Sizes: %d", sizes.size()); 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()); // Remember current tab @@ -332,74 +346,98 @@ void PropertiesWidget::reloadPreferences() { } void PropertiesWidget::loadDynamicData() { - // Refresh only if the torrent handle is valid and if visible - if (!m_torrent || (main_window->getCurrentTabWidget() != transferList) || (state != VISIBLE)) return; + // Refresh only if the torrent handle is valid and if visible + if (!m_torrent || (main_window->getCurrentTabWidget() != transferList) || (state != VISIBLE)) return; // Transfer infos - if (stackedProperties->currentIndex() == PropTabBar::MAIN_TAB) { + switch(stackedProperties->currentIndex()) { + case PropTabBar::MAIN_TAB: { + 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")+")"); + 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_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()); + if (m_torrent->isSeed()) + elapsed_txt += " ("+tr("Seeded for %1", "e.g. Seeded for 3m10s").arg(Utils::Misc::userFriendlyDuration(m_torrent->seedingTime()))+")"; - 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")+")"); - 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_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()); - if (m_torrent->isSeed()) { - elapsed_txt += " ("+tr("Seeded for %1", "e.g. Seeded for 3m10s").arg(Utils::Misc::userFriendlyDuration(m_torrent->seedingTime()))+")"; - } - 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()))+")"); - else - lbl_connections->setText(QString::number(m_torrent->connectionsLimit())); - // Update next announce time - reannounce_lbl->setText(Utils::Misc::userFriendlyDuration(m_torrent->nextAnnounce())); - // Update ratio info - const qreal ratio = m_torrent->realRatio(); - shareRatio->setText(ratio > BitTorrent::TorrentHandle::MAX_RATIO ? QString::fromUtf8("∞") : Utils::String::fromDouble(ratio, 2)); - if (!m_torrent->isSeed() && m_torrent->hasMetadata()) { - showPiecesDownloaded(true); - // Downloaded pieces - downloaded_pieces->setProgress(m_torrent->pieces(), m_torrent->downloadingPieces()); - // Pieces availability - if (!m_torrent->isPaused() && !m_torrent->isQueued() && !m_torrent->isChecking()) { - showPiecesAvailability(true); - pieces_availability->setAvailability(m_torrent->pieceAvailability()); - avail_average_lbl->setText(Utils::String::fromDouble(m_torrent->distributedCopies(), 3)); - } else { - showPiecesAvailability(false); + lbl_elapsed->setText(elapsed_txt); + + lbl_connections->setText(QString::number(m_torrent->connectionsCount())); + label_eta_val->setText(Utils::Misc::userFriendlyDuration(m_torrent->eta())); + + // Update next announce time + reannounce_lbl->setText(Utils::Misc::userFriendlyDuration(m_torrent->nextAnnounce())); + + // Update ratio info + const qreal ratio = m_torrent->realRatio(); + shareRatio->setText(ratio > BitTorrent::TorrentHandle::MAX_RATIO ? QString::fromUtf8("∞") : Utils::String::fromDouble(ratio, 2)); + + label_seeds_val->setText(QString::number(m_torrent->seedsCount()) + " " + tr("(%1 total)","e.g. (10 total)").arg(QString::number(m_torrent->totalSeedsCount()))); + label_peers_val->setText(QString::number(m_torrent->leechsCount()) + " " + tr("(%1 total)","e.g. (10 total)").arg(QString::number(m_torrent->totalLeechersCount()))); + + 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 + showPiecesAvailability(true); + pieces_availability->setAvailability(m_torrent->pieceAvailability()); + avail_average_lbl->setText(Utils::String::fromDouble(m_torrent->distributedCopies(), 3)); + } + else { + showPiecesAvailability(false); + } + + // Progress + qreal progress = m_torrent->progress() * 100.; + progress_lbl->setText(Utils::String::fromDouble(progress, 1)+"%"); + downloaded_pieces->setProgress(m_torrent->pieces(), m_torrent->downloadingPieces()); } - // Progress - qreal progress = m_torrent->progress() * 100.; - progress_lbl->setText(Utils::String::fromDouble(progress, 1)+"%"); - } else { - showPiecesAvailability(false); - showPiecesDownloaded(false); - } - return; + else { + showPiecesAvailability(false); + } + + return; } - if (stackedProperties->currentIndex() == PropTabBar::TRACKERS_TAB) { - // Trackers - trackerList->loadTrackers(); - return; + + case PropTabBar::TRACKERS_TAB: { + // Trackers + trackerList->loadTrackers(); + return; } - if (stackedProperties->currentIndex() == PropTabBar::PEERS_TAB) { - // Load peers - peersList->loadPeers(m_torrent); - return; + + case PropTabBar::PEERS_TAB: { + // Load peers + peersList->loadPeers(m_torrent); + return; } - if (stackedProperties->currentIndex() == PropTabBar::FILES_TAB) { - // Files progress - if (m_torrent->hasMetadata()) { - qDebug("Updating priorities in files tab"); - filesList->setUpdatesEnabled(false); - PropListModel->model()->updateFilesProgress(m_torrent->filesProgress()); - // XXX: We don't update file priorities regularly for performance - // reasons. This means that priorities will not be updated if - // set from the Web UI. - // PropListModel->model()->updateFilesPriorities(h.file_priorities()); - filesList->setUpdatesEnabled(true); - } + + case PropTabBar::FILES_TAB: { + // Files progress + if (m_torrent->hasMetadata()) { + qDebug("Updating priorities in files tab"); + filesList->setUpdatesEnabled(false); + PropListModel->model()->updateFilesProgress(m_torrent->filesProgress()); + // XXX: We don't update file priorities regularly for performance + // reasons. This means that priorities will not be updated if + // set from the Web UI. + // PropListModel->model()->updateFilesPriorities(h.file_priorities()); + filesList->setUpdatesEnabled(true); + } + } + + default: + return; } } diff --git a/src/gui/properties/propertieswidget.ui b/src/gui/properties/propertieswidget.ui index 16c46fbc6..59276403d 100644 --- a/src/gui/properties/propertieswidget.ui +++ b/src/gui/properties/propertieswidget.ui @@ -36,7 +36,7 @@ - + 0 0 @@ -74,7 +74,7 @@ - Downloaded: + Progress: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -96,10 +96,10 @@ - 0.0% + - Qt::AlignCenter + Qt::AlignLeading 0 @@ -137,6 +137,12 @@ + + + 0 + 0 + + 50 @@ -144,10 +150,10 @@ - 0.0 + - Qt::AlignCenter + Qt::AlignLeading @@ -162,14 +168,26 @@ + + + 0 + 0 + + Transfer - + + + + 0 + 0 + + - Uploaded: + Time Active: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -177,16 +195,28 @@ - + + + + 0 + 0 + + - 0 Kb + - + + + + 0 + 0 + + - UP limit: + ETA: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -194,31 +224,55 @@ - + + + + 0 + 0 + + - + - + + + + 0 + 0 + + - Share ratio: + Connections: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - + + + + + 0 + 0 + + - 1.0 + + + + 0 + 0 + + Downloaded: @@ -229,47 +283,228 @@ + + + 0 + 0 + + - 0 Kb + - + + + + 0 + 0 + + - DL limit: + Uploaded: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - + + + + + 0 + 0 + + - + - + + + + 0 + 0 + + - Connections: + Seeds: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - + + + + + 0 + 0 + + - 0 + + + + + 0 + 0 + + + + Download Speed: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + + + + + + + + + 0 + 0 + + + + Upload Speed: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + + + + + + + + + 0 + 0 + + + + Peers: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + + + + + + + + + 0 + 0 + + + + Download Limit: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + + + + + + + + + 0 + 0 + + + + Upload Limit: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + + + + + + + + 0 + 0 + + Wasted: @@ -278,42 +513,8 @@ - + - - 0 kb - - - - - - - Time active: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - - - - - Reannounce in: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - 0 @@ -325,25 +526,118 @@ + + + + + 0 + 0 + + + + Share Ratio: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + + + + + + + + + 0 + 0 + + + + Reannounce In: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + + + + + + + + + 0 + 0 + + + + Last Seen Complete: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + + + + + + + 0 + 0 + + Information - + - + 0 0 - Save path: + Total Size: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -351,45 +645,57 @@ - - - - - - 0 - 0 - - - - path - - - - - - - Qt::Horizontal - - - - 40 - 14 - - - - - - - - + - + 0 0 - Created on: + + + + + + + + + 0 + 0 + + + + Pieces: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + + + + + + + + + 0 + 0 + + + + Added On: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -397,45 +703,57 @@ - - - - - - 0 - 0 - - - - date - - - - - - - Qt::Horizontal - - - - 40 - 14 - - - - - - - - + - + 0 0 - Torrent hash: + + + + + + + + + 0 + 0 + + + + Completed On: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + + + + + + + + + 0 + 0 + + + + Created On: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -443,104 +761,142 @@ - - - - - - 0 - 0 - - - - hash - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - - - - - Qt::Horizontal - - - - 40 - 14 - - - - - - - - + + + + 0 + 0 + + - Piece size: + + + + + + + + + 0 + 0 + + + + Created By: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - 0 - 0 - - - - piece size - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - - - - - Qt::Horizontal - - - - 40 - 14 - - - - - + + + + + 0 + 0 + + + + + + + + + + + + 0 + 0 + + + + Torrent Hash: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + + + + Qt::TextSelectableByMouse + + + + + + 0 + 0 + + + + Save Path: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + + + + Qt::TextSelectableByMouse + + + + + + + 0 + 0 + + Comment: - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + Qt::AlignRight|Qt::AlignTop|Qt::AlignTrailing - - - - - - true - - - true - - - - + + + + + 0 + 0 + + + + true + + + true + + @@ -729,14 +1085,12 @@ - + - Normal + Do not download - - - - High + + Do not download @@ -744,12 +1098,14 @@ Maximum - + - Do not download + High - - Do not download + + + + Normal