mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-13 16:53:08 -07:00
- The torrent size displayed now takes filtered files into consideration
This commit is contained in:
parent
9c83c195e3
commit
45d51e1d44
8 changed files with 28 additions and 9 deletions
20
src/GUI.cpp
20
src/GUI.cpp
|
@ -155,6 +155,7 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent){
|
|||
// Configure BT session according to options
|
||||
configureSession(true);
|
||||
force_exit = false;
|
||||
connect(&BTSession, SIGNAL(updateFileSize(QString)), this, SLOT(updateFileSize(QString)));
|
||||
// Resume unfinished torrents
|
||||
BTSession.resumeUnfinishedTorrents();
|
||||
// Add torrent given on command line
|
||||
|
@ -959,6 +960,18 @@ void GUI::on_actionDelete_triggered(){
|
|||
}
|
||||
}
|
||||
|
||||
size_type GUI::torrentEffectiveSize(QString hash) const{
|
||||
torrent_handle h = BTSession.getTorrentHandle(hash);
|
||||
torrent_info t = h.get_torrent_info();
|
||||
unsigned short nbFiles = t.num_files();
|
||||
size_type effective_size = 0;
|
||||
for(unsigned int i=0; i<nbFiles; ++i){
|
||||
if(h.piece_priority(i) != 0)
|
||||
effective_size += t.file_at(i).size;
|
||||
}
|
||||
return effective_size;
|
||||
}
|
||||
|
||||
// Called when a torrent is added
|
||||
void GUI::torrentAdded(const QString& path, torrent_handle& h, bool fastResume){
|
||||
QString hash = QString(misc::toString(h.info_hash()).c_str());
|
||||
|
@ -970,7 +983,7 @@ void GUI::torrentAdded(const QString& path, torrent_handle& h, bool fastResume){
|
|||
// Adding torrent to download list
|
||||
DLListModel->insertRow(row);
|
||||
DLListModel->setData(DLListModel->index(row, NAME), QVariant(h.name().c_str()));
|
||||
DLListModel->setData(DLListModel->index(row, SIZE), QVariant((qlonglong)h.get_torrent_info().total_size()));
|
||||
DLListModel->setData(DLListModel->index(row, SIZE), QVariant((qlonglong)torrentEffectiveSize(hash)));
|
||||
DLListModel->setData(DLListModel->index(row, DLSPEED), QVariant((double)0.));
|
||||
DLListModel->setData(DLListModel->index(row, UPSPEED), QVariant((double)0.));
|
||||
DLListModel->setData(DLListModel->index(row, SEEDSLEECH), QVariant("0/0"));
|
||||
|
@ -1070,6 +1083,11 @@ void GUI::showProperties(const QModelIndex &index){
|
|||
prop->show();
|
||||
}
|
||||
|
||||
void GUI::updateFileSize(QString hash){
|
||||
int row = getRowFromHash(hash);
|
||||
DLListModel->setData(DLListModel->index(row, SIZE), QVariant((qlonglong)torrentEffectiveSize(hash)));
|
||||
}
|
||||
|
||||
// Set BT session configuration
|
||||
void GUI::configureSession(bool deleteOptions){
|
||||
qDebug("Configuring session");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue