mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-23 04:54:18 +00:00
A better fix for progress column sorting on restart (still untested, gtsoul please check)
This commit is contained in:
parent
ee4a4c81bf
commit
55538934e0
@ -75,6 +75,9 @@ FinishedTorrents::~FinishedTorrents(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void FinishedTorrents::addFinishedSHA(QString hash){
|
void FinishedTorrents::addFinishedSHA(QString hash){
|
||||||
|
if(BTSession->getUncheckedTorrentsList().indexOf(hash) != -1){
|
||||||
|
BTSession->setTorrentFinishedChecking(hash);
|
||||||
|
}
|
||||||
if(finishedSHAs.indexOf(hash) == -1) {
|
if(finishedSHAs.indexOf(hash) == -1) {
|
||||||
finishedSHAs << hash;
|
finishedSHAs << hash;
|
||||||
int row = finishedListModel->rowCount();
|
int row = finishedListModel->rowCount();
|
||||||
|
18
src/GUI.cpp
18
src/GUI.cpp
@ -140,6 +140,7 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent){
|
|||||||
connect(&BTSession, SIGNAL(fullDiskError(torrent_handle&)), this, SLOT(fullDiskError(torrent_handle&)));
|
connect(&BTSession, SIGNAL(fullDiskError(torrent_handle&)), this, SLOT(fullDiskError(torrent_handle&)));
|
||||||
connect(&BTSession, SIGNAL(portListeningFailure()), this, SLOT(portListeningFailure()));
|
connect(&BTSession, SIGNAL(portListeningFailure()), this, SLOT(portListeningFailure()));
|
||||||
connect(&BTSession, SIGNAL(trackerError(const QString&, const QString&, const QString&)), this, SLOT(trackerError(const QString&, const QString&, const QString&)));
|
connect(&BTSession, SIGNAL(trackerError(const QString&, const QString&, const QString&)), this, SLOT(trackerError(const QString&, const QString&, const QString&)));
|
||||||
|
connect(&BTSession,SIGNAL(allTorrentsFinishedChecking()), this, SLOT(sortProgressColumnDelayed()));
|
||||||
connect(&BTSession, SIGNAL(trackerAuthenticationRequired(torrent_handle&)), this, SLOT(trackerAuthenticationRequired(torrent_handle&)));
|
connect(&BTSession, SIGNAL(trackerAuthenticationRequired(torrent_handle&)), this, SLOT(trackerAuthenticationRequired(torrent_handle&)));
|
||||||
connect(&BTSession, SIGNAL(scanDirFoundTorrents(const QStringList&)), this, SLOT(processScannedFiles(const QStringList&)));
|
connect(&BTSession, SIGNAL(scanDirFoundTorrents(const QStringList&)), this, SLOT(processScannedFiles(const QStringList&)));
|
||||||
connect(&BTSession, SIGNAL(newDownloadedTorrent(const QString&, const QString&)), this, SLOT(processDownloadedFiles(const QString&, const QString&)));
|
connect(&BTSession, SIGNAL(newDownloadedTorrent(const QString&, const QString&)), this, SLOT(processDownloadedFiles(const QString&, const QString&)));
|
||||||
@ -448,6 +449,14 @@ void GUI::displayInfoBarMenu(const QPoint& pos){
|
|||||||
myLogMenu.exec(mapToGlobal(pos)+QPoint(22,383));
|
myLogMenu.exec(mapToGlobal(pos)+QPoint(22,383));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GUI::sortProgressColumnDelayed() {
|
||||||
|
if(delayedSorting){
|
||||||
|
sortDownloadListFloat(PROGRESS, delayedSortingOrder);
|
||||||
|
qDebug("Delayed sorting of progress column");
|
||||||
|
delayedSorting = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// get information from torrent handles and
|
// get information from torrent handles and
|
||||||
// update download list accordingly
|
// update download list accordingly
|
||||||
void GUI::updateDlList(bool force){
|
void GUI::updateDlList(bool force){
|
||||||
@ -480,6 +489,11 @@ void GUI::updateDlList(bool force){
|
|||||||
torrent_status torrentStatus = h.status();
|
torrent_status torrentStatus = h.status();
|
||||||
QString fileHash = QString(misc::toString(h.info_hash()).c_str());
|
QString fileHash = QString(misc::toString(h.info_hash()).c_str());
|
||||||
int row = getRowFromHash(fileHash);
|
int row = getRowFromHash(fileHash);
|
||||||
|
if(delayedSorting && BTSession.getUncheckedTorrentsList().indexOf(fileHash) != -1){
|
||||||
|
if(torrentStatus.state != torrent_status::checking_files && torrentStatus.state != torrent_status::queued_for_checking){
|
||||||
|
BTSession.setTorrentFinishedChecking(fileHash);
|
||||||
|
}
|
||||||
|
}
|
||||||
if(BTSession.getTorrentsToPauseAfterChecking().indexOf(fileHash) != -1){
|
if(BTSession.getTorrentsToPauseAfterChecking().indexOf(fileHash) != -1){
|
||||||
// Pause torrent if it finished checking and it is was supposed to be paused.
|
// Pause torrent if it finished checking and it is was supposed to be paused.
|
||||||
// This is a trick to see the progress of the pause torrents on startup
|
// This is a trick to see the progress of the pause torrents on startup
|
||||||
@ -487,8 +501,6 @@ void GUI::updateDlList(bool force){
|
|||||||
qDebug("Paused torrent finished checking with state: %d", torrentStatus.state);
|
qDebug("Paused torrent finished checking with state: %d", torrentStatus.state);
|
||||||
DLListModel->setData(DLListModel->index(row, PROGRESS), QVariant((double)torrentStatus.progress));
|
DLListModel->setData(DLListModel->index(row, PROGRESS), QVariant((double)torrentStatus.progress));
|
||||||
BTSession.pauseTorrent(fileHash);
|
BTSession.pauseTorrent(fileHash);
|
||||||
if(delayedSorting)
|
|
||||||
sortDownloadListFloat(PROGRESS, delayedSortingOrder);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1133,7 +1145,7 @@ void GUI::processDownloadedFiles(const QString& path, const QString& url){
|
|||||||
connect(dialog, SIGNAL(setInfoBarGUI(const QString&, const QString&)), this, SLOT(setInfoBar(const QString&, const QString&)));
|
connect(dialog, SIGNAL(setInfoBarGUI(const QString&, const QString&)), this, SLOT(setInfoBar(const QString&, const QString&)));
|
||||||
dialog->showLoad(path, false, url);
|
dialog->showLoad(path, false, url);
|
||||||
}else{
|
}else{
|
||||||
BTSession.addTorrent(path, false, url);
|
BTSession.addTorrent(path, false, false, url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,6 +170,7 @@ class GUI : public QMainWindow, private Ui::MainWindow{
|
|||||||
void trackerAuthenticationRequired(torrent_handle& h);
|
void trackerAuthenticationRequired(torrent_handle& h);
|
||||||
void setTabText(int index, QString text);
|
void setTabText(int index, QString text);
|
||||||
void updateFileSize(QString hash);
|
void updateFileSize(QString hash);
|
||||||
|
void sortProgressColumnDelayed();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void closeEvent(QCloseEvent *);
|
void closeEvent(QCloseEvent *);
|
||||||
|
@ -144,7 +144,7 @@ void bittorrent::resumeTorrent(const QString& hash){
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add a torrent to the bittorrent session
|
// Add a torrent to the bittorrent session
|
||||||
void bittorrent::addTorrent(const QString& path, bool fromScanDir, const QString& from_url){
|
void bittorrent::addTorrent(const QString& path, bool fromScanDir, bool onStartup, const QString& from_url){
|
||||||
torrent_handle h;
|
torrent_handle h;
|
||||||
entry resume_data;
|
entry resume_data;
|
||||||
bool fastResume=false;
|
bool fastResume=false;
|
||||||
@ -173,6 +173,10 @@ void bittorrent::addTorrent(const QString& path, bool fromScanDir, const QString
|
|||||||
// Getting torrent file informations
|
// Getting torrent file informations
|
||||||
torrent_info t(e);
|
torrent_info t(e);
|
||||||
QString hash = QString(misc::toString(t.info_hash()).c_str());
|
QString hash = QString(misc::toString(t.info_hash()).c_str());
|
||||||
|
if(onStartup){
|
||||||
|
qDebug("Added a hash to the unchecked torrents list");
|
||||||
|
torrentsUnchecked << hash;
|
||||||
|
}
|
||||||
if(s->find_torrent(t.info_hash()).is_valid()){
|
if(s->find_torrent(t.info_hash()).is_valid()){
|
||||||
// Update info Bar
|
// Update info Bar
|
||||||
if(!fromScanDir){
|
if(!fromScanDir){
|
||||||
@ -831,6 +835,22 @@ QList<torrent_handle> bittorrent::getFinishedTorrentHandles() const{
|
|||||||
return finished;
|
return finished;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QStringList bittorrent::getUncheckedTorrentsList() const{
|
||||||
|
return torrentsUnchecked;
|
||||||
|
}
|
||||||
|
|
||||||
|
void bittorrent::setTorrentFinishedChecking(QString hash){
|
||||||
|
int index = torrentsUnchecked.indexOf(hash);
|
||||||
|
if(index != -1){
|
||||||
|
qDebug("torrent %s finished checking", (const char*)hash.toUtf8());
|
||||||
|
torrentsUnchecked.removeAt(index);
|
||||||
|
qDebug("Still %d unchecked torrents", torrentsUnchecked.size());
|
||||||
|
if(torrentsUnchecked.size() == 0){
|
||||||
|
emit allTorrentsFinishedChecking();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Save DHT entry to hard drive
|
// Save DHT entry to hard drive
|
||||||
void bittorrent::saveDHTEntry(){
|
void bittorrent::saveDHTEntry(){
|
||||||
// Save DHT entry
|
// Save DHT entry
|
||||||
@ -867,7 +887,7 @@ void bittorrent::resumeUnfinished(){
|
|||||||
}
|
}
|
||||||
// Resume downloads
|
// Resume downloads
|
||||||
foreach(fileName, filePaths){
|
foreach(fileName, filePaths){
|
||||||
addTorrent(fileName);
|
addTorrent(fileName, false, true);
|
||||||
}
|
}
|
||||||
qDebug("Unfinished torrents resumed");
|
qDebug("Unfinished torrents resumed");
|
||||||
}
|
}
|
||||||
|
@ -58,6 +58,7 @@ class bittorrent : public QObject{
|
|||||||
QStringList supported_preview_extensions;
|
QStringList supported_preview_extensions;
|
||||||
QString defaultSavePath;
|
QString defaultSavePath;
|
||||||
QStringList torrentsToPauseAfterChecking;
|
QStringList torrentsToPauseAfterChecking;
|
||||||
|
QStringList torrentsUnchecked;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QString getSavePath(const QString& hash);
|
QString getSavePath(const QString& hash);
|
||||||
@ -78,9 +79,10 @@ class bittorrent : public QObject{
|
|||||||
session_status getSessionStatus() const;
|
session_status getSessionStatus() const;
|
||||||
int getListenPort() const;
|
int getListenPort() const;
|
||||||
QStringList getTorrentsToPauseAfterChecking() const;
|
QStringList getTorrentsToPauseAfterChecking() const;
|
||||||
|
QStringList getUncheckedTorrentsList() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void addTorrent(const QString& path, bool fromScanDir = false, const QString& from_url = QString());
|
void addTorrent(const QString& path, bool fromScanDir = false, bool onStartup = false, const QString& from_url = QString());
|
||||||
void downloadFromUrl(const QString& url);
|
void downloadFromUrl(const QString& url);
|
||||||
void downloadFromURLList(const QStringList& url_list);
|
void downloadFromURLList(const QStringList& url_list);
|
||||||
void deleteTorrent(const QString& hash, bool permanent = false);
|
void deleteTorrent(const QString& hash, bool permanent = false);
|
||||||
@ -98,6 +100,7 @@ class bittorrent : public QObject{
|
|||||||
void enableIPFilter(ip_filter filter);
|
void enableIPFilter(ip_filter filter);
|
||||||
void disableIPFilter();
|
void disableIPFilter();
|
||||||
void reloadTorrent(const torrent_handle &h, bool compact_mode = true);
|
void reloadTorrent(const torrent_handle &h, bool compact_mode = true);
|
||||||
|
void setTorrentFinishedChecking(QString hash);
|
||||||
void resumeUnfinishedTorrents();
|
void resumeUnfinishedTorrents();
|
||||||
// Session configuration - Setters
|
// Session configuration - Setters
|
||||||
void setListeningPortsRange(std::pair<unsigned short, unsigned short> ports);
|
void setListeningPortsRange(std::pair<unsigned short, unsigned short> ports);
|
||||||
@ -135,6 +138,7 @@ class bittorrent : public QObject{
|
|||||||
void newDownloadedTorrent(const QString& path, const QString& url);
|
void newDownloadedTorrent(const QString& path, const QString& url);
|
||||||
void aboutToDownloadFromUrl(const QString& url);
|
void aboutToDownloadFromUrl(const QString& url);
|
||||||
void updateFileSize(QString hash);
|
void updateFileSize(QString hash);
|
||||||
|
void allTorrentsFinishedChecking();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user