- Improved a lot switching between tabs

This commit is contained in:
Christophe Dumez 2007-04-15 18:15:22 +00:00
parent 79253c76f1
commit 6802e22f7e
4 changed files with 23 additions and 10 deletions

View file

@ -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(){
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);