mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-30 20:28:05 -06:00
Allow to use regular expression to filter torrent content
PR #20944. Closes #19934.
This commit is contained in:
committed by
sledgehammer999
parent
5e5aa8a563
commit
c2cf898ccd
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* Copyright (C) 2022 Vladimir Golovnev <glassez@yandex.ru>
|
||||
* Copyright (C) 2022-2024 Vladimir Golovnev <glassez@yandex.ru>
|
||||
* Copyright (C) 2014 Ivan Sorokin <vanyacpp@gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -173,10 +173,20 @@ Path TorrentContentWidget::getItemPath(const QModelIndex &index) const
|
||||
return path;
|
||||
}
|
||||
|
||||
void TorrentContentWidget::setFilterPattern(const QString &patternText)
|
||||
void TorrentContentWidget::setFilterPattern(const QString &patternText, const FilterPatternFormat format)
|
||||
{
|
||||
const QString pattern = Utils::String::wildcardToRegexPattern(patternText);
|
||||
m_filterModel->setFilterRegularExpression(QRegularExpression(pattern, QRegularExpression::CaseInsensitiveOption));
|
||||
if (format == FilterPatternFormat::PlainText)
|
||||
{
|
||||
m_filterModel->setFilterFixedString(patternText);
|
||||
m_filterModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
|
||||
}
|
||||
else
|
||||
{
|
||||
const QString pattern = ((format == FilterPatternFormat::Regex)
|
||||
? patternText : Utils::String::wildcardToRegexPattern(patternText));
|
||||
m_filterModel->setFilterRegularExpression(QRegularExpression(pattern, QRegularExpression::CaseInsensitiveOption));
|
||||
}
|
||||
|
||||
if (patternText.isEmpty())
|
||||
{
|
||||
collapseAll();
|
||||
|
||||
Reference in New Issue
Block a user