Browse Source

- Added some ASSERTS

- Improved session ratio calculation in main window
adaptive-webui-19844
Christophe Dumez 18 years ago
parent
commit
3cb0612cc6
  1. 44
      src/GUI.cpp

44
src/GUI.cpp

@ -588,8 +588,6 @@ void GUI::updateDlList(bool force){
setRowColor(row, "red"); setRowColor(row, "red");
BTSession->pauseTorrent(fileHash); BTSession->pauseTorrent(fileHash);
continue; continue;
}else{
qDebug("%s should be paused but it hasn't finished checking yet", (const char*)DLListModel->index(row, NAME).data().toString().toUtf8());
} }
} }
if(delayedSorting && BTSession->getUncheckedTorrentsList().indexOf(fileHash) != -1){ if(delayedSorting && BTSession->getUncheckedTorrentsList().indexOf(fileHash) != -1){
@ -1478,22 +1476,28 @@ void GUI::on_actionTorrent_Properties_triggered(){
// called when a torrent has finished // called when a torrent has finished
void GUI::finishedTorrent(torrent_handle& h){ void GUI::finishedTorrent(torrent_handle& h){
QSettings settings("qBittorrent", "qBittorrent"); QSettings settings("qBittorrent", "qBittorrent");
bool show_msg = true;
QString fileName = QString(h.name().c_str()); QString fileName = QString(h.name().c_str());
int useOSD = settings.value("Options/OSDEnabled", 1).toInt(); int useOSD = settings.value("Options/OSDEnabled", 1).toInt();
// Add it to finished tab // Add it to finished tab
QString hash = QString(misc::toString(h.info_hash()).c_str()); QString hash = QString(misc::toString(h.info_hash()).c_str());
if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".finished")) return; if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".finished")){
setInfoBar(tr("%1 has finished downloading.", "e.g: xxx.avi has finished downloading.").arg(fileName)); show_msg = false;
qDebug("We received a finished signal for torrent %s, but it already has a .finished file", (const char*)hash.toUtf8());
}
if(show_msg)
setInfoBar(tr("%1 has finished downloading.", "e.g: xxx.avi has finished downloading.").arg(fileName));
finishedTorrentTab->addFinishedSHA(hash); finishedTorrentTab->addFinishedSHA(hash);
QList<QStandardItem *> items = DLListModel->findItems(hash, Qt::MatchExactly, HASH ); QList<QStandardItem *> items = DLListModel->findItems(hash, Qt::MatchExactly, HASH);
if(items.size() != 1){ Q_ASSERT(items.size() <= 1);
qDebug("Problem: Can't delete finished torrent from download list"); if(items.size() != 0){
return; DLListModel->removeRow(DLListModel->indexFromItem(items.at(0)).row());
--nbTorrents;
tabs->setTabText(0, tr("Downloads") +" ("+QString(misc::toString(nbTorrents).c_str())+")");
}else{
qDebug("finished torrent %s is not in download list, nothing to do", (const char*)hash.toUtf8());
} }
DLListModel->removeRow(DLListModel->indexFromItem(items.at(0)).row()); if(show_msg && systrayIntegration && (useOSD == 1 || (useOSD == 2 && (isMinimized() || isHidden())))) {
--nbTorrents;
tabs->setTabText(0, tr("Downloads") +" ("+QString(misc::toString(nbTorrents).c_str())+")");
if(systrayIntegration && (useOSD == 1 || (useOSD == 2 && (isMinimized() || isHidden())))) {
myTrayIcon->showMessage(tr("Download finished"), tr("%1 has finished downloading.", "e.g: xxx.avi has finished downloading.").arg(fileName), QSystemTrayIcon::Information, TIME_TRAY_BALLOON); myTrayIcon->showMessage(tr("Download finished"), tr("%1 has finished downloading.", "e.g: xxx.avi has finished downloading.").arg(fileName), QSystemTrayIcon::Information, TIME_TRAY_BALLOON);
} }
} }
@ -1507,6 +1511,7 @@ void GUI::fullDiskError(torrent_handle& h){
} }
// Download will be paused by libtorrent. Updating GUI information accordingly // Download will be paused by libtorrent. Updating GUI information accordingly
int row = getRowFromHash(QString(misc::toString(h.info_hash()).c_str())); int row = getRowFromHash(QString(misc::toString(h.info_hash()).c_str()));
Q_ASSERT(row != -1);
DLListModel->setData(DLListModel->index(row, DLSPEED), QVariant((double)0.0)); DLListModel->setData(DLListModel->index(row, DLSPEED), QVariant((double)0.0));
DLListModel->setData(DLListModel->index(row, UPSPEED), QVariant((double)0.0)); DLListModel->setData(DLListModel->index(row, UPSPEED), QVariant((double)0.0));
DLListModel->setData(DLListModel->index(row, ETA), QVariant((qlonglong)-1)); DLListModel->setData(DLListModel->index(row, ETA), QVariant((qlonglong)-1));
@ -1536,11 +1541,15 @@ void GUI::checkConnectionStatus(){
session_status sessionStatus = BTSession->getSessionStatus(); session_status sessionStatus = BTSession->getSessionStatus();
// Update ratio info // Update ratio info
float ratio = 1.; float ratio = 1.;
if(sessionStatus.total_payload_download != 0){ if(sessionStatus.total_payload_download == 0){
ratio = (float)sessionStatus.total_payload_upload/(float)sessionStatus.total_payload_download; if(sessionStatus.total_payload_upload == 0)
} ratio = 1.;
if(ratio > 10.){ else
ratio = 10.; ratio = 10.;
}else{
float ratio = (float)sessionStatus.total_payload_upload / (float)sessionStatus.total_payload_download;
if(ratio > 10.)
ratio = 10.;
} }
snprintf(tmp, MAX_CHAR_TMP, "%.1f", ratio); snprintf(tmp, MAX_CHAR_TMP, "%.1f", ratio);
LCD_Ratio->display(tmp); LCD_Ratio->display(tmp);
@ -1568,7 +1577,6 @@ void GUI::checkConnectionStatus(){
connecStatusLblIcon->setToolTip("<b>"+tr("Connection status:")+"</b><br>"+tr("Offline")+"<br><i>"+tr("No peers found...")+"</i>"); connecStatusLblIcon->setToolTip("<b>"+tr("Connection status:")+"</b><br>"+tr("Offline")+"<br><i>"+tr("No peers found...")+"</i>");
} }
} }
// qDebug("Connection status updated");
} }
/***************************************************** /*****************************************************

Loading…
Cancel
Save