Browse Source

Fix search-related file/class names.

adaptive-webui-19844
Vladimir Golovnev (Glassez) 9 years ago
parent
commit
3797cc767f
  1. 4
      src/gui/mainwindow.cpp
  2. 4
      src/gui/mainwindow.h
  3. 62
      src/searchengine/engineselectdlg.cpp
  4. 9
      src/searchengine/engineselectdlg.h
  5. 4
      src/searchengine/engineselectdlg.ui
  6. 14
      src/searchengine/pluginsourcedlg.h
  7. 4
      src/searchengine/pluginsourcedlg.ui
  8. 12
      src/searchengine/searchengine.pri
  9. 2
      src/searchengine/searchlistdelegate.h
  10. 4
      src/searchengine/searchtab.cpp
  11. 21
      src/searchengine/searchtab.h
  12. 52
      src/searchengine/searchwidget.cpp
  13. 18
      src/searchengine/searchwidget.h
  14. 4
      src/searchengine/searchwidget.ui

4
src/gui/mainwindow.cpp

@ -53,7 +53,7 @@ @@ -53,7 +53,7 @@
#include "torrentcreatordlg.h"
#include "downloadfromurldlg.h"
#include "addnewtorrentdialog.h"
#include "searchengine.h"
#include "searchwidget.h"
#include "rss_imp.h"
#include "base/bittorrent/session.h"
#include "base/bittorrent/sessionstatus.h"
@ -526,7 +526,7 @@ void MainWindow::displaySearchTab(bool enable) @@ -526,7 +526,7 @@ void MainWindow::displaySearchTab(bool enable)
if (enable) {
// RSS tab
if (!searchEngine) {
searchEngine = new SearchEngine(this);
searchEngine = new SearchWidget(this);
tabs->insertTab(1, searchEngine, GuiIconProvider::instance()->getIcon("edit-find"), tr("Search"));
}
}

4
src/gui/mainwindow.h

@ -38,7 +38,7 @@ @@ -38,7 +38,7 @@
#include "statsdialog.h"
class downloadFromURL;
class SearchEngine;
class SearchWidget;
class RSSImp;
class about;
class options_imp;
@ -192,7 +192,7 @@ private: @@ -192,7 +192,7 @@ private:
QSplitter *hSplitter;
QSplitter *vSplitter;
// Search
QPointer<SearchEngine> searchEngine;
QPointer<SearchWidget> searchEngine;
// RSS
QPointer<RSSImp> rssWidget;
// Execution Log

62
src/searchengine/engineselectdlg.cpp

