|
|
@ -39,6 +39,7 @@ |
|
|
|
#include <iostream> |
|
|
|
#include <iostream> |
|
|
|
#include <QTimer> |
|
|
|
#include <QTimer> |
|
|
|
#include <QDir> |
|
|
|
#include <QDir> |
|
|
|
|
|
|
|
#include <QMenu> |
|
|
|
|
|
|
|
|
|
|
|
#include "searchEngine.h" |
|
|
|
#include "searchEngine.h" |
|
|
|
#include "bittorrent.h" |
|
|
|
#include "bittorrent.h" |
|
|
@ -53,9 +54,8 @@ SearchEngine::SearchEngine(bittorrent *BTSession, QSystemTrayIcon *myTrayIcon, b |
|
|
|
setupUi(this); |
|
|
|
setupUi(this); |
|
|
|
// new qCompleter to the search pattern
|
|
|
|
// new qCompleter to the search pattern
|
|
|
|
startSearchHistory(); |
|
|
|
startSearchHistory(); |
|
|
|
searchCompleter = new QCompleter(searchHistory, this); |
|
|
|
searchCompleter = 0; |
|
|
|
searchCompleter->setCaseSensitivity(Qt::CaseInsensitive); |
|
|
|
createCompleter(); |
|
|
|
search_pattern->setCompleter(searchCompleter); |
|
|
|
|
|
|
|
// Add close tab button
|
|
|
|
// Add close tab button
|
|
|
|
closeTab_button = new QPushButton(); |
|
|
|
closeTab_button = new QPushButton(); |
|
|
|
closeTab_button->setIcon(QIcon(QString::fromUtf8(":/Icons/gnome-shutdown.png"))); |
|
|
|
closeTab_button->setIcon(QIcon(QString::fromUtf8(":/Icons/gnome-shutdown.png"))); |
|
|
@ -79,6 +79,7 @@ SearchEngine::SearchEngine(bittorrent *BTSession, QSystemTrayIcon *myTrayIcon, b |
|
|
|
loadEngineSettings(); |
|
|
|
loadEngineSettings(); |
|
|
|
// Update nova.py search plugin if necessary
|
|
|
|
// Update nova.py search plugin if necessary
|
|
|
|
updateNova(); |
|
|
|
updateNova(); |
|
|
|
|
|
|
|
connect(search_pattern, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(displayPatternContextMenu(QPoint))); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
SearchEngine::~SearchEngine(){ |
|
|
|
SearchEngine::~SearchEngine(){ |
|
|
@ -94,9 +95,23 @@ SearchEngine::~SearchEngine(){ |
|
|
|
} |
|
|
|
} |
|
|
|
delete searchTimeout; |
|
|
|
delete searchTimeout; |
|
|
|
delete searchProcess; |
|
|
|
delete searchProcess; |
|
|
|
|
|
|
|
if(searchCompleter) |
|
|
|
delete searchCompleter; |
|
|
|
delete searchCompleter; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SearchEngine::displayPatternContextMenu(QPoint) { |
|
|
|
|
|
|
|
QMenu myMenu(this); |
|
|
|
|
|
|
|
QAction clearHistoryAct(tr("Clear history"), &myMenu); |
|
|
|
|
|
|
|
myMenu.addAction(&clearHistoryAct); |
|
|
|
|
|
|
|
QAction *act = myMenu.exec(QCursor::pos()); |
|
|
|
|
|
|
|
if(act != 0) { |
|
|
|
|
|
|
|
if(act == &clearHistoryAct) { |
|
|
|
|
|
|
|
searchHistory.clear(); |
|
|
|
|
|
|
|
createCompleter(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
@ -178,12 +193,9 @@ void SearchEngine::on_search_button_clicked(){ |
|
|
|
// verify the max size of the history
|
|
|
|
// verify the max size of the history
|
|
|
|
if(searchHistory.size() > SEARCHHISTORY_MAXSIZE) |
|
|
|
if(searchHistory.size() > SEARCHHISTORY_MAXSIZE) |
|
|
|
searchHistory = searchHistory.mid(searchHistory.size()/2,searchHistory.size()/2); |
|
|
|
searchHistory = searchHistory.mid(searchHistory.size()/2,searchHistory.size()/2); |
|
|
|
searchCompleter = new QCompleter(searchHistory, this); |
|
|
|
createCompleter(); |
|
|
|
searchCompleter->setCaseSensitivity(Qt::CaseInsensitive); |
|
|
|
|
|
|
|
search_pattern->setCompleter(searchCompleter); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Getting checked search engines
|
|
|
|
// Getting checked search engines
|
|
|
|
Q_ASSERT(!enabled_engines.empty()); |
|
|
|
Q_ASSERT(!enabled_engines.empty()); |
|
|
|
QStringList params; |
|
|
|
QStringList params; |
|
|
@ -203,6 +215,14 @@ void SearchEngine::on_search_button_clicked(){ |
|
|
|
searchTimeout->start(180000); // 3min
|
|
|
|
searchTimeout->start(180000); // 3min
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SearchEngine::createCompleter() { |
|
|
|
|
|
|
|
if(searchCompleter) |
|
|
|
|
|
|
|
delete searchCompleter; |
|
|
|
|
|
|
|
searchCompleter = new QCompleter(searchHistory, this); |
|
|
|
|
|
|
|
searchCompleter->setCaseSensitivity(Qt::CaseInsensitive); |
|
|
|
|
|
|
|
search_pattern->setCompleter(searchCompleter); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void SearchEngine::propagateSectionResized(int index, int , int newsize) { |
|
|
|
void SearchEngine::propagateSectionResized(int index, int , int newsize) { |
|
|
|
foreach(SearchTab * tab, all_tab) { |
|
|
|
foreach(SearchTab * tab, all_tab) { |
|
|
|
tab->getCurrentTreeView()->setColumnWidth(index, newsize); |
|
|
|
tab->getCurrentTreeView()->setColumnWidth(index, newsize); |
|
|
|