Use nova2dl.py script instead of DownloadManager

Closes #5026
This commit is contained in:
Vladimir Golovnev (Glassez)
2016-04-06 12:32:44 +03:00
parent b13c991f4b
commit a9e63283cc
8 changed files with 243 additions and 66 deletions

View File

@@ -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

View File

@@ -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);
}
}
}

View File

@@ -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;