mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-23 04:54:18 +00:00
Add option for regexps in the transferlist search filter's context menu
This commit is contained in:
parent
e59841d35c
commit
2485525896
@ -1489,6 +1489,16 @@ void Preferences::setTransHeaderState(const QByteArray &state)
|
|||||||
setValue("TransferList/qt5/HeaderState", state);
|
setValue("TransferList/qt5/HeaderState", state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Preferences::getRegexAsFilteringPattern() const
|
||||||
|
{
|
||||||
|
return value("TransferList/UseRegexAsFilteringPattern", false).toBool();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Preferences::setRegexAsFilteringPattern(const bool checked)
|
||||||
|
{
|
||||||
|
setValue("TransferList/UseRegexAsFilteringPattern", checked);
|
||||||
|
}
|
||||||
|
|
||||||
// From old RssSettings class
|
// From old RssSettings class
|
||||||
bool Preferences::isRSSWidgetEnabled() const
|
bool Preferences::isRSSWidgetEnabled() const
|
||||||
{
|
{
|
||||||
|
@ -350,6 +350,8 @@ public:
|
|||||||
void setTransSelFilter(const int &index);
|
void setTransSelFilter(const int &index);
|
||||||
QByteArray getTransHeaderState() const;
|
QByteArray getTransHeaderState() const;
|
||||||
void setTransHeaderState(const QByteArray &state);
|
void setTransHeaderState(const QByteArray &state);
|
||||||
|
bool getRegexAsFilteringPattern() const;
|
||||||
|
void setRegexAsFilteringPattern(bool checked);
|
||||||
int getToolbarTextPosition() const;
|
int getToolbarTextPosition() const;
|
||||||
void setToolbarTextPosition(const int position);
|
void setToolbarTextPosition(const int position);
|
||||||
|
|
||||||
|
@ -232,9 +232,11 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
|
|
||||||
// Name filter
|
// Name filter
|
||||||
m_searchFilter = new LineEdit(this);
|
m_searchFilter = new LineEdit(this);
|
||||||
m_searchFilterAction = m_ui->toolBar->insertWidget(m_ui->actionLock, m_searchFilter);
|
|
||||||
m_searchFilter->setPlaceholderText(tr("Filter torrent list..."));
|
m_searchFilter->setPlaceholderText(tr("Filter torrent list..."));
|
||||||
m_searchFilter->setFixedWidth(Utils::Gui::scaledSize(this, 200));
|
m_searchFilter->setFixedWidth(Utils::Gui::scaledSize(this, 200));
|
||||||
|
m_searchFilter->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
connect(m_searchFilter, &QWidget::customContextMenuRequested, this, &MainWindow::showFilterContextMenu);
|
||||||
|
m_searchFilterAction = m_ui->toolBar->insertWidget(m_ui->actionLock, m_searchFilter);
|
||||||
|
|
||||||
QWidget *spacer = new QWidget(this);
|
QWidget *spacer = new QWidget(this);
|
||||||
spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||||
@ -695,6 +697,23 @@ void MainWindow::displayRSSTab(bool enable)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::showFilterContextMenu(const QPoint &)
|
||||||
|
{
|
||||||
|
const Preferences *pref = Preferences::instance();
|
||||||
|
|
||||||
|
QMenu *menu = m_searchFilter->createStandardContextMenu();
|
||||||
|
menu->addSeparator();
|
||||||
|
QAction *useRegexAct = new QAction(tr("Use regular expressions"), menu);
|
||||||
|
useRegexAct->setCheckable(true);
|
||||||
|
useRegexAct->setChecked(pref->getRegexAsFilteringPattern());
|
||||||
|
menu->addAction(useRegexAct);
|
||||||
|
|
||||||
|
connect(useRegexAct, &QAction::toggled, pref, &Preferences::setRegexAsFilteringPattern);
|
||||||
|
connect(useRegexAct, &QAction::toggled, this, [this]() { m_transferListWidget->applyNameFilter(m_searchFilter->text()); });
|
||||||
|
|
||||||
|
menu->exec(QCursor::pos());
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::displaySearchTab(bool enable)
|
void MainWindow::displaySearchTab(bool enable)
|
||||||
{
|
{
|
||||||
Preferences::instance()->setSearchEnabled(enable);
|
Preferences::instance()->setSearchEnabled(enable);
|
||||||
|
@ -102,6 +102,7 @@ public:
|
|||||||
void showNotificationBaloon(QString title, QString msg) const;
|
void showNotificationBaloon(QString title, QString msg) const;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
void showFilterContextMenu(const QPoint &);
|
||||||
void balloonClicked();
|
void balloonClicked();
|
||||||
void writeSettings();
|
void writeSettings();
|
||||||
void readSettings();
|
void readSettings();
|
||||||
|
@ -1188,7 +1188,9 @@ void TransferListWidget::applyTrackerFilter(const QStringList &hashes)
|
|||||||
|
|
||||||
void TransferListWidget::applyNameFilter(const QString &name)
|
void TransferListWidget::applyNameFilter(const QString &name)
|
||||||
{
|
{
|
||||||
m_sortFilterModel->setFilterRegExp(QRegExp(name, Qt::CaseInsensitive, QRegExp::WildcardUnix));
|
const QRegExp::PatternSyntax patternSyntax = Preferences::instance()->getRegexAsFilteringPattern()
|
||||||
|
? QRegExp::RegExp : QRegExp::WildcardUnix;
|
||||||
|
m_sortFilterModel->setFilterRegExp(QRegExp(name, Qt::CaseInsensitive, patternSyntax));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransferListWidget::applyStatusFilter(int f)
|
void TransferListWidget::applyStatusFilter(int f)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user