From 45d51e1d44f2116703d2697ec68d6386ee771861 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Thu, 12 Apr 2007 21:28:15 +0000 Subject: [PATCH] - The torrent size displayed now takes filtered files into consideration --- Changelog | 2 +- TODO | 1 - src/GUI.cpp | 20 +++++++++++++++++++- src/GUI.h | 4 +++- src/bittorrent.cpp | 2 ++ src/bittorrent.h | 1 + src/properties_imp.cpp | 6 +----- src/properties_imp.h | 1 + 8 files changed, 28 insertions(+), 9 deletions(-) diff --git a/Changelog b/Changelog index 243064083..fc4814d8e 100644 --- a/Changelog +++ b/Changelog @@ -12,7 +12,7 @@ - FEATURE: Allow to set upload/download limit per torrent (right click) - FEATURE: Ask for exit confirmation only if download list is not empty - FEATURE: Better systems integration (buttons, dialogs...) - - BUGFIX: Window can now stay maximized on exit + - BUGFIX: The torrent size displayed now takes filtered files into consideration - COSMETIC: Redesigned torrent properties a little - COSMETIC: Redesigned options a little - COSMETIC: Display more logs messages concerning features diff --git a/TODO b/TODO index 56d071233..6b06e9922 100644 --- a/TODO +++ b/TODO @@ -45,6 +45,5 @@ - Use its piece prioritization support (debug) - Get upload/download limit per torrent (uncomment some code) ALMOST - Improve ratio display / calculation / saving / per torrent... -- Display the sum of the size of the selected files in the torrent instead of the whole torrent size in download list - Sorting in Download Status column should be smarter than just an alphabetical sort - Windows port : http://www.peerweb.nl/qbittorrent/experimentalbuild/testing.zip \ No newline at end of file diff --git a/src/GUI.cpp b/src/GUI.cpp index e7a67f865..ea0e2a7b4 100644 --- a/src/GUI.cpp +++ b/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; iinsertRow(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"); diff --git a/src/GUI.h b/src/GUI.h index 0365626d6..2d6b08982 100644 --- a/src/GUI.h +++ b/src/GUI.h @@ -126,6 +126,7 @@ class GUI : public QMainWindow, private Ui::MainWindow{ void on_actionExit_triggered(); void createTrayIcon(); // Torrent actions + size_type torrentEffectiveSize(QString hash) const; void showProperties(const QModelIndex &index); void on_actionTorrent_Properties_triggered(); void on_actionPause_triggered(); @@ -168,6 +169,7 @@ class GUI : public QMainWindow, private Ui::MainWindow{ void trackerError(const QString& hash, const QString& time, const QString& msg); void trackerAuthenticationRequired(torrent_handle& h); void setTabText(int index, QString text); + void updateFileSize(QString hash); protected: void closeEvent(QCloseEvent *); @@ -178,7 +180,7 @@ class GUI : public QMainWindow, private Ui::MainWindow{ GUI(QWidget *parent=0, QStringList torrentCmdLine=QStringList()); ~GUI(); // Methods - int getRowFromHash(const QString& name) const; + int getRowFromHash(const QString& hash) const; QPoint screenCenter(); }; diff --git a/src/bittorrent.cpp b/src/bittorrent.cpp index 723c917fc..97bda17ba 100644 --- a/src/bittorrent.cpp +++ b/src/bittorrent.cpp @@ -709,6 +709,7 @@ void bittorrent::readAlerts(){ } void bittorrent::reloadTorrent(const torrent_handle &h, bool compact_mode){ + qDebug("** Reloading a torrent"); if(!h.is_valid()){ qDebug("/!\\ Error: Invalid handle"); return; @@ -767,6 +768,7 @@ void bittorrent::reloadTorrent(const torrent_handle &h, bool compact_mode){ qDebug("Incremental download enabled for %s", (const char*)fileName.toUtf8()); new_h.set_sequenced_download_threshold(15); } + emit updateFileSize(fileHash); } int bittorrent::getListenPort() const{ diff --git a/src/bittorrent.h b/src/bittorrent.h index 1f4407565..89706ab97 100644 --- a/src/bittorrent.h +++ b/src/bittorrent.h @@ -151,6 +151,7 @@ class bittorrent : public QObject{ void scanDirFoundTorrents(const QStringList& pathList); void newDownloadedTorrent(const QString& path, const QString& url); void aboutToDownloadFromUrl(const QString& url); + void updateFileSize(QString hash); #ifndef NO_UPNP void noWanServiceDetected(); void wanServiceDetected(); diff --git a/src/properties_imp.cpp b/src/properties_imp.cpp index dd34c3928..a4a5bb64e 100644 --- a/src/properties_imp.cpp +++ b/src/properties_imp.cpp @@ -343,10 +343,6 @@ void properties::savePiecesPriorities(){ pieces_file.write(QByteArray((misc::toString(priority)+"\n").c_str())); } pieces_file.close(); - if(!has_filtered_files){ - // Don't need to reload torrent - // if already in full allocation mode - emit changedFilteredFiles(h, !hasFilteredFiles); - } + emit changedFilteredFiles(h, !hasFilteredFiles); has_filtered_files = hasFilteredFiles; } diff --git a/src/properties_imp.h b/src/properties_imp.h index 1557f1907..b4f1811d5 100644 --- a/src/properties_imp.h +++ b/src/properties_imp.h @@ -57,6 +57,7 @@ class properties : public QDialog, private Ui::properties{ signals: void changedFilteredFiles(torrent_handle h, bool compact_mode); + void fileSizeChanged(QString fileHash); public: // Constructor