Improve Search handling

Legacy SearchEngine class really has three roles:
  1. Manage search plugins,
  2. Handle the search job, and
  3. Handle the download of the torrent file using the search plugin.
Now it is splitted into 3 classes: SearchManager, SearchHandler and
SearchDownloadHandler.
Search GUI is also improved.
This commit is contained in:
Vladimir Golovnev (Glassez)
2018-01-29 17:05:29 +03:00
parent 078982ada6
commit f3d370870d
14 changed files with 872 additions and 662 deletions

View File

@@ -1,6 +1,6 @@
/*
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2015 Vladimir Golovnev <glassez@yandex.ru>
* Copyright (C) 2015, 2018 Vladimir Golovnev <glassez@yandex.ru>
* Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
*
* This program is free software; you can redistribute it and/or
@@ -25,22 +25,19 @@
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/
#ifndef SEARCHWIDGET_H
#define SEARCHWIDGET_H
#pragma once
#include <QList>
#include <QPointer>
#include <QWidget>
class QSignalMapper;
class QTabWidget;
class MainWindow;
class SearchEngine;
struct SearchResult;
class SearchPluginManager;
class SearchTab;
namespace Ui
@@ -48,56 +45,46 @@ namespace Ui
class SearchWidget;
}
class SearchWidget: public QWidget
class SearchWidget : public QWidget
{
Q_OBJECT
Q_DISABLE_COPY(SearchWidget)
public:
explicit SearchWidget(MainWindow *mainWindow);
~SearchWidget();
~SearchWidget() override;
void downloadTorrent(const QString &siteUrl, const QString &url);
void giveFocusToSearchInput();
QTabWidget* searchTabs() const;
private slots:
// Search slots
void tab_changed(int); //to prevent the use of the download button when the tab is empty
void on_searchButton_clicked();
void on_downloadButton_clicked();
void on_goToDescBtn_clicked();
void on_copyURLBtn_clicked();
void on_pluginsButton_clicked();
private:
void tabChanged(int index);
void closeTab(int index);
void appendSearchResults(const QList<SearchResult> &results);
void searchStarted();
void searchFinished(bool cancelled);
void searchFailed();
void resultsCountUpdated();
void tabStatusChanged(QWidget *tab);
void selectMultipleBox(int index);
void addTorrentToSession(const QString &source);
void fillCatCombobox();
void fillPluginComboBox();
void selectActivePage();
void searchTextEdited(QString);
void updateButtons();
private:
QString selectedCategory() const;
QString selectedPlugin() const;
Ui::SearchWidget *m_ui;
SearchEngine *m_searchEngine;
SearchPluginManager *m_searchManager;
QSignalMapper *m_tabStatusChangedMapper;
QPointer<SearchTab> m_currentSearchTab; // Selected tab
QPointer<SearchTab> m_activeSearchTab; // Tab with running search
QList<QPointer<SearchTab>> m_allTabs; // To store all tabs
QList<SearchTab *> m_allTabs; // To store all tabs
MainWindow *m_mainWindow;
bool m_isNewQueryString;
bool m_noSearchResults;
QByteArray m_searchResultLineTruncated;
};
#endif // SEARCHWIDGET_H