mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-23 04:54:18 +00:00
Disable search completion (closes #89)
This commit is contained in:
parent
2a5c9ae382
commit
c79e801929
@ -30,7 +30,6 @@
|
|||||||
|
|
||||||
#include <QStandardItemModel>
|
#include <QStandardItemModel>
|
||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
#include <QCompleter>
|
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QTemporaryFile>
|
#include <QTemporaryFile>
|
||||||
#include <QSystemTrayIcon>
|
#include <QSystemTrayIcon>
|
||||||
@ -76,9 +75,6 @@ SearchEngine::SearchEngine(MainWindow* parent)
|
|||||||
download_button->setIcon(IconProvider::instance()->getIcon("download"));
|
download_button->setIcon(IconProvider::instance()->getIcon("download"));
|
||||||
goToDescBtn->setIcon(IconProvider::instance()->getIcon("application-x-mswinurl"));
|
goToDescBtn->setIcon(IconProvider::instance()->getIcon("application-x-mswinurl"));
|
||||||
enginesButton->setIcon(IconProvider::instance()->getIcon("preferences-system-network"));
|
enginesButton->setIcon(IconProvider::instance()->getIcon("preferences-system-network"));
|
||||||
// new qCompleter to the search pattern
|
|
||||||
startSearchHistory();
|
|
||||||
createCompleter();
|
|
||||||
tabWidget->setTabsClosable(true);
|
tabWidget->setTabsClosable(true);
|
||||||
connect(tabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int)));
|
connect(tabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int)));
|
||||||
// Boolean initialization
|
// Boolean initialization
|
||||||
@ -106,7 +102,6 @@ SearchEngine::SearchEngine(MainWindow* parent)
|
|||||||
// Fill in category combobox
|
// Fill in category combobox
|
||||||
fillCatCombobox();
|
fillCatCombobox();
|
||||||
|
|
||||||
connect(search_pattern, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(displayPatternContextMenu(QPoint)));
|
|
||||||
connect(search_pattern, SIGNAL(textEdited(QString)), this, SLOT(searchTextEdited(QString)));
|
connect(search_pattern, SIGNAL(textEdited(QString)), this, SLOT(searchTextEdited(QString)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,8 +180,6 @@ QString SearchEngine::selectedCategory() const {
|
|||||||
|
|
||||||
SearchEngine::~SearchEngine() {
|
SearchEngine::~SearchEngine() {
|
||||||
qDebug("Search destruction");
|
qDebug("Search destruction");
|
||||||
// save the searchHistory for later uses
|
|
||||||
saveSearchHistory();
|
|
||||||
searchProcess->kill();
|
searchProcess->kill();
|
||||||
searchProcess->waitForFinished();
|
searchProcess->waitForFinished();
|
||||||
foreach (QProcess *downloader, downloaders) {
|
foreach (QProcess *downloader, downloaders) {
|
||||||
@ -201,53 +194,6 @@ SearchEngine::~SearchEngine() {
|
|||||||
delete searchTimeout;
|
delete searchTimeout;
|
||||||
delete searchProcess;
|
delete searchProcess;
|
||||||
delete supported_engines;
|
delete supported_engines;
|
||||||
if (searchCompleter)
|
|
||||||
delete searchCompleter;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SearchEngine::displayPatternContextMenu(QPoint) {
|
|
||||||
QMenu myMenu(this);
|
|
||||||
QAction cutAct(IconProvider::instance()->getIcon("edit-cut"), tr("Cut"), &myMenu);
|
|
||||||
QAction copyAct(IconProvider::instance()->getIcon("edit-copy"), tr("Copy"), &myMenu);
|
|
||||||
QAction pasteAct(IconProvider::instance()->getIcon("edit-paste"), tr("Paste"), &myMenu);
|
|
||||||
QAction clearAct(IconProvider::instance()->getIcon("edit-clear"), tr("Clear field"), &myMenu);
|
|
||||||
QAction clearHistoryAct(IconProvider::instance()->getIcon("edit-clear-history"), tr("Clear completion history"), &myMenu);
|
|
||||||
bool hasCopyAct = false;
|
|
||||||
if (search_pattern->hasSelectedText()) {
|
|
||||||
myMenu.addAction(&cutAct);
|
|
||||||
myMenu.addAction(©Act);
|
|
||||||
hasCopyAct = true;
|
|
||||||
}
|
|
||||||
if (qApp->clipboard()->mimeData()->hasText()) {
|
|
||||||
myMenu.addAction(&pasteAct);
|
|
||||||
hasCopyAct = true;
|
|
||||||
}
|
|
||||||
if (hasCopyAct)
|
|
||||||
myMenu.addSeparator();
|
|
||||||
myMenu.addAction(&clearHistoryAct);
|
|
||||||
myMenu.addAction(&clearAct);
|
|
||||||
QAction *act = myMenu.exec(QCursor::pos());
|
|
||||||
if (act != 0) {
|
|
||||||
if (act == &clearHistoryAct) {
|
|
||||||
// Ask for confirmation
|
|
||||||
if (QMessageBox::question(this, tr("Confirmation"), tr("Are you sure you want to clear the history?"), QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes) == QMessageBox::Yes) {
|
|
||||||
// Clear history
|
|
||||||
searchHistory.setStringList(QStringList());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (act == &pasteAct) {
|
|
||||||
search_pattern->paste();
|
|
||||||
}
|
|
||||||
else if (act == &cutAct) {
|
|
||||||
search_pattern->cut();
|
|
||||||
}
|
|
||||||
else if (act == ©Act) {
|
|
||||||
search_pattern->copy();
|
|
||||||
}
|
|
||||||
else if (act == &clearAct) {
|
|
||||||
search_pattern->clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SearchEngine::tab_changed(int t)
|
void SearchEngine::tab_changed(int t)
|
||||||
@ -270,18 +216,6 @@ void SearchEngine::on_enginesButton_clicked() {
|
|||||||
connect(dlg, SIGNAL(enginesChanged()), this, SLOT(fillCatCombobox()));
|
connect(dlg, SIGNAL(enginesChanged()), this, SLOT(fillCatCombobox()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the last searchs from a QIniSettings to a QStringList
|
|
||||||
void SearchEngine::startSearchHistory() {
|
|
||||||
QIniSettings settings("qBittorrent", "qBittorrent");
|
|
||||||
searchHistory.setStringList(settings.value("Search/searchHistory",QStringList()).toStringList());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save the history list into the QIniSettings for the next session
|
|
||||||
void SearchEngine::saveSearchHistory() {
|
|
||||||
QIniSettings settings("qBittorrent", "qBittorrent");
|
|
||||||
settings.setValue("Search/searchHistory",searchHistory.stringList());
|
|
||||||
}
|
|
||||||
|
|
||||||
void SearchEngine::searchTextEdited(QString) {
|
void SearchEngine::searchTextEdited(QString) {
|
||||||
// Enable search button
|
// Enable search button
|
||||||
search_button->setText(tr("Search"));
|
search_button->setText(tr("Search"));
|
||||||
@ -337,16 +271,6 @@ void SearchEngine::on_search_button_clicked() {
|
|||||||
tabName.replace(QRegExp("&{1}"), "&&");
|
tabName.replace(QRegExp("&{1}"), "&&");
|
||||||
tabWidget->addTab(currentSearchTab, tabName);
|
tabWidget->addTab(currentSearchTab, tabName);
|
||||||
tabWidget->setCurrentWidget(currentSearchTab);
|
tabWidget->setCurrentWidget(currentSearchTab);
|
||||||
// if the pattern is not in the pattern
|
|
||||||
QStringList wordList = searchHistory.stringList();
|
|
||||||
if (wordList.indexOf(pattern) == -1) {
|
|
||||||
//update the searchHistory list
|
|
||||||
wordList.append(pattern);
|
|
||||||
// verify the max size of the history
|
|
||||||
if (wordList.size() > SEARCHHISTORY_MAXSIZE)
|
|
||||||
wordList = wordList.mid(wordList.size()/2);
|
|
||||||
searchHistory.setStringList(wordList);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Getting checked search engines
|
// Getting checked search engines
|
||||||
QStringList params;
|
QStringList params;
|
||||||
@ -367,14 +291,6 @@ void SearchEngine::on_search_button_clicked() {
|
|||||||
searchTimeout->start(180000); // 3min
|
searchTimeout->start(180000); // 3min
|
||||||
}
|
}
|
||||||
|
|
||||||
void SearchEngine::createCompleter() {
|
|
||||||
if (searchCompleter)
|
|
||||||
delete searchCompleter;
|
|
||||||
searchCompleter = new QCompleter(&searchHistory);
|
|
||||||
searchCompleter->setCaseSensitivity(Qt::CaseInsensitive);
|
|
||||||
search_pattern->setCompleter(searchCompleter);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SearchEngine::propagateSectionResized(int index, int , int newsize) {
|
void SearchEngine::propagateSectionResized(int index, int , int newsize) {
|
||||||
foreach (SearchTab * tab, all_tab) {
|
foreach (SearchTab * tab, all_tab) {
|
||||||
tab->getCurrentTreeView()->setColumnWidth(index, newsize);
|
tab->getCurrentTreeView()->setColumnWidth(index, newsize);
|
||||||
|
@ -100,15 +100,11 @@ protected slots:
|
|||||||
void searchFinished(int exitcode,QProcess::ExitStatus);
|
void searchFinished(int exitcode,QProcess::ExitStatus);
|
||||||
void readSearchOutput();
|
void readSearchOutput();
|
||||||
void searchStarted();
|
void searchStarted();
|
||||||
void startSearchHistory();
|
|
||||||
void updateNova();
|
void updateNova();
|
||||||
void saveSearchHistory();
|
|
||||||
void on_enginesButton_clicked();
|
void on_enginesButton_clicked();
|
||||||
void propagateSectionResized(int index, int oldsize , int newsize);
|
void propagateSectionResized(int index, int oldsize , int newsize);
|
||||||
void saveResultsColumnsWidth();
|
void saveResultsColumnsWidth();
|
||||||
void downloadFinished(int exitcode, QProcess::ExitStatus);
|
void downloadFinished(int exitcode, QProcess::ExitStatus);
|
||||||
void displayPatternContextMenu(QPoint);
|
|
||||||
void createCompleter();
|
|
||||||
void fillCatCombobox();
|
void fillCatCombobox();
|
||||||
void searchTextEdited(QString);
|
void searchTextEdited(QString);
|
||||||
#ifdef Q_WS_WIN
|
#ifdef Q_WS_WIN
|
||||||
@ -130,8 +126,6 @@ private:
|
|||||||
bool no_search_results;
|
bool no_search_results;
|
||||||
QByteArray search_result_line_truncated;
|
QByteArray search_result_line_truncated;
|
||||||
unsigned long nb_search_results;
|
unsigned long nb_search_results;
|
||||||
QPointer<QCompleter> searchCompleter;
|
|
||||||
QStringListModel searchHistory;
|
|
||||||
SupportedEngines *supported_engines;
|
SupportedEngines *supported_engines;
|
||||||
QTimer *searchTimeout;
|
QTimer *searchTimeout;
|
||||||
QPointer<SearchTab> currentSearchTab;
|
QPointer<SearchTab> currentSearchTab;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user