mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-31 08:54:26 +00:00
FEATURE: Added full regex support to RSS downloader
This commit is contained in:
parent
0a17eb32cc
commit
92c7996ff4
@ -5,6 +5,7 @@
|
|||||||
- FEATURE: Added UPnP/NAT-PMP port forward for the Web UI port
|
- FEATURE: Added UPnP/NAT-PMP port forward for the Web UI port
|
||||||
- FEATURE: qBittorrent can update dynamic DNS services (DynDNS, no-ip)
|
- FEATURE: qBittorrent can update dynamic DNS services (DynDNS, no-ip)
|
||||||
- FEATURE: Display peer connection type in peer list (BT, uTP, Web)
|
- FEATURE: Display peer connection type in peer list (BT, uTP, Web)
|
||||||
|
- FEATURE: Added full regex support to RSS downloader
|
||||||
- BUGFIX: Change systray icon on the fly (no restart needed)
|
- BUGFIX: Change systray icon on the fly (no restart needed)
|
||||||
- BUGFIX: Remember peer-level rate limits (requires libtorrent v0.16)
|
- BUGFIX: Remember peer-level rate limits (requires libtorrent v0.16)
|
||||||
- COSMETIC: Added monochrome icon for light themes
|
- COSMETIC: Added monochrome icon for light themes
|
||||||
|
@ -197,6 +197,7 @@ void AutomatedRssDownloader::updateRuleDefinitionBox()
|
|||||||
ui->lineNotContains->setText(rule.mustNotContain());
|
ui->lineNotContains->setText(rule.mustNotContain());
|
||||||
ui->saveDiffDir_check->setChecked(!rule.savePath().isEmpty());
|
ui->saveDiffDir_check->setChecked(!rule.savePath().isEmpty());
|
||||||
ui->lineSavePath->setText(rule.savePath());
|
ui->lineSavePath->setText(rule.savePath());
|
||||||
|
ui->checkRegex->setChecked(rule.useRegex());
|
||||||
if(rule.label().isEmpty()) {
|
if(rule.label().isEmpty()) {
|
||||||
ui->comboLabel->setCurrentIndex(-1);
|
ui->comboLabel->setCurrentIndex(-1);
|
||||||
ui->comboLabel->clearEditText();
|
ui->comboLabel->clearEditText();
|
||||||
@ -225,6 +226,7 @@ void AutomatedRssDownloader::clearRuleDefinitionBox()
|
|||||||
ui->saveDiffDir_check->setChecked(false);
|
ui->saveDiffDir_check->setChecked(false);
|
||||||
ui->lineSavePath->clear();
|
ui->lineSavePath->clear();
|
||||||
ui->comboLabel->clearEditText();
|
ui->comboLabel->clearEditText();
|
||||||
|
ui->checkRegex->setChecked(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
RssDownloadRule AutomatedRssDownloader::getCurrentRule() const
|
RssDownloadRule AutomatedRssDownloader::getCurrentRule() const
|
||||||
@ -261,6 +263,7 @@ void AutomatedRssDownloader::saveEditedRule()
|
|||||||
rule.setEnabled(false);
|
rule.setEnabled(false);
|
||||||
else
|
else
|
||||||
rule.setEnabled(true);
|
rule.setEnabled(true);
|
||||||
|
rule.setUseRegex(ui->checkRegex->isChecked());
|
||||||
rule.setMustContain(ui->lineContains->text());
|
rule.setMustContain(ui->lineContains->text());
|
||||||
rule.setMustNotContain(ui->lineNotContains->text());
|
rule.setMustNotContain(ui->lineNotContains->text());
|
||||||
if(ui->saveDiffDir_check->isChecked())
|
if(ui->saveDiffDir_check->isChecked())
|
||||||
|
@ -129,7 +129,7 @@
|
|||||||
<property name="bottomMargin">
|
<property name="bottomMargin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item row="0" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="QLabel" name="label_4">
|
<widget class="QLabel" name="label_4">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Must contain:</string>
|
<string>Must contain:</string>
|
||||||
@ -139,10 +139,10 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="1" column="1">
|
||||||
<widget class="QLineEdit" name="lineContains"/>
|
<widget class="QLineEdit" name="lineContains"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="2" column="0">
|
||||||
<widget class="QLabel" name="label_5">
|
<widget class="QLabel" name="label_5">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Must not contain:</string>
|
<string>Must not contain:</string>
|
||||||
@ -152,10 +152,10 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="2" column="1">
|
||||||
<widget class="QLineEdit" name="lineNotContains"/>
|
<widget class="QLineEdit" name="lineNotContains"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="4" column="0">
|
||||||
<widget class="QLabel" name="label_7">
|
<widget class="QLabel" name="label_7">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Assign label:</string>
|
<string>Assign label:</string>
|
||||||
@ -165,21 +165,21 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1">
|
<item row="4" column="1">
|
||||||
<widget class="QComboBox" name="comboLabel">
|
<widget class="QComboBox" name="comboLabel">
|
||||||
<property name="editable">
|
<property name="editable">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0" colspan="2">
|
<item row="5" column="0" colspan="2">
|
||||||
<widget class="QCheckBox" name="saveDiffDir_check">
|
<widget class="QCheckBox" name="saveDiffDir_check">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Save to a different directory</string>
|
<string>Save to a different directory</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="0">
|
<item row="6" column="0">
|
||||||
<widget class="QLabel" name="label_6">
|
<widget class="QLabel" name="label_6">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
@ -192,7 +192,7 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="1">
|
<item row="6" column="1">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLineEdit" name="lineSavePath">
|
<widget class="QLineEdit" name="lineSavePath">
|
||||||
@ -213,6 +213,20 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="0" column="0" colspan="2">
|
||||||
|
<widget class="QCheckBox" name="checkRegex">
|
||||||
|
<property name="text">
|
||||||
|
<string>Use regular expressions</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0" colspan="2">
|
||||||
|
<widget class="Line" name="line">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
#include "rssfeed.h"
|
#include "rssfeed.h"
|
||||||
#include "rssarticle.h"
|
#include "rssarticle.h"
|
||||||
|
|
||||||
RssDownloadRule::RssDownloadRule()
|
RssDownloadRule::RssDownloadRule(): m_enabled(false), m_useRegex(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ bool RssDownloadRule::matches(const QString &article_title) const
|
|||||||
foreach(const QString& token, m_mustContain) {
|
foreach(const QString& token, m_mustContain) {
|
||||||
if(token.isEmpty() || token == "")
|
if(token.isEmpty() || token == "")
|
||||||
continue;
|
continue;
|
||||||
QRegExp reg(token, Qt::CaseInsensitive, QRegExp::Wildcard);
|
QRegExp reg(token, Qt::CaseInsensitive, m_useRegex ? QRegExp::RegExp : QRegExp::Wildcard);
|
||||||
//reg.setMinimal(false);
|
//reg.setMinimal(false);
|
||||||
if(reg.indexIn(article_title) < 0) return false;
|
if(reg.indexIn(article_title) < 0) return false;
|
||||||
}
|
}
|
||||||
@ -54,7 +54,7 @@ bool RssDownloadRule::matches(const QString &article_title) const
|
|||||||
// Checking not matching
|
// Checking not matching
|
||||||
foreach(const QString& token, m_mustNotContain) {
|
foreach(const QString& token, m_mustNotContain) {
|
||||||
if(token.isEmpty()) continue;
|
if(token.isEmpty()) continue;
|
||||||
QRegExp reg(token, Qt::CaseInsensitive, QRegExp::Wildcard);
|
QRegExp reg(token, Qt::CaseInsensitive, m_useRegex ? QRegExp::RegExp : QRegExp::Wildcard);
|
||||||
if(reg.indexIn(article_title) > -1) return false;
|
if(reg.indexIn(article_title) > -1) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -62,12 +62,18 @@ bool RssDownloadRule::matches(const QString &article_title) const
|
|||||||
|
|
||||||
void RssDownloadRule::setMustContain(const QString &tokens)
|
void RssDownloadRule::setMustContain(const QString &tokens)
|
||||||
{
|
{
|
||||||
m_mustContain = tokens.split(" ");
|
if(m_useRegex)
|
||||||
|
m_mustContain = QStringList() << tokens;
|
||||||
|
else
|
||||||
|
m_mustContain = tokens.split(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
void RssDownloadRule::setMustNotContain(const QString &tokens)
|
void RssDownloadRule::setMustNotContain(const QString &tokens)
|
||||||
{
|
{
|
||||||
m_mustNotContain = tokens.split(QRegExp("[\\s|]"));
|
if(m_useRegex)
|
||||||
|
m_mustNotContain = QStringList() << tokens;
|
||||||
|
else
|
||||||
|
m_mustNotContain = tokens.split(QRegExp("[\\s|]"));
|
||||||
}
|
}
|
||||||
|
|
||||||
RssDownloadRule RssDownloadRule::fromOldFormat(const QVariantHash &rule_hash, const QString &feed_url, const QString &rule_name)
|
RssDownloadRule RssDownloadRule::fromOldFormat(const QVariantHash &rule_hash, const QString &feed_url, const QString &rule_name)
|
||||||
@ -98,6 +104,7 @@ RssDownloadRule RssDownloadRule::fromNewFormat(const QVariantHash &rule_hash)
|
|||||||
rule.setEnabled(rule_hash.value("enabled", false).toBool());
|
rule.setEnabled(rule_hash.value("enabled", false).toBool());
|
||||||
rule.setSavePath(rule_hash.value("save_path").toString());
|
rule.setSavePath(rule_hash.value("save_path").toString());
|
||||||
rule.setLabel(rule_hash.value("label_assigned").toString());
|
rule.setLabel(rule_hash.value("label_assigned").toString());
|
||||||
|
rule.setUseRegex(rule_hash.value("use_regex", false).toBool());
|
||||||
return rule;
|
return rule;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,6 +118,7 @@ QVariantHash RssDownloadRule::toVariantHash() const
|
|||||||
hash["affected_feeds"] = m_rssFeeds;
|
hash["affected_feeds"] = m_rssFeeds;
|
||||||
hash["enabled"] = m_enabled;
|
hash["enabled"] = m_enabled;
|
||||||
hash["label_assigned"] = m_label;
|
hash["label_assigned"] = m_label;
|
||||||
|
hash["use_regex"] = m_useRegex;
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,6 +60,8 @@ public:
|
|||||||
inline bool isValid() const { return !m_name.isEmpty(); }
|
inline bool isValid() const { return !m_name.isEmpty(); }
|
||||||
inline QString mustContain() const { return m_mustContain.join(" "); }
|
inline QString mustContain() const { return m_mustContain.join(" "); }
|
||||||
inline QString mustNotContain() const { return m_mustNotContain.join(" "); }
|
inline QString mustNotContain() const { return m_mustNotContain.join(" "); }
|
||||||
|
inline bool useRegex() const { return m_useRegex; }
|
||||||
|
inline void setUseRegex(bool enabled) { m_useRegex = enabled; }
|
||||||
QStringList findMatchingArticles(const RssFeed* feed) const;
|
QStringList findMatchingArticles(const RssFeed* feed) const;
|
||||||
// Operators
|
// Operators
|
||||||
bool operator==(const RssDownloadRule &other);
|
bool operator==(const RssDownloadRule &other);
|
||||||
@ -72,6 +74,7 @@ private:
|
|||||||
QString m_label;
|
QString m_label;
|
||||||
bool m_enabled;
|
bool m_enabled;
|
||||||
QStringList m_rssFeeds;
|
QStringList m_rssFeeds;
|
||||||
|
bool m_useRegex;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // RSSDOWNLOADRULE_H
|
#endif // RSSDOWNLOADRULE_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user