mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-02-10 05:44:25 +00:00
- Initial commit for multi tab support in search engine (code by Grigis Gaëtan)
This commit is contained in:
parent
6f13325e76
commit
0e09ce1dd3
@ -5,7 +5,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>811</width>
|
<width>820</width>
|
||||||
<height>453</height>
|
<height>453</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@ -195,6 +195,10 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QTabWidget" name="tabWidget" >
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" >
|
<layout class="QVBoxLayout" >
|
||||||
<property name="spacing" >
|
<property name="spacing" >
|
||||||
@ -212,87 +216,6 @@
|
|||||||
<property name="bottomMargin" >
|
<property name="bottomMargin" >
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" >
|
|
||||||
<property name="spacing" >
|
|
||||||
<number>6</number>
|
|
||||||
</property>
|
|
||||||
<property name="leftMargin" >
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="topMargin" >
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="rightMargin" >
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="bottomMargin" >
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="results_lbl" >
|
|
||||||
<property name="maximumSize" >
|
|
||||||
<size>
|
|
||||||
<width>16777215</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="font" >
|
|
||||||
<font>
|
|
||||||
<family>Sans Serif</family>
|
|
||||||
<pointsize>9</pointsize>
|
|
||||||
<weight>75</weight>
|
|
||||||
<italic>false</italic>
|
|
||||||
<bold>true</bold>
|
|
||||||
<underline>false</underline>
|
|
||||||
<strikeout>false</strikeout>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="text" >
|
|
||||||
<string>Results:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer>
|
|
||||||
<property name="orientation" >
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" >
|
|
||||||
<size>
|
|
||||||
<width>721</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QTreeView" name="resultsBrowser" >
|
|
||||||
<property name="minimumSize" >
|
|
||||||
<size>
|
|
||||||
<width>0</width>
|
|
||||||
<height>200</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="contextMenuPolicy" >
|
|
||||||
<enum>Qt::CustomContextMenu</enum>
|
|
||||||
</property>
|
|
||||||
<property name="autoScroll" >
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="selectionMode" >
|
|
||||||
<enum>QAbstractItemView::ExtendedSelection</enum>
|
|
||||||
</property>
|
|
||||||
<property name="indentation" >
|
|
||||||
<number>1</number>
|
|
||||||
</property>
|
|
||||||
<property name="itemsExpandable" >
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" >
|
<layout class="QHBoxLayout" >
|
||||||
<property name="spacing" >
|
<property name="spacing" >
|
||||||
|
@ -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);
|
setLayout(box);
|
||||||
SearchDelegate = new SearchListDelegate();
|
// Set Search results list model
|
||||||
resultsBrowser->setItemDelegate(SearchDelegate);
|
SearchListModel = new QStandardItemModel(0,5);
|
||||||
// Make search list header clickable for sorting
|
SearchListModel->setHeaderData(SEARCH_NAME, Qt::Horizontal, tr("Name", "i.e: file name"));
|
||||||
resultsBrowser->header()->setClickable(true);
|
SearchListModel->setHeaderData(SEARCH_SIZE, Qt::Horizontal, tr("Size", "i.e: file size"));
|
||||||
resultsBrowser->header()->setSortIndicatorShown(true);
|
SearchListModel->setHeaderData(SEARCH_SEEDERS, Qt::Horizontal, tr("Seeders", "i.e: Number of full sources"));
|
||||||
// Load last columns width for search results list
|
SearchListModel->setHeaderData(SEARCH_LEECHERS, Qt::Horizontal, tr("Leechers", "i.e: Number of partial sources"));
|
||||||
if(!loadColWidthSearchList()){
|
SearchListModel->setHeaderData(SEARCH_ENGINE, Qt::Horizontal, tr("Search engine"));
|
||||||
resultsBrowser->header()->resizeSection(0, 275);
|
resultsBrowser->setModel(SearchListModel);
|
||||||
}
|
SearchDelegate = new SearchListDelegate();
|
||||||
|
resultsBrowser->setItemDelegate(SearchDelegate);
|
||||||
// new qCompleter to the search pattern
|
// Make search list header clickable for sorting
|
||||||
startSearchHistory();
|
resultsBrowser->header()->setClickable(true);
|
||||||
searchCompleter = new QCompleter(searchHistory, this);
|
resultsBrowser->header()->setSortIndicatorShown(true);
|
||||||
searchCompleter->setCaseSensitivity(Qt::CaseInsensitive);
|
|
||||||
search_pattern->setCompleter(searchCompleter);
|
// Connect signals to slots (search part)
|
||||||
|
connect(resultsBrowser, SIGNAL(doubleClicked(const QModelIndex&)), searchEngi, SLOT(downloadSelectedItem(const QModelIndex&)));
|
||||||
// Boolean initialization
|
connect(resultsBrowser->header(), SIGNAL(sectionPressed(int)), this, SLOT(sortSearchList(int)));
|
||||||
search_stopped = false;
|
|
||||||
// Connect signals to slots (search part)
|
// Load last columns width for search results list
|
||||||
connect(resultsBrowser, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(downloadSelectedItem(const QModelIndex&)));
|
if(!loadColWidthSearchList()){
|
||||||
connect(resultsBrowser->header(), SIGNAL(sectionPressed(int)), this, SLOT(sortSearchList(int)));
|
resultsBrowser->header()->resizeSection(0, 275);
|
||||||
// Creating Search Process
|
}
|
||||||
searchProcess = new QProcess(this);
|
tab_barWidget->addTab(this, title);
|
||||||
connect(searchProcess, SIGNAL(started()), this, SLOT(searchStarted()));
|
all_tab->append(this);
|
||||||
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(){
|
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");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,8 @@
|
|||||||
#define TIME_TRAY_BALLOON 5000
|
#define TIME_TRAY_BALLOON 5000
|
||||||
|
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
|
#include <QList>
|
||||||
|
#include <QTreeView>
|
||||||
#include "ui_search.h"
|
#include "ui_search.h"
|
||||||
#include "engineSelectDlg.h"
|
#include "engineSelectDlg.h"
|
||||||
|
|
||||||
@ -34,6 +36,33 @@ class bittorrent;
|
|||||||
class QSystemTrayIcon;
|
class QSystemTrayIcon;
|
||||||
class downloadThread;
|
class downloadThread;
|
||||||
class QTimer;
|
class QTimer;
|
||||||
|
class SearchEngine;
|
||||||
|
class TabbedSearch : public QWidget, public Ui::search_engine
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
private:
|
||||||
|
QVBoxLayout *box;
|
||||||
|
QLabel *results_lbl;
|
||||||
|
QTreeView *resultsBrowser;
|
||||||
|
QStandardItemModel *SearchListModel;
|
||||||
|
SearchListDelegate *SearchDelegate;
|
||||||
|
public:
|
||||||
|
static QList<TabbedSearch*> *all_tab; // To store all tabs
|
||||||
|
TabbedSearch(QString &title,QTabWidget *tab_barWidget,SearchEngine *searchEngi);
|
||||||
|
~TabbedSearch();
|
||||||
|
bool loadColWidthSearchList();
|
||||||
|
QLabel * getCurrentLabel();
|
||||||
|
QStandardItemModel * getCurrentSearchListModel();
|
||||||
|
QTreeView * getCurrentTreeView();
|
||||||
|
void setRowColor(int row, QString color);
|
||||||
|
protected slots:
|
||||||
|
void sortSearchList(int index);
|
||||||
|
void sortSearchListInt(int index, Qt::SortOrder sortOrder);
|
||||||
|
void sortSearchListString(int index, Qt::SortOrder sortOrder);
|
||||||
|
void saveColWidthSearchList() const;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
class SearchEngine : public QWidget, public Ui::search_engine{
|
class SearchEngine : public QWidget, public Ui::search_engine{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -48,42 +77,34 @@ class SearchEngine : public QWidget, public Ui::search_engine{
|
|||||||
unsigned long nb_search_results;
|
unsigned long nb_search_results;
|
||||||
QCompleter *searchCompleter;
|
QCompleter *searchCompleter;
|
||||||
QStringList searchHistory;
|
QStringList searchHistory;
|
||||||
QStandardItemModel *SearchListModel;
|
|
||||||
SearchListDelegate *SearchDelegate;
|
|
||||||
bittorrent *BTSession;
|
bittorrent *BTSession;
|
||||||
QSystemTrayIcon *myTrayIcon;
|
QSystemTrayIcon *myTrayIcon;
|
||||||
bool systrayIntegration;
|
bool systrayIntegration;
|
||||||
downloadThread *downloader;
|
downloadThread *downloader;
|
||||||
QStringList enabled_engines;
|
QStringList enabled_engines;
|
||||||
QTimer *searchTimeout;
|
QTimer *searchTimeout;
|
||||||
|
TabbedSearch *tab_search;
|
||||||
public:
|
public:
|
||||||
SearchEngine(bittorrent *BTSession, QSystemTrayIcon *myTrayIcon, bool systrayIntegration);
|
SearchEngine(bittorrent *BTSession, QSystemTrayIcon *myTrayIcon, bool systrayIntegration);
|
||||||
~SearchEngine();
|
~SearchEngine();
|
||||||
float getPluginVersion(QString filePath) const;
|
float getPluginVersion(QString filePath) const;
|
||||||
bool loadColWidthSearchList();
|
public slots:
|
||||||
|
void on_download_button_clicked();
|
||||||
|
void downloadSelectedItem(const QModelIndex& index);
|
||||||
protected slots:
|
protected slots:
|
||||||
// Search slots
|
// Search slots
|
||||||
void on_search_button_clicked();
|
void on_search_button_clicked();
|
||||||
void on_stop_search_button_clicked();
|
void on_stop_search_button_clicked();
|
||||||
void on_clear_button_clicked();
|
void on_clear_button_clicked();
|
||||||
void on_download_button_clicked();
|
|
||||||
void appendSearchResult(QString line);
|
void appendSearchResult(QString line);
|
||||||
void searchFinished(int exitcode,QProcess::ExitStatus);
|
void searchFinished(int exitcode,QProcess::ExitStatus);
|
||||||
void readSearchOutput();
|
void readSearchOutput();
|
||||||
void setRowColor(int row, QString color);
|
void loadEngineSettings();
|
||||||
void searchStarted();
|
void searchStarted();
|
||||||
void downloadSelectedItem(const QModelIndex& index);
|
|
||||||
void startSearchHistory();
|
void startSearchHistory();
|
||||||
void updateNova();
|
void updateNova();
|
||||||
void saveSearchHistory();
|
void saveSearchHistory();
|
||||||
void saveColWidthSearchList() const;
|
|
||||||
void sortSearchList(int index);
|
|
||||||
void sortSearchListInt(int index, Qt::SortOrder sortOrder);
|
|
||||||
void sortSearchListString(int index, Qt::SortOrder sortOrder);
|
|
||||||
void on_enginesButton_clicked();
|
void on_enginesButton_clicked();
|
||||||
void loadEngineSettings();
|
|
||||||
void on_clearPatternButton_clicked();
|
void on_clearPatternButton_clicked();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user