mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-10 14:57:52 +00:00
- Implemented Start/Pause in finished list
This commit is contained in:
parent
a615038498
commit
775afd6ac2
@ -52,8 +52,6 @@ class FinishedTorrents : public QWidget, public Ui::seeding{
|
||||
void showProperties(const QModelIndex &index);
|
||||
void propertiesSelection();
|
||||
void displayFinishedListMenu(const QPoint&);
|
||||
|
||||
protected slots:
|
||||
void setRowColor(int row, const QString& color);
|
||||
|
||||
};
|
||||
|
71
src/GUI.cpp
71
src/GUI.cpp
@ -1140,25 +1140,46 @@ void GUI::pauseAll(){
|
||||
|
||||
// pause selected items in the list
|
||||
void GUI::pauseSelection(){
|
||||
QModelIndexList selectedIndexes = downloadList->selectionModel()->selectedIndexes();
|
||||
if(tabs->currentIndex() > 1) return;
|
||||
QModelIndexList selectedIndexes;
|
||||
bool inDownloadList = true;
|
||||
if(tabs->currentIndex() == 0) {
|
||||
selectedIndexes = downloadList->selectionModel()->selectedIndexes();
|
||||
} else {
|
||||
selectedIndexes = finishedTorrentTab->getFinishedList()->selectionModel()->selectedIndexes();
|
||||
inDownloadList = false;
|
||||
}
|
||||
QModelIndex index;
|
||||
foreach(index, selectedIndexes){
|
||||
if(index.column() == NAME){
|
||||
// Get the file name
|
||||
QString fileHash = DLListModel->data(DLListModel->index(index.row(), HASH)).toString();
|
||||
// Get the file hash
|
||||
QString fileHash;
|
||||
if(inDownloadList)
|
||||
fileHash = DLListModel->data(DLListModel->index(index.row(), HASH)).toString();
|
||||
else
|
||||
fileHash = finishedTorrentTab->getFinishedListModel()->data(finishedTorrentTab->getFinishedListModel()->index(index.row(), HASH)).toString();
|
||||
if(!BTSession.isPaused(fileHash)){
|
||||
// Pause the torrent
|
||||
BTSession.pauseTorrent(fileHash);
|
||||
// Update DL status
|
||||
int row = index.row();
|
||||
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, STATUS), QVariant(tr("Paused")));
|
||||
DLListModel->setData(DLListModel->index(row, ETA), QVariant((qlonglong)-1));
|
||||
if(inDownloadList) {
|
||||
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, STATUS), QVariant(tr("Paused")));
|
||||
DLListModel->setData(DLListModel->index(row, ETA), QVariant((qlonglong)-1));
|
||||
DLListModel->setData(DLListModel->index(row, NAME), QIcon(":/Icons/skin/paused.png"), Qt::DecorationRole);
|
||||
DLListModel->setData(DLListModel->index(row, SEEDSLEECH), QVariant("0/0"));
|
||||
setRowColor(row, "red");
|
||||
} else {
|
||||
finishedTorrentTab->getFinishedListModel()->setData(finishedTorrentTab->getFinishedListModel()->index(row, DLSPEED), QVariant((double)0.0));
|
||||
finishedTorrentTab->getFinishedListModel()->setData(finishedTorrentTab->getFinishedListModel()->index(row, UPSPEED), QVariant((double)0.0));
|
||||
finishedTorrentTab->getFinishedListModel()->setData(finishedTorrentTab->getFinishedListModel()->index(row, STATUS), QVariant(tr("Paused")));
|
||||
finishedTorrentTab->getFinishedListModel()->setData(finishedTorrentTab->getFinishedListModel()->index(row, ETA), QVariant((qlonglong)-1));
|
||||
finishedTorrentTab->getFinishedListModel()->setData(finishedTorrentTab->getFinishedListModel()->index(row, NAME), QIcon(":/Icons/skin/paused.png"), Qt::DecorationRole);
|
||||
finishedTorrentTab->getFinishedListModel()->setData(finishedTorrentTab->getFinishedListModel()->index(row, SEEDSLEECH), QVariant("0/0"));
|
||||
}
|
||||
setInfoBar(tr("'%1' paused.", "xxx.avi paused.").arg(QString(BTSession.getTorrentHandle(fileHash).name().c_str())));
|
||||
DLListModel->setData(DLListModel->index(row, NAME), QIcon(":/Icons/skin/paused.png"), Qt::DecorationRole);
|
||||
DLListModel->setData(DLListModel->index(row, SEEDSLEECH), QVariant("0/0"));
|
||||
setRowColor(row, "red");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1184,12 +1205,24 @@ void GUI::resumeAll(){
|
||||
|
||||
// start selected items in the list
|
||||
void GUI::startSelection(){
|
||||
QModelIndexList selectedIndexes = downloadList->selectionModel()->selectedIndexes();
|
||||
if(tabs->currentIndex() > 1) return;
|
||||
QModelIndexList selectedIndexes;
|
||||
bool inDownloadList = true;
|
||||
if(tabs->currentIndex() == 0) {
|
||||
selectedIndexes = downloadList->selectionModel()->selectedIndexes();
|
||||
} else {
|
||||
selectedIndexes = finishedTorrentTab->getFinishedList()->selectionModel()->selectedIndexes();
|
||||
inDownloadList = false;
|
||||
}
|
||||
QModelIndex index;
|
||||
foreach(index, selectedIndexes){
|
||||
if(index.column() == NAME){
|
||||
// Get the file name
|
||||
QString fileHash = DLListModel->data(DLListModel->index(index.row(), HASH)).toString();
|
||||
// Get the file hash
|
||||
QString fileHash;
|
||||
if(inDownloadList)
|
||||
fileHash = DLListModel->data(DLListModel->index(index.row(), HASH)).toString();
|
||||
else
|
||||
fileHash = finishedTorrentTab->getFinishedListModel()->data(finishedTorrentTab->getFinishedListModel()->index(index.row(), HASH)).toString();
|
||||
if(BTSession.isPaused(fileHash)){
|
||||
// Resume the torrent
|
||||
BTSession.resumeTorrent(fileHash);
|
||||
@ -1197,10 +1230,16 @@ void GUI::startSelection(){
|
||||
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileHash+".paused");
|
||||
// Update DL status
|
||||
int row = index.row();
|
||||
DLListModel->setData(DLListModel->index(row, STATUS), QVariant(tr("Connecting...")));
|
||||
if(inDownloadList) {
|
||||
DLListModel->setData(DLListModel->index(row, STATUS), QVariant(tr("Connecting...")));
|
||||
DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(":/Icons/skin/connecting.png")), Qt::DecorationRole);
|
||||
setRowColor(row, "grey");
|
||||
} else {
|
||||
finishedTorrentTab->getFinishedListModel()->setData(finishedTorrentTab->getFinishedListModel()->index(row, STATUS), QVariant(tr("Finished", "i.e: Torrent has finished downloading")));
|
||||
finishedTorrentTab->getFinishedListModel()->setData(finishedTorrentTab->getFinishedListModel()->index(row, NAME), QVariant(QIcon(":/Icons/skin/seeding.png")), Qt::DecorationRole);
|
||||
finishedTorrentTab->setRowColor(row, "orange");
|
||||
}
|
||||
setInfoBar(tr("'%1' resumed.", "e.g: xxx.avi resumed.").arg(QString(BTSession.getTorrentHandle(fileHash).name().c_str())));
|
||||
DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(":/Icons/skin/connecting.png")), Qt::DecorationRole);
|
||||
setRowColor(row, "grey");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user