Browse Source

- Fixed row color update

- Code cleanup
adaptive-webui-19844
Christophe Dumez 17 years ago
parent
commit
95bad03321
  1. 5
      src/SearchTab.cpp
  2. 2
      src/SearchTab.h
  3. 47
      src/search.ui
  4. 41
      src/searchEngine.cpp
  5. 2
      src/searchEngine.h

5
src/SearchTab.cpp

@ -37,7 +37,7 @@
#define SEARCH_ENGINE 4 #define SEARCH_ENGINE 4
QList<SearchTab*>* SearchTab::all_tab = new QList<SearchTab*>(); 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(); box=new QVBoxLayout();
results_lbl=new QLabel(); results_lbl=new QLabel();
@ -61,14 +61,13 @@ SearchTab::SearchTab(QString &title,QTabWidget *tab_barWidget,SearchEngine *sear
resultsBrowser->header()->setSortIndicatorShown(true); resultsBrowser->header()->setSortIndicatorShown(true);
// Connect signals to slots (search part) // 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))); connect(resultsBrowser->header(), SIGNAL(sectionPressed(int)), this, SLOT(sortSearchList(int)));
// Load last columns width for search results list // Load last columns width for search results list
if(!loadColWidthSearchList()){ if(!loadColWidthSearchList()){
resultsBrowser->header()->resizeSection(0, 275); resultsBrowser->header()->resizeSection(0, 275);
} }
tab_barWidget->addTab(this, title);
all_tab->append(this); all_tab->append(this);
} }

2
src/SearchTab.h

@ -41,7 +41,7 @@ class SearchTab : public QWidget, public Ui::search_engine
SearchListDelegate *SearchDelegate; SearchListDelegate *SearchDelegate;
public: public:
static QList<SearchTab*> *all_tab; // To store all tabs static QList<SearchTab*> *all_tab; // To store all tabs
SearchTab(QString &title,QTabWidget *tab_barWidget, SearchEngine *searchEngi); SearchTab(SearchEngine *parent);
~SearchTab(); ~SearchTab();
bool loadColWidthSearchList(); bool loadColWidthSearchList();
QLabel * getCurrentLabel(); QLabel * getCurrentLabel();

47
src/search.ui

@ -18,16 +18,7 @@
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin" > <property name="margin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
@ -76,7 +67,8 @@
<string/> <string/>
</property> </property>
<property name="icon" > <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>
<property name="iconSize" > <property name="iconSize" >
<size> <size>
@ -185,7 +177,7 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" > <property name="sizeHint" stdset="0" >
<size> <size>
<width>188</width> <width>188</width>
<height>21</height> <height>21</height>
@ -196,24 +188,14 @@
</layout> </layout>
</item> </item>
<item> <item>
<widget class="QTabWidget" name="tabWidget" > <widget class="QTabWidget" name="tabWidget" />
</widget>
</item> </item>
<item> <item>
<layout class="QVBoxLayout" > <layout class="QVBoxLayout" >
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin" > <property name="margin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
@ -221,16 +203,7 @@
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin" > <property name="margin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
@ -244,12 +217,12 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="clear_button" > <widget class="QPushButton" name="closeTab_button" >
<property name="enabled" > <property name="enabled" >
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="text" > <property name="text" >
<string>Clear</string> <string>Close tab</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -258,7 +231,7 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" > <property name="sizeHint" stdset="0" >
<size> <size>
<width>601</width> <width>601</width>
<height>20</height> <height>20</height>

41
src/searchEngine.cpp

@ -128,13 +128,15 @@ 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 SearchTab(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"));
return; 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 the pattern is not in the pattern
if(searchHistory.indexOf(pattern) == -1){ if(searchHistory.indexOf(pattern) == -1){
//update the searchHistory list //update the searchHistory list
@ -187,7 +189,7 @@ void SearchEngine::downloadSelectedItem(const QModelIndex& index){
// Download from url // Download from url
BTSession->downloadFromUrl(url); BTSession->downloadFromUrl(url);
// Set item color to RED // 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 // search Qprocess return output as soon as it gets new
@ -326,7 +328,6 @@ void SearchEngine::appendSearchResult(QString line){
no_search_results = false; no_search_results = false;
++nb_search_results; ++nb_search_results;
// Enable clear & download buttons // Enable clear & download buttons
clear_button->setEnabled(true);
download_button->setEnabled(true); download_button->setEnabled(true);
} }
@ -339,21 +340,21 @@ void SearchEngine::on_stop_search_button_clicked(){
} }
// Clear search results list // Clear search results list
void SearchEngine::on_clear_button_clicked(){ void SearchEngine::on_closeTab_button_clicked(){
// Kill process //// Kill process
searchProcess->terminate(); //searchProcess->terminate();
search_stopped = true; //search_stopped = true;
searchTimeout->stop(); //searchTimeout->stop();
searchResultsUrls.clear(); //searchResultsUrls.clear();
tab_search->getCurrentSearchListModel()->removeRows(0, tab_search->getCurrentSearchListModel()->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;
tab_search->getCurrentLabel()->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();
} }
void SearchEngine::on_clearPatternButton_clicked() { void SearchEngine::on_clearPatternButton_clicked() {
@ -371,7 +372,7 @@ void SearchEngine::on_download_button_clicked(){
// 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);
tab_search->setRowColor(index.row(), "red"); SearchTab::all_tab->at(tabWidget->currentIndex())->setRowColor(index.row(), "red");
} }
} }
} }

2
src/searchEngine.h

@ -67,7 +67,7 @@ class SearchEngine : public QWidget, public Ui::search_engine{
// 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_closeTab_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();

Loading…
Cancel
Save