@ -34,8 +34,8 @@ @@ -34,8 +34,8 @@
#include "base/utils/fs.h"
#include "base/utils/misc.h"
#include "ico.h"
#include "searchengine.h"
#include "pluginsource.h"
#include "searchwidget.h"
#include "pluginsourcedlg.h"
#include "guiiconprovider.h"
#include "autoexpandabledialog.h"
#include <QProcess>
@ -53,7 +53,7 @@ @@ -53,7 +53,7 @@
enum EngineColumns {ENGINE_NAME, ENGINE_VERSION, ENGINE_URL, ENGINE_STATE, ENGINE_ID};
engineSelectDlg::engineSelectDlg(QWidget *parent, SupportedEngines *supported_engines)
EngineSelectDlg::EngineSelectDlg(QWidget *parent, SupportedEngines *supported_engines)
: QDialog(parent)
, supported_engines(supported_engines)
, m_updateUrl(QString("https://raw.github.com/qbittorrent/qBittorrent/master/src/searchengine/") + (Utils::Misc::pythonVersion() >= 3 ? "nova3" : "nova") + "/engines/")
@ -82,13 +82,13 @@ engineSelectDlg::engineSelectDlg(QWidget *parent, SupportedEngines *supported_en @@ -82,13 +82,13 @@ engineSelectDlg::engineSelectDlg(QWidget *parent, SupportedEngines *supported_en
show();
}
engineSelectDlg::~engineSelectDlg() {
EngineSelectDlg::~EngineSelectDlg() {
qDebug("Destroying engineSelectDlg");
emit enginesChanged();
qDebug("Engine plugins dialog destroyed");
}
void engineSelectDlg::dropEvent(QDropEvent *event) {
void EngineSelectDlg::dropEvent(QDropEvent *event) {
event->acceptProposedAction();
QStringList files;
if (event->mimeData()->hasUrls()) {
@ -123,7 +123,7 @@ void engineSelectDlg::dropEvent(QDropEvent *event) { @@ -123,7 +123,7 @@ void engineSelectDlg::dropEvent(QDropEvent *event) {
}
// Decode if we accept drag 'n drop or not
void engineSelectDlg::dragEnterEvent(QDragEnterEvent *event) {
void EngineSelectDlg::dragEnterEvent(QDragEnterEvent *event) {
QString mime;
foreach (mime, event->mimeData()->formats()) {
qDebug("mimeData: %s", qPrintable(mime));
@ -133,13 +133,13 @@ void engineSelectDlg::dragEnterEvent(QDragEnterEvent *event) { @@ -133,13 +133,13 @@ void engineSelectDlg::dragEnterEvent(QDragEnterEvent *event) {
}
}
void engineSelectDlg::on_updateButton_clicked() {
void EngineSelectDlg::on_updateButton_clicked() {
// Download version file from update server on sourceforge
setCursor(QCursor(Qt::WaitCursor));
downloadFromUrl(m_updateUrl + "versions.txt");
}
void engineSelectDlg::toggleEngineState(QTreeWidgetItem *item, int) {
void EngineSelectDlg::toggleEngineState(QTreeWidgetItem *item, int) {
SupportedEngine *engine = supported_engines->value(item->text(ENGINE_ID));
engine->setEnabled(!engine->isEnabled());
if (engine->isEnabled()) {
@ -151,7 +151,7 @@ void engineSelectDlg::toggleEngineState(QTreeWidgetItem *item, int) { @@ -151,7 +151,7 @@ void engineSelectDlg::toggleEngineState(QTreeWidgetItem *item, int) {
}
}
void engineSelectDlg::displayContextMenu(const QPoint&) {
void EngineSelectDlg::displayContextMenu(const QPoint&) {
QMenu myContextMenu(this);
// Enable/disable pause/start action given the DL state
QList<QTreeWidgetItem *> items = pluginsTree->selectedItems();
@ -164,11 +164,11 @@ void engineSelectDlg::displayContextMenu(const QPoint&) { @@ -164,11 +164,11 @@ void engineSelectDlg::displayContextMenu(const QPoint&) {
myContextMenu.exec(QCursor::pos());
}
void engineSelectDlg::on_closeButton_clicked() {
void EngineSelectDlg::on_closeButton_clicked() {
close();
}
void engineSelectDlg::on_actionUninstall_triggered() {
void EngineSelectDlg::on_actionUninstall_triggered() {
QList<QTreeWidgetItem *> items = pluginsTree->selectedItems();
QTreeWidgetItem *item;
bool error = false;
@ -205,7 +205,7 @@ void engineSelectDlg::on_actionUninstall_triggered() { @@ -205,7 +205,7 @@ void engineSelectDlg::on_actionUninstall_triggered() {
QMessageBox::information(0, tr("Uninstall success"), tr("All selected plugins were uninstalled successfully"));
}
void engineSelectDlg::enableSelection(bool enable) {
void EngineSelectDlg::enableSelection(bool enable) {
QList<QTreeWidgetItem *> items = pluginsTree->selectedItems();
QTreeWidgetItem *item;
foreach (item, items) {
@ -224,14 +224,14 @@ void engineSelectDlg::enableSelection(bool enable) { @@ -224,14 +224,14 @@ void engineSelectDlg::enableSelection(bool enable) {
}
// Set the color of a row in data model
void engineSelectDlg::setRowColor(int row, QString color) {
void EngineSelectDlg::setRowColor(int row, QString color) {
QTreeWidgetItem *item = pluginsTree->topLevelItem(row);
for (int i=0; i<pluginsTree->columnCount(); ++i) {
item->setData(i, Qt::ForegroundRole, QVariant(QColor(color)));
}
}
QList<QTreeWidgetItem*> engineSelectDlg::findItemsWithUrl(QString url) {
QList<QTreeWidgetItem*> EngineSelectDlg::findItemsWithUrl(QString url) {
QList<QTreeWidgetItem*> res;
for (int i=0; i<pluginsTree->topLevelItemCount(); ++i) {
QTreeWidgetItem *item = pluginsTree->topLevelItem(i);
@ -241,7 +241,7 @@ QList<QTreeWidgetItem*> engineSelectDlg::findItemsWithUrl(QString url) { @@ -241,7 +241,7 @@ QList<QTreeWidgetItem*> engineSelectDlg::findItemsWithUrl(QString url) {
return res;
}
QTreeWidgetItem* engineSelectDlg::findItemWithID(QString id) {
QTreeWidgetItem* EngineSelectDlg::findItemWithID(QString id) {
QList<QTreeWidgetItem*> res;
for (int i=0; i<pluginsTree->topLevelItemCount(); ++i) {
QTreeWidgetItem *item = pluginsTree->topLevelItem(i);
@ -251,15 +251,15 @@ QTreeWidgetItem* engineSelectDlg::findItemWithID(QString id) { @@ -251,15 +251,15 @@ QTreeWidgetItem* engineSelectDlg::findItemWithID(QString id) {
return 0;
}
bool engineSelectDlg::isUpdateNeeded(QString plugin_name, qreal new_version) const {
qreal old_version = SearchEngine::getPluginVersion(Utils::Fs::searchEngineLocation() + "/engines/" + plugin_name + ".py");
bool EngineSelectDlg::isUpdateNeeded(QString plugin_name, qreal new_version) const {
qreal old_version = SearchWidget::getPluginVersion(Utils::Fs::searchEngineLocation() + "/engines/" + plugin_name + ".py");
qDebug("IsUpdate needed? tobeinstalled: %.2f, alreadyinstalled: %.2f", new_version, old_version);
return (new_version > old_version);
}
void engineSelectDlg::installPlugin(QString path, QString plugin_name) {
void EngineSelectDlg::installPlugin(QString path, QString plugin_name) {
qDebug("Asked to install plugin at %s", qPrintable(path));
qreal new_version = SearchEngine::getPluginVersion(path);
qreal new_version = SearchWidget::getPluginVersion(path);
if (new_version == 0.0) {
QMessageBox::warning(this, tr("Invalid plugin"), tr("The search engine plugin is invalid, please contact the author."));
return;
@ -304,7 +304,7 @@ void engineSelectDlg::installPlugin(QString path, QString plugin_name) { @@ -304,7 +304,7 @@ void engineSelectDlg::installPlugin(QString path, QString plugin_name) {
// Install was successful, remove backup and update plugin version
if (update) {
Utils::Fs::forceRemove(dest_path+".bak");
qreal version = SearchEngine::getPluginVersion(Utils::Fs::searchEngineLocation() + "/engines/" + plugin_name + ".py");
qreal version = SearchWidget::getPluginVersion(Utils::Fs::searchEngineLocation() + "/engines/" + plugin_name + ".py");
QTreeWidgetItem *item = findItemWithID(plugin_name);
item->setText(ENGINE_VERSION, QString::number(version, 'f', 2));
QMessageBox::information(this, tr("Search plugin install"), tr("'%1' search engine plugin was successfully updated.", "%1 is the name of the search engine").arg(plugin_name));
@ -315,7 +315,7 @@ void engineSelectDlg::installPlugin(QString path, QString plugin_name) { @@ -315,7 +315,7 @@ void engineSelectDlg::installPlugin(QString path, QString plugin_name) {
}
}
void engineSelectDlg::loadSupportedSearchEngines() {
void EngineSelectDlg::loadSupportedSearchEngines() {
// Some clean up first
pluginsTree->clear();
foreach (QString name, supported_engines->keys()) {
@ -323,7 +323,7 @@ void engineSelectDlg::loadSupportedSearchEngines() { @@ -323,7 +323,7 @@ void engineSelectDlg::loadSupportedSearchEngines() {
}
}
void engineSelectDlg::addNewEngine(QString engine_name) {
void EngineSelectDlg::addNewEngine(QString engine_name) {
QTreeWidgetItem *item = new QTreeWidgetItem(pluginsTree);
SupportedEngine *engine = supported_engines->value(engine_name);
item->setText(ENGINE_NAME, engine->getFullName());
@ -351,17 +351,17 @@ void engineSelectDlg::addNewEngine(QString engine_name) { @@ -351,17 +351,17 @@ void engineSelectDlg::addNewEngine(QString engine_name) {
}
}
// Load version
qreal version = SearchEngine::getPluginVersion(Utils::Fs::searchEngineLocation() + "/engines/" + engine->getName() + ".py");
qreal version = SearchWidget::getPluginVersion(Utils::Fs::searchEngineLocation() + "/engines/" + engine->getName() + ".py");
item->setText(ENGINE_VERSION, QString::number(version, 'f', 2));
}
void engineSelectDlg::on_installButton_clicked() {
pluginSourceDlg *dlg = new pluginSourceDlg(this);
void EngineSelectDlg::on_installButton_clicked() {
PluginSourceDlg *dlg = new PluginSourceDlg(this);
connect(dlg, SIGNAL(askForLocalFile()), this, SLOT(askForLocalPlugin()));
connect(dlg, SIGNAL(askForUrl()), this, SLOT(askForPluginUrl()));
}
void engineSelectDlg::askForPluginUrl() {
void EngineSelectDlg::askForPluginUrl() {
bool ok(false);
QString clipTxt = qApp->clipboard()->text();
QString defaultUrl = "http://";
@ -391,7 +391,7 @@ void engineSelectDlg::askForPluginUrl() { @@ -391,7 +391,7 @@ void engineSelectDlg::askForPluginUrl() {
downloadFromUrl(url);
}
void engineSelectDlg::askForLocalPlugin() {
void EngineSelectDlg::askForLocalPlugin() {
QStringList pathsList = QFileDialog::getOpenFileNames(0,
tr("Select search plugins"), QDir::homePath(),
tr("qBittorrent search plugin")+QString::fromUtf8(" (*.py)"));
@ -404,7 +404,7 @@ void engineSelectDlg::askForLocalPlugin() { @@ -404,7 +404,7 @@ void engineSelectDlg::askForLocalPlugin() {
}
}
bool engineSelectDlg::parseVersionsFile(QString versions_file) {
bool EngineSelectDlg::parseVersionsFile(QString versions_file) {
qDebug("Checking if update is needed");
bool file_correct = false;
QFile versions(versions_file);
@ -450,14 +450,14 @@ bool engineSelectDlg::parseVersionsFile(QString versions_file) { @@ -450,14 +450,14 @@ bool engineSelectDlg::parseVersionsFile(QString versions_file) {
return file_correct;
}
void engineSelectDlg::downloadFromUrl(const QString &url)
void EngineSelectDlg::downloadFromUrl(const QString &url)
{
Net::DownloadHandler *handler = Net::DownloadManager::instance()->downloadUrl(url, true);
connect(handler, SIGNAL(downloadFinished(QString, QString)), this, SLOT(processDownloadedFile(QString, QString)));
connect(handler, SIGNAL(downloadFailed(QString, QString)), this, SLOT(handleDownloadFailure(QString, QString)));
}
void engineSelectDlg::processDownloadedFile(const QString &url, QString filePath) {
void EngineSelectDlg::processDownloadedFile(const QString &url, QString filePath) {
filePath = Utils::Fs::fromNativePath(filePath);
setCursor(QCursor(Qt::ArrowCursor));
qDebug("engineSelectDlg received %s", qPrintable(url));
@ -500,7 +500,7 @@ void engineSelectDlg::processDownloadedFile(const QString &url, QString filePath @@ -500,7 +500,7 @@ void engineSelectDlg::processDownloadedFile(const QString &url, QString filePath
}
}
void engineSelectDlg::handleDownloadFailure(const QString &url, const QString &reason) {
void EngineSelectDlg::handleDownloadFailure(const QString &url, const QString &reason) {
setCursor(QCursor(Qt::ArrowCursor));
if (url.endsWith("favicon.ico", Qt::CaseInsensitive)) {
qDebug("Could not download favicon: %s, reason: %s", qPrintable(url), qPrintable(reason));

9
src/searchengine/engineselectdlg.h

@ -31,14 +31,15 @@ @@ -31,14 +31,15 @@
#ifndef ENGINE_SELECT_DLG_H
#define ENGINE_SELECT_DLG_H
#include "ui_engineselect.h"
#include "ui_engineselectdlg.h"
#include "supportedengines.h"
QT_BEGIN_NAMESPACE
class QDropEvent;
QT_END_NAMESPACE
class engineSelectDlg : public QDialog, public Ui::engineSelect{
class EngineSelectDlg : public QDialog, public Ui::EngineSelectDlg
{
Q_OBJECT
private:
@ -48,8 +49,8 @@ class engineSelectDlg : public QDialog, public Ui::engineSelect{ @@ -48,8 +49,8 @@ class engineSelectDlg : public QDialog, public Ui::engineSelect{
const QString m_updateUrl;
public:
engineSelectDlg(QWidget *parent, SupportedEngines *supported_engines);
~engineSelectDlg();
EngineSelectDlg(QWidget *parent, SupportedEngines *supported_engines);
~EngineSelectDlg();
QList<QTreeWidgetItem*> findItemsWithUrl(QString url);
QTreeWidgetItem* findItemWithID(QString id);

4
src/searchengine/engineselect.ui → src/searchengine/engineselectdlg.ui

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>engineSelect</class>
<widget class="QDialog" name="engineSelect">
<class>EngineSelectDlg</class>
<widget class="QDialog" name="EngineSelectDlg">
<property name="geometry">
<rect>
<x>0</x>

14
src/searchengine/pluginsource.h → src/searchengine/pluginsourcedlg.h

@ -28,13 +28,13 @@ @@ -28,13 +28,13 @@
* Contact : chris@qbittorrent.org
*/
#ifndef PLUGIN_SOURCE_H
#define PLUGIN_SOURCE_H
#ifndef PLUGINSOURCEDLG_H
#define PLUGINSOURCEDLG_H
#include <QDialog>
#include "ui_pluginsource.h"
#include "ui_pluginsourcedlg.h"
class pluginSourceDlg: public QDialog, private Ui::pluginSourceDlg {
class PluginSourceDlg: public QDialog, private Ui::PluginSourceDlg {
Q_OBJECT
signals:
@ -53,13 +53,13 @@ class pluginSourceDlg: public QDialog, private Ui::pluginSourceDlg { @@ -53,13 +53,13 @@ class pluginSourceDlg: public QDialog, private Ui::pluginSourceDlg {
}
public:
pluginSourceDlg(QWidget* parent): QDialog(parent) {
PluginSourceDlg(QWidget* parent): QDialog(parent) {
setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
show();
}
~pluginSourceDlg() {}
~PluginSourceDlg() {}
};
#endif
#endif // PLUGINSOURCEDLG_H

4
src/searchengine/pluginsource.ui → src/searchengine/pluginsourcedlg.ui

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
<ui version="4.0" >
<class>pluginSourceDlg</class>
<widget class="QDialog" name="pluginSourceDlg" >
<class>PluginSourceDlg</class>
<widget class="QDialog" name="PluginSourceDlg" >
<property name="geometry" >
<rect>
<x>0</x>

12
src/searchengine/searchengine.pri

@ -1,18 +1,18 @@ @@ -1,18 +1,18 @@
INCLUDEPATH += $$PWD
FORMS += $$PWD/search.ui \
$$PWD/engineselect.ui \
$$PWD/pluginsource.ui
FORMS += $$PWD/searchwidget.ui \
$$PWD/engineselectdlg.ui \
$$PWD/pluginsourcedlg.ui
HEADERS += $$PWD/searchengine.h \
HEADERS += $$PWD/searchwidget.h \
$$PWD/searchtab.h \
$$PWD/engineselectdlg.h \
$$PWD/pluginsource.h \
$$PWD/pluginsourcedlg.h \
$$PWD/searchlistdelegate.h \
$$PWD/supportedengines.h \
$$PWD/searchsortmodel.h
SOURCES += $$PWD/searchengine.cpp \
SOURCES += $$PWD/searchwidget.cpp \
$$PWD/searchtab.cpp \
$$PWD/engineselectdlg.cpp

2
src/searchengine/searchlistdelegate.h

@ -37,7 +37,7 @@ @@ -37,7 +37,7 @@
#include <QPainter>
#include <QProgressBar>
#include "base/utils/misc.h"
#include "searchengine.h"
#include "searchwidget.h"
class SearchListDelegate: public QItemDelegate {
Q_OBJECT

4
src/searchengine/searchtab.cpp

@ -40,10 +40,10 @@ @@ -40,10 +40,10 @@
#include "searchtab.h"
#include "searchlistdelegate.h"
#include "base/utils/misc.h"
#include "searchengine.h"
#include "searchwidget.h"
#include "base/preferences.h"
SearchTab::SearchTab(SearchEngine *parent) : QWidget(), parent(parent)
SearchTab::SearchTab(SearchWidget *parent) : QWidget(), parent(parent)
{
box = new QVBoxLayout();
results_lbl = new QLabel();

21
src/searchengine/searchtab.h

@ -28,25 +28,26 @@ @@ -28,25 +28,26 @@
* Contact : chris@qbittorrent.org
*/
#ifndef SEARCH_TAB_H
#define SEARCH_TAB_H
#ifndef SEARCHTAB_H
#define SEARCHTAB_H
#include <QLabel>
#include <QVBoxLayout>
#include "ui_search.h"
#include "searchsortmodel.h"
#define ENGINE_URL_COLUMN 4
#define URL_COLUMN 5
class SearchListDelegate;
class SearchEngine;
class SearchWidget;
QT_BEGIN_NAMESPACE
class QTreeView;
class QHeaderView;
class QStandardItemModel;
QT_END_NAMESPACE
class SearchTab: public QWidget, public Ui::search_engine {
class SearchTab: public QWidget
{
Q_OBJECT
private:
@ -56,13 +57,13 @@ private: @@ -56,13 +57,13 @@ private:
QStandardItemModel *SearchListModel;
SearchSortModel *proxyModel;
SearchListDelegate *SearchDelegate;
SearchEngine *parent;
SearchWidget *parent;
protected slots:
void downloadSelectedItem(const QModelIndex& index);
public:
SearchTab(SearchEngine *parent);
SearchTab(SearchWidget *parent);
~SearchTab();
bool loadColWidthResultsList();
QLabel * getCurrentLabel();
@ -74,5 +75,5 @@ public: @@ -74,5 +75,5 @@ public:
QString status;
};
#endif
#endif // SEARCHTAB_H

52
src/searchengine/searchengine.cpp → src/searchengine/searchwidget.cpp

@ -48,7 +48,6 @@ @@ -48,7 +48,6 @@
#include <stdlib.h>
#endif
#include "searchengine.h"
#include "base/bittorrent/session.h"
#include "base/utils/fs.h"
#include "base/utils/misc.h"
@ -58,11 +57,12 @@ @@ -58,11 +57,12 @@
#include "addnewtorrentdialog.h"
#include "guiiconprovider.h"
#include "lineedit.h"
#include "searchwidget.h"
#define SEARCHHISTORY_MAXSIZE 50
/*SEARCH ENGINE START*/
SearchEngine::SearchEngine(MainWindow* parent)
SearchWidget::SearchWidget(MainWindow* parent)
: QWidget(parent)
, search_pattern(new LineEdit(this))
, mp_mainWindow(parent)
@ -101,7 +101,7 @@ SearchEngine::SearchEngine(MainWindow* parent) @@ -101,7 +101,7 @@ SearchEngine::SearchEngine(MainWindow* parent)
connect(selectEngine, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(selectMultipleBox(const QString &)));
}
void SearchEngine::fillCatCombobox()
void SearchWidget::fillCatCombobox()
{
comboCategory->clear();
comboCategory->addItem(full_cat_names["all"], QVariant("all"));
@ -112,7 +112,7 @@ void SearchEngine::fillCatCombobox() @@ -112,7 +112,7 @@ void SearchEngine::fillCatCombobox()
}
}
void SearchEngine::fillEngineComboBox()
void SearchWidget::fillEngineComboBox()
{
selectEngine->clear();
selectEngine->addItem(tr("All enabled"), QVariant("enabled"));
@ -122,17 +122,17 @@ void SearchEngine::fillEngineComboBox() @@ -122,17 +122,17 @@ void SearchEngine::fillEngineComboBox()
selectEngine->addItem(tr("Multiple..."), QVariant("multi"));
}
QString SearchEngine::selectedCategory() const
QString SearchWidget::selectedCategory() const
{
return comboCategory->itemData(comboCategory->currentIndex()).toString();
}
QString SearchEngine::selectedEngine() const
QString SearchWidget::selectedEngine() const
{
return selectEngine->itemData(selectEngine->currentIndex()).toString();
}
SearchEngine::~SearchEngine()
SearchWidget::~SearchWidget()
{
qDebug("Search destruction");
searchProcess->kill();
@ -151,7 +151,7 @@ SearchEngine::~SearchEngine() @@ -151,7 +151,7 @@ SearchEngine::~SearchEngine()
delete supported_engines;
}
void SearchEngine::tab_changed(int t)
void SearchWidget::tab_changed(int t)
{
//when we switch from a tab that is not empty to another that is empty the download button
//doesn't have to be available
@ -172,32 +172,32 @@ void SearchEngine::tab_changed(int t) @@ -172,32 +172,32 @@ void SearchEngine::tab_changed(int t)
}
}
void SearchEngine::selectMultipleBox(const QString &text)
void SearchWidget::selectMultipleBox(const QString &text)
{
if (text == tr("Multiple...")) on_enginesButton_clicked();
}
void SearchEngine::on_enginesButton_clicked()
void SearchWidget::on_enginesButton_clicked()
{
engineSelectDlg *dlg = new engineSelectDlg(this, supported_engines);
EngineSelectDlg *dlg = new EngineSelectDlg(this, supported_engines);
connect(dlg, SIGNAL(enginesChanged()), this, SLOT(fillCatCombobox()));
connect(dlg, SIGNAL(enginesChanged()), this, SLOT(fillEngineComboBox()));
}
void SearchEngine::searchTextEdited(QString)
void SearchWidget::searchTextEdited(QString)
{
// Enable search button
search_button->setText(tr("Search"));
newQueryString = true;
}
void SearchEngine::giveFocusToSearchInput()
void SearchWidget::giveFocusToSearchInput()
{
search_pattern->setFocus();
}
// Function called when we click on search button
void SearchEngine::on_search_button_clicked()
void SearchWidget::on_search_button_clicked()
{
if (Utils::Misc::pythonVersion() < 0) {
mp_mainWindow->showNotificationBaloon(tr("Search Engine"), tr("Please install Python to use the Search Engine."));
@ -265,7 +265,7 @@ void SearchEngine::on_search_button_clicked() @@ -265,7 +265,7 @@ void SearchEngine::on_search_button_clicked()
searchTimeout->start(180000); // 3min
}
void SearchEngine::saveResultsColumnsWidth()
void SearchWidget::saveResultsColumnsWidth()
{
if (all_tab.isEmpty())
return;
@ -281,7 +281,7 @@ void SearchEngine::saveResultsColumnsWidth() @@ -281,7 +281,7 @@ void SearchEngine::saveResultsColumnsWidth()
pref->setSearchColsWidth(new_width_list.join(" "));
}
void SearchEngine::downloadTorrent(QString engine_url, QString torrent_url)
void SearchWidget::downloadTorrent(QString engine_url, QString torrent_url)
{
if (torrent_url.startsWith("bc://bt/", Qt::CaseInsensitive)) {
qDebug("Converting bc link to magnet link");
@ -307,7 +307,7 @@ void SearchEngine::downloadTorrent(QString engine_url, QString torrent_url) @@ -307,7 +307,7 @@ void SearchEngine::downloadTorrent(QString engine_url, QString torrent_url)
}
}
void SearchEngine::searchStarted()
void SearchWidget::searchStarted()
{
// Update SearchEngine widgets
activeSearchTab->status = tr("Searching...");
@ -319,7 +319,7 @@ void SearchEngine::searchStarted() @@ -319,7 +319,7 @@ void SearchEngine::searchStarted()
// search Qprocess return output as soon as it gets new
// stuff to read. We split it into lines and add each
// line to search results calling appendSearchResult().
void SearchEngine::readSearchOutput()
void SearchWidget::readSearchOutput()
{
QByteArray output = searchProcess->readAllStandardOutput();
output.replace("\r", "");
@ -334,7 +334,7 @@ void SearchEngine::readSearchOutput() @@ -334,7 +334,7 @@ void SearchEngine::readSearchOutput()
activeSearchTab->getCurrentLabel()->setText(tr("Results <i>(%1)</i>:", "i.e: Search results").arg(nb_search_results));
}
void SearchEngine::downloadFinished(int exitcode, QProcess::ExitStatus)
void SearchWidget::downloadFinished(int exitcode, QProcess::ExitStatus)
{
QProcess *downloadProcess = (QProcess*)sender();
if (exitcode == 0) {
@ -361,7 +361,7 @@ static inline void removePythonScriptIfExists(const QString& script_path) @@ -361,7 +361,7 @@ static inline void removePythonScriptIfExists(const QString& script_path)
}
// Update nova.py search plugin if necessary
void SearchEngine::updateNova()
void SearchWidget::updateNova()
{
qDebug("Updating nova");
// create nova directory if necessary
@ -444,7 +444,7 @@ void SearchEngine::updateNova() @@ -444,7 +444,7 @@ void SearchEngine::updateNova()
// Slot called when search is Finished
// Search can be finished for 3 reasons :
// Error | Stopped by user | Finished normally
void SearchEngine::searchFinished(int exitcode, QProcess::ExitStatus)
void SearchWidget::searchFinished(int exitcode, QProcess::ExitStatus)
{
if (searchTimeout->isActive())
searchTimeout->stop();
@ -482,7 +482,7 @@ void SearchEngine::searchFinished(int exitcode, QProcess::ExitStatus) @@ -482,7 +482,7 @@ void SearchEngine::searchFinished(int exitcode, QProcess::ExitStatus)
// SLOT to append one line to search results list
// Line is in the following form :
// file url | file name | file size | nb seeds | nb leechers | Search engine url
void SearchEngine::appendSearchResult(const QString &line)
void SearchWidget::appendSearchResult(const QString &line)
{
if (activeSearchTab.isNull()) {
if (searchProcess->state() != QProcess::NotRunning) {
@ -536,7 +536,7 @@ void SearchEngine::appendSearchResult(const QString &line) @@ -536,7 +536,7 @@ void SearchEngine::appendSearchResult(const QString &line)
copyURLBtn->setEnabled(true);
}
void SearchEngine::closeTab(int index)
void SearchWidget::closeTab(int index)
{
// Search is run for active tab so if user decided to close it, then stop search
if (!activeSearchTab.isNull() && index == tabWidget->indexOf(activeSearchTab)) {
@ -564,7 +564,7 @@ void SearchEngine::closeTab(int index) @@ -564,7 +564,7 @@ void SearchEngine::closeTab(int index)
}
// Download selected items in search results list
void SearchEngine::on_download_button_clicked()
void SearchWidget::on_download_button_clicked()
{
//QModelIndexList selectedIndexes = currentSearchTab->getCurrentTreeView()->selectionModel()->selectedIndexes();
QModelIndexList selectedIndexes = all_tab.at(tabWidget->currentIndex())->getCurrentTreeView()->selectionModel()->selectedIndexes();
@ -580,7 +580,7 @@ void SearchEngine::on_download_button_clicked() @@ -580,7 +580,7 @@ void SearchEngine::on_download_button_clicked()
}
}
void SearchEngine::on_goToDescBtn_clicked()
void SearchWidget::on_goToDescBtn_clicked()
{
QModelIndexList selectedIndexes = all_tab.at(tabWidget->currentIndex())->getCurrentTreeView()->selectionModel()->selectedIndexes();
foreach (const QModelIndex &index, selectedIndexes) {
@ -593,7 +593,7 @@ void SearchEngine::on_goToDescBtn_clicked() @@ -593,7 +593,7 @@ void SearchEngine::on_goToDescBtn_clicked()
}
}
void SearchEngine::on_copyURLBtn_clicked()
void SearchWidget::on_copyURLBtn_clicked()
{
QStringList urls;
QModelIndexList selectedIndexes = all_tab.at(tabWidget->currentIndex())->getCurrentTreeView()->selectionModel()->selectedIndexes();

18
src/searchengine/searchengine.h → src/searchengine/searchwidget.h

@ -28,20 +28,20 @@ @@ -28,20 +28,20 @@
* Contact : chris@qbittorrent.org
*/
#ifndef SEARCH_H
#define SEARCH_H
#ifndef SEARCHWIDGET_H
#define SEARCHWIDGET_H
#include <QProcess>
#include <QList>
#include <QPair>
#include <QPointer>
#include <QStringListModel>
#include "ui_search.h"
#include "ui_searchwidget.h"
#include "engineselectdlg.h"
#include "searchtab.h"
#include "supportedengines.h"
class SearchEngine;
class SearchWidget;
class MainWindow;
class LineEdit;
@ -49,16 +49,16 @@ QT_BEGIN_NAMESPACE @@ -49,16 +49,16 @@ QT_BEGIN_NAMESPACE
class QTimer;
QT_END_NAMESPACE
class SearchEngine : public QWidget, public Ui::search_engine{
class SearchWidget : public QWidget, private Ui::SearchWidget{
Q_OBJECT
Q_DISABLE_COPY(SearchEngine)
Q_DISABLE_COPY(SearchWidget)
private:
enum PluginColumn { PL_DL_LINK, PL_NAME, PL_SIZE, PL_SEEDS, PL_LEECHS, PL_ENGINE_URL, PL_DESC_LINK, NB_PLUGIN_COLUMNS };
public:
SearchEngine(MainWindow *mp_mainWindow);
~SearchEngine();
SearchWidget(MainWindow *mp_mainWindow);
~SearchWidget();
QString selectedCategory() const;
QString selectedEngine() const;
@ -130,4 +130,4 @@ private: @@ -130,4 +130,4 @@ private:
bool newQueryString;
};
#endif
#endif // SEARCHWIDGET_H

4
src/searchengine/search.ui → src/searchengine/searchwidget.ui

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>search_engine</class>
<widget class="QWidget" name="search_engine">
<class>SearchWidget</class>
<widget class="QWidget" name="SearchWidget">
<property name="geometry">
<rect>
<x>0</x>
Loading…
Cancel
Save