mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-02-02 01:44:26 +00:00
- COSMETIC: Now displaying the number of downloads in tab title
- BUGFIX: Fixed problems that could happen with delete selection action
This commit is contained in:
parent
a3f9de767b
commit
dd65bb7292
@ -24,6 +24,8 @@
|
|||||||
- BUGFIX: Fixed Memory leaks in search engine
|
- BUGFIX: Fixed Memory leaks in search engine
|
||||||
- BUGFIX: Remove torrent file from scanned directory if it is already in download list
|
- BUGFIX: Remove torrent file from scanned directory if it is already in download list
|
||||||
- BUGFIX: Fixed possible segfault on loading due to columns size loading
|
- BUGFIX: Fixed possible segfault on loading due to columns size loading
|
||||||
|
- BUGFIX: Fixed problems that could happen with delete selection action
|
||||||
|
- COSMETIC: Now displaying the number of downloads in tab title
|
||||||
- COSMETIC: Redesigned download from url dialog
|
- COSMETIC: Redesigned download from url dialog
|
||||||
- COSMETIC: Added a message to warn user that we started download from an url
|
- COSMETIC: Added a message to warn user that we started download from an url
|
||||||
- COSMETIC: Renamed main tab from "Downloads" to "Transfers"
|
- COSMETIC: Renamed main tab from "Downloads" to "Transfers"
|
||||||
|
63
src/GUI.cpp
63
src/GUI.cpp
@ -122,6 +122,8 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent){
|
|||||||
// download thread
|
// download thread
|
||||||
downloader = new downloadThread(this);
|
downloader = new downloadThread(this);
|
||||||
connect(downloader, SIGNAL(downloadFinished(QString, QString, int, QString)), this, SLOT(processDownloadedFile(QString, QString, int, QString)));
|
connect(downloader, SIGNAL(downloadFinished(QString, QString, int, QString)), this, SLOT(processDownloadedFile(QString, QString, int, QString)));
|
||||||
|
nbTorrents = 0;
|
||||||
|
tabs->setTabText(0, tr("Transfers") +" (0)");
|
||||||
//Resume unfinished torrent downloads
|
//Resume unfinished torrent downloads
|
||||||
resumeUnfinished();
|
resumeUnfinished();
|
||||||
// Add torrent given on command line
|
// Add torrent given on command line
|
||||||
@ -1115,6 +1117,8 @@ void GUI::deleteAll(){
|
|||||||
}
|
}
|
||||||
// Clear Download list
|
// Clear Download list
|
||||||
DLListModel->removeRows(0, DLListModel->rowCount());
|
DLListModel->removeRows(0, DLListModel->rowCount());
|
||||||
|
nbTorrents = 0;
|
||||||
|
tabs->setTabText(0, tr("Transfers") +" (0)");
|
||||||
//Update info Bar
|
//Update info Bar
|
||||||
setInfoBar(tr("Download list cleared."));
|
setInfoBar(tr("Download list cleared."));
|
||||||
}
|
}
|
||||||
@ -1138,35 +1142,42 @@ void GUI::deleteSelection(){
|
|||||||
QString(), 0, 1) == 0) {
|
QString(), 0, 1) == 0) {
|
||||||
//User clicked YES
|
//User clicked YES
|
||||||
QModelIndex index;
|
QModelIndex index;
|
||||||
|
QList<QPair<int, QModelIndex> > sortedIndexes;
|
||||||
|
// We have to remove items from the bottom
|
||||||
|
// to the top in order not to change indexes
|
||||||
|
// of files to delete.
|
||||||
foreach(index, selectedIndexes){
|
foreach(index, selectedIndexes){
|
||||||
if(index.column() == NAME){
|
if(index.column() == NAME){
|
||||||
// Get the file name
|
qDebug("row to delete: %d", index.row());
|
||||||
QString fileName = index.data().toString();
|
misc::insertSort2(sortedIndexes, QPair<int, QModelIndex>(index.row(), index), Qt::DescendingOrder);
|
||||||
// Get handle and pause the torrent
|
|
||||||
torrent_handle h = handles.value(fileName);
|
|
||||||
s->remove_torrent(h);
|
|
||||||
// remove it from scan dir or it will start again
|
|
||||||
if(isScanningDir){
|
|
||||||
QFile::remove(scan_dir+fileName+".torrent");
|
|
||||||
}
|
|
||||||
// Remove torrent from handles
|
|
||||||
handles.remove(fileName);
|
|
||||||
// Remove it from torrent backup directory
|
|
||||||
torrentBackup.remove(fileName+".torrent");
|
|
||||||
torrentBackup.remove(fileName+".fastresume");
|
|
||||||
torrentBackup.remove(fileName+".paused");
|
|
||||||
torrentBackup.remove(fileName+".incremental");
|
|
||||||
// Update info bar
|
|
||||||
setInfoBar("'" + fileName +"' "+tr("removed.", "<file> removed."));
|
|
||||||
// Delete item from download list
|
|
||||||
int row = getRowFromName(fileName);
|
|
||||||
if(row == -1){
|
|
||||||
std::cout << "Error: Couldn't find filename in download list...\n";
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
DLListModel->removeRow(row);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
QPair<int, QModelIndex> sortedIndex;
|
||||||
|
foreach(sortedIndex, sortedIndexes){
|
||||||
|
qDebug("deleting row: %d, %d, col: %d", sortedIndex.first, sortedIndex.second.row(), sortedIndex.second.column());
|
||||||
|
// Get the file name
|
||||||
|
QString fileName = sortedIndex.second.data().toString();
|
||||||
|
// Delete item from download list
|
||||||
|
DLListModel->removeRow(sortedIndex.first);
|
||||||
|
// Get handle and pause the torrent
|
||||||
|
torrent_handle h = handles.value(fileName);
|
||||||
|
s->remove_torrent(h);
|
||||||
|
// Remove torrent from handles
|
||||||
|
handles.remove(fileName);
|
||||||
|
// remove it from scan dir or it will start again
|
||||||
|
if(isScanningDir){
|
||||||
|
QFile::remove(scan_dir+fileName+".torrent");
|
||||||
|
}
|
||||||
|
// Remove it from torrent backup directory
|
||||||
|
torrentBackup.remove(fileName+".torrent");
|
||||||
|
torrentBackup.remove(fileName+".fastresume");
|
||||||
|
torrentBackup.remove(fileName+".paused");
|
||||||
|
torrentBackup.remove(fileName+".incremental");
|
||||||
|
// Update info bar
|
||||||
|
setInfoBar("'" + fileName +"' "+tr("removed.", "<file> removed."));
|
||||||
|
--nbTorrents;
|
||||||
|
tabs->setTabText(0, tr("Transfers") +" ("+QString(misc::toString(nbTorrents).c_str())+")");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1328,6 +1339,8 @@ void GUI::addTorrents(const QStringList& pathsList, bool fromScanDir, const QStr
|
|||||||
setInfoBar("'" + file + "' "+tr("resumed. (fast resume)"));
|
setInfoBar("'" + file + "' "+tr("resumed. (fast resume)"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
++nbTorrents;
|
||||||
|
tabs->setTabText(0, tr("Transfers") +" ("+QString(misc::toString(nbTorrents).c_str())+")");
|
||||||
}catch (invalid_encoding& e){ // Raised by bdecode()
|
}catch (invalid_encoding& e){ // Raised by bdecode()
|
||||||
std::cout << "Could not decode file, reason: " << e.what() << '\n';
|
std::cout << "Could not decode file, reason: " << e.what() << '\n';
|
||||||
// Display warning to tell user we can't decode the torrent file
|
// Display warning to tell user we can't decode the torrent file
|
||||||
|
@ -82,6 +82,7 @@ class GUI : public QMainWindow, private Ui::MainWindow{
|
|||||||
QStandardItemModel *SearchListModel;
|
QStandardItemModel *SearchListModel;
|
||||||
SearchListDelegate *SearchDelegate;
|
SearchListDelegate *SearchDelegate;
|
||||||
QStringList supported_preview_extensions;
|
QStringList supported_preview_extensions;
|
||||||
|
unsigned int nbTorrents;
|
||||||
// Preview
|
// Preview
|
||||||
previewSelect *previewSelection;
|
previewSelect *previewSelection;
|
||||||
QProcess *previewProcess;
|
QProcess *previewProcess;
|
||||||
|
14
src/misc.h
14
src/misc.h
@ -135,6 +135,20 @@ class misc : public QObject{
|
|||||||
list.insert(i, value);
|
list.insert(i, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <class T> static void insertSort2(QList<QPair<int, T> > &list, const QPair<int, T>& value, Qt::SortOrder sortOrder){
|
||||||
|
int i = 0;
|
||||||
|
if(sortOrder == Qt::AscendingOrder){
|
||||||
|
while(i < list.size() and value.first > list.at(i).first){
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
while(i < list.size() and value.first < list.at(i).first){
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
list.insert(i, value);
|
||||||
|
}
|
||||||
|
|
||||||
// Can't use template class for QString because >,< use unicode code for sorting
|
// Can't use template class for QString because >,< use unicode code for sorting
|
||||||
// which is not what a human would expect when sorting strings.
|
// which is not what a human would expect when sorting strings.
|
||||||
static void insertSortString(QList<QPair<int, QString> > &list, QPair<int, QString> value, Qt::SortOrder sortOrder){
|
static void insertSortString(QList<QPair<int, QString> > &list, QPair<int, QString> value, Qt::SortOrder sortOrder){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user