Browse Source

Add a name filter for search results

Closes #8226
adaptive-webui-19844
thalieht 7 years ago
parent
commit
df9aa6dc36
  1. 14
      src/gui/search/searchjobwidget.cpp
  2. 3
      src/gui/search/searchjobwidget.h

14
src/gui/search/searchjobwidget.cpp

@ -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);
@ -327,6 +335,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) {

3
src/gui/search/searchjobwidget.h

@ -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;
@ -93,6 +94,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 +117,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;
}; };

Loading…
Cancel
Save