1
0
mirror of https://github.com/d47081/qBittorrent.git synced 2025-01-28 23:44:32 +00:00

Merge pull request #5101 from evsh/deduplicate-search-download-code

Remove duplicated code from search tab and widget
This commit is contained in:
sledgehammer999 2016-04-12 15:31:25 -05:00
commit 50f7c734cb
3 changed files with 6 additions and 8 deletions

View File

@ -98,7 +98,7 @@ SearchTab::SearchTab(SearchWidget *parent)
m_ui->resultsBrowser->setSortingEnabled(true);
// Connect signals to slots (search part)
connect(m_ui->resultsBrowser, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(downloadSelectedItem(const QModelIndex&)));
connect(m_ui->resultsBrowser, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(downloadItem(const QModelIndex&)));
// Load last columns width for search results list
if (!loadColWidthResultsList())
@ -129,7 +129,7 @@ SearchTab::~SearchTab()
delete m_ui;
}
void SearchTab::downloadSelectedItem(const QModelIndex &index)
void SearchTab::downloadItem(const QModelIndex &index)
{
QString torrentUrl = m_proxyModel->data(m_proxyModel->index(index.row(), SearchSortModel::DL_LINK)).toString();
setRowColor(index.row(), "blue");

View File

@ -92,8 +92,10 @@ public:
void updateResultsCount();
public slots:
void downloadItem(const QModelIndex &index);
private slots:
void downloadSelectedItem(const QModelIndex &index);
void updateFilter();
private:

View File

@ -392,11 +392,7 @@ void SearchWidget::on_downloadButton_clicked()
QModelIndexList selectedIndexes = m_allTabs.at(tabWidget->currentIndex())->getCurrentTreeView()->selectionModel()->selectedIndexes();
foreach (const QModelIndex &index, selectedIndexes) {
if (index.column() == SearchSortModel::NAME) {
// Get Item url
QSortFilterProxyModel *model = m_allTabs.at(tabWidget->currentIndex())->getCurrentSearchListProxy();
QString torrentUrl = model->data(model->index(index.row(), URL_COLUMN)).toString();
downloadTorrent(torrentUrl);
m_allTabs.at(tabWidget->currentIndex())->setRowColor(index.row(), "blue");
m_allTabs.at(tabWidget->currentIndex())->downloadItem(index);
}
}
}