From 8f0c7fbdfe804dec4a286bc4184b0dc479305721 Mon Sep 17 00:00:00 2001 From: alexandrut Date: Fri, 14 Aug 2009 20:48:53 +0000 Subject: [PATCH] clear downloads which are in queue directly from custom menu cancel action (until now they were remaining in queue when for ex all list was selected for a clear and a separate action was needed for them) git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1537 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- retroshare-gui/src/gui/TransfersDialog.cpp | 39 ++++++++++++++-------- retroshare-gui/src/gui/TransfersDialog.h | 1 + 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/retroshare-gui/src/gui/TransfersDialog.cpp b/retroshare-gui/src/gui/TransfersDialog.cpp index f78db247b..fba93fc66 100644 --- a/retroshare-gui/src/gui/TransfersDialog.cpp +++ b/retroshare-gui/src/gui/TransfersDialog.cpp @@ -905,31 +905,39 @@ QString TransfersDialog::getPeerName(const std::string& id) const void TransfersDialog::cancel() { - QString queryWrn2; + QString queryWrn2; queryWrn2.clear(); queryWrn2.append(tr("Are you sure that you want to cancel and delete these files?")); if ((QMessageBox::question(this, tr("RetroShare"),queryWrn2,QMessageBox::Ok|QMessageBox::No, QMessageBox::Ok))== QMessageBox::Ok) { - - for(int i = 0; i <= DLListModel->rowCount(); i++) { if(selection->isRowSelected(i, QModelIndex())) { - std::string id = getID(i, DLListModel).toStdString(); -#ifdef UNUSED - QString qname = getFileName(i, DLListModel); - /* XXX -> Should not have to 'trim' filename ... something wrong here.. - * but otherwise, not exact filename .... BUG - */ - std::string name = (qname.trimmed()).toStdString(); -#endif - rsFiles->FileCancel(id); /* hash */ + QVector pri; + pri << "Low" << "Normal" << "High" << "Auto"; + QString priority = getPriority(i, DLListModel).trimmed(); + std::string id = getID(i, DLListModel).toStdString(); + if (pri.indexOf(priority) >= 0) + { + /* for file that is just in dwl queue */ + rsFiles->clearDownload(id); + } + else + { +#ifdef UNUSED + QString qname = getFileName(i, DLListModel); + /* XXX -> Should not have to 'trim' filename ... something wrong here.. + * but otherwise, not exact filename .... BUG + */ + std::string name = (qname.trimmed()).toStdString(); +#endif + rsFiles->FileCancel(id); /* hash */ + } } } - } else return; @@ -1276,6 +1284,11 @@ QString TransfersDialog::getID(int row, QStandardItemModel *model) return model->data(model->index(row, ID), Qt::DisplayRole).toString(); } +QString TransfersDialog::getPriority(int row, QStandardItemModel *model) +{ + return model->data(model->index(row, PRIORITY), Qt::DisplayRole).toString(); +} + qlonglong TransfersDialog::getFileSize(int row, QStandardItemModel *model) { bool ok = false; diff --git a/retroshare-gui/src/gui/TransfersDialog.h b/retroshare-gui/src/gui/TransfersDialog.h index f39eebfc6..8573816d9 100644 --- a/retroshare-gui/src/gui/TransfersDialog.h +++ b/retroshare-gui/src/gui/TransfersDialog.h @@ -161,6 +161,7 @@ class TransfersDialog : public MainPage QString getFileName(int row, QStandardItemModel *model); QString getStatus(int row, QStandardItemModel *model); QString getID(int row, QStandardItemModel *model); + QString getPriority(int row, QStandardItemModel *model); qlonglong getFileSize(int row, QStandardItemModel *model); qlonglong getTransfered(int row, QStandardItemModel *model); qlonglong getRemainingTime(int row, QStandardItemModel *model);