mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-23 21:14:33 +00:00
Merge pull request #8538 from thalieht/searchFilter
Add a name filter for search results
This commit is contained in:
commit
6c9a4df515
@ -890,7 +890,7 @@ void MainWindow::createKeyboardShortcuts()
|
|||||||
connect(switchRSSShortcut, &QShortcut::activated, this, static_cast<Func>(&MainWindow::displayRSSTab));
|
connect(switchRSSShortcut, &QShortcut::activated, this, static_cast<Func>(&MainWindow::displayRSSTab));
|
||||||
QShortcut *switchExecutionLogShortcut = new QShortcut(Qt::ALT + Qt::Key_4, this);
|
QShortcut *switchExecutionLogShortcut = new QShortcut(Qt::ALT + Qt::Key_4, this);
|
||||||
connect(switchExecutionLogShortcut, &QShortcut::activated, this, &MainWindow::displayExecutionLogTab);
|
connect(switchExecutionLogShortcut, &QShortcut::activated, this, &MainWindow::displayExecutionLogTab);
|
||||||
QShortcut *switchSearchFilterShortcut = new QShortcut(QKeySequence::Find, this);
|
QShortcut *switchSearchFilterShortcut = new QShortcut(QKeySequence::Find, m_transferListWidget);
|
||||||
connect(switchSearchFilterShortcut, &QShortcut::activated, this, &MainWindow::focusSearchFilter);
|
connect(switchSearchFilterShortcut, &QShortcut::activated, this, &MainWindow::focusSearchFilter);
|
||||||
|
|
||||||
m_ui->actionDocumentation->setShortcut(QKeySequence::HelpContents);
|
m_ui->actionDocumentation->setShortcut(QKeySequence::HelpContents);
|
||||||
|
@ -49,9 +49,11 @@
|
|||||||
#include "base/utils/misc.h"
|
#include "base/utils/misc.h"
|
||||||
#include "addnewtorrentdialog.h"
|
#include "addnewtorrentdialog.h"
|
||||||
#include "guiiconprovider.h"
|
#include "guiiconprovider.h"
|
||||||
|
#include "lineedit.h"
|
||||||
#include "searchlistdelegate.h"
|
#include "searchlistdelegate.h"
|
||||||
#include "searchsortmodel.h"
|
#include "searchsortmodel.h"
|
||||||
#include "ui_searchjobwidget.h"
|
#include "ui_searchjobwidget.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
SearchJobWidget::SearchJobWidget(SearchHandler *searchHandler, QWidget *parent)
|
SearchJobWidget::SearchJobWidget(SearchHandler *searchHandler, QWidget *parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
@ -126,6 +128,12 @@ SearchJobWidget::SearchJobWidget(SearchHandler *searchHandler, QWidget *parent)
|
|||||||
|
|
||||||
updateFilter();
|
updateFilter();
|
||||||
|
|
||||||
|
m_lineEditSearchResultsFilter = new LineEdit(this);
|
||||||
|
m_lineEditSearchResultsFilter->setFixedWidth(Utils::Gui::scaledSize(this, 170));
|
||||||
|
m_lineEditSearchResultsFilter->setPlaceholderText(tr("Filter search results..."));
|
||||||
|
m_ui->horizontalLayout->insertWidget(0, m_lineEditSearchResultsFilter);
|
||||||
|
|
||||||
|
connect(m_lineEditSearchResultsFilter, &LineEdit::textChanged, this, &SearchJobWidget::filterSearchResults);
|
||||||
connect(m_ui->filterMode, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged)
|
connect(m_ui->filterMode, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged)
|
||||||
, this, &SearchJobWidget::updateFilter);
|
, this, &SearchJobWidget::updateFilter);
|
||||||
connect(m_ui->minSeeds, &QAbstractSpinBox::editingFinished, this, &SearchJobWidget::updateFilter);
|
connect(m_ui->minSeeds, &QAbstractSpinBox::editingFinished, this, &SearchJobWidget::updateFilter);
|
||||||
@ -190,6 +198,11 @@ int SearchJobWidget::visibleResultsCount() const
|
|||||||
return m_proxyModel->rowCount();
|
return m_proxyModel->rowCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LineEdit *SearchJobWidget::lineEditSearchResultsFilter() const
|
||||||
|
{
|
||||||
|
return m_lineEditSearchResultsFilter;
|
||||||
|
}
|
||||||
|
|
||||||
void SearchJobWidget::cancelSearch()
|
void SearchJobWidget::cancelSearch()
|
||||||
{
|
{
|
||||||
m_searchHandler->cancelSearch();
|
m_searchHandler->cancelSearch();
|
||||||
@ -327,6 +340,12 @@ void SearchJobWidget::fillFilterComboBoxes()
|
|||||||
m_ui->filterMode->setCurrentIndex((index == -1) ? 0 : index);
|
m_ui->filterMode->setCurrentIndex((index == -1) ? 0 : index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SearchJobWidget::filterSearchResults(const QString &name)
|
||||||
|
{
|
||||||
|
m_proxyModel->setFilterRegExp(QRegExp(name, Qt::CaseInsensitive));
|
||||||
|
updateResultsCount();
|
||||||
|
}
|
||||||
|
|
||||||
QString SearchJobWidget::statusText(SearchJobWidget::Status st)
|
QString SearchJobWidget::statusText(SearchJobWidget::Status st)
|
||||||
{
|
{
|
||||||
switch (st) {
|
switch (st) {
|
||||||
|
@ -41,6 +41,7 @@ class QStandardItemModel;
|
|||||||
|
|
||||||
template <typename T> class CachedSettingValue;
|
template <typename T> class CachedSettingValue;
|
||||||
|
|
||||||
|
class LineEdit;
|
||||||
class SearchHandler;
|
class SearchHandler;
|
||||||
class SearchListDelegate;
|
class SearchListDelegate;
|
||||||
class SearchSortModel;
|
class SearchSortModel;
|
||||||
@ -78,6 +79,7 @@ public:
|
|||||||
|
|
||||||
Status status() const;
|
Status status() const;
|
||||||
int visibleResultsCount() const;
|
int visibleResultsCount() const;
|
||||||
|
LineEdit *lineEditSearchResultsFilter() const;
|
||||||
|
|
||||||
void cancelSearch();
|
void cancelSearch();
|
||||||
|
|
||||||
@ -93,6 +95,7 @@ private:
|
|||||||
void loadSettings();
|
void loadSettings();
|
||||||
void saveSettings() const;
|
void saveSettings() const;
|
||||||
void updateFilter();
|
void updateFilter();
|
||||||
|
void filterSearchResults(const QString &name);
|
||||||
void displayToggleColumnsMenu(const QPoint&);
|
void displayToggleColumnsMenu(const QPoint&);
|
||||||
void onItemDoubleClicked(const QModelIndex &index);
|
void onItemDoubleClicked(const QModelIndex &index);
|
||||||
void searchFinished(bool cancelled);
|
void searchFinished(bool cancelled);
|
||||||
@ -115,6 +118,7 @@ private:
|
|||||||
QStandardItemModel *m_searchListModel;
|
QStandardItemModel *m_searchListModel;
|
||||||
SearchSortModel *m_proxyModel;
|
SearchSortModel *m_proxyModel;
|
||||||
SearchListDelegate *m_searchDelegate;
|
SearchListDelegate *m_searchDelegate;
|
||||||
|
LineEdit *m_lineEditSearchResultsFilter;
|
||||||
Status m_status = Status::Ongoing;
|
Status m_status = Status::Ongoing;
|
||||||
bool m_noSearchResults = true;
|
bool m_noSearchResults = true;
|
||||||
};
|
};
|
||||||
|
@ -41,6 +41,7 @@
|
|||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
|
#include <QShortcut>
|
||||||
#include <QSignalMapper>
|
#include <QSignalMapper>
|
||||||
#include <QSortFilterProxyModel>
|
#include <QSortFilterProxyModel>
|
||||||
#include <QStandardItemModel>
|
#include <QStandardItemModel>
|
||||||
@ -154,6 +155,9 @@ SearchWidget::SearchWidget(MainWindow *mainWindow)
|
|||||||
, this, &SearchWidget::selectMultipleBox);
|
, this, &SearchWidget::selectMultipleBox);
|
||||||
connect(m_ui->selectPlugin, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged)
|
connect(m_ui->selectPlugin, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged)
|
||||||
, this, &SearchWidget::fillCatCombobox);
|
, this, &SearchWidget::fillCatCombobox);
|
||||||
|
|
||||||
|
m_focusSearchHotkey = new QShortcut(QKeySequence::Find, this);
|
||||||
|
connect(m_focusSearchHotkey, &QShortcut::activated, this, &SearchWidget::toggleFocusBetweenLineEdits);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SearchWidget::fillCatCombobox()
|
void SearchWidget::fillCatCombobox()
|
||||||
@ -260,6 +264,18 @@ void SearchWidget::selectMultipleBox(int index)
|
|||||||
on_pluginsButton_clicked();
|
on_pluginsButton_clicked();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SearchWidget::toggleFocusBetweenLineEdits()
|
||||||
|
{
|
||||||
|
if (m_ui->lineEditSearchPattern->hasFocus() && m_currentSearchTab) {
|
||||||
|
m_currentSearchTab->lineEditSearchResultsFilter()->setFocus();
|
||||||
|
m_currentSearchTab->lineEditSearchResultsFilter()->selectAll();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
m_ui->lineEditSearchPattern->setFocus();
|
||||||
|
m_ui->lineEditSearchPattern->selectAll();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void SearchWidget::on_pluginsButton_clicked()
|
void SearchWidget::on_pluginsButton_clicked()
|
||||||
{
|
{
|
||||||
new PluginSelectDialog(SearchPluginManager::instance(), this);
|
new PluginSelectDialog(SearchPluginManager::instance(), this);
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
|
class QShortcut;
|
||||||
class QSignalMapper;
|
class QSignalMapper;
|
||||||
class QTabWidget;
|
class QTabWidget;
|
||||||
|
|
||||||
@ -68,6 +69,7 @@ private:
|
|||||||
void resultsCountUpdated();
|
void resultsCountUpdated();
|
||||||
void tabStatusChanged(QWidget *tab);
|
void tabStatusChanged(QWidget *tab);
|
||||||
void selectMultipleBox(int index);
|
void selectMultipleBox(int index);
|
||||||
|
void toggleFocusBetweenLineEdits();
|
||||||
|
|
||||||
void fillCatCombobox();
|
void fillCatCombobox();
|
||||||
void fillPluginComboBox();
|
void fillPluginComboBox();
|
||||||
@ -85,4 +87,5 @@ private:
|
|||||||
QList<SearchJobWidget *> m_allTabs; // To store all tabs
|
QList<SearchJobWidget *> m_allTabs; // To store all tabs
|
||||||
MainWindow *m_mainWindow;
|
MainWindow *m_mainWindow;
|
||||||
bool m_isNewQueryString;
|
bool m_isNewQueryString;
|
||||||
|
QShortcut *m_focusSearchHotkey;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user