Browse Source

- Improved a lot switching between tabs

adaptive-webui-19844
Christophe Dumez 18 years ago
parent
commit
6802e22f7e
  1. 3
      TODO
  2. 23
      src/FinishedTorrents.cpp
  3. 4
      src/FinishedTorrents.h
  4. 3
      src/GUI.cpp

3
TODO

@ -45,5 +45,4 @@ @@ -45,5 +45,4 @@
- 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
- MUST Improve torrent switching between download & finished list (and vice-versa) (USE SIGNALs/SLOTS)
- Windows port : http://www.peerweb.nl/qbittorrent/experimentalbuild/testing.zip

23
src/FinishedTorrents.cpp

@ -243,22 +243,21 @@ void FinishedTorrents::updateFinishedList(){ @@ -243,22 +243,21 @@ void FinishedTorrents::updateFinishedList(){
continue;
}
if(h.is_paused()){
h.resume();
continue;
h.resume(); // No paused torrents in finished list
}
torrent_status torrentStatus = h.status();
if(torrentStatus.state == torrent_status::downloading) {
if(torrentStatus.state == torrent_status::downloading || (torrentStatus.state != torrent_status::checking_files && torrentStatus.state != torrent_status::queued_for_checking && torrentStatus.progress != 1.)) {
// What are you doing here, go back to download tab!
qDebug("Info: a torrent was moved from finished to download tab");
deleteFromFinishedList(hash);
emit torrentMovedFromFinishedList(h);
continue;
}
QList<QStandardItem *> items = finishedListModel->findItems(hash, Qt::MatchExactly, HASH );
if(items.size() != 1){
qDebug("Problem: Can't find torrent in finished list");
int row = getRowFromHash(hash);
if(row == -1){
std::cerr << "ERROR: Can't find torrent in finished list\n";
continue;
}
int row = items.at(0)->row();
finishedListModel->setData(finishedListModel->index(row, UPSPEED), QVariant((double)torrentStatus.upload_payload_rate));
finishedListModel->setData(finishedListModel->index(row, SEEDSLEECH), QVariant(QString(misc::toString(torrentStatus.num_seeds, true).c_str())+"/"+QString(misc::toString(torrentStatus.num_peers - torrentStatus.num_seeds, true).c_str())));
}
@ -268,6 +267,16 @@ QStringList FinishedTorrents::getFinishedSHAs(){ @@ -268,6 +267,16 @@ QStringList FinishedTorrents::getFinishedSHAs(){
return finishedSHAs;
}
int FinishedTorrents::getRowFromHash(const QString& hash) const{
unsigned int nbRows = finishedListModel->rowCount();
for(unsigned int i=0; i<nbRows; ++i){
if(finishedListModel->data(finishedListModel->index(i, HASH)) == hash){
return i;
}
}
return -1;
}
// Will move it to download tab
void FinishedTorrents::deleteFromFinishedList(QString hash){
finishedSHAs.removeAll(hash);

4
src/FinishedTorrents.h

@ -45,6 +45,7 @@ class FinishedTorrents : public QWidget, public Ui::seeding{ @@ -45,6 +45,7 @@ class FinishedTorrents : public QWidget, public Ui::seeding{
QTreeView* getFinishedList();
QStandardItemModel* getFinishedListModel();
bool loadColWidthFinishedList();
int getRowFromHash(const QString& hash) const;
public slots:
void addFinishedSHA(QString sha);
@ -62,6 +63,9 @@ class FinishedTorrents : public QWidget, public Ui::seeding{ @@ -62,6 +63,9 @@ class FinishedTorrents : public QWidget, public Ui::seeding{
protected slots:
void on_actionSet_upload_limit_triggered();
signals:
void torrentMovedFromFinishedList(torrent_handle);
};
#endif

3
src/GUI.cpp

@ -69,6 +69,7 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent){ @@ -69,6 +69,7 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent){
finishedTorrentTab = new FinishedTorrents(this, &BTSession);
tabs->addTab(finishedTorrentTab, tr("Finished"));
tabs->setTabIcon(1, QIcon(QString::fromUtf8(":/Icons/skin/seeding.png")));
connect(finishedTorrentTab, SIGNAL(torrentMovedFromFinishedList(torrent_handle)), this, SLOT(restoreInDownloadList(torrent_handle)));
// Search engine tab
searchEngine = new SearchEngine(&BTSession, myTrayIcon, systrayIntegration);
tabs->addTab(searchEngine, tr("Search"));
@ -490,7 +491,7 @@ void GUI::updateDlList(bool force){ @@ -490,7 +491,7 @@ void GUI::updateDlList(bool force){
if(finishedSHAs.indexOf(fileHash) != -1) continue;
int row = getRowFromHash(fileHash);
if(row == -1){
qDebug("Could not find filename in download list, adding it...");
qDebug("Info: Could not find filename in download list, adding it...");
restoreInDownloadList(h);
row = getRowFromHash(fileHash);
}

Loading…
Cancel
Save