mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-23 00:47:21 -06:00
@@ -132,8 +132,9 @@ SearchTab::~SearchTab()
|
||||
void SearchTab::downloadItem(const QModelIndex &index)
|
||||
{
|
||||
QString torrentUrl = m_proxyModel->data(m_proxyModel->index(index.row(), SearchSortModel::DL_LINK)).toString();
|
||||
QString siteUrl = m_proxyModel->data(m_proxyModel->index(index.row(), SearchSortModel::ENGINE_URL)).toString();
|
||||
setRowColor(index.row(), "blue");
|
||||
m_parent->downloadTorrent(torrentUrl);
|
||||
m_parent->downloadTorrent(siteUrl, torrentUrl);
|
||||
}
|
||||
|
||||
QHeaderView* SearchTab::header() const
|
||||
|
||||
@@ -116,6 +116,7 @@ SearchWidget::SearchWidget(MainWindow *mainWindow)
|
||||
connect(m_searchEngine, SIGNAL(newSearchResults(QList<SearchResult>)), SLOT(appendSearchResults(QList<SearchResult>)));
|
||||
connect(m_searchEngine, SIGNAL(searchFinished(bool)), SLOT(searchFinished(bool)));
|
||||
connect(m_searchEngine, SIGNAL(searchFailed()), SLOT(searchFailed()));
|
||||
connect(m_searchEngine, SIGNAL(torrentFileDownloaded(QString)), SLOT(addTorrentToSession(QString)));
|
||||
|
||||
// Fill in category combobox
|
||||
fillCatCombobox();
|
||||
@@ -161,6 +162,14 @@ SearchWidget::~SearchWidget()
|
||||
delete m_searchEngine;
|
||||
}
|
||||
|
||||
void SearchWidget::downloadTorrent(const QString &siteUrl, const QString &url)
|
||||
{
|
||||
if (url.startsWith("bc://bt/", Qt::CaseInsensitive) || url.startsWith("magnet:", Qt::CaseInsensitive))
|
||||
addTorrentToSession(url);
|
||||
else
|
||||
m_searchEngine->downloadTorrent(siteUrl, url);
|
||||
}
|
||||
|
||||
void SearchWidget::tab_changed(int t)
|
||||
{
|
||||
//when we switch from a tab that is not empty to another that is empty the download button
|
||||
@@ -187,6 +196,14 @@ void SearchWidget::selectMultipleBox(const QString &text)
|
||||
on_pluginsButton_clicked();
|
||||
}
|
||||
|
||||
void SearchWidget::addTorrentToSession(const QString &source)
|
||||
{
|
||||
if (AddNewTorrentDialog::isEnabled())
|
||||
AddNewTorrentDialog::show(source, this);
|
||||
else
|
||||
BitTorrent::Session::instance()->addTorrent(source);
|
||||
}
|
||||
|
||||
void SearchWidget::on_pluginsButton_clicked()
|
||||
{
|
||||
PluginSelectDlg *dlg = new PluginSelectDlg(m_searchEngine, this);
|
||||
@@ -281,14 +298,6 @@ void SearchWidget::saveResultsColumnsWidth()
|
||||
Preferences::instance()->setSearchColsWidth(newWidthList.join(" "));
|
||||
}
|
||||
|
||||
void SearchWidget::downloadTorrent(QString url)
|
||||
{
|
||||
if (AddNewTorrentDialog::isEnabled())
|
||||
AddNewTorrentDialog::show(url, this);
|
||||
else
|
||||
BitTorrent::Session::instance()->addTorrent(url);
|
||||
}
|
||||
|
||||
void SearchWidget::searchStarted()
|
||||
{
|
||||
// Update SearchEngine widgets
|
||||
@@ -391,9 +400,8 @@ void SearchWidget::on_downloadButton_clicked()
|
||||
//QModelIndexList selectedIndexes = currentSearchTab->getCurrentTreeView()->selectionModel()->selectedIndexes();
|
||||
QModelIndexList selectedIndexes = m_allTabs.at(tabWidget->currentIndex())->getCurrentTreeView()->selectionModel()->selectedIndexes();
|
||||
foreach (const QModelIndex &index, selectedIndexes) {
|
||||
if (index.column() == SearchSortModel::NAME) {
|
||||
if (index.column() == SearchSortModel::NAME)
|
||||
m_allTabs.at(tabWidget->currentIndex())->downloadItem(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ public:
|
||||
explicit SearchWidget(MainWindow *mainWindow);
|
||||
~SearchWidget();
|
||||
|
||||
void downloadTorrent(QString url);
|
||||
void downloadTorrent(const QString &siteUrl, const QString &url);
|
||||
void giveFocusToSearchInput();
|
||||
|
||||
QTabWidget* searchTabs() const;
|
||||
@@ -73,6 +73,8 @@ private slots:
|
||||
void searchFailed();
|
||||
void selectMultipleBox(const QString &text);
|
||||
|
||||
void addTorrentToSession(const QString &source);
|
||||
|
||||
void saveResultsColumnsWidth();
|
||||
void fillCatCombobox();
|
||||
void fillPluginComboBox();
|
||||
@@ -86,7 +88,7 @@ private:
|
||||
SearchEngine *m_searchEngine;
|
||||
QPointer<SearchTab> m_currentSearchTab; // Selected tab
|
||||
QPointer<SearchTab> m_activeSearchTab; // Tab with running search
|
||||
QList<QPointer<SearchTab> > m_allTabs; // To store all tabs
|
||||
QList<QPointer<SearchTab>> m_allTabs; // To store all tabs
|
||||
MainWindow *m_mainWindow;
|
||||
bool m_isNewQueryString;
|
||||
bool m_noSearchResults;
|
||||
|
||||
Reference in New Issue
Block a user