|
|
|
@ -92,8 +92,10 @@ SearchEngine::SearchEngine(MainWindow* parent)
@@ -92,8 +92,10 @@ SearchEngine::SearchEngine(MainWindow* parent)
|
|
|
|
|
supported_engines = new SupportedEngines(); |
|
|
|
|
// Fill in category combobox
|
|
|
|
|
fillCatCombobox(); |
|
|
|
|
fillEngineComboBox(); |
|
|
|
|
|
|
|
|
|
connect(search_pattern, SIGNAL(textEdited(QString)), this, SLOT(searchTextEdited(QString))); |
|
|
|
|
connect(selectEngine, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(selectMultipleBox(const QString&))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void SearchEngine::fillCatCombobox() { |
|
|
|
@ -106,10 +108,23 @@ 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 { |
|
|
|
|
return comboCategory->itemData(comboCategory->currentIndex()).toString(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
QString SearchEngine::selectedEngine() const { |
|
|
|
|
return selectEngine->itemData(selectEngine->currentIndex()).toString(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
SearchEngine::~SearchEngine() { |
|
|
|
|
qDebug("Search destruction"); |
|
|
|
|
searchProcess->kill(); |
|
|
|
@ -131,21 +146,26 @@ SearchEngine::~SearchEngine() {
@@ -131,21 +146,26 @@ SearchEngine::~SearchEngine() {
|
|
|
|
|
void SearchEngine::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
|
|
|
|
|
if (t>-1) |
|
|
|
|
{//-1 = no more tab
|
|
|
|
|
if (t>-1) {//-1 = no more tab
|
|
|
|
|
if (all_tab.at(tabWidget->currentIndex())->getCurrentSearchListModel()->rowCount()) { |
|
|
|
|
download_button->setEnabled(true); |
|
|
|
|
goToDescBtn->setEnabled(true); |
|
|
|
|
} else { |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
download_button->setEnabled(false); |
|
|
|
|
goToDescBtn->setEnabled(false); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void SearchEngine::selectMultipleBox(const QString &text) { |
|
|
|
|
if (text == "Multiple...") on_enginesButton_clicked(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void SearchEngine::on_enginesButton_clicked() { |
|
|
|
|
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) { |
|
|
|
@ -185,7 +205,7 @@ void SearchEngine::on_search_button_clicked() {
@@ -185,7 +205,7 @@ void SearchEngine::on_search_button_clicked() {
|
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
// Tab Addition
|
|
|
|
|
currentSearchTab=new SearchTab(this); |
|
|
|
|
currentSearchTab = new SearchTab(this); |
|
|
|
|
connect(currentSearchTab->header(), SIGNAL(sectionResized(int, int, int)), this, SLOT(propagateSectionResized(int,int,int))); |
|
|
|
|
all_tab.append(currentSearchTab); |
|
|
|
|
QString tabName = pattern; |
|
|
|
@ -197,7 +217,10 @@ void SearchEngine::on_search_button_clicked() {
@@ -197,7 +217,10 @@ void SearchEngine::on_search_button_clicked() {
|
|
|
|
|
QStringList params; |
|
|
|
|
search_stopped = false; |
|
|
|
|
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())); |
|
|
|
|
params << selectedCategory(); |
|
|
|
|
params << pattern.split(" "); |
|
|
|
@ -231,6 +254,7 @@ void SearchEngine::saveResultsColumnsWidth() {
@@ -231,6 +254,7 @@ void SearchEngine::saveResultsColumnsWidth() {
|
|
|
|
|
if (!line.isEmpty()) { |
|
|
|
|
width_list = line.split(' '); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
for (short i=0; i<nbColumns; ++i) { |
|
|
|
|
if (treeview->columnWidth(i)<1 && width_list.size() == nbColumns && width_list.at(i).toInt()>=1) { |
|
|
|
|
// load the former width
|
|
|
|
@ -428,6 +452,7 @@ void SearchEngine::searchFinished(int exitcode,QProcess::ExitStatus) {
@@ -428,6 +452,7 @@ void SearchEngine::searchFinished(int exitcode,QProcess::ExitStatus) {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (currentSearchTab) |
|
|
|
|
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")); |
|
|
|
|