@ -47,8 +47,8 @@
@@ -47,8 +47,8 @@
# include "ui_automatedrssdownloader.h"
# include "automatedrssdownloader.h"
AutomatedRssDownloader : : AutomatedRssDownloader ( const QWeakPointer < Rss : : Manager > & manager , QWidget * parent ) :
QDialog ( parent ) ,
AutomatedRssDownloader : : AutomatedRssDownloader ( const QWeakPointer < Rss : : Manager > & manager , QWidget * parent )
: QDialog ( parent ) ,
ui ( new Ui : : AutomatedRssDownloader ) ,
m_manager ( manager ) , m_editedRule ( 0 )
{
@ -76,15 +76,15 @@ AutomatedRssDownloader::AutomatedRssDownloader(const QWeakPointer<Rss::Manager>&
@@ -76,15 +76,15 @@ AutomatedRssDownloader::AutomatedRssDownloader(const QWeakPointer<Rss::Manager>&
Qt : : CaseInsensitive ) ,
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> " +
" <li> " + tr ( " Episode number is a mandatory non-zero value " ) + " </li> " +
" <li> " + tr ( " Filter must end with semicolon " ) + " </li> " +
" <li> " + tr ( " Three range types for episodes are supported: " ) + " </li> " + " <li><ul> "
" <li> " + tr ( " Single number: <b>1x25;</b> matches episode 25 of season one " ) + " </li> " +
" <li> " + tr ( " Normal range: <b>1x25-40;</b> matches episodes 25 through 40 of season one " ) + " </li> " +
" <li> " + tr ( " Infinite range: <b>1x25-;</b> matches episodes 25 and upward of season one " ) + " </li> " + " </ul></li></ul> " ;
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> "
+ " <li> " + tr ( " Episode number is a mandatory non-zero value " ) + " </li> "
+ " <li> " + tr ( " Filter must end with semicolon " ) + " </li> "
+ " <li> " + tr ( " Three range types for episodes are supported: " ) + " </li> " + " <li><ul> "
" <li> " + tr ( " Single number: <b>1x25;</b> matches episode 25 of season one " ) + " </li> "
+ " <li> " + tr ( " Normal range: <b>1x25-40;</b> matches episodes 25 through 40 of season one " ) + " </li> "
+ " <li> " + tr ( " Infinite range: <b>1x25-;</b> matches episodes 25 and upward of season one " ) + " </li> " + " </ul></li></ul> " ;
ui - > lineEFilter - > setToolTip ( tip ) ;
initCategoryCombobox ( ) ;
loadFeedList ( ) ;
@ -159,9 +159,8 @@ void AutomatedRssDownloader::saveSettings()
@@ -159,9 +159,8 @@ void AutomatedRssDownloader::saveSettings()
void AutomatedRssDownloader : : loadRulesList ( )
{
// Make sure we save the current item before clearing
if ( m_editedRule ) {
if ( m_editedRule )
saveEditedRule ( ) ;
}
ui - > listRules - > clear ( ) ;
foreach ( const QString & rule_name , m_editableRuleList - > ruleNames ( ) ) {
QListWidgetItem * item = new QListWidgetItem ( rule_name , ui - > listRules ) ;
@ -171,7 +170,7 @@ void AutomatedRssDownloader::loadRulesList()
@@ -171,7 +170,7 @@ void AutomatedRssDownloader::loadRulesList()
else
item - > setCheckState ( Qt : : Unchecked ) ;
}
if ( ui - > listRules - > count ( ) > 0 & & ! ui - > listRules - > currentItem ( ) )
if ( ( ui - > listRules - > count ( ) > 0 ) & & ! ui - > listRules - > currentItem ( ) )
ui - > listRules - > setCurrentRow ( 0 ) ;
}
@ -204,13 +203,13 @@ void AutomatedRssDownloader::updateFeedList()
@@ -204,13 +203,13 @@ void AutomatedRssDownloader::updateFeedList()
Rss : : DownloadRulePtr rule = m_editableRuleList - > getRule ( ruleItem - > text ( ) ) ;
if ( ! rule ) continue ;
qDebug ( ) < < " Rule " < < rule - > name ( ) < < " affects " < < rule - > rssFeeds ( ) . size ( ) < < " feeds. " ;
foreach ( QString test , rule - > rssFeeds ( ) ) {
foreach ( QString test , rule - > rssFeeds ( ) )
qDebug ( ) < < " Feed is " < < test ;
}
if ( rule - > rssFeeds ( ) . contains ( feed_url ) ) {
qDebug ( ) < < " Rule " < < rule - > name ( ) < < " affects feed " < < feed_url ;
all_enabled = true ;
} else {
}
else {
qDebug ( ) < < " Rule " < < rule - > name ( ) < < " does NOT affect feed " < < feed_url ;
all_enabled = false ;
break ;
@ -257,7 +256,8 @@ void AutomatedRssDownloader::updateRuleDefinitionBox()
@@ -257,7 +256,8 @@ void AutomatedRssDownloader::updateRuleDefinitionBox()
if ( rule - > category ( ) . isEmpty ( ) ) {
ui - > comboCategory - > setCurrentIndex ( - 1 ) ;
ui - > comboCategory - > clearEditText ( ) ;
} else {
}
else {
ui - > comboCategory - > setCurrentIndex ( ui - > comboCategory - > findText ( rule - > category ( ) ) ) ;
}
ui - > comboAddPaused - > setCurrentIndex ( rule - > addPaused ( ) ) ;
@ -271,7 +271,8 @@ void AutomatedRssDownloader::updateRuleDefinitionBox()
@@ -271,7 +271,8 @@ void AutomatedRssDownloader::updateRuleDefinitionBox()
ui - > lblLastMatch - > setText ( lMatch ) ;
updateMustLineValidity ( ) ;
updateMustNotLineValidity ( ) ;
} else {
}
else {
// New rule
clearRuleDefinitionBox ( ) ;
ui - > lineContains - > setText ( selection . first ( ) - > text ( ) ) ;
@ -280,7 +281,8 @@ void AutomatedRssDownloader::updateRuleDefinitionBox()
@@ -280,7 +281,8 @@ void AutomatedRssDownloader::updateRuleDefinitionBox()
updateFieldsToolTips ( ui - > checkRegex - > isChecked ( ) ) ;
// Enable
ui - > ruleDefBox - > setEnabled ( true ) ;
} else {
}
else {
m_editedRule = 0 ;
// Clear
clearRuleDefinitionBox ( ) ;
@ -353,7 +355,6 @@ void AutomatedRssDownloader::saveEditedRule()
@@ -353,7 +355,6 @@ void AutomatedRssDownloader::saveEditedRule()
m_editableRuleList - > saveRule ( rule ) ;
}
void AutomatedRssDownloader : : on_addRuleBtn_clicked ( )
{
// Ask for a rule name
@ -447,7 +448,8 @@ void AutomatedRssDownloader::displayRulesListMenu(const QPoint &pos)
@@ -447,7 +448,8 @@ void AutomatedRssDownloader::displayRulesListMenu(const QPoint &pos)
delAct = menu . addAction ( GuiIconProvider : : instance ( ) - > getIcon ( " list-remove " ) , tr ( " Delete rule " ) ) ;
menu . addSeparator ( ) ;
renameAct = menu . addAction ( GuiIconProvider : : instance ( ) - > getIcon ( " edit-rename " ) , tr ( " Rename rule... " ) ) ;
} else {
}
else {
delAct = menu . addAction ( GuiIconProvider : : instance ( ) - > getIcon ( " list-remove " ) , tr ( " Delete selected rules " ) ) ;
}
}
@ -480,7 +482,8 @@ void AutomatedRssDownloader::renameSelectedRule()
@@ -480,7 +482,8 @@ void AutomatedRssDownloader::renameSelectedRule()
if ( new_name . isEmpty ( ) ) return ;
if ( m_editableRuleList - > ruleNames ( ) . contains ( new_name , Qt : : CaseInsensitive ) ) {
QMessageBox : : warning ( this , tr ( " Rule name conflict " ) , tr ( " A rule with this name already exists, please choose another name. " ) ) ;
} else {
}
else {
// Rename the rule
m_editableRuleList - > renameRule ( item - > text ( ) , new_name ) ;
item - > setText ( new_name ) ;
@ -491,10 +494,9 @@ void AutomatedRssDownloader::renameSelectedRule()
@@ -491,10 +494,9 @@ void AutomatedRssDownloader::renameSelectedRule()
void AutomatedRssDownloader : : handleFeedCheckStateChange ( QListWidgetItem * feed_item )
{
if ( ui - > ruleDefBox - > isEnabled ( ) ) {
if ( ui - > ruleDefBox - > isEnabled ( ) )
// Make sure the current rule is saved
saveEditedRule ( ) ;
}
const QString feed_url = feed_item - > data ( Qt : : UserRole ) . toString ( ) ;
foreach ( QListWidgetItem * rule_item , ui - > listRules - > selectedItems ( ) ) {
Rss : : DownloadRulePtr rule = m_editableRuleList - > getRule ( rule_item - > text ( ) ) ;
@ -503,10 +505,9 @@ void AutomatedRssDownloader::handleFeedCheckStateChange(QListWidgetItem *feed_it
@@ -503,10 +505,9 @@ void AutomatedRssDownloader::handleFeedCheckStateChange(QListWidgetItem *feed_it
if ( feed_item - > checkState ( ) = = Qt : : Checked ) {
if ( ! affected_feeds . contains ( feed_url ) )
affected_feeds < < feed_url ;
} else {
if ( affected_feeds . contains ( feed_url ) )
affected_feeds . removeOne ( feed_url ) ;
}
else if ( affected_feeds . contains ( feed_url ) )
affected_feeds . removeOne ( feed_url ) ;
// Save the updated rule
if ( affected_feeds . size ( ) ! = rule - > rssFeeds ( ) . size ( ) ) {
rule - > setRssFeeds ( affected_feeds ) ;
@ -580,7 +581,8 @@ void AutomatedRssDownloader::updateFieldsToolTips(bool regex)
@@ -580,7 +581,8 @@ void AutomatedRssDownloader::updateFieldsToolTips(bool regex)
tip = tr ( " Regex mode: use Perl-like regular expressions " ) ;
ui - > lineContains - > setToolTip ( tip ) ;
ui - > lineNotContains - > setToolTip ( tip ) ;
} else {
}
else {
tip = tr ( " Wildcard mode: you can use<ul><li>? to match any single character</li><li>* to match zero or more of any characters</li><li>Whitespaces count as AND operators</li></ul> " ) ;
ui - > lineContains - > setToolTip ( tip ) ;
tip = tr ( " Wildcard mode: you can use<ul><li>? to match any single character</li><li>* to match zero or more of any characters</li><li>| is used as OR operator</li></ul> " ) ;
@ -607,7 +609,8 @@ void AutomatedRssDownloader::updateMustLineValidity()
@@ -607,7 +609,8 @@ void AutomatedRssDownloader::updateMustLineValidity()
if ( valid ) {
ui - > lineContains - > setStyleSheet ( " " ) ;
ui - > lbl_must_stat - > setPixmap ( QPixmap ( ) ) ;
} else {
}
else {
ui - > lineContains - > setStyleSheet ( " QLineEdit { color: #ff0000; } " ) ;
ui - > lbl_must_stat - > setPixmap ( GuiIconProvider : : instance ( ) - > getIcon ( " task-attention " ) . pixmap ( 16 , 16 ) ) ;
}
@ -632,13 +635,15 @@ void AutomatedRssDownloader::updateMustNotLineValidity()
@@ -632,13 +635,15 @@ void AutomatedRssDownloader::updateMustNotLineValidity()
if ( valid ) {
ui - > lineNotContains - > setStyleSheet ( " " ) ;
ui - > lbl_mustnot_stat - > setPixmap ( QPixmap ( ) ) ;
} else {
}
else {
ui - > lineNotContains - > setStyleSheet ( " QLineEdit { color: #ff0000; } " ) ;
ui - > lbl_mustnot_stat - > setPixmap ( GuiIconProvider : : instance ( ) - > getIcon ( " task-attention " ) . pixmap ( 16 , 16 ) ) ;
}
}
void AutomatedRssDownloader : : onFinished ( int result ) {
void AutomatedRssDownloader : : onFinished ( int result )
{
Q_UNUSED ( result ) ;
// Save current item on exit
saveEditedRule ( ) ;