Skip to content

Commit 50f7c73

Browse files
Merge pull request qbittorrent#5101 from evsh/deduplicate-search-download-code
Remove duplicated code from search tab and widget
2 parents 8cb4e79 + 5063940 commit 50f7c73

3 files changed

Lines changed: 6 additions & 8 deletions

File tree

src/gui/search/searchtab.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ SearchTab::SearchTab(SearchWidget *parent)
9898
m_ui->resultsBrowser->setSortingEnabled(true);
9999

100100
// Connect signals to slots (search part)
101-
connect(m_ui->resultsBrowser, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(downloadSelectedItem(const QModelIndex&)));
101+
connect(m_ui->resultsBrowser, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(downloadItem(const QModelIndex&)));
102102

103103
// Load last columns width for search results list
104104
if (!loadColWidthResultsList())
@@ -129,7 +129,7 @@ SearchTab::~SearchTab()
129129
delete m_ui;
130130
}
131131

132-
void SearchTab::downloadSelectedItem(const QModelIndex &index)
132+
void SearchTab::downloadItem(const QModelIndex &index)
133133
{
134134
QString torrentUrl = m_proxyModel->data(m_proxyModel->index(index.row(), SearchSortModel::DL_LINK)).toString();
135135
setRowColor(index.row(), "blue");

src/gui/search/searchtab.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,10 @@ class SearchTab: public QWidget
9292

9393
void updateResultsCount();
9494

95+
public slots:
96+
void downloadItem(const QModelIndex &index);
97+
9598
private slots:
96-
void downloadSelectedItem(const QModelIndex &index);
9799
void updateFilter();
98100

99101
private:

src/gui/search/searchwidget.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -392,11 +392,7 @@ void SearchWidget::on_downloadButton_clicked()
392392
QModelIndexList selectedIndexes = m_allTabs.at(tabWidget->currentIndex())->getCurrentTreeView()->selectionModel()->selectedIndexes();
393393
foreach (const QModelIndex &index, selectedIndexes) {
394394
if (index.column() == SearchSortModel::NAME) {
395-
// Get Item url
396-
QSortFilterProxyModel *model = m_allTabs.at(tabWidget->currentIndex())->getCurrentSearchListProxy();
397-
QString torrentUrl = model->data(model->index(index.row(), URL_COLUMN)).toString();
398-
downloadTorrent(torrentUrl);
399-
m_allTabs.at(tabWidget->currentIndex())->setRowColor(index.row(), "blue");
395+
m_allTabs.at(tabWidget->currentIndex())->downloadItem(index);
400396
}
401397
}
402398
}

0 commit comments

Comments
 (0)