Browse Source

- The torrent size displayed now takes filtered files into consideration

adaptive-webui-19844
Christophe Dumez 18 years ago
parent
commit
45d51e1d44
  1. 2
      Changelog
  2. 1
      TODO
  3. 20
      src/GUI.cpp
  4. 4
      src/GUI.h
  5. 2
      src/bittorrent.cpp
  6. 1
      src/bittorrent.h
  7. 4
      src/properties_imp.cpp
  8. 1
      src/properties_imp.h

2
Changelog

@ -12,7 +12,7 @@
- FEATURE: Allow to set upload/download limit per torrent (right click) - FEATURE: Allow to set upload/download limit per torrent (right click)
- FEATURE: Ask for exit confirmation only if download list is not empty - FEATURE: Ask for exit confirmation only if download list is not empty
- FEATURE: Better systems integration (buttons, dialogs...) - 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 torrent properties a little
- COSMETIC: Redesigned options a little - COSMETIC: Redesigned options a little
- COSMETIC: Display more logs messages concerning features - COSMETIC: Display more logs messages concerning features

1
TODO

@ -45,6 +45,5 @@
- Use its piece prioritization support (debug) - Use its piece prioritization support (debug)
- Get upload/download limit per torrent (uncomment some code) ALMOST - Get upload/download limit per torrent (uncomment some code) ALMOST
- Improve ratio display / calculation / saving / per torrent... - 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 - Sorting in Download Status column should be smarter than just an alphabetical sort
- Windows port : http://www.peerweb.nl/qbittorrent/experimentalbuild/testing.zip - Windows port : http://www.peerweb.nl/qbittorrent/experimentalbuild/testing.zip

20
src/GUI.cpp

@ -155,6 +155,7 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent){
// Configure BT session according to options // Configure BT session according to options
configureSession(true); configureSession(true);
force_exit = false; force_exit = false;
connect(&BTSession, SIGNAL(updateFileSize(QString)), this, SLOT(updateFileSize(QString)));
// Resume unfinished torrents // Resume unfinished torrents
BTSession.resumeUnfinishedTorrents(); BTSession.resumeUnfinishedTorrents();
// Add torrent given on command line // 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 // Called when a torrent is added
void GUI::torrentAdded(const QString& path, torrent_handle& h, bool fastResume){ void GUI::torrentAdded(const QString& path, torrent_handle& h, bool fastResume){
QString hash = QString(misc::toString(h.info_hash()).c_str()); 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 // Adding torrent to download list
DLListModel->insertRow(row); DLListModel->insertRow(row);
DLListModel->setData(DLListModel->index(row, NAME), QVariant(h.name().c_str())); 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, DLSPEED), QVariant((double)0.));
DLListModel->setData(DLListModel->index(row, UPSPEED), QVariant((double)0.)); DLListModel->setData(DLListModel->index(row, UPSPEED), QVariant((double)0.));
DLListModel->setData(DLListModel->index(row, SEEDSLEECH), QVariant("0/0")); DLListModel->setData(DLListModel->index(row, SEEDSLEECH), QVariant("0/0"));
@ -1070,6 +1083,11 @@ void GUI::showProperties(const QModelIndex &index){
prop->show(); 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 // Set BT session configuration
void GUI::configureSession(bool deleteOptions){ void GUI::configureSession(bool deleteOptions){
qDebug("Configuring session"); qDebug("Configuring session");

4
src/GUI.h

@ -126,6 +126,7 @@ class GUI : public QMainWindow, private Ui::MainWindow{
void on_actionExit_triggered(); void on_actionExit_triggered();
void createTrayIcon(); void createTrayIcon();
// Torrent actions // Torrent actions
size_type torrentEffectiveSize(QString hash) const;
void showProperties(const QModelIndex &index); void showProperties(const QModelIndex &index);
void on_actionTorrent_Properties_triggered(); void on_actionTorrent_Properties_triggered();
void on_actionPause_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 trackerError(const QString& hash, const QString& time, const QString& msg);
void trackerAuthenticationRequired(torrent_handle& h); void trackerAuthenticationRequired(torrent_handle& h);
void setTabText(int index, QString text); void setTabText(int index, QString text);
void updateFileSize(QString hash);
protected: protected:
void closeEvent(QCloseEvent *); void closeEvent(QCloseEvent *);
@ -178,7 +180,7 @@ class GUI : public QMainWindow, private Ui::MainWindow{
GUI(QWidget *parent=0, QStringList torrentCmdLine=QStringList()); GUI(QWidget *parent=0, QStringList torrentCmdLine=QStringList());
~GUI(); ~GUI();
// Methods // Methods
int getRowFromHash(const QString& name) const; int getRowFromHash(const QString& hash) const;
QPoint screenCenter(); QPoint screenCenter();
}; };

2
src/bittorrent.cpp

@ -709,6 +709,7 @@ void bittorrent::readAlerts(){
} }
void bittorrent::reloadTorrent(const torrent_handle &h, bool compact_mode){ void bittorrent::reloadTorrent(const torrent_handle &h, bool compact_mode){
qDebug("** Reloading a torrent");
if(!h.is_valid()){ if(!h.is_valid()){
qDebug("/!\\ Error: Invalid handle"); qDebug("/!\\ Error: Invalid handle");
return; 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()); qDebug("Incremental download enabled for %s", (const char*)fileName.toUtf8());
new_h.set_sequenced_download_threshold(15); new_h.set_sequenced_download_threshold(15);
} }
emit updateFileSize(fileHash);
} }
int bittorrent::getListenPort() const{ int bittorrent::getListenPort() const{

1
src/bittorrent.h

@ -151,6 +151,7 @@ class bittorrent : public QObject{
void scanDirFoundTorrents(const QStringList& pathList); void scanDirFoundTorrents(const QStringList& pathList);
void newDownloadedTorrent(const QString& path, const QString& url); void newDownloadedTorrent(const QString& path, const QString& url);
void aboutToDownloadFromUrl(const QString& url); void aboutToDownloadFromUrl(const QString& url);
void updateFileSize(QString hash);
#ifndef NO_UPNP #ifndef NO_UPNP
void noWanServiceDetected(); void noWanServiceDetected();
void wanServiceDetected(); void wanServiceDetected();

4
src/properties_imp.cpp

@ -343,10 +343,6 @@ void properties::savePiecesPriorities(){
pieces_file.write(QByteArray((misc::toString(priority)+"\n").c_str())); pieces_file.write(QByteArray((misc::toString(priority)+"\n").c_str()));
} }
pieces_file.close(); 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; has_filtered_files = hasFilteredFiles;
} }

1
src/properties_imp.h

@ -57,6 +57,7 @@ class properties : public QDialog, private Ui::properties{
signals: signals:
void changedFilteredFiles(torrent_handle h, bool compact_mode); void changedFilteredFiles(torrent_handle h, bool compact_mode);
void fileSizeChanged(QString fileHash);
public: public:
// Constructor // Constructor

Loading…
Cancel
Save