diff --git a/TODO b/TODO index f1fc4f05e..2d27f0798 100644 --- a/TODO +++ b/TODO @@ -45,4 +45,5 @@ - Use its piece prioritization support (debug) - Improve ratio display / calculation / saving / per torrent... - 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 +- Windows port : http://www.peerweb.nl/qbittorrent/experimentalbuild/testing.zip +- MUST Improve torrent switching between download & finished list (and vice-versa) (USE SIGNALs/SLOTS) \ No newline at end of file diff --git a/src/GUI.cpp b/src/GUI.cpp index 05346c57a..4a8270866 100644 --- a/src/GUI.cpp +++ b/src/GUI.cpp @@ -490,8 +490,9 @@ void GUI::updateDlList(bool force){ if(finishedSHAs.indexOf(fileHash) != -1) continue; int row = getRowFromHash(fileHash); if(row == -1){ - std::cerr << "Error: Could not find filename in download list..\n"; - continue; + qDebug("Could not find filename in download list, adding it..."); + restoreInDownloadList(h); + row = getRowFromHash(fileHash); } // Parse download state torrent_info ti = h.get_torrent_info(); @@ -554,6 +555,31 @@ void GUI::updateDlList(bool force){ // qDebug("Updated Download list"); } +void GUI::restoreInDownloadList(torrent_handle h){ + unsigned int row = DLListModel->rowCount(); + QString hash = QString(misc::toString(h.info_hash()).c_str()); + // 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)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")); + DLListModel->setData(DLListModel->index(row, ETA), QVariant((qlonglong)-1)); + DLListModel->setData(DLListModel->index(row, HASH), QVariant(hash)); + // Pause torrent if it was paused last time + if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".paused")){ + DLListModel->setData(DLListModel->index(row, STATUS), QVariant(tr("Paused"))); + DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(":/Icons/skin/paused.png")), Qt::DecorationRole); + setRowColor(row, "red"); + }else{ + DLListModel->setData(DLListModel->index(row, STATUS), QVariant(tr("Connecting..."))); + DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(":/Icons/skin/connecting.png")), Qt::DecorationRole); + setRowColor(row, "grey"); + } + ++nbTorrents; +} + void GUI::setTabText(int index, QString text){ tabs->setTabText(index, text); } diff --git a/src/GUI.h b/src/GUI.h index 2d6b08982..a0b99adb2 100644 --- a/src/GUI.h +++ b/src/GUI.h @@ -131,6 +131,7 @@ class GUI : public QMainWindow, private Ui::MainWindow{ void on_actionTorrent_Properties_triggered(); void on_actionPause_triggered(); void on_actionPause_All_triggered(); + void restoreInDownloadList(torrent_handle h); void on_actionStart_triggered(); void on_actionStart_All_triggered(); void on_actionOpen_triggered();