Browse Source

- Sync with stable branch (lot of bug fixing)

adaptive-webui-19844
Christophe Dumez 16 years ago
parent
commit
95ecaec11e
  1. 10
      Changelog
  2. 58
      src/FinishedTorrents.cpp
  3. 4
      src/FinishedTorrents.h
  4. 22
      src/GUI.cpp
  5. 1
      src/GUI.h
  6. 38
      src/bittorrent.cpp
  7. 5
      src/bittorrent.h
  8. 84
      src/downloadingTorrents.cpp
  9. 7
      src/downloadingTorrents.h

10
Changelog

@ -1,6 +1,5 @@ @@ -1,6 +1,5 @@
* Unknown - Christophe Dumez <chris@qbittorrent.org> - v1.2.0
- FEATURE: Torrent queueing system (with priorities)
- FEATURE: DHT is always ON (no longer used as fallback)
- FEATURE: The number of DHT nodes is displayed
- FEATURE: RSS can now be disabled from program preferences
- BUGFIX: Disable ETA calculation when ETA column is hidden
@ -10,6 +9,15 @@ @@ -10,6 +9,15 @@
- COSMETIC: Allow to hide or display top toolbar
- COSMETIC: Log is now in a separate dialog
* Unknown - Christophe Dumez <chris@qbittorrent.org> - v1.1.4
- FEATURE: DHT is no longer used as fallback only
- BUGFIX: Fixed 'start seeding after torrent creation' feature
- BUGFIX: Fixed compilation with boost v1.36
- BUGFIX: Some code optimization
- BUGFIX: Fixed memory leak in Web UI
- BUGFIX: Fixed problems with column sorting
- BUGFIX: Improved code for pausing torrents on startup
* Tue Aug 26 2008 - Christophe Dumez <chris@qbittorrent.org> - v1.1.3
- BUGFIX: Fixed ratio saving for seeding torrents
- I18N: Added czech and traditional chinese translations

58
src/FinishedTorrents.cpp

