diff -NaurU 6 src/searchengine.orig//screenedsearch.cpp src/searchengine//screenedsearch.cpp --- src/searchengine.orig//screenedsearch.cpp 1970-01-01 01:00:00.000000000 +0100 +++ src/searchengine//screenedsearch.cpp 2011-06-04 09:59:24.330183922 +0200 @@ -0,0 +1,82 @@ +/** +* This file is part of the QBittorrent Project +* +* Bittorrent Client using Qt4 and libtorrent. +* Copyright (C) 2006 Christophe Dumez +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Library General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Library General Public License for more details. +* +* You should have received a copy of the GNU Library General Public License +* along with this library; see the file COPYING.LIB. If not, write to +* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +* Boston, MA 02110-1301, USA. +**/ + +#include "screenedsearch.h" + +/* QtCore */ +#include + +/* QtGui */ +#include +#include + +ScreenedSearch::ScreenedSearch( QWidget * parent ) + : QGroupBox ( parent ) + , characters ( 3 ) +{ + Q_ASSERT ( parent ); + setObjectName ( QLatin1String( "ScreenedSearch" ) ); + setupUi ( this ); + setEnabled( false ); + + connect ( cmdInput, SIGNAL ( textChanged ( const QString & ) ), + this, SLOT ( searchTextChanged ( const QString & ) ) ); +} + +void ScreenedSearch::searchTextChanged ( const QString &txt ) +{ + QString buffer ( txt ); + buffer.trimmed(); + + if ( buffer.length() <= charactersSet->value() ) + { + emit prepareSearchResult ( QString() ); + return; + } + + emit prepareSearchResult ( buffer ); + buffer.clear(); +} + +void ScreenedSearch::searchTextStart() +{ + searchTextChanged ( cmdInput->text() ); +} + +int ScreenedSearch::getCharacters() +{ + return charactersSet->value(); +} + +void ScreenedSearch::setCharacters ( int c ) +{ + if ( c >= 3 ) + { + characters = c; + charactersSet->setValue(c); + } +} + +ScreenedSearch::~ScreenedSearch() +{ + cmdInput->clear(); +} diff -NaurU 6 src/searchengine.orig//screenedsearch.h src/searchengine//screenedsearch.h --- src/searchengine.orig//screenedsearch.h 1970-01-01 01:00:00.000000000 +0100 +++ src/searchengine//screenedsearch.h 2011-06-04 10:11:44.057308678 +0200 @@ -0,0 +1,78 @@ +/** +* This file is part of the QBittorrent Project +* +* Bittorrent Client using Qt4 and libtorrent. +* Copyright (C) 2006 Christophe Dumez +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Library General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Library General Public License for more details. +* +* You should have received a copy of the GNU Library General Public License +* along with this library; see the file COPYING.LIB. If not, write to +* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +* Boston, MA 02110-1301, USA. +**/ + +#ifndef SCREENEDSEARCH_H +#define SCREENEDSEARCH_H + +/* QtCore */ +#include +#include +#include + +/* QtGui */ +#include +#include + +/* UI */ +#include "ui_screenedsearchmain.h" + +/** +* \class ScreenedSearch +* \short this class provides methodes for filter search results +* \author Juergen Heinemann (Undfined) http://www.hjcms.de +*/ +class ScreenedSearch : public QGroupBox, protected Ui::ScreenedSearchMain +{ + Q_OBJECT + Q_CLASSINFO ( "Author", "Jürgen Heinemann (Undefined)" ) + Q_CLASSINFO ( "URL", "http://www.hjcms.de" ) + Q_PROPERTY ( int characters READ getCharacters WRITE setCharacters ) + + private: + int characters; + + private Q_SLOTS: + void searchTextChanged ( const QString &txt ); + + Q_SIGNALS: + /** this signal is emitted whenever the text has changed more then \ref characters length! + * \param txt text to find or exclude from search result */ + void prepareSearchResult ( const QString &txt ); + + public Q_SLOTS: + void searchTextStart (); + + public: + ScreenedSearch ( QWidget * parent = 0 ); + + /** current text length when trigger \ref prepareSearchResult */ + int getCharacters(); + + /** set minimum required text length before trigger \ref prepareSearchResult + * \param c default value is minimum 3 characters */ + void setCharacters ( int c ); + + virtual ~ScreenedSearch(); + +}; + +#endif diff -NaurU 6 src/searchengine.orig//screenedsearchmain.ui src/searchengine//screenedsearchmain.ui --- src/searchengine.orig//screenedsearchmain.ui 1970-01-01 01:00:00.000000000 +0100 +++ src/searchengine//screenedsearchmain.ui 2011-06-04 09:57:02.796672105 +0200 @@ -0,0 +1,88 @@ + + + ScreenedSearchMain + + + false + + + + 0 + 0 + 652 + 58 + + + + GroupBox + + + search result optimization + + + false + + + false + + + + + + + + + + + + ... + + + Qt::ToolButtonFollowStyle + + + Qt::RightArrow + + + + + + + + + + + + + + + + 3 + + + 50 + + + + + + + + + btnClear + clicked() + cmdInput + clear() + + + 205 + 36 + + + 349 + 37 + + + + + diff -NaurU 6 src/searchengine.orig//search.ui src/searchengine//search.ui --- src/searchengine.orig//search.ui 2011-01-06 09:19:34.000000000 +0100 +++ src/searchengine//search.ui 2011-06-04 08:55:24.552980534 +0200 @@ -3,22 +3,22 @@ search_engine 0 0 - 820 - 453 + 650 + 310 Search - + 16777215 22 @@ -90,91 +90,90 @@ Stopped - + Qt::Horizontal - 188 + 361 21 - - - 6 - - - 0 + + + search result optimization + + + + + + + + false + + + Download + + + + + + + false + + + Go to description page + + + - - - 6 - - - 0 - - - - - false - - - Download - - - - - - - false - - - Go to description page - - - - - - - Qt::Horizontal - - - - 601 - 20 - - - - - - - - Search engines... - - - - + + + Qt::Horizontal + + + + 250 + 20 + + + + + + + + Search engines... + + + + + ScreenedSearch + QGroupBox +
screenedsearch.h
+ 1 +
+
search_pattern returnPressed() search_button diff -NaurU 6 src/searchengine.orig//searchengine.cpp src/searchengine//searchengine.cpp --- src/searchengine.orig//searchengine.cpp 2011-04-11 18:21:07.000000000 +0200 +++ src/searchengine//searchengine.cpp 2011-06-04 09:58:52.659740084 +0200 @@ -40,12 +40,13 @@ #include #include #include #include #include #include +#include #ifdef Q_WS_WIN #include #endif #include "searchengine.h" @@ -54,12 +55,13 @@ #include "misc.h" #include "preferences.h" #include "searchlistdelegate.h" #include "qinisettings.h" #include "mainwindow.h" #include "iconprovider.h" +#include "screenedsearch.h" #define SEARCHHISTORY_MAXSIZE 50 /*SEARCH ENGINE START*/ SearchEngine::SearchEngine(MainWindow *parent) : QWidget(parent), mp_mainWindow(parent) { setupUi(this); @@ -105,12 +107,14 @@ #endif ); // Fill in category combobox fillCatCombobox(); connect(search_pattern, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(displayPatternContextMenu(QPoint))); connect(search_pattern, SIGNAL(textEdited(QString)), this, SLOT(searchTextEdited(QString))); + connect ( m_ScreenedSearch, SIGNAL ( prepareSearchResult ( const QString & ) ), + this, SLOT ( visibleSearchResult ( const QString & ) ) ); } void SearchEngine::fillCatCombobox() { comboCategory->clear(); comboCategory->addItem(full_cat_names["all"], QVariant("all")); QStringList supported_cat = supported_engines->supportedCategories(); @@ -587,20 +591,24 @@ if(exitcode){ #ifdef Q_WS_WIN search_status->setText(tr("Search aborted")); #else search_status->setText(tr("An error occured during search...")); #endif + m_ScreenedSearch->setEnabled ( false ); }else{ if(search_stopped){ search_status->setText(tr("Search aborted")); + m_ScreenedSearch->setEnabled ( false ); }else{ if(no_search_results){ search_status->setText(tr("Search returned no results")); + m_ScreenedSearch->setEnabled ( false ); }else{ search_status->setText(tr("Search has finished")); + m_ScreenedSearch->setEnabled ( true ); } } } if(currentSearchTab) currentSearchTab->getCurrentLabel()->setText(tr("Results", "i.e: Search results")+QString::fromUtf8(" (")+QString::number(nb_search_results)+QString::fromUtf8("):")); search_button->setText("Search"); @@ -730,6 +738,15 @@ const QString desc_url = model->data(model->index(index.row(), DESC_LINK)).toString(); if(!desc_url.isEmpty()) QDesktopServices::openUrl(QUrl::fromEncoded(desc_url.toUtf8())); } } } + +void SearchEngine::visibleSearchResult ( const QString &txt ) +{ + QString find = QRegExp::escape(txt); + QRegExp regexp ( find, Qt::CaseInsensitive ); + QSortFilterProxyModel* model = all_tab.at(tabWidget->currentIndex())->getCurrentSearchListProxy(); + model->setFilterRegExp( regexp ); + model->sort( NAME, Qt::AscendingOrder ); +} diff -NaurU 6 src/searchengine.orig//searchengine.h src/searchengine//searchengine.h --- src/searchengine.orig//searchengine.h 2011-02-27 16:41:05.000000000 +0100 +++ src/searchengine//searchengine.h 2011-06-04 09:59:46.016803284 +0200 @@ -120,12 +120,13 @@ void pythonDownloadSuccess(QString url, QString file_path); void pythonDownloadFailure(QString url, QString error); #endif private slots: void on_goToDescBtn_clicked(); + void visibleSearchResult ( const QString &txt ); private: // Search related QProcess *searchProcess; QList downloaders; bool search_stopped; diff -NaurU 6 src/searchengine.orig//searchengine.pri src/searchengine//searchengine.pri --- src/searchengine.orig//searchengine.pri 2010-11-20 18:21:40.000000000 +0100 +++ src/searchengine//searchengine.pri 2011-06-04 07:11:43.551529943 +0200 @@ -1,18 +1,21 @@ INCLUDEPATH += $$PWD FORMS += $$PWD/search.ui \ $$PWD/engineselect.ui \ - $$PWD/pluginsource.ui + $$PWD/pluginsource.ui \ + $$PWD/screenedsearchmain.ui HEADERS += $$PWD/searchengine.h \ $$PWD/searchtab.h \ $$PWD/engineselectdlg.h \ $$PWD/pluginsource.h \ $$PWD/searchlistdelegate.h \ - $$PWD/supportedengines.h + $$PWD/supportedengines.h \ + $$PWD/screenedsearch.h SOURCES += $$PWD/searchengine.cpp \ $$PWD/searchtab.cpp \ - $$PWD/engineselectdlg.cpp + $$PWD/engineselectdlg.cpp \ + $$PWD/screenedsearch.cpp RESOURCES += $$PWD/search.qrc diff -NaurU 6 src/searchengine.orig//searchtab.cpp src/searchengine//searchtab.cpp --- src/searchengine.orig//searchtab.cpp 2010-12-26 10:51:37.000000000 +0100 +++ src/searchengine//searchtab.cpp 2011-06-04 08:47:57.675122591 +0200 @@ -35,23 +35,23 @@ #include #include "searchtab.h" #include "searchlistdelegate.h" #include "misc.h" #include "searchengine.h" +#include "screenedsearch.h" #include "qinisettings.h" SearchTab::SearchTab(SearchEngine *parent) : QWidget(), parent(parent) { box=new QVBoxLayout(); results_lbl=new QLabel(); resultsBrowser = new QTreeView(); resultsBrowser->setSelectionMode(QAbstractItemView::ExtendedSelection); box->addWidget(results_lbl); box->addWidget(resultsBrowser); - setLayout(box); // Set Search results list model SearchListModel = new QStandardItemModel(0, SearchEngine::NB_SEARCH_COLUMNS); SearchListModel->setHeaderData(SearchEngine::NAME, Qt::Horizontal, tr("Name", "i.e: file name")); SearchListModel->setHeaderData(SearchEngine::SIZE, Qt::Horizontal, tr("Size", "i.e: file size")); SearchListModel->setHeaderData(SearchEngine::SEEDS, Qt::Horizontal, tr("Seeders", "i.e: Number of full sources")); @@ -80,12 +80,13 @@ if(!loadColWidthResultsList()){ resultsBrowser->header()->resizeSection(0, 275); } // Sort by Seeds resultsBrowser->sortByColumn(SearchEngine::SEEDS, Qt::DescendingOrder); + } void SearchTab::downloadSelectedItem(const QModelIndex& index) { QString engine_url = proxyModel->data(proxyModel->index(index.row(), SearchEngine::ENGINE_URL)).toString(); QString torrent_url = proxyModel->data(proxyModel->index(index.row(), SearchEngine::DL_LINK)).toString(); setRowColor(index.row(), "red");