|
|
@ -92,8 +92,10 @@ SearchEngine::SearchEngine(MainWindow* parent) |
|
|
|
supported_engines = new SupportedEngines(); |
|
|
|
supported_engines = new SupportedEngines(); |
|
|
|
// Fill in category combobox
|
|
|
|
// Fill in category combobox
|
|
|
|
fillCatCombobox(); |
|
|
|
fillCatCombobox(); |
|
|
|
|
|
|
|
fillEngineComboBox(); |
|
|
|
|
|
|
|
|
|
|
|
connect(search_pattern, SIGNAL(textEdited(QString)), this, SLOT(searchTextEdited(QString))); |
|
|
|
connect(search_pattern, SIGNAL(textEdited(QString)), this, SLOT(searchTextEdited(QString))); |
|
|
|
|
|
|
|
connect(selectEngine, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(selectMultipleBox(const QString&))); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void SearchEngine::fillCatCombobox() { |
|
|
|
void SearchEngine::fillCatCombobox() { |
|
|
@ -106,10 +108,23 @@ void SearchEngine::fillCatCombobox() { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SearchEngine::fillEngineComboBox() { |
|
|
|
|
|
|
|
selectEngine->clear(); |
|
|
|
|
|
|
|
selectEngine->addItem("All enabled", QVariant("enabled")); |
|
|
|
|
|
|
|
selectEngine->addItem("All engines", QVariant("all")); |
|
|
|
|
|
|
|
foreach (QString engi, supported_engines->enginesEnabled()) |
|
|
|
|
|
|
|
selectEngine->addItem(engi, QVariant(engi)); |
|
|
|
|
|
|
|
selectEngine->addItem("Multiple...", QVariant("multi")); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
QString SearchEngine::selectedCategory() const { |
|
|
|
QString SearchEngine::selectedCategory() const { |
|
|
|
return comboCategory->itemData(comboCategory->currentIndex()).toString(); |
|
|
|
return comboCategory->itemData(comboCategory->currentIndex()).toString(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QString SearchEngine::selectedEngine() const { |
|
|
|
|
|
|
|
return selectEngine->itemData(selectEngine->currentIndex()).toString(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
SearchEngine::~SearchEngine() { |
|
|
|
SearchEngine::~SearchEngine() { |
|
|
|
qDebug("Search destruction"); |
|
|
|
qDebug("Search destruction"); |
|
|
|
searchProcess->kill(); |
|
|
|
searchProcess->kill(); |
|
|
@ -131,21 +146,26 @@ SearchEngine::~SearchEngine() { |
|
|
|
void SearchEngine::tab_changed(int t) |
|
|
|
void SearchEngine::tab_changed(int t) |
|
|
|
{//when we switch from a tab that is not empty to another that is empty the download button
|
|
|
|
{//when we switch from a tab that is not empty to another that is empty the download button
|
|
|
|
//doesn't have to be available
|
|
|
|
//doesn't have to be available
|
|
|
|
if (t>-1) |
|
|
|
if (t>-1) {//-1 = no more tab
|
|
|
|
{//-1 = no more tab
|
|
|
|
|
|
|
|
if (all_tab.at(tabWidget->currentIndex())->getCurrentSearchListModel()->rowCount()) { |
|
|
|
if (all_tab.at(tabWidget->currentIndex())->getCurrentSearchListModel()->rowCount()) { |
|
|
|
download_button->setEnabled(true); |
|
|
|
download_button->setEnabled(true); |
|
|
|
goToDescBtn->setEnabled(true); |
|
|
|
goToDescBtn->setEnabled(true); |
|
|
|
} else { |
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
download_button->setEnabled(false); |
|
|
|
download_button->setEnabled(false); |
|
|
|
goToDescBtn->setEnabled(false); |
|
|
|
goToDescBtn->setEnabled(false); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SearchEngine::selectMultipleBox(const QString &text) { |
|
|
|
|
|
|
|
if (text == "Multiple...") on_enginesButton_clicked(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void SearchEngine::on_enginesButton_clicked() { |
|
|
|
void SearchEngine::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(fillCatCombobox())); |
|
|
|
|
|
|
|
connect(dlg, SIGNAL(enginesChanged()), this, SLOT(fillEngineComboBox())); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void SearchEngine::searchTextEdited(QString) { |
|
|
|
void SearchEngine::searchTextEdited(QString) { |
|
|
@ -197,7 +217,10 @@ void SearchEngine::on_search_button_clicked() { |
|
|
|
QStringList params; |
|
|
|
QStringList params; |
|
|
|
search_stopped = false; |
|
|
|
search_stopped = false; |
|
|
|
params << fsutils::toNativePath(fsutils::searchEngineLocation() + "/nova2.py"); |
|
|
|
params << fsutils::toNativePath(fsutils::searchEngineLocation() + "/nova2.py"); |
|
|
|
params << supported_engines->enginesEnabled().join(","); |
|
|
|
if (selectedEngine() == "all") params << supported_engines->enginesAll().join(","); |
|
|
|
|
|
|
|
else if (selectedEngine() == "enabled") params << supported_engines->enginesEnabled().join(","); |
|
|
|
|
|
|
|
else if (selectedEngine() == "multi") params << supported_engines->enginesEnabled().join(","); |
|
|
|
|
|
|
|
else params << selectedEngine(); |
|
|
|
qDebug("Search with category: %s", qPrintable(selectedCategory())); |
|
|
|
qDebug("Search with category: %s", qPrintable(selectedCategory())); |
|
|
|
params << selectedCategory(); |
|
|
|
params << selectedCategory(); |
|
|
|
params << pattern.split(" "); |
|
|
|
params << pattern.split(" "); |
|
|
@ -231,6 +254,7 @@ void SearchEngine::saveResultsColumnsWidth() { |
|
|
|
if (!line.isEmpty()) { |
|
|
|
if (!line.isEmpty()) { |
|
|
|
width_list = line.split(' '); |
|
|
|
width_list = line.split(' '); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for (short i=0; i<nbColumns; ++i) { |
|
|
|
for (short i=0; i<nbColumns; ++i) { |
|
|
|
if (treeview->columnWidth(i)<1 && width_list.size() == nbColumns && width_list.at(i).toInt()>=1) { |
|
|
|
if (treeview->columnWidth(i)<1 && width_list.size() == nbColumns && width_list.at(i).toInt()>=1) { |
|
|
|
// load the former width
|
|
|
|
// load the former width
|
|
|
@ -428,6 +452,7 @@ void SearchEngine::searchFinished(int exitcode,QProcess::ExitStatus) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (currentSearchTab) |
|
|
|
if (currentSearchTab) |
|
|
|
currentSearchTab->getCurrentLabel()->setText(tr("Results", "i.e: Search results")+QString::fromUtf8(" <i>(")+QString::number(nb_search_results)+QString::fromUtf8(")</i>:")); |
|
|
|
currentSearchTab->getCurrentLabel()->setText(tr("Results", "i.e: Search results")+QString::fromUtf8(" <i>(")+QString::number(nb_search_results)+QString::fromUtf8(")</i>:")); |
|
|
|
search_button->setText(tr("Search")); |
|
|
|
search_button->setText(tr("Search")); |
|
|
|