@ -58,7 +58,7 @@ FinishedTorrents::FinishedTorrents(QObject *parent, bittorrent *BTSession) : par @@ -58,7 +58,7 @@ FinishedTorrents::FinishedTorrents(QObject *parent, bittorrent *BTSession) : par
// Make download list header clickable for sorting
finishedList->header()->setClickable(true);
finishedList->header()->setSortIndicatorShown(true);
connect(finishedList->header(), SIGNAL(sectionPressed(int)), this, SLOT(sortFinishedList(int)));
connect(finishedList->header(), SIGNAL(sectionPressed(int)), this, SLOT(toggleFinishedListSortOrder(int)));
finishedListDelegate = new FinishedListDelegate(finishedList);
finishedList->setItemDelegate(finishedListDelegate);
connect(finishedList, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayFinishedListMenu(const QPoint&)));
@ -139,6 +139,7 @@ void FinishedTorrents::addTorrent(QString hash){ @@ -139,6 +139,7 @@ void FinishedTorrents::addTorrent(QString hash){
// Update the number of finished torrents
++nbFinished;
emit finishedTorrentsNumberChanged(nbFinished);
sortFinishedList();
}
void FinishedTorrents::torrentAdded(QTorrentHandle& h) {
@ -190,10 +191,27 @@ bool FinishedTorrents::loadColWidthFinishedList(){ @@ -190,10 +191,27 @@ bool FinishedTorrents::loadColWidthFinishedList(){
for(unsigned int i=0; i<listSize; ++i){
finishedList->header()->resizeSection(i, width_list.at(i).toInt());
}
loadLastSortedColumn();
qDebug("Finished list columns width loaded");
return true;
}
void FinishedTorrents::loadLastSortedColumn() {
// Loading last sorted column
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
QString sortedCol = settings.value(QString::fromUtf8("FinishedListSortedCol"), QString()).toString();
if(!sortedCol.isEmpty()) {
Qt::SortOrder sortOrder;
if(sortedCol.endsWith(QString::fromUtf8("d")))
sortOrder = Qt::DescendingOrder;
else
sortOrder = Qt::AscendingOrder;
sortedCol = sortedCol.left(sortedCol.size()-1);
int index = sortedCol.toInt();
sortFinishedList(index, sortOrder);
}
}
// Save columns width in a file to remember them
// (finished list)
void FinishedTorrents::saveColWidthFinishedList() const{
@ -262,9 +280,6 @@ void FinishedTorrents::updateFinishedList(){ @@ -262,9 +280,6 @@ void FinishedTorrents::updateFinishedList(){
}
}
if(h.is_paused()) continue;
if(BTSession->getTorrentsToPauseAfterChecking().indexOf(hash) != -1) {
continue;
}
if(h.state() == torrent_status::downloading || (h.state() != torrent_status::checking_files && h.state() != torrent_status::queued_for_checking && h.is_seed())) {
// What are you doing here? go back to download tab!
int reponse = QMessageBox::question(this, tr("Incomplete torrent in seeding list"), tr("It appears that the state of '%1' torrent changed from 'seeding' to 'downloading'. Would you like to move it back to download list? (otherwise the torrent will simply be deleted)").arg(h.name()), QMessageBox::Yes | QMessageBox::No);
@ -577,20 +592,39 @@ QAction* FinishedTorrents::getActionHoSCol(int index) { @@ -577,20 +592,39 @@ QAction* FinishedTorrents::getActionHoSCol(int index) {
* Sorting functions
*/
void FinishedTorrents::sortFinishedList(int index){
static Qt::SortOrder sortOrder = Qt::AscendingOrder;
void FinishedTorrents::toggleFinishedListSortOrder(int index) {
Qt::SortOrder sortOrder = Qt::AscendingOrder;
if(finishedList->header()->sortIndicatorSection() == index){
if(sortOrder == Qt::AscendingOrder){
sortOrder = Qt::DescendingOrder;
}else{
sortOrder = Qt::AscendingOrder;
sortOrder = (Qt::SortOrder)!(bool)finishedList->header()->sortIndicatorSection();
}
switch(index) {
case F_SIZE:
case F_UPSPEED:
case F_PRIORITY:
sortFinishedListFloat(index, sortOrder);
break;
default:
sortFinishedListString(index, sortOrder);
}
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
QString sortOrderLetter;
if(sortOrder == Qt::AscendingOrder)
sortOrderLetter = QString::fromUtf8("a");
else
sortOrderLetter = QString::fromUtf8("d");
settings.setValue(QString::fromUtf8("FinishedListSortedCol"), misc::toQString(index)+sortOrderLetter);
}
void FinishedTorrents::sortFinishedList(int index, Qt::SortOrder sortOrder){
if(index == -1) {
index = finishedList->header()->sortIndicatorSection();
sortOrder = finishedList->header()->sortIndicatorOrder();
} else {
finishedList->header()->setSortIndicator(index, sortOrder);
switch(index){
}
switch(index) {
case F_SIZE:
case F_UPSPEED:
case F_PRIORITY:
sortFinishedListFloat(index, sortOrder);
break;
default:

4
src/FinishedTorrents.h

@ -60,7 +60,9 @@ class FinishedTorrents : public QWidget, public Ui::seeding { @@ -60,7 +60,9 @@ class FinishedTorrents : public QWidget, public Ui::seeding {
void displayFinishedHoSMenu(const QPoint&);
void setRowColor(int row, QString color);
void saveColWidthFinishedList() const;
void sortFinishedList(int index);
void loadLastSortedColumn();
void toggleFinishedListSortOrder(int index);
void sortFinishedList(int index=-1, Qt::SortOrder sortOrder=Qt::AscendingOrder);
void sortFinishedListFloat(int index, Qt::SortOrder sortOrder);
void sortFinishedListString(int index, Qt::SortOrder sortOrder);
void updateFileSize(QString hash);

22
src/GUI.cpp

@ -125,7 +125,6 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis @@ -125,7 +125,6 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
BTSession = new bittorrent();
connect(BTSession, SIGNAL(fullDiskError(QTorrentHandle&)), this, SLOT(fullDiskError(QTorrentHandle&)));
connect(BTSession, SIGNAL(finishedTorrent(QTorrentHandle&)), this, SLOT(finishedTorrent(QTorrentHandle&)));
connect(BTSession, SIGNAL(torrentFinishedChecking(QString)), this, SLOT(torrentChecked(QString)));
connect(BTSession, SIGNAL(trackerAuthenticationRequired(QTorrentHandle&)), this, SLOT(trackerAuthenticationRequired(QTorrentHandle&)));
connect(BTSession, SIGNAL(scanDirFoundTorrents(const QStringList&)), this, SLOT(processScannedFiles(const QStringList&)));
connect(BTSession, SIGNAL(newDownloadedTorrent(QString, QString)), this, SLOT(processDownloadedFiles(QString, QString)));
@ -338,27 +337,6 @@ void GUI::writeSettings() { @@ -338,27 +337,6 @@ void GUI::writeSettings() {
settings.endGroup();
}
// Called when a torrent finished checking
void GUI::torrentChecked(QString hash) const {
// Check if the torrent was paused after checking
if(BTSession->isPaused(hash)) {
// Was paused, change its icon/color
if(BTSession->isFinished(hash)) {
// In finished list
qDebug("Automatically paused torrent was in finished list");
finishedTorrentTab->pauseTorrent(hash);
}else{
// In download list
downloadingTorrentTab->pauseTorrent(hash);
}
}
if(!BTSession->isFinished(hash)){
// Delayed Sorting
downloadingTorrentTab->updateFileSizeAndProgress(hash);
downloadingTorrentTab->sortProgressColumnDelayed();
}
}
// called when a torrent has finished
void GUI::finishedTorrent(QTorrentHandle& h) const {
qDebug("In GUI, a torrent has finished");

1
src/GUI.h

@ -163,7 +163,6 @@ class GUI : public QMainWindow, private Ui::MainWindow{ @@ -163,7 +163,6 @@ class GUI : public QMainWindow, private Ui::MainWindow{
void downloadFromURLList(const QStringList& urls);
void deleteTorrent(QString hash);
void finishedTorrent(QTorrentHandle& h) const;
void torrentChecked(QString hash) const;
void updateLists();
bool initWebUi(QString username, QString password, int port);
void pauseTorrent(QString hash);

38
src/bittorrent.cpp

@ -574,8 +574,6 @@ bool bittorrent::isPaused(QString hash) const{ @@ -574,8 +574,6 @@ bool bittorrent::isPaused(QString hash) const{
qDebug("/!\\ Error: Invalid handle");
return true;
}
if(torrentsToPauseAfterChecking.contains(hash))
return true;
return h.is_paused();
}
@ -833,11 +831,6 @@ bool bittorrent::resumeTorrent(QString hash) { @@ -833,11 +831,6 @@ bool bittorrent::resumeTorrent(QString hash) {
// Delete .paused file
if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".paused"))
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".paused");
int index = torrentsToPauseAfterChecking.indexOf(hash);
if(index != -1) {
torrentsToPauseAfterChecking.removeAt(index);
change = true;
}
if(queueingEnabled) {
updateDownloadQueue();
updateUploadQueue();
@ -892,7 +885,7 @@ void bittorrent::loadWebSeeds(QString hash) { @@ -892,7 +885,7 @@ void bittorrent::loadWebSeeds(QString hash) {
}
// Add a torrent to the bittorrent session
void bittorrent::addTorrent(QString path, bool fromScanDir, QString from_url, bool resumed) {
void bittorrent::addTorrent(QString path, bool fromScanDir, QString from_url, bool) {
QTorrentHandle h;
entry resume_data;
bool fastResume=false;
@ -1005,18 +998,15 @@ void bittorrent::addTorrent(QString path, bool fromScanDir, QString from_url, bo @@ -1005,18 +998,15 @@ void bittorrent::addTorrent(QString path, bool fromScanDir, QString from_url, bo
// Copy it to torrentBackup directory
QFile::copy(file, newFile);
}
// Pause torrent if it was paused last time
if((!resumed && addInPause) || QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".paused")) {
torrentsToPauseAfterChecking << hash;
qDebug("Adding a torrent to the torrentsToPauseAfterChecking list");
}
// Incremental download
if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".incremental")) {
qDebug("Incremental download enabled for %s", t->name().c_str());
h.set_sequenced_download_threshold(1);
}
if(!addInPause && !QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".paused")) {
// Start torrent because it was added in paused state
h.resume();
}
if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".finished")) {
finishedTorrents << hash;
if(queueingEnabled) {
@ -1353,6 +1343,14 @@ void bittorrent::loadDownloadUploadForTorrent(QString hash) { @@ -1353,6 +1343,14 @@ void bittorrent::loadDownloadUploadForTorrent(QString hash) {
ratioData[hash] = downUp;
}
float bittorrent::getUncheckedTorrentProgress(QString hash) const {
/*if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".finished"))
return 1.;*/
QTorrentHandle h = getTorrentHandle(hash);
QPair<size_type,size_type> downUpInfo = ratioData.value(hash, QPair<size_type,size_type>(0,0));
return (float)downUpInfo.first / (float)h.actual_size();
}
float bittorrent::getRealRatio(QString hash) const{
QPair<size_type,size_type> downUpInfo = ratioData.value(hash, QPair<size_type,size_type>(0,0));
size_type download = downUpInfo.first;
@ -1813,20 +1811,14 @@ void bittorrent::readAlerts() { @@ -1813,20 +1811,14 @@ void bittorrent::readAlerts() {
if(h.is_valid()){
QString hash = h.hash();
qDebug("%s have just finished checking", hash.toUtf8().data());
int index = torrentsToPauseAfterChecking.indexOf(hash);
if(index != -1) {
torrentsToPauseAfterChecking.removeAt(index);
// Pause torrent
pauseTorrent(hash);
qDebug("%s was paused after checking", hash.toUtf8().data());
} else {
if(!h.is_paused()) {
// Save Addition DateTime
if(calculateETA) {
TorrentsStartTime[hash] = QDateTime::currentDateTime();
TorrentsStartData[hash] = h.total_payload_download();
}
}
emit torrentFinishedChecking(hash);
//emit torrentFinishedChecking(hash);
}
}
a = s->pop_alert();
@ -1837,10 +1829,6 @@ QHash<QString, QString> bittorrent::getTrackersErrors(QString hash) const{ @@ -1837,10 +1829,6 @@ QHash<QString, QString> bittorrent::getTrackersErrors(QString hash) const{
return trackersErrors.value(hash, QHash<QString, QString>());
}
QStringList bittorrent::getTorrentsToPauseAfterChecking() const{
return torrentsToPauseAfterChecking;
}
// Reload a torrent with full allocation mode
void bittorrent::reloadTorrent(const QTorrentHandle &h, bool full_alloc) {
qDebug("** Reloading a torrent");

5
src/bittorrent.h

@ -54,7 +54,6 @@ class bittorrent : public QObject { @@ -54,7 +54,6 @@ class bittorrent : public QObject {
bool DHTEnabled;
downloadThread *downloader;
QString defaultSavePath;
QStringList torrentsToPauseAfterChecking;
QHash<QString, QDateTime> TorrentsStartTime;
QHash<QString, size_type> TorrentsStartData;
QHash<QString, QPair<size_type,size_type> > ratioData;
@ -100,7 +99,6 @@ class bittorrent : public QObject { @@ -100,7 +99,6 @@ class bittorrent : public QObject {
float getPayloadUploadRate() const;
session_status getSessionStatus() const;
int getListenPort() const;
QStringList getTorrentsToPauseAfterChecking() const;
qlonglong getETA(QString hash) const;
float getRealRatio(QString hash) const;
session* getSession() const;
@ -121,6 +119,7 @@ class bittorrent : public QObject { @@ -121,6 +119,7 @@ class bittorrent : public QObject {
int loadTorrentPriority(QString hash);
QStringList getConsoleMessages() const;
QStringList getPeerBanMessages() const;
float getUncheckedTorrentProgress(QString hash) const;
public slots:
void addTorrent(QString path, bool fromScanDir = false, QString from_url = QString(), bool resumed = false);
@ -215,7 +214,7 @@ class bittorrent : public QObject { @@ -215,7 +214,7 @@ class bittorrent : public QObject {
void downloadFromUrlFailure(QString url, QString reason);
//void fastResumeDataRejected(QString name);
//void urlSeedProblem(QString url, QString msg);
void torrentFinishedChecking(QString hash);
//void torrentFinishedChecking(QString hash);
//void torrent_ratio_deleted(QString fileName);
//void UPnPError(QString msg);
//void UPnPSuccess(QString msg);

84
src/downloadingTorrents.cpp

@ -33,7 +33,7 @@ @@ -33,7 +33,7 @@
#include <QTime>
#include <QMenu>
DownloadingTorrents::DownloadingTorrents(QObject *parent, bittorrent *BTSession) : parent(parent), BTSession(BTSession), delayedSorting(false), nbTorrents(0) {
DownloadingTorrents::DownloadingTorrents(QObject *parent, bittorrent *BTSession) : parent(parent), BTSession(BTSession), nbTorrents(0) {
setupUi(this);
// Setting icons
actionStart->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/play.png")));
@ -79,7 +79,7 @@ DownloadingTorrents::DownloadingTorrents(QObject *parent, bittorrent *BTSession) @@ -79,7 +79,7 @@ DownloadingTorrents::DownloadingTorrents(QObject *parent, bittorrent *BTSession)
downloadList->header()->setSortIndicatorShown(true);
// Connecting Actions to slots
connect(downloadList, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(notifyTorrentDoubleClicked(const QModelIndex&)));
connect(downloadList->header(), SIGNAL(sectionPressed(int)), this, SLOT(sortDownloadList(int)));
connect(downloadList->header(), SIGNAL(sectionPressed(int)), this, SLOT(toggleDownloadListSortOrder(int)));
connect(downloadList, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayDLListMenu(const QPoint&)));
downloadList->header()->setContextMenuPolicy(Qt::CustomContextMenu);
connect(downloadList->header(), SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayDLHoSMenu(const QPoint&)));
@ -146,7 +146,7 @@ void DownloadingTorrents::pauseTorrent(QString hash) { @@ -146,7 +146,7 @@ void DownloadingTorrents::pauseTorrent(QString hash) {
DLListModel->setData(DLListModel->index(row, NAME), QIcon(QString::fromUtf8(":/Icons/skin/paused.png")), Qt::DecorationRole);
DLListModel->setData(DLListModel->index(row, SEEDSLEECH), QVariant(QString::fromUtf8("0/0")));
QTorrentHandle h = BTSession->getTorrentHandle(hash);
DLListModel->setData(DLListModel->index(row, PROGRESS), QVariant((double)h.progress()));
//DLListModel->setData(DLListModel->index(row, PROGRESS), QVariant((double)h.progress()));
setRowColor(row, QString::fromUtf8("red"));
}
@ -476,13 +476,6 @@ QStringList DownloadingTorrents::getSelectedTorrents(bool only_one) const{ @@ -476,13 +476,6 @@ QStringList DownloadingTorrents::getSelectedTorrents(bool only_one) const{
return res;
}
void DownloadingTorrents::sortProgressColumnDelayed() {
if(delayedSorting) {
sortDownloadListFloat(PROGRESS, delayedSortingOrder);
qDebug("Delayed sorting of progress column");
}
}
// get information from torrent handles and
// update download list accordingly
void DownloadingTorrents::updateDlList() {
@ -517,12 +510,6 @@ void DownloadingTorrents::updateDlList() { @@ -517,12 +510,6 @@ void DownloadingTorrents::updateDlList() {
}
// No need to update a paused torrent
if(h.is_paused()) continue;
if(BTSession->getTorrentsToPauseAfterChecking().indexOf(hash) != -1) {
if(!downloadList->isColumnHidden(PROGRESS)) {
DLListModel->setData(DLListModel->index(row, PROGRESS), QVariant((double)h.progress()));
}
continue;
}
// Parse download state
// Setting download state
switch(h.state()) {
@ -630,6 +617,7 @@ void DownloadingTorrents::addTorrent(QString hash) { @@ -630,6 +617,7 @@ void DownloadingTorrents::addTorrent(QString hash) {
DLListModel->setData(DLListModel->index(row, HASH), QVariant(hash));
// Pause torrent if it was paused last time
if(BTSession->isPaused(hash)) {
DLListModel->setData(DLListModel->index(row, PROGRESS), QVariant((double)BTSession->getUncheckedTorrentProgress(hash)));
DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(QString::fromUtf8(":/Icons/skin/paused.png"))), Qt::DecorationRole);
setRowColor(row, QString::fromUtf8("red"));
}else{
@ -638,6 +626,7 @@ void DownloadingTorrents::addTorrent(QString hash) { @@ -638,6 +626,7 @@ void DownloadingTorrents::addTorrent(QString hash) {
}
++nbTorrents;
emit unfinishedTorrentsNumberChanged(nbTorrents);
sortDownloadList();
}
void DownloadingTorrents::sortDownloadListFloat(int index, Qt::SortOrder sortOrder) {
@ -686,27 +675,36 @@ void DownloadingTorrents::sortDownloadListString(int index, Qt::SortOrder sortOr @@ -686,27 +675,36 @@ void DownloadingTorrents::sortDownloadListString(int index, Qt::SortOrder sortOr
DLListModel->removeRows(0, nbRows_old);
}
void DownloadingTorrents::sortDownloadList(int index, Qt::SortOrder startSortOrder, bool fromLoadColWidth) {
qDebug("Called sort download list");
static Qt::SortOrder sortOrder = startSortOrder;
if(!fromLoadColWidth && downloadList->header()->sortIndicatorSection() == index) {
if(sortOrder == Qt::AscendingOrder) {
sortOrder = Qt::DescendingOrder;
}else{
sortOrder = Qt::AscendingOrder;
void DownloadingTorrents::toggleDownloadListSortOrder(int index) {
Qt::SortOrder sortOrder = Qt::AscendingOrder;
qDebug("Toggling column sort order");
if(downloadList->header()->sortIndicatorSection() == index) {
sortOrder = (Qt::SortOrder)!(bool)downloadList->header()->sortIndicatorOrder();
}
switch(index) {
case SIZE:
case ETA:
case UPSPEED:
case DLSPEED:
case PROGRESS:
sortDownloadListFloat(index, sortOrder);
break;
default:
sortDownloadListString(index, sortOrder);
}
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
QString sortOrderLetter;
if(sortOrder == Qt::AscendingOrder)
sortOrderLetter = QString::fromUtf8("a");
else
sortOrderLetter = QString::fromUtf8("d");
if(fromLoadColWidth) {
// XXX: Why is this needed?
if(sortOrder == Qt::DescendingOrder)
downloadList->header()->setSortIndicator(index, Qt::AscendingOrder);
else
downloadList->header()->setSortIndicator(index, Qt::DescendingOrder);
settings.setValue(QString::fromUtf8("DownloadListSortedCol"), misc::toQString(index)+sortOrderLetter);
}
void DownloadingTorrents::sortDownloadList(int index, Qt::SortOrder sortOrder) {
if(index == -1) {
index = downloadList->header()->sortIndicatorSection();
sortOrder = downloadList->header()->sortIndicatorOrder();
} else {
downloadList->header()->setSortIndicator(index, sortOrder);
}
@ -716,23 +714,12 @@ void DownloadingTorrents::sortDownloadList(int index, Qt::SortOrder startSortOrd @@ -716,23 +714,12 @@ void DownloadingTorrents::sortDownloadList(int index, Qt::SortOrder startSortOrd
case UPSPEED:
case DLSPEED:
case PRIORITY:
sortDownloadListFloat(index, sortOrder);
break;
case PROGRESS:
if(fromLoadColWidth) {
// Progress sorting must be delayed until files are checked (on startup)
delayedSorting = true;
qDebug("Delayed sorting of the progress column");
delayedSortingOrder = sortOrder;
}else{
sortDownloadListFloat(index, sortOrder);
}
break;
default:
sortDownloadListString(index, sortOrder);
}
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
settings.setValue(QString::fromUtf8("DownloadListSortedCol"), misc::toQString(index)+sortOrderLetter);
}
// Save columns width in a file to remember them
@ -781,7 +768,14 @@ bool DownloadingTorrents::loadColWidthDLList() { @@ -781,7 +768,14 @@ bool DownloadingTorrents::loadColWidthDLList() {
for(unsigned int i=0; i<listSize; ++i) {
downloadList->header()->resizeSection(i, width_list.at(i).toInt());
}
loadLastSortedColumn();
qDebug("Download list columns width loaded");
return true;
}
void DownloadingTorrents::loadLastSortedColumn() {
// Loading last sorted column
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
QString sortedCol = settings.value(QString::fromUtf8("DownloadListSortedCol"), QString()).toString();
if(!sortedCol.isEmpty()) {
Qt::SortOrder sortOrder;
@ -791,10 +785,8 @@ bool DownloadingTorrents::loadColWidthDLList() { @@ -791,10 +785,8 @@ bool DownloadingTorrents::loadColWidthDLList() {
sortOrder = Qt::AscendingOrder;
sortedCol = sortedCol.left(sortedCol.size()-1);
int index = sortedCol.toInt();
sortDownloadList(index, sortOrder, true);
sortDownloadList(index, sortOrder);
}
qDebug("Download list columns width loaded");
return true;
}
// Called when a torrent is added
@ -818,6 +810,7 @@ void DownloadingTorrents::torrentAdded(QTorrentHandle& h) { @@ -818,6 +810,7 @@ void DownloadingTorrents::torrentAdded(QTorrentHandle& h) {
// Pause torrent if it was paused last time
// Not using isPaused function because torrents are paused after checking now
if(QFile::exists(misc::qBittorrentPath()+QString::fromUtf8("BT_backup")+QDir::separator()+hash+QString::fromUtf8(".paused"))) {
DLListModel->setData(DLListModel->index(row, PROGRESS), QVariant((double)BTSession->getUncheckedTorrentProgress(hash)));
DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(QString::fromUtf8(":/Icons/skin/paused.png"))), Qt::DecorationRole);
setRowColor(row, QString::fromUtf8("red"));
}else{
@ -826,6 +819,7 @@ void DownloadingTorrents::torrentAdded(QTorrentHandle& h) { @@ -826,6 +819,7 @@ void DownloadingTorrents::torrentAdded(QTorrentHandle& h) {
}
++nbTorrents;
emit unfinishedTorrentsNumberChanged(nbTorrents);
sortDownloadList();
}
void DownloadingTorrents::updateFileSizeAndProgress(QString hash) {
@ -833,7 +827,7 @@ void DownloadingTorrents::updateFileSizeAndProgress(QString hash) { @@ -833,7 +827,7 @@ void DownloadingTorrents::updateFileSizeAndProgress(QString hash) {
Q_ASSERT(row != -1);
QTorrentHandle h = BTSession->getTorrentHandle(hash);
DLListModel->setData(DLListModel->index(row, SIZE), QVariant((qlonglong)h.actual_size()));
DLListModel->setData(DLListModel->index(row, PROGRESS), QVariant((double)h.progress()));
//DLListModel->setData(DLListModel->index(row, PROGRESS), QVariant((double)h.progress()));
}
// Set the color of a row in data model

7
src/downloadingTorrents.h

@ -38,9 +38,7 @@ class DownloadingTorrents : public QWidget, public Ui::downloading{ @@ -38,9 +38,7 @@ class DownloadingTorrents : public QWidget, public Ui::downloading{
bittorrent *BTSession;
DLListDelegate *DLDelegate;
QStandardItemModel *DLListModel;
bool delayedSorting;
unsigned int nbTorrents;
Qt::SortOrder delayedSortingOrder;
void hideOrShowColumn(int index);
bool loadHiddenColumns();
void saveHiddenColumns();
@ -69,7 +67,8 @@ class DownloadingTorrents : public QWidget, public Ui::downloading{ @@ -69,7 +67,8 @@ class DownloadingTorrents : public QWidget, public Ui::downloading{
void displayDLListMenu(const QPoint& pos);
void displayDLHoSMenu(const QPoint&);
void addTorrent(QString hash);
void sortDownloadList(int index, Qt::SortOrder startSortOrder=Qt::AscendingOrder, bool fromLoadColWidth=false);
void sortDownloadList(int index=-1, Qt::SortOrder startSortOrder=Qt::AscendingOrder);
void toggleDownloadListSortOrder(int index);
void sortDownloadListFloat(int index, Qt::SortOrder sortOrder);
void sortDownloadListString(int index, Qt::SortOrder sortOrder);
void saveColWidthDLList() const;
@ -85,6 +84,7 @@ class DownloadingTorrents : public QWidget, public Ui::downloading{ @@ -85,6 +84,7 @@ class DownloadingTorrents : public QWidget, public Ui::downloading{
void hideOrShowColumnRatio();
void hideOrShowColumnEta();
void hideOrShowColumnPriority();
void loadLastSortedColumn();
public slots:
void updateDlList();
@ -92,7 +92,6 @@ class DownloadingTorrents : public QWidget, public Ui::downloading{ @@ -92,7 +92,6 @@ class DownloadingTorrents : public QWidget, public Ui::downloading{
void resumeTorrent(QString hash);
void deleteTorrent(QString hash);
void propertiesSelection();
void sortProgressColumnDelayed();
void updateFileSizeAndProgress(QString hash);
void showPropertiesFromHash(QString hash);
void hidePriorityColumn(bool hide);

Loading…
Cancel
Save