RSS use red text to indicate invalid filter. Closes #6165.

--HG--
branch : magao-dev
This commit is contained in:
Tim Delaney 2016-11-06 16:53:06 +11:00
parent 2244b7cb66
commit 935b30b17a
3 changed files with 27 additions and 4 deletions

View file

@ -73,8 +73,6 @@ AutomatedRssDownloader::AutomatedRssDownloader(const QWeakPointer<Rss::Manager>
m_editableRuleList = new Rss::DownloadRuleList; // Read rule list from disk
m_episodeRegex = new QRegExp("^(^[1-9]{1,1}\\d{0,3}x([1-9]{1,1}\\d{0,3}(-([1-9]{1,1}\\d{0,3})?)?;){1,}){1,1}",
Qt::CaseInsensitive);
m_episodeValidator = new QRegExpValidator(*m_episodeRegex, ui->lineEFilter);
ui->lineEFilter->setValidator(m_episodeValidator);
QString tip = "<p>" + tr("Matches articles based on episode filter.") + "</p><p><b>" + tr("Example: ")
+ "1x2;8-15;5;30-;</b>" + tr(" will match 2, 5, 8 through 15, 30 and onward episodes of season one", "example X will match") + "</p>";
tip += "<p>" + tr("Episode filter rules: ") + "</p><ul><li>" + tr("Season number is a mandatory non-zero value") + "</li>"
@ -103,6 +101,8 @@ AutomatedRssDownloader::AutomatedRssDownloader(const QWeakPointer<Rss::Manager>
Q_ASSERT(ok);
ok = connect(ui->lineNotContains, SIGNAL(textEdited(QString)), SLOT(updateMustNotLineValidity()));
Q_ASSERT(ok);
ok = connect(ui->lineEFilter, SIGNAL(textEdited(QString)), SLOT(updateEpisodeFilterValidity()));
Q_ASSERT(ok);
ok = connect(ui->checkRegex, SIGNAL(stateChanged(int)), SLOT(updateMatchingArticles()));
Q_ASSERT(ok);
ok = connect(ui->checkRegex, SIGNAL(stateChanged(int)), SLOT(updateMustLineValidity()));
@ -132,7 +132,6 @@ AutomatedRssDownloader::~AutomatedRssDownloader()
delete deleteHotkey;
delete ui;
delete m_editableRuleList;
delete m_episodeValidator;
delete m_episodeRegex;
}
@ -642,6 +641,20 @@ void AutomatedRssDownloader::updateMustNotLineValidity()
}
}
void AutomatedRssDownloader::updateEpisodeFilterValidity()
{
const QString text = ui->lineEFilter->text();
bool valid = m_episodeRegex->indexIn(text) != -1;
if (valid) {
ui->lineEFilter->setStyleSheet("");
ui->lbl_epfilter_stat->setPixmap(QPixmap());
}
else {
ui->lineEFilter->setStyleSheet("QLineEdit { color: #ff0000; }");
ui->lbl_epfilter_stat->setPixmap(GuiIconProvider::instance()->getIcon("task-attention").pixmap(16, 16));
}
}
void AutomatedRssDownloader::onFinished(int result)
{
Q_UNUSED(result);

View file

@ -86,6 +86,7 @@ private slots:
void updateFieldsToolTips(bool regex);
void updateMustLineValidity();
void updateMustNotLineValidity();
void updateEpisodeFilterValidity();
void onFinished(int result);
private:
@ -100,7 +101,6 @@ private:
Rss::DownloadRuleList *m_ruleList;
Rss::DownloadRuleList *m_editableRuleList;
QRegExp *m_episodeRegex;
QRegExpValidator *m_episodeValidator;
QShortcut *editHotkey;
QShortcut *deleteHotkey;
};

View file

@ -151,6 +151,16 @@
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLabel" name="lbl_epfilter_stat">
<property name="maximumSize">
<size>
<width>18</width>
<height>18</height>
</size>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="lineNotContains"/>
</item>