Browse Source

added autocompletion to search engine

adaptive-webui-19844
Arnaud Demaiziere 18 years ago
parent
commit
8df90e2567
  1. 1
      Changelog
  2. 1
      TODO
  3. 46
      src/GUI.cpp
  4. 5
      src/GUI.h

1
Changelog

@ -10,6 +10,7 @@ @@ -10,6 +10,7 @@
- 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: Implemented close to systray
- FEATURE: Added Autocompletion to search engine
- BUGFIX: Two torrents can now have the same name although they are different
- BUGFIX: Fixed download from url that would fail sometimes
- BUGFIX: Save directory was reset to default when filtering files in torrent

1
TODO

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

46
src/GUI.cpp

@ -34,6 +34,7 @@ @@ -34,6 +34,7 @@
#include <QScrollBar>
#include <QSettings>
#include <QDesktopServices>
#include <QCompleter>
#include <boost/format.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
@ -53,6 +54,8 @@ @@ -53,6 +54,8 @@
#include "downloadFromURLImp.h"
#include "torrentAddition.h"
#define SEARCHHISTORY_MAXSIZE 50
/*****************************************************
* *
* GUI *
@ -64,8 +67,8 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent){ @@ -64,8 +67,8 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent){
setupUi(this);
setWindowTitle(tr("qBittorrent ")+VERSION);
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
this->setWindowIcon(QIcon(QString::fromUtf8(":/Icons/qbittorrent32.png")));
actionOpen->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/open.png")));
@ -215,6 +218,14 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent){ @@ -215,6 +218,14 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent){
if(!loadColWidthSearchList()){
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
search_stopped = false;
// Connect signals to slots (search part)
@ -256,6 +267,7 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent){ @@ -256,6 +267,7 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent){
// Destructor
GUI::~GUI(){
qDebug("GUI destruction");
delete options;
delete checkConnect;
delete timerScan;
@ -876,6 +888,8 @@ void GUI::closeEvent(QCloseEvent *e){ @@ -876,6 +888,8 @@ void GUI::closeEvent(QCloseEvent *e){
return;
}
}
// save the searchHistory for later uses
saveSearchHistory();
// Save DHT entry
if(DHTEnabled){
try{
@ -1923,6 +1937,23 @@ void GUI::checkConnectionStatus(){ @@ -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
void GUI::on_search_button_clicked(){
QString pattern = search_pattern->text().trimmed();
@ -1931,6 +1962,19 @@ void GUI::on_search_button_clicked(){ @@ -1931,6 +1962,19 @@ void GUI::on_search_button_clicked(){
QMessageBox::critical(0, tr("Empty search pattern"), tr("Please type a search pattern first"));
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
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."));

5
src/GUI.h

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

Loading…
Cancel
Save