added autocompletion to search engine

This commit is contained in:
Arnaud Demaiziere 2007-03-04 17:13:29 +00:00
parent dbd6c404ec
commit 8df90e2567
4 changed files with 52 additions and 3 deletions

View file

@ -10,6 +10,7 @@
- FEATURE: User is warned when hard drive becomes full and downloads are paused - FEATURE: User is warned when hard drive becomes full and downloads are paused
- FEATURE: Number of complete/incomplete sources are now displayed in download list for each torrent - FEATURE: Number of complete/incomplete sources are now displayed in download list for each torrent
- FEATURE: Implemented close to systray - FEATURE: Implemented close to systray
- FEATURE: Added Autocompletion to search engine
- BUGFIX: Two torrents can now have the same name although they are different - BUGFIX: Two torrents can now have the same name although they are different
- BUGFIX: Fixed download from url that would fail sometimes - BUGFIX: Fixed download from url that would fail sometimes
- BUGFIX: Save directory was reset to default when filtering files in torrent - BUGFIX: Save directory was reset to default when filtering files in torrent

1
TODO
View file

@ -30,7 +30,6 @@
- Split kernel from GUI? (would be a lot better but require some deep changes) - Split kernel from GUI? (would be a lot better but require some deep changes)
- Web interface? - Web interface?
- Use downloader class to download search plugin updates - Use downloader class to download search plugin updates
- Add autocompletion in search engine
- Allow to set upload limit for each torrent - Allow to set upload limit for each torrent
- Add a torrent scheduler - Add a torrent scheduler

View file

@ -34,6 +34,7 @@
#include <QScrollBar> #include <QScrollBar>
#include <QSettings> #include <QSettings>
#include <QDesktopServices> #include <QDesktopServices>
#include <QCompleter>
#include <boost/format.hpp> #include <boost/format.hpp>
#include <boost/date_time/posix_time/posix_time.hpp> #include <boost/date_time/posix_time/posix_time.hpp>
@ -53,6 +54,8 @@
#include "downloadFromURLImp.h" #include "downloadFromURLImp.h"
#include "torrentAddition.h" #include "torrentAddition.h"
#define SEARCHHISTORY_MAXSIZE 50
/***************************************************** /*****************************************************
* * * *
* GUI * * GUI *
@ -64,8 +67,8 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent){
setupUi(this); setupUi(this);
setWindowTitle(tr("qBittorrent ")+VERSION); setWindowTitle(tr("qBittorrent ")+VERSION);
readSettings(); readSettings();
s = new session(fingerprint("qB", VERSION_MAJOR, VERSION_MINOR, VERSION_BUGFIX, 0));
s = new session(fingerprint("qB", VERSION_MAJOR, VERSION_MINOR, VERSION_BUGFIX, 0));
// Setting icons // Setting icons
this->setWindowIcon(QIcon(QString::fromUtf8(":/Icons/qbittorrent32.png"))); this->setWindowIcon(QIcon(QString::fromUtf8(":/Icons/qbittorrent32.png")));
actionOpen->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/open.png"))); actionOpen->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/open.png")));
@ -215,6 +218,14 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent){
if(!loadColWidthSearchList()){ if(!loadColWidthSearchList()){
resultsBrowser->header()->resizeSection(0, 275); resultsBrowser->header()->resizeSection(0, 275);
} }
// new qCompleter to the search pattern
startSearchHistory();
QCompleter *searchCompleter = new QCompleter(searchHistory, this);
searchCompleter->setCaseSensitivity(Qt::CaseInsensitive);
search_pattern->setCompleter(searchCompleter);
// Boolean initialization // Boolean initialization
search_stopped = false; search_stopped = false;
// Connect signals to slots (search part) // Connect signals to slots (search part)
@ -256,6 +267,7 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent){
// Destructor // Destructor
GUI::~GUI(){ GUI::~GUI(){
qDebug("GUI destruction");
delete options; delete options;
delete checkConnect; delete checkConnect;
delete timerScan; delete timerScan;
@ -876,6 +888,8 @@ void GUI::closeEvent(QCloseEvent *e){
return; return;
} }
} }
// save the searchHistory for later uses
saveSearchHistory();
// Save DHT entry // Save DHT entry
if(DHTEnabled){ if(DHTEnabled){
try{ try{
@ -1923,6 +1937,23 @@ void GUI::checkConnectionStatus(){
* * * *
*****************************************************/ *****************************************************/
// get the last searchs from a QSettings to a QStringList
void GUI::startSearchHistory(){
QSettings settings("qBittorrent", "qBittorrent");
settings.beginGroup("Search");
searchHistory = settings.value("searchHistory",-1).toStringList();
settings.endGroup();
}
// Save the history list into the QSettings for the next session
void GUI::saveSearchHistory()
{
QSettings settings("qBittorrent", "qBittorrent");
settings.beginGroup("Search");
settings.setValue("searchHistory",searchHistory);
settings.endGroup();
}
// Function called when we click on search button // Function called when we click on search button
void GUI::on_search_button_clicked(){ void GUI::on_search_button_clicked(){
QString pattern = search_pattern->text().trimmed(); QString pattern = search_pattern->text().trimmed();
@ -1931,6 +1962,19 @@ void GUI::on_search_button_clicked(){
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;
} }
// if the pattern is not in the pattern
if(searchHistory.indexOf(pattern) == -1){
//update the searchHistory list
searchHistory.append(pattern);
// verify the max size of the history
if(searchHistory.size() > SEARCHHISTORY_MAXSIZE)
searchHistory = searchHistory.mid(searchHistory.size()/2,searchHistory.size()/2);
searchCompleter = new QCompleter(searchHistory, this);
searchCompleter->setCaseSensitivity(Qt::CaseInsensitive);
search_pattern->setCompleter(searchCompleter);
}
// Getting checked search engines // Getting checked search engines
if(!mininova->isChecked() && ! piratebay->isChecked()/* && !reactor->isChecked()*/ && !isohunt->isChecked()/* && !btjunkie->isChecked()*/ && !meganova->isChecked()){ if(!mininova->isChecked() && ! piratebay->isChecked()/* && !reactor->isChecked()*/ && !isohunt->isChecked()/* && !btjunkie->isChecked()*/ && !meganova->isChecked()){
QMessageBox::critical(0, tr("No seach engine selected"), tr("You must select at least one search engine.")); QMessageBox::critical(0, tr("No seach engine selected"), tr("You must select at least one search engine."));

View file

@ -50,6 +50,7 @@
class createtorrent; class createtorrent;
class QTimer; class QTimer;
class QCompleter;
class DLListDelegate; class DLListDelegate;
class SearchListDelegate; class SearchListDelegate;
class downloadThread; class downloadThread;
@ -101,6 +102,8 @@ class GUI : public QMainWindow, private Ui::MainWindow{
unsigned long nb_search_results; unsigned long nb_search_results;
QTcpServer tcpServer; QTcpServer tcpServer;
QTcpSocket *clientConnection; QTcpSocket *clientConnection;
QCompleter *searchCompleter;
QStringList searchHistory;
protected slots: protected slots:
// GUI related slots // GUI related slots
@ -174,6 +177,8 @@ class GUI : public QMainWindow, private Ui::MainWindow{
void readSearchOutput(); void readSearchOutput();
void searchStarted(); void searchStarted();
void downloadSelectedItem(const QModelIndex& index); void downloadSelectedItem(const QModelIndex& index);
void startSearchHistory();
void saveSearchHistory();
// Utils slots // Utils slots
void setRowColor(int row, const QString& color, bool inDLList=true); void setRowColor(int row, const QString& color, bool inDLList=true);
// Options slots // Options slots