bit better logic for dt article decisions

This commit is contained in:
Martin Rotter 2023-07-26 09:26:29 +02:00
parent dbad3978a5
commit 05a28d0cad
2 changed files with 10 additions and 10 deletions

View File

@ -197,11 +197,11 @@ SettingsFeedsMessages::SettingsFeedsMessages(Settings* settings, QWidget* parent
m_ui->m_spinFeedUpdateTimeout->setSuffix(QSL(" ") + m_ui->m_spinFeedUpdateTimeout->suffix()); m_ui->m_spinFeedUpdateTimeout->setSuffix(QSL(" ") + m_ui->m_spinFeedUpdateTimeout->suffix());
} }
m_ui->m_dtDateTimeToAvoid->setDisplayFormat(qApp->localization()->loadedLocale().dateFormat());
connect(m_ui->m_gbAvoidOldArticles, &QGroupBox::toggled, this, &SettingsFeedsMessages::dirtifySettings); connect(m_ui->m_gbAvoidOldArticles, &QGroupBox::toggled, this, &SettingsFeedsMessages::dirtifySettings);
connect(m_ui->m_dtDateTimeToAvoid, &QDateTimeEdit::dateTimeChanged, this, &SettingsFeedsMessages::dirtifySettings); connect(m_ui->m_dtDateTimeToAvoid, &QDateTimeEdit::dateTimeChanged, this, &SettingsFeedsMessages::dirtifySettings);
m_ui->m_spinRelativeArticleTime->setValue(-1); m_ui->m_spinRelativeArticleTime->setValue(-1);
} }
@ -265,8 +265,10 @@ void SettingsFeedsMessages::loadSettings() {
->setChecked(settings()->value(GROUP(Feeds), SETTING(Feeds::AutoUpdateOnlyUnfocused)).toBool()); ->setChecked(settings()->value(GROUP(Feeds), SETTING(Feeds::AutoUpdateOnlyUnfocused)).toBool());
m_ui->m_spinAutoUpdateInterval->setValue(settings()->value(GROUP(Feeds), SETTING(Feeds::AutoUpdateInterval)).toInt()); m_ui->m_spinAutoUpdateInterval->setValue(settings()->value(GROUP(Feeds), SETTING(Feeds::AutoUpdateInterval)).toInt());
m_ui->m_spinFeedUpdateTimeout->setValue(settings()->value(GROUP(Feeds), SETTING(Feeds::UpdateTimeout)).toInt()); m_ui->m_spinFeedUpdateTimeout->setValue(settings()->value(GROUP(Feeds), SETTING(Feeds::UpdateTimeout)).toInt());
m_ui->m_gbAvoidOldArticles->setChecked(settings()->value(GROUP(Messages), SETTING(Messages::AvoidOldArticles)).toBool()); m_ui->m_gbAvoidOldArticles
m_ui->m_dtDateTimeToAvoid->setDateTime(settings()->value(GROUP(Messages), SETTING(Messages::DateTimeToAvoidArticle)).toDateTime()); ->setChecked(settings()->value(GROUP(Messages), SETTING(Messages::AvoidOldArticles)).toBool());
m_ui->m_dtDateTimeToAvoid
->setDateTime(settings()->value(GROUP(Messages), SETTING(Messages::DateTimeToAvoidArticle)).toDateTime());
m_ui->m_cmbFastAutoUpdate->setChecked(settings()->value(GROUP(Feeds), SETTING(Feeds::FastAutoUpdate)).toBool()); m_ui->m_cmbFastAutoUpdate->setChecked(settings()->value(GROUP(Feeds), SETTING(Feeds::FastAutoUpdate)).toBool());
m_ui->m_checkUpdateAllFeedsOnStartup m_ui->m_checkUpdateAllFeedsOnStartup
->setChecked(settings()->value(GROUP(Feeds), SETTING(Feeds::FeedsUpdateOnStartup)).toBool()); ->setChecked(settings()->value(GROUP(Feeds), SETTING(Feeds::FeedsUpdateOnStartup)).toBool());

View File

@ -257,22 +257,20 @@ QList<Message> StandardServiceRoot::obtainNewMessages(Feed* feed,
} }
if (!feed->addAnyDatetimeArticles()) { if (!feed->addAnyDatetimeArticles()) {
QDateTime dt_to_avoid;
QDateTime datetimeToAvoid;
if (feed->datetimeToAvoid().isValid()) { if (feed->datetimeToAvoid().isValid()) {
datetimeToAvoid = feed->datetimeToAvoid(); dt_to_avoid = feed->datetimeToAvoid();
} }
else if (qApp->settings()->value(GROUP(Messages), SETTING(Messages::AvoidOldArticles)).toBool()) { else if (qApp->settings()->value(GROUP(Messages), SETTING(Messages::AvoidOldArticles)).toBool()) {
datetimeToAvoid = dt_to_avoid = qApp->settings()->value(GROUP(Messages), SETTING(Messages::DateTimeToAvoidArticle)).toDateTime();
qApp->settings()->value(GROUP(Messages), SETTING(Messages::DateTimeToAvoidArticle)).toDateTime();
} }
else { else {
return messages; return messages;
} }
for (int i = 0; i < messages.size(); i++) { for (int i = 0; i < messages.size(); i++) {
if (messages.at(i).m_createdFromFeed && messages.at(i).m_created < datetimeToAvoid) { if (messages.at(i).m_createdFromFeed && messages.at(i).m_created < dt_to_avoid) {
messages.removeAt(i--); messages.removeAt(i--);
} }
} }