|
|
@ -43,82 +43,78 @@ |
|
|
|
|
|
|
|
|
|
|
|
#define SEARCHHISTORY_MAXSIZE 50 |
|
|
|
#define SEARCHHISTORY_MAXSIZE 50 |
|
|
|
|
|
|
|
|
|
|
|
SearchEngine::SearchEngine(bittorrent *BTSession, QSystemTrayIcon *myTrayIcon, bool systrayIntegration) : QWidget(), BTSession(BTSession), myTrayIcon(myTrayIcon), systrayIntegration(systrayIntegration){ |
|
|
|
/*TAB SYSTEM TO MOVE IN ANOTHER FILE*/ |
|
|
|
setupUi(this); |
|
|
|
QList<TabbedSearch*>* TabbedSearch::all_tab = new QList<TabbedSearch*>(); |
|
|
|
downloader = new downloadThread(this); |
|
|
|
TabbedSearch::TabbedSearch(QString &title,QTabWidget *tab_barWidget,SearchEngine *searchEngi) : QWidget() |
|
|
|
// Set Search results list model
|
|
|
|
{ |
|
|
|
SearchListModel = new QStandardItemModel(0,5); |
|
|
|
box=new QVBoxLayout(); |
|
|
|
SearchListModel->setHeaderData(SEARCH_NAME, Qt::Horizontal, tr("Name", "i.e: file name")); |
|
|
|
results_lbl=new QLabel(); |
|
|
|
SearchListModel->setHeaderData(SEARCH_SIZE, Qt::Horizontal, tr("Size", "i.e: file size")); |
|
|
|
resultsBrowser = new QTreeView(); |
|
|
|
SearchListModel->setHeaderData(SEARCH_SEEDERS, Qt::Horizontal, tr("Seeders", "i.e: Number of full sources")); |
|
|
|
box->addWidget(results_lbl); |
|
|
|
SearchListModel->setHeaderData(SEARCH_LEECHERS, Qt::Horizontal, tr("Leechers", "i.e: Number of partial sources")); |
|
|
|
box->addWidget(resultsBrowser); |
|
|
|
SearchListModel->setHeaderData(SEARCH_ENGINE, Qt::Horizontal, tr("Search engine")); |
|
|
|
|
|
|
|
resultsBrowser->setModel(SearchListModel); |
|
|
|
|
|
|
|
SearchDelegate = new SearchListDelegate(); |
|
|
|
|
|
|
|
resultsBrowser->setItemDelegate(SearchDelegate); |
|
|
|
|
|
|
|
// Make search list header clickable for sorting
|
|
|
|
|
|
|
|
resultsBrowser->header()->setClickable(true); |
|
|
|
|
|
|
|
resultsBrowser->header()->setSortIndicatorShown(true); |
|
|
|
|
|
|
|
// Load last columns width for search results list
|
|
|
|
|
|
|
|
if(!loadColWidthSearchList()){ |
|
|
|
|
|
|
|
resultsBrowser->header()->resizeSection(0, 275); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// new qCompleter to the search pattern
|
|
|
|
setLayout(box); |
|
|
|
startSearchHistory(); |
|
|
|
// Set Search results list model
|
|
|
|
searchCompleter = new QCompleter(searchHistory, this); |
|
|
|
SearchListModel = new QStandardItemModel(0,5); |
|
|
|
searchCompleter->setCaseSensitivity(Qt::CaseInsensitive); |
|
|
|
SearchListModel->setHeaderData(SEARCH_NAME, Qt::Horizontal, tr("Name", "i.e: file name")); |
|
|
|
search_pattern->setCompleter(searchCompleter); |
|
|
|
SearchListModel->setHeaderData(SEARCH_SIZE, Qt::Horizontal, tr("Size", "i.e: file size")); |
|
|
|
|
|
|
|
SearchListModel->setHeaderData(SEARCH_SEEDERS, Qt::Horizontal, tr("Seeders", "i.e: Number of full sources")); |
|
|
|
|
|
|
|
SearchListModel->setHeaderData(SEARCH_LEECHERS, Qt::Horizontal, tr("Leechers", "i.e: Number of partial sources")); |
|
|
|
|
|
|
|
SearchListModel->setHeaderData(SEARCH_ENGINE, Qt::Horizontal, tr("Search engine")); |
|
|
|
|
|
|
|
resultsBrowser->setModel(SearchListModel); |
|
|
|
|
|
|
|
SearchDelegate = new SearchListDelegate(); |
|
|
|
|
|
|
|
resultsBrowser->setItemDelegate(SearchDelegate); |
|
|
|
|
|
|
|
// Make search list header clickable for sorting
|
|
|
|
|
|
|
|
resultsBrowser->header()->setClickable(true); |
|
|
|
|
|
|
|
resultsBrowser->header()->setSortIndicatorShown(true); |
|
|
|
|
|
|
|
|
|
|
|
// Boolean initialization
|
|
|
|
// Connect signals to slots (search part)
|
|
|
|
search_stopped = false; |
|
|
|
connect(resultsBrowser, SIGNAL(doubleClicked(const QModelIndex&)), searchEngi, SLOT(downloadSelectedItem(const QModelIndex&))); |
|
|
|
// Connect signals to slots (search part)
|
|
|
|
connect(resultsBrowser->header(), SIGNAL(sectionPressed(int)), this, SLOT(sortSearchList(int))); |
|
|
|
connect(resultsBrowser, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(downloadSelectedItem(const QModelIndex&))); |
|
|
|
|
|
|
|
connect(resultsBrowser->header(), SIGNAL(sectionPressed(int)), this, SLOT(sortSearchList(int))); |
|
|
|
// Load last columns width for search results list
|
|
|
|
// Creating Search Process
|
|
|
|
if(!loadColWidthSearchList()){ |
|
|
|
searchProcess = new QProcess(this); |
|
|
|
resultsBrowser->header()->resizeSection(0, 275); |
|
|
|
connect(searchProcess, SIGNAL(started()), this, SLOT(searchStarted())); |
|
|
|
} |
|
|
|
connect(searchProcess, SIGNAL(readyReadStandardOutput()), this, SLOT(readSearchOutput())); |
|
|
|
tab_barWidget->addTab(this, title); |
|
|
|
connect(searchProcess, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(searchFinished(int,QProcess::ExitStatus))); |
|
|
|
all_tab->append(this); |
|
|
|
searchTimeout = new QTimer(this); |
|
|
|
|
|
|
|
searchTimeout->setSingleShot(true); |
|
|
|
|
|
|
|
connect(searchTimeout, SIGNAL(timeout()), this, SLOT(on_stop_search_button_clicked())); |
|
|
|
|
|
|
|
// Check last enabled search engines
|
|
|
|
|
|
|
|
loadEngineSettings(); |
|
|
|
|
|
|
|
// Update nova.py search plugin if necessary
|
|
|
|
|
|
|
|
updateNova(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
SearchEngine::~SearchEngine(){ |
|
|
|
TabbedSearch::~TabbedSearch() |
|
|
|
qDebug("Search destruction"); |
|
|
|
{ |
|
|
|
// save the searchHistory for later uses
|
|
|
|
saveColWidthSearchList(); |
|
|
|
saveSearchHistory(); |
|
|
|
delete resultsBrowser; |
|
|
|
saveColWidthSearchList(); |
|
|
|
delete SearchListModel; |
|
|
|
searchProcess->kill(); |
|
|
|
delete SearchDelegate; |
|
|
|
searchProcess->waitForFinished(); |
|
|
|
} |
|
|
|
delete searchTimeout; |
|
|
|
|
|
|
|
delete searchProcess; |
|
|
|
/*LES FONCTIONS POUR GET LA BETE*/ |
|
|
|
delete searchCompleter; |
|
|
|
QLabel* TabbedSearch::getCurrentLabel() |
|
|
|
delete SearchListModel; |
|
|
|
{ |
|
|
|
delete SearchDelegate; |
|
|
|
return results_lbl; |
|
|
|
delete downloader; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QTreeView* TabbedSearch::getCurrentTreeView() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return resultsBrowser; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QStandardItemModel* TabbedSearch::getCurrentSearchListModel() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return SearchListModel; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Set the color of a row in data model
|
|
|
|
// Set the color of a row in data model
|
|
|
|
void SearchEngine::setRowColor(int row, QString color){ |
|
|
|
void TabbedSearch::setRowColor(int row, QString color){ |
|
|
|
for(int i=0; i<SearchListModel->columnCount(); ++i){ |
|
|
|
for(int i=0; i<SearchListModel->columnCount(); ++i){ |
|
|
|
SearchListModel->setData(SearchListModel->index(row, i), QVariant(QColor(color)), Qt::ForegroundRole); |
|
|
|
SearchListModel->setData(SearchListModel->index(row, i), QVariant(QColor(color)), Qt::ForegroundRole); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void SearchEngine::sortSearchList(int index){ |
|
|
|
void TabbedSearch::sortSearchList(int index){ |
|
|
|
static Qt::SortOrder sortOrder = Qt::AscendingOrder; |
|
|
|
static Qt::SortOrder sortOrder = Qt::AscendingOrder; |
|
|
|
if(resultsBrowser->header()->sortIndicatorSection() == index){ |
|
|
|
if(resultsBrowser->header()->sortIndicatorSection() == index){ |
|
|
|
if(sortOrder == Qt::AscendingOrder){ |
|
|
|
sortOrder = (sortOrder == Qt::DescendingOrder) ? Qt::AscendingOrder : Qt::DescendingOrder; ; |
|
|
|
sortOrder = Qt::DescendingOrder; |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
sortOrder = Qt::AscendingOrder; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
resultsBrowser->header()->setSortIndicator(index, sortOrder); |
|
|
|
resultsBrowser->header()->setSortIndicator(index, sortOrder); |
|
|
|
switch(index){ |
|
|
|
switch(index){ |
|
|
@ -133,7 +129,7 @@ void SearchEngine::sortSearchList(int index){ |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void SearchEngine::sortSearchListInt(int index, Qt::SortOrder sortOrder){ |
|
|
|
void TabbedSearch::sortSearchListInt(int index, Qt::SortOrder sortOrder){ |
|
|
|
QList<QPair<int, qlonglong> > lines; |
|
|
|
QList<QPair<int, qlonglong> > lines; |
|
|
|
// Insertion sorting
|
|
|
|
// Insertion sorting
|
|
|
|
for(int i=0; i<SearchListModel->rowCount(); ++i){ |
|
|
|
for(int i=0; i<SearchListModel->rowCount(); ++i){ |
|
|
@ -153,7 +149,7 @@ void SearchEngine::sortSearchListInt(int index, Qt::SortOrder sortOrder){ |
|
|
|
SearchListModel->removeRows(0, nbRows_old); |
|
|
|
SearchListModel->removeRows(0, nbRows_old); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void SearchEngine::sortSearchListString(int index, Qt::SortOrder sortOrder){ |
|
|
|
void TabbedSearch::sortSearchListString(int index, Qt::SortOrder sortOrder){ |
|
|
|
QList<QPair<int, QString> > lines; |
|
|
|
QList<QPair<int, QString> > lines; |
|
|
|
// Insetion sorting
|
|
|
|
// Insetion sorting
|
|
|
|
for(int i=0; i<SearchListModel->rowCount(); ++i){ |
|
|
|
for(int i=0; i<SearchListModel->rowCount(); ++i){ |
|
|
@ -175,7 +171,7 @@ void SearchEngine::sortSearchListString(int index, Qt::SortOrder sortOrder){ |
|
|
|
|
|
|
|
|
|
|
|
// Save columns width in a file to remember them
|
|
|
|
// Save columns width in a file to remember them
|
|
|
|
// (download list)
|
|
|
|
// (download list)
|
|
|
|
void SearchEngine::saveColWidthSearchList() const{ |
|
|
|
void TabbedSearch::saveColWidthSearchList() const{ |
|
|
|
qDebug("Saving columns width in search list"); |
|
|
|
qDebug("Saving columns width in search list"); |
|
|
|
QSettings settings("qBittorrent", "qBittorrent"); |
|
|
|
QSettings settings("qBittorrent", "qBittorrent"); |
|
|
|
QStringList width_list; |
|
|
|
QStringList width_list; |
|
|
@ -186,14 +182,9 @@ void SearchEngine::saveColWidthSearchList() const{ |
|
|
|
qDebug("Search list columns width saved"); |
|
|
|
qDebug("Search list columns width saved"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void SearchEngine::on_enginesButton_clicked() { |
|
|
|
|
|
|
|
engineSelectDlg *dlg = new engineSelectDlg(this); |
|
|
|
|
|
|
|
connect(dlg, SIGNAL(enginesChanged()), this, SLOT(loadEngineSettings())); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Load columns width in a file that were saved previously
|
|
|
|
// Load columns width in a file that were saved previously
|
|
|
|
// (search list)
|
|
|
|
// (search list)
|
|
|
|
bool SearchEngine::loadColWidthSearchList(){ |
|
|
|
bool TabbedSearch::loadColWidthSearchList(){ |
|
|
|
qDebug("Loading columns width for search list"); |
|
|
|
qDebug("Loading columns width for search list"); |
|
|
|
QSettings settings("qBittorrent", "qBittorrent"); |
|
|
|
QSettings settings("qBittorrent", "qBittorrent"); |
|
|
|
QString line = settings.value("SearchListColsWidth", QString()).toString(); |
|
|
|
QString line = settings.value("SearchListColsWidth", QString()).toString(); |
|
|
@ -208,6 +199,51 @@ bool SearchEngine::loadColWidthSearchList(){ |
|
|
|
qDebug("Search list columns width loaded"); |
|
|
|
qDebug("Search list columns width loaded"); |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/*END TAB SYSTME*/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*SEARCH ENGINE START*/ |
|
|
|
|
|
|
|
SearchEngine::SearchEngine(bittorrent *BTSession, QSystemTrayIcon *myTrayIcon, bool systrayIntegration) : QWidget(), BTSession(BTSession), myTrayIcon(myTrayIcon), systrayIntegration(systrayIntegration){ |
|
|
|
|
|
|
|
setupUi(this); |
|
|
|
|
|
|
|
downloader = new downloadThread(this); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// new qCompleter to the search pattern
|
|
|
|
|
|
|
|
startSearchHistory(); |
|
|
|
|
|
|
|
searchCompleter = new QCompleter(searchHistory, this); |
|
|
|
|
|
|
|
searchCompleter->setCaseSensitivity(Qt::CaseInsensitive); |
|
|
|
|
|
|
|
search_pattern->setCompleter(searchCompleter); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Boolean initialization
|
|
|
|
|
|
|
|
search_stopped = false; |
|
|
|
|
|
|
|
// Creating Search Process
|
|
|
|
|
|
|
|
searchProcess = new QProcess(this); |
|
|
|
|
|
|
|
connect(searchProcess, SIGNAL(started()), this, SLOT(searchStarted())); |
|
|
|
|
|
|
|
connect(searchProcess, SIGNAL(readyReadStandardOutput()), this, SLOT(readSearchOutput())); |
|
|
|
|
|
|
|
connect(searchProcess, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(searchFinished(int,QProcess::ExitStatus))); |
|
|
|
|
|
|
|
searchTimeout = new QTimer(this); |
|
|
|
|
|
|
|
searchTimeout->setSingleShot(true); |
|
|
|
|
|
|
|
connect(searchTimeout, SIGNAL(timeout()), this, SLOT(on_stop_search_button_clicked())); |
|
|
|
|
|
|
|
// Check last enabled search engines
|
|
|
|
|
|
|
|
loadEngineSettings(); |
|
|
|
|
|
|
|
// Update nova.py search plugin if necessary
|
|
|
|
|
|
|
|
updateNova(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SearchEngine::~SearchEngine(){ |
|
|
|
|
|
|
|
qDebug("Search destruction"); |
|
|
|
|
|
|
|
// save the searchHistory for later uses
|
|
|
|
|
|
|
|
saveSearchHistory(); |
|
|
|
|
|
|
|
searchProcess->kill(); |
|
|
|
|
|
|
|
searchProcess->waitForFinished(); |
|
|
|
|
|
|
|
delete searchTimeout; |
|
|
|
|
|
|
|
delete searchProcess; |
|
|
|
|
|
|
|
delete searchCompleter; |
|
|
|
|
|
|
|
delete downloader; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SearchEngine::on_enginesButton_clicked() { |
|
|
|
|
|
|
|
engineSelectDlg *dlg = new engineSelectDlg(this); |
|
|
|
|
|
|
|
connect(dlg, SIGNAL(enginesChanged()), this, SLOT(loadEngineSettings())); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// get the last searchs from a QSettings to a QStringList
|
|
|
|
// get the last searchs from a QSettings to a QStringList
|
|
|
|
void SearchEngine::startSearchHistory(){ |
|
|
|
void SearchEngine::startSearchHistory(){ |
|
|
@ -254,6 +290,8 @@ void SearchEngine::on_search_button_clicked(){ |
|
|
|
searchTimeout->stop(); |
|
|
|
searchTimeout->stop(); |
|
|
|
} |
|
|
|
} |
|
|
|
QString pattern = search_pattern->text().trimmed(); |
|
|
|
QString pattern = search_pattern->text().trimmed(); |
|
|
|
|
|
|
|
//AJOUT TAB obligé de passé le widget en param sinon crash
|
|
|
|
|
|
|
|
tab_search=new TabbedSearch(pattern,tabWidget,this); |
|
|
|
// No search pattern entered
|
|
|
|
// No search pattern entered
|
|
|
|
if(pattern.isEmpty()){ |
|
|
|
if(pattern.isEmpty()){ |
|
|
|
QMessageBox::critical(0, tr("Empty search pattern"), tr("Please type a search pattern first")); |
|
|
|
QMessageBox::critical(0, tr("Empty search pattern"), tr("Please type a search pattern first")); |
|
|
@ -284,7 +322,8 @@ void SearchEngine::on_search_button_clicked(){ |
|
|
|
no_search_results = true; |
|
|
|
no_search_results = true; |
|
|
|
nb_search_results = 0; |
|
|
|
nb_search_results = 0; |
|
|
|
search_result_line_truncated.clear(); |
|
|
|
search_result_line_truncated.clear(); |
|
|
|
results_lbl->setText(tr("Results")+" <i>(0)</i>:"); |
|
|
|
//on change le texte du label courrant
|
|
|
|
|
|
|
|
tab_search->getCurrentLabel()->setText(tr("Results")+" <i>(0)</i>:"); |
|
|
|
// Launch search
|
|
|
|
// Launch search
|
|
|
|
searchProcess->start("python", params, QIODevice::ReadOnly); |
|
|
|
searchProcess->start("python", params, QIODevice::ReadOnly); |
|
|
|
searchTimeout->start(180000); // 3min
|
|
|
|
searchTimeout->start(180000); // 3min
|
|
|
@ -296,21 +335,21 @@ void SearchEngine::searchStarted(){ |
|
|
|
search_status->repaint(); |
|
|
|
search_status->repaint(); |
|
|
|
stop_search_button->setEnabled(true); |
|
|
|
stop_search_button->setEnabled(true); |
|
|
|
stop_search_button->repaint(); |
|
|
|
stop_search_button->repaint(); |
|
|
|
// clear results window
|
|
|
|
// clear results window ... not needed since we got Tabbed
|
|
|
|
SearchListModel->removeRows(0, SearchListModel->rowCount()); |
|
|
|
//SearchListModel->removeRows(0, SearchListModel->rowCount());
|
|
|
|
// Clear previous results urls too
|
|
|
|
// Clear previous results urls too
|
|
|
|
searchResultsUrls.clear(); |
|
|
|
//searchResultsUrls.clear();
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Download the given item from search results list
|
|
|
|
// Download the given item from search results list
|
|
|
|
void SearchEngine::downloadSelectedItem(const QModelIndex& index){ |
|
|
|
void SearchEngine::downloadSelectedItem(const QModelIndex& index){ |
|
|
|
int row = index.row(); |
|
|
|
int row = index.row(); |
|
|
|
// Get Item url
|
|
|
|
// Get Item url
|
|
|
|
QString url = searchResultsUrls.value(SearchListModel->data(SearchListModel->index(row, NAME)).toString()); |
|
|
|
QString url = searchResultsUrls.value(TabbedSearch::all_tab->at(tabWidget->currentIndex())->getCurrentSearchListModel()->data(TabbedSearch::all_tab->at(tabWidget->currentIndex())->getCurrentSearchListModel()->index(row, NAME)).toString()); |
|
|
|
// Download from url
|
|
|
|
// Download from url
|
|
|
|
BTSession->downloadFromUrl(url); |
|
|
|
BTSession->downloadFromUrl(url); |
|
|
|
// Set item color to RED
|
|
|
|
// Set item color to RED
|
|
|
|
setRowColor(row, "red"); |
|
|
|
tab_search->setRowColor(row, "red"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// search Qprocess return output as soon as it gets new
|
|
|
|
// search Qprocess return output as soon as it gets new
|
|
|
@ -329,7 +368,7 @@ void SearchEngine::readSearchOutput(){ |
|
|
|
foreach(line, lines_list){ |
|
|
|
foreach(line, lines_list){ |
|
|
|
appendSearchResult(QString(line)); |
|
|
|
appendSearchResult(QString(line)); |
|
|
|
} |
|
|
|
} |
|
|
|
results_lbl->setText(tr("Results")+QString::fromUtf8(" <i>(")+misc::toQString(nb_search_results)+QString::fromUtf8(")</i>:")); |
|
|
|
tab_search->getCurrentLabel()->setText(tr("Results")+QString::fromUtf8(" <i>(")+misc::toQString(nb_search_results)+QString::fromUtf8(")</i>:")); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Update nova.py search plugin if necessary
|
|
|
|
// Update nova.py search plugin if necessary
|
|
|
@ -416,7 +455,7 @@ void SearchEngine::searchFinished(int exitcode,QProcess::ExitStatus){ |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
results_lbl->setText(tr("Results", "i.e: Search results")+QString::fromUtf8(" <i>(")+misc::toQString(nb_search_results)+QString::fromUtf8(")</i>:")); |
|
|
|
tab_search->getCurrentLabel()->setText(tr("Results", "i.e: Search results")+QString::fromUtf8(" <i>(")+misc::toQString(nb_search_results)+QString::fromUtf8(")</i>:")); |
|
|
|
search_button->setEnabled(true); |
|
|
|
search_button->setEnabled(true); |
|
|
|
stop_search_button->setEnabled(false); |
|
|
|
stop_search_button->setEnabled(false); |
|
|
|
} |
|
|
|
} |
|
|
@ -436,13 +475,13 @@ void SearchEngine::appendSearchResult(QString line){ |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
// Add item to search result list
|
|
|
|
// Add item to search result list
|
|
|
|
int row = SearchListModel->rowCount(); |
|
|
|
int row = tab_search->getCurrentSearchListModel()->rowCount(); |
|
|
|
SearchListModel->insertRow(row); |
|
|
|
tab_search->getCurrentSearchListModel()->insertRow(row); |
|
|
|
for(int i=0; i<5; ++i){ |
|
|
|
for(int i=0; i<5; ++i){ |
|
|
|
if(parts.at(i).toFloat() == -1 && i != SIZE) |
|
|
|
if(parts.at(i).toFloat() == -1 && i != SIZE) |
|
|
|
SearchListModel->setData(SearchListModel->index(row, i), tr("Unknown")); |
|
|
|
tab_search->getCurrentSearchListModel()->setData(tab_search->getCurrentSearchListModel()->index(row, i), tr("Unknown")); |
|
|
|
else |
|
|
|
else |
|
|
|
SearchListModel->setData(SearchListModel->index(row, i), QVariant(parts.at(i))); |
|
|
|
tab_search->getCurrentSearchListModel()->setData(tab_search->getCurrentSearchListModel()->index(row, i), QVariant(parts.at(i))); |
|
|
|
} |
|
|
|
} |
|
|
|
// Add url to searchResultsUrls associative array
|
|
|
|
// Add url to searchResultsUrls associative array
|
|
|
|
searchResultsUrls.insert(filename, url); |
|
|
|
searchResultsUrls.insert(filename, url); |
|
|
@ -468,12 +507,12 @@ void SearchEngine::on_clear_button_clicked(){ |
|
|
|
search_stopped = true; |
|
|
|
search_stopped = true; |
|
|
|
searchTimeout->stop(); |
|
|
|
searchTimeout->stop(); |
|
|
|
searchResultsUrls.clear(); |
|
|
|
searchResultsUrls.clear(); |
|
|
|
SearchListModel->removeRows(0, SearchListModel->rowCount()); |
|
|
|
tab_search->getCurrentSearchListModel()->removeRows(0, tab_search->getCurrentSearchListModel()->rowCount()); |
|
|
|
// Disable clear & download buttons
|
|
|
|
// Disable clear & download buttons
|
|
|
|
clear_button->setEnabled(false); |
|
|
|
clear_button->setEnabled(false); |
|
|
|
download_button->setEnabled(false); |
|
|
|
download_button->setEnabled(false); |
|
|
|
nb_search_results = 0; |
|
|
|
nb_search_results = 0; |
|
|
|
results_lbl->setText(tr("Results")+" <i>(0)</i>:"); |
|
|
|
tab_search->getCurrentLabel()->setText(tr("Results")+" <i>(0)</i>:"); |
|
|
|
// focus on search pattern
|
|
|
|
// focus on search pattern
|
|
|
|
search_pattern->clear(); |
|
|
|
search_pattern->clear(); |
|
|
|
search_pattern->setFocus(); |
|
|
|
search_pattern->setFocus(); |
|
|
@ -486,14 +525,15 @@ void SearchEngine::on_clearPatternButton_clicked() { |
|
|
|
|
|
|
|
|
|
|
|
// Download selected items in search results list
|
|
|
|
// Download selected items in search results list
|
|
|
|
void SearchEngine::on_download_button_clicked(){ |
|
|
|
void SearchEngine::on_download_button_clicked(){ |
|
|
|
QModelIndexList selectedIndexes = resultsBrowser->selectionModel()->selectedIndexes(); |
|
|
|
//QModelIndexList selectedIndexes = tab_search->getCurrentTreeView()->selectionModel()->selectedIndexes();
|
|
|
|
|
|
|
|
QModelIndexList selectedIndexes = TabbedSearch::all_tab->at(tabWidget->currentIndex())->getCurrentTreeView()->selectionModel()->selectedIndexes(); |
|
|
|
QModelIndex index; |
|
|
|
QModelIndex index; |
|
|
|
foreach(index, selectedIndexes){ |
|
|
|
foreach(index, selectedIndexes){ |
|
|
|
if(index.column() == NAME){ |
|
|
|
if(index.column() == NAME){ |
|
|
|
// Get Item url
|
|
|
|
// Get Item url
|
|
|
|
QString url = searchResultsUrls.value(index.data().toString()); |
|
|
|
QString url = searchResultsUrls.value(index.data().toString()); |
|
|
|
BTSession->downloadFromUrl(url); |
|
|
|
BTSession->downloadFromUrl(url); |
|
|
|
setRowColor(index.row(), "red"); |
|
|
|
tab_search->setRowColor(index.row(), "red"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|