Skip to content

Commit

Permalink
FEATURE: Display close tab button into the tabs in search engine (Qt …
Browse files Browse the repository at this point in the history
…>= 4.5 only)
  • Loading branch information
Christophe Dumez committed Nov 26, 2009
1 parent 77ded75 commit 893c5e6
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 3 deletions.
1 change: 1 addition & 0 deletions Changelog
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
- FEATURE: Added option to download first and last piece of a torrent main file first (for preview)
- FEATURE: Graphically display piece availability in torrent properties
- FEATURE: Dropped Qt 4.3 support (Qt >= 4.4 is now required)
- FEATURE: Display close tab button into the tabs in search engine (Qt >= 4.5 only)
- FEATURE: Show official documentation when pressing F1 key
- FEATURE: Announce to all trackers specified for a torrent (µTorrent behavior) (libtorrent >= v0.15 only)
- FEATURE: Added per-torrent super seeding mode (libtorrent >= v0.15 only)
Expand Down
5 changes: 4 additions & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ cat >$1/modules.cpp <<EOT
#line 1 "qt4.qcm"
/*
-----BEGIN QCMOD-----
name: Qt >= 4.3
name: Qt >= 4.4
-----END QCMOD-----
*/
class qc_qt4 : public ConfObj
Expand All @@ -284,6 +284,9 @@ public:
QString shortname() const { return "Qt 4.4"; }
bool exec()
{
if(QT_VERSION >= 0x040500) {
conf->addDefine("QT_4_5");
}
return(QT_VERSION >= 0x040400);
}
Expand Down
5 changes: 4 additions & 1 deletion qcm/qt4.qcm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
-----BEGIN QCMOD-----
name: Qt >= 4.3
name: Qt >= 4.4
-----END QCMOD-----
*/
class qc_qt4 : public ConfObj
Expand All @@ -11,6 +11,9 @@ public:
QString shortname() const { return "Qt 4.4"; }
bool exec()
{
if(QT_VERSION >= 0x040500) {
conf->addDefine("QT_4_5");
}
return(QT_VERSION >= 0x040400);

}
Expand Down
32 changes: 31 additions & 1 deletion src/searchengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,17 @@ SearchEngine::SearchEngine(GUI *parent, Bittorrent *BTSession) : QWidget(parent)
// new qCompleter to the search pattern
startSearchHistory();
createCompleter();
#ifdef QT_4_5
tabWidget->setTabsClosable(true);
connect(tabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int)));
#else
// Add close tab button
closeTab_button = new QPushButton();
closeTab_button->setIcon(QIcon(QString::fromUtf8(":/Icons/oxygen/tab-close.png")));
closeTab_button->setFlat(true);
connect(closeTab_button, SIGNAL(clicked()), this, SLOT(closeTab_button_clicked()));
tabWidget->setCornerWidget(closeTab_button);
connect(closeTab_button, SIGNAL(clicked()), this, SLOT(closeTab_button_clicked()));
#endif
// Boolean initialization
search_stopped = false;
// Creating Search Process
Expand Down Expand Up @@ -113,6 +118,9 @@ SearchEngine::~SearchEngine(){
downloader->waitForFinished();
delete downloader;
}
#ifndef QT_4_5
delete closeTab_button;
#endif
delete searchTimeout;
delete searchProcess;
delete supported_engines;
Expand Down Expand Up @@ -214,7 +222,9 @@ void SearchEngine::on_search_button_clicked(){
all_tab.append(currentSearchTab);
tabWidget->addTab(currentSearchTab, pattern);
tabWidget->setCurrentWidget(currentSearchTab);
#ifndef QT_4_5
closeTab_button->setEnabled(true);
#endif
// if the pattern is not in the pattern
QStringList wordList = searchHistory.stringList();
if(wordList.indexOf(pattern) == -1){
Expand Down Expand Up @@ -490,6 +500,25 @@ void SearchEngine::appendSearchResult(QString line){
download_button->setEnabled(true);
}

#ifdef QT_4_5
void SearchEngine::closeTab(int index) {
if(index == tabWidget->indexOf(currentSearchTab)) {
qDebug("Deleted current search Tab");
if(searchProcess->state() != QProcess::NotRunning){
searchProcess->terminate();
}
if(searchTimeout->isActive()) {
searchTimeout->stop();
}
search_stopped = true;
currentSearchTab = 0;
}
delete all_tab.takeAt(tabWidget->currentIndex());
if(!all_tab.size()) {
download_button->setEnabled(false);
}
}
#else
// Clear search results list
void SearchEngine::closeTab_button_clicked(){
if(all_tab.size()) {
Expand All @@ -513,6 +542,7 @@ void SearchEngine::closeTab_button_clicked(){
}
}
}
#endif

// Download selected items in search results list
void SearchEngine::on_download_button_clicked(){
Expand Down
6 changes: 6 additions & 0 deletions src/searchengine.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ class SearchEngine : public QWidget, public Ui::search_engine{
SupportedEngines *supported_engines;
QTimer *searchTimeout;
SearchTab *currentSearchTab;
#ifndef QT_4_5
QPushButton *closeTab_button;
#endif
QList<SearchTab*> all_tab; // To store all tabs
const SearchCategories full_cat_names;
GUI *parent;
Expand Down Expand Up @@ -104,7 +106,11 @@ protected slots:
// Search slots
void tab_changed(int);//to prevent the use of the download button when the tab is empty
void on_search_button_clicked();
#ifdef QT_4_5
void closeTab(int index);
#else
void closeTab_button_clicked();
#endif
void appendSearchResult(QString line);
void searchFinished(int exitcode,QProcess::ExitStatus);
void readSearchOutput();
Expand Down

0 comments on commit 893c5e6

Please sign in to comment.