mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-27 03:39:39 +03:00
- Fixed row color update
- Code cleanup
This commit is contained in:
parent
cecd1e11b1
commit
95bad03321
5 changed files with 35 additions and 62 deletions
|
@ -37,7 +37,7 @@
|
|||
#define SEARCH_ENGINE 4
|
||||
|
||||
QList<SearchTab*>* SearchTab::all_tab = new QList<SearchTab*>();
|
||||
SearchTab::SearchTab(QString &title,QTabWidget *tab_barWidget,SearchEngine *searchEngi) : QWidget()
|
||||
SearchTab::SearchTab(SearchEngine *parent) : QWidget()
|
||||
{
|
||||
box=new QVBoxLayout();
|
||||
results_lbl=new QLabel();
|
||||
|
@ -61,14 +61,13 @@ SearchTab::SearchTab(QString &title,QTabWidget *tab_barWidget,SearchEngine *sear
|
|||
resultsBrowser->header()->setSortIndicatorShown(true);
|
||||
|
||||
// Connect signals to slots (search part)
|
||||
connect(resultsBrowser, SIGNAL(doubleClicked(const QModelIndex&)), searchEngi, SLOT(downloadSelectedItem(const QModelIndex&)));
|
||||
connect(resultsBrowser, SIGNAL(doubleClicked(const QModelIndex&)), parent, SLOT(downloadSelectedItem(const QModelIndex&)));
|
||||
connect(resultsBrowser->header(), SIGNAL(sectionPressed(int)), this, SLOT(sortSearchList(int)));
|
||||
|
||||
// Load last columns width for search results list
|
||||
if(!loadColWidthSearchList()){
|
||||
resultsBrowser->header()->resizeSection(0, 275);
|
||||
}
|
||||
tab_barWidget->addTab(this, title);
|
||||
all_tab->append(this);
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ class SearchTab : public QWidget, public Ui::search_engine
|
|||
SearchListDelegate *SearchDelegate;
|
||||
public:
|
||||
static QList<SearchTab*> *all_tab; // To store all tabs
|
||||
SearchTab(QString &title,QTabWidget *tab_barWidget, SearchEngine *searchEngi);
|
||||
SearchTab(SearchEngine *parent);
|
||||
~SearchTab();
|
||||
bool loadColWidthSearchList();
|
||||
QLabel * getCurrentLabel();
|
||||
|
|
|
@ -18,16 +18,7 @@
|
|||
<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" >
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
|
@ -76,7 +67,8 @@
|
|||
<string/>
|
||||
</property>
|
||||
<property name="icon" >
|
||||
<iconset resource="icons.qrc" >:/Icons/edit_clear.png</iconset>
|
||||
<iconset resource="icons.qrc" >
|
||||
<normaloff>:/Icons/edit_clear.png</normaloff>:/Icons/edit_clear.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize" >
|
||||
<size>
|
||||
|
@ -185,7 +177,7 @@
|
|||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<property name="sizeHint" stdset="0" >
|
||||
<size>
|
||||
<width>188</width>
|
||||
<height>21</height>
|
||||
|
@ -196,24 +188,14 @@
|
|||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget" >
|
||||
</widget>
|
||||
<widget class="QTabWidget" name="tabWidget" />
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" >
|
||||
<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" >
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
|
@ -221,16 +203,7 @@
|
|||
<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" >
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
|
@ -244,12 +217,12 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="clear_button" >
|
||||
<widget class="QPushButton" name="closeTab_button" >
|
||||
<property name="enabled" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>Clear</string>
|
||||
<string>Close tab</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -258,7 +231,7 @@
|
|||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<property name="sizeHint" stdset="0" >
|
||||
<size>
|
||||
<width>601</width>
|
||||
<height>20</height>
|
||||
|
|
|
@ -128,13 +128,15 @@ void SearchEngine::on_search_button_clicked(){
|
|||
searchTimeout->stop();
|
||||
}
|
||||
QString pattern = search_pattern->text().trimmed();
|
||||
//AJOUT TAB obligé de passé le widget en param sinon crash
|
||||
tab_search=new SearchTab(pattern,tabWidget,this);
|
||||
// No search pattern entered
|
||||
if(pattern.isEmpty()){
|
||||
QMessageBox::critical(0, tr("Empty search pattern"), tr("Please type a search pattern first"));
|
||||
return;
|
||||
}
|
||||
// Tab Addition
|
||||
tab_search=new SearchTab(this);
|
||||
tabWidget->addTab(tab_search, pattern);
|
||||
closeTab_button->setEnabled(true);
|
||||
// if the pattern is not in the pattern
|
||||
if(searchHistory.indexOf(pattern) == -1){
|
||||
//update the searchHistory list
|
||||
|
@ -187,7 +189,7 @@ void SearchEngine::downloadSelectedItem(const QModelIndex& index){
|
|||
// Download from url
|
||||
BTSession->downloadFromUrl(url);
|
||||
// Set item color to RED
|
||||
tab_search->setRowColor(row, "red");
|
||||
SearchTab::all_tab->at(tabWidget->currentIndex())->setRowColor(row, "red");
|
||||
}
|
||||
|
||||
// search Qprocess return output as soon as it gets new
|
||||
|
@ -326,7 +328,6 @@ void SearchEngine::appendSearchResult(QString line){
|
|||
no_search_results = false;
|
||||
++nb_search_results;
|
||||
// Enable clear & download buttons
|
||||
clear_button->setEnabled(true);
|
||||
download_button->setEnabled(true);
|
||||
}
|
||||
|
||||
|
@ -339,21 +340,21 @@ void SearchEngine::on_stop_search_button_clicked(){
|
|||
}
|
||||
|
||||
// Clear search results list
|
||||
void SearchEngine::on_clear_button_clicked(){
|
||||
// Kill process
|
||||
searchProcess->terminate();
|
||||
search_stopped = true;
|
||||
searchTimeout->stop();
|
||||
searchResultsUrls.clear();
|
||||
tab_search->getCurrentSearchListModel()->removeRows(0, tab_search->getCurrentSearchListModel()->rowCount());
|
||||
// Disable clear & download buttons
|
||||
clear_button->setEnabled(false);
|
||||
download_button->setEnabled(false);
|
||||
nb_search_results = 0;
|
||||
tab_search->getCurrentLabel()->setText(tr("Results")+" <i>(0)</i>:");
|
||||
// focus on search pattern
|
||||
search_pattern->clear();
|
||||
search_pattern->setFocus();
|
||||
void SearchEngine::on_closeTab_button_clicked(){
|
||||
//// Kill process
|
||||
//searchProcess->terminate();
|
||||
//search_stopped = true;
|
||||
//searchTimeout->stop();
|
||||
//searchResultsUrls.clear();
|
||||
//tab_search->getCurrentSearchListModel()->removeRows(0, tab_search->getCurrentSearchListModel()->rowCount());
|
||||
//// Disable clear & download buttons
|
||||
//clear_button->setEnabled(false);
|
||||
//download_button->setEnabled(false);
|
||||
//nb_search_results = 0;
|
||||
//tab_search->getCurrentLabel()->setText(tr("Results")+" <i>(0)</i>:");
|
||||
//// focus on search pattern
|
||||
//search_pattern->clear();
|
||||
//search_pattern->setFocus();
|
||||
}
|
||||
|
||||
void SearchEngine::on_clearPatternButton_clicked() {
|
||||
|
@ -371,7 +372,7 @@ void SearchEngine::on_download_button_clicked(){
|
|||
// Get Item url
|
||||
QString url = searchResultsUrls.value(index.data().toString());
|
||||
BTSession->downloadFromUrl(url);
|
||||
tab_search->setRowColor(index.row(), "red");
|
||||
SearchTab::all_tab->at(tabWidget->currentIndex())->setRowColor(index.row(), "red");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ class SearchEngine : public QWidget, public Ui::search_engine{
|
|||
// Search slots
|
||||
void on_search_button_clicked();
|
||||
void on_stop_search_button_clicked();
|
||||
void on_clear_button_clicked();
|
||||
void on_closeTab_button_clicked();
|
||||
void appendSearchResult(QString line);
|
||||
void searchFinished(int exitcode,QProcess::ExitStatus);
|
||||
void readSearchOutput();
|
||||
|
|
Loading…
Reference in a new issue