diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index ac9bbd729..953392430 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -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) 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")); } } diff --git a/src/gui/mainwindow.h b/src/gui/mainwindow.h index a8cd49944..5c2338c3e 100644 --- a/src/gui/mainwindow.h +++ b/src/gui/mainwindow.h @@ -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: QSplitter *hSplitter; QSplitter *vSplitter; // Search - QPointer searchEngine; + QPointer searchEngine; // RSS QPointer rssWidget; // Execution Log diff --git a/src/searchengine/engineselectdlg.cpp b/src/searchengine/engineselectdlg.cpp index 0d78a81ef..d51f4cb2d 100644 --- a/src/searchengine/engineselectdlg.cpp +++ b/src/searchengine/engineselectdlg.cpp @@ -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 @@ -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 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) { } // 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) { } } -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) { } } -void engineSelectDlg::displayContextMenu(const QPoint&) { +void EngineSelectDlg::displayContextMenu(const QPoint&) { QMenu myContextMenu(this); // Enable/disable pause/start action given the DL state QList items = pluginsTree->selectedItems(); @@ -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 items = pluginsTree->selectedItems(); QTreeWidgetItem *item; bool error = false; @@ -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 items = pluginsTree->selectedItems(); QTreeWidgetItem *item; foreach (item, items) { @@ -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; icolumnCount(); ++i) { item->setData(i, Qt::ForegroundRole, QVariant(QColor(color))); } } -QList engineSelectDlg::findItemsWithUrl(QString url) { +QList EngineSelectDlg::findItemsWithUrl(QString url) { QList res; for (int i=0; itopLevelItemCount(); ++i) { QTreeWidgetItem *item = pluginsTree->topLevelItem(i); @@ -241,7 +241,7 @@ QList engineSelectDlg::findItemsWithUrl(QString url) { return res; } -QTreeWidgetItem* engineSelectDlg::findItemWithID(QString id) { +QTreeWidgetItem* EngineSelectDlg::findItemWithID(QString id) { QList res; for (int i=0; itopLevelItemCount(); ++i) { QTreeWidgetItem *item = pluginsTree->topLevelItem(i); @@ -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) { // 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) { } } -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() { } } -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) { } } // 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() { 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() { } } -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) { 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 } } -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)); diff --git a/src/searchengine/engineselectdlg.h b/src/searchengine/engineselectdlg.h index abcb19001..a98f54bad 100644 --- a/src/searchengine/engineselectdlg.h +++ b/src/searchengine/engineselectdlg.h @@ -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{ const QString m_updateUrl; public: - engineSelectDlg(QWidget *parent, SupportedEngines *supported_engines); - ~engineSelectDlg(); + EngineSelectDlg(QWidget *parent, SupportedEngines *supported_engines); + ~EngineSelectDlg(); QList findItemsWithUrl(QString url); QTreeWidgetItem* findItemWithID(QString id); diff --git a/src/searchengine/engineselect.ui b/src/searchengine/engineselectdlg.ui similarity index 97% rename from src/searchengine/engineselect.ui rename to src/searchengine/engineselectdlg.ui index 7db8f90e3..4ba4f2f54 100644 --- a/src/searchengine/engineselect.ui +++ b/src/searchengine/engineselectdlg.ui @@ -1,7 +1,7 @@ - engineSelect - + EngineSelectDlg + 0 diff --git a/src/searchengine/pluginsource.h b/src/searchengine/pluginsourcedlg.h similarity index 87% rename from src/searchengine/pluginsource.h rename to src/searchengine/pluginsourcedlg.h index aea63711b..cfabee362 100644 --- a/src/searchengine/pluginsource.h +++ b/src/searchengine/pluginsourcedlg.h @@ -28,13 +28,13 @@ * Contact : chris@qbittorrent.org */ -#ifndef PLUGIN_SOURCE_H -#define PLUGIN_SOURCE_H +#ifndef PLUGINSOURCEDLG_H +#define PLUGINSOURCEDLG_H #include -#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 { } public: - pluginSourceDlg(QWidget* parent): QDialog(parent) { + PluginSourceDlg(QWidget* parent): QDialog(parent) { setupUi(this); setAttribute(Qt::WA_DeleteOnClose); show(); } - ~pluginSourceDlg() {} + ~PluginSourceDlg() {} }; -#endif +#endif // PLUGINSOURCEDLG_H diff --git a/src/searchengine/pluginsource.ui b/src/searchengine/pluginsourcedlg.ui similarity index 93% rename from src/searchengine/pluginsource.ui rename to src/searchengine/pluginsourcedlg.ui index ecfcbc49c..a2ca22d95 100644 --- a/src/searchengine/pluginsource.ui +++ b/src/searchengine/pluginsourcedlg.ui @@ -1,6 +1,6 @@ - pluginSourceDlg - + PluginSourceDlg + 0 diff --git a/src/searchengine/searchengine.pri b/src/searchengine/searchengine.pri index 9a514a4b4..9a2812827 100644 --- a/src/searchengine/searchengine.pri +++ b/src/searchengine/searchengine.pri @@ -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 diff --git a/src/searchengine/searchlistdelegate.h b/src/searchengine/searchlistdelegate.h index 78ba36ac5..2986e6d41 100644 --- a/src/searchengine/searchlistdelegate.h +++ b/src/searchengine/searchlistdelegate.h @@ -37,7 +37,7 @@ #include #include #include "base/utils/misc.h" -#include "searchengine.h" +#include "searchwidget.h" class SearchListDelegate: public QItemDelegate { Q_OBJECT diff --git a/src/searchengine/searchtab.cpp b/src/searchengine/searchtab.cpp index e4b4e414f..5d2d69624 100644 --- a/src/searchengine/searchtab.cpp +++ b/src/searchengine/searchtab.cpp @@ -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(); diff --git a/src/searchengine/searchtab.h b/src/searchengine/searchtab.h index 05920007d..cab2ab714 100644 --- a/src/searchengine/searchtab.h +++ b/src/searchengine/searchtab.h @@ -28,25 +28,26 @@ * Contact : chris@qbittorrent.org */ -#ifndef SEARCH_TAB_H -#define SEARCH_TAB_H +#ifndef SEARCHTAB_H +#define SEARCHTAB_H + +#include +#include -#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: 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: QString status; }; -#endif +#endif // SEARCHTAB_H diff --git a/src/searchengine/searchengine.cpp b/src/searchengine/searchwidget.cpp similarity index 95% rename from src/searchengine/searchengine.cpp rename to src/searchengine/searchwidget.cpp index dd3f143a3..b28c6857a 100644 --- a/src/searchengine/searchengine.cpp +++ b/src/searchengine/searchwidget.cpp @@ -48,7 +48,6 @@ #include #endif -#include "searchengine.h" #include "base/bittorrent/session.h" #include "base/utils/fs.h" #include "base/utils/misc.h" @@ -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) 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() } } -void SearchEngine::fillEngineComboBox() +void SearchWidget::fillEngineComboBox() { selectEngine->clear(); selectEngine->addItem(tr("All enabled"), QVariant("enabled")); @@ -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() 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) } } -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() searchTimeout->start(180000); // 3min } -void SearchEngine::saveResultsColumnsWidth() +void SearchWidget::saveResultsColumnsWidth() { if (all_tab.isEmpty()) return; @@ -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) } } -void SearchEngine::searchStarted() +void SearchWidget::searchStarted() { // Update SearchEngine widgets activeSearchTab->status = tr("Searching..."); @@ -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() activeSearchTab->getCurrentLabel()->setText(tr("Results (%1):", "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) } // 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() // 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) // 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) 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) } // 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() } } -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() } } -void SearchEngine::on_copyURLBtn_clicked() +void SearchWidget::on_copyURLBtn_clicked() { QStringList urls; QModelIndexList selectedIndexes = all_tab.at(tabWidget->currentIndex())->getCurrentTreeView()->selectionModel()->selectedIndexes(); diff --git a/src/searchengine/searchengine.h b/src/searchengine/searchwidget.h similarity index 93% rename from src/searchengine/searchengine.h rename to src/searchengine/searchwidget.h index bc2d26626..9751a620b 100644 --- a/src/searchengine/searchengine.h +++ b/src/searchengine/searchwidget.h @@ -28,20 +28,20 @@ * Contact : chris@qbittorrent.org */ -#ifndef SEARCH_H -#define SEARCH_H +#ifndef SEARCHWIDGET_H +#define SEARCHWIDGET_H #include #include #include #include #include -#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 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: bool newQueryString; }; -#endif +#endif // SEARCHWIDGET_H diff --git a/src/searchengine/search.ui b/src/searchengine/searchwidget.ui similarity index 98% rename from src/searchengine/search.ui rename to src/searchengine/searchwidget.ui index ae35d4927..03e422c28 100644 --- a/src/searchengine/search.ui +++ b/src/searchengine/searchwidget.ui @@ -1,7 +1,7 @@ - search_engine - + SearchWidget + 0