optional ignoring if contents changes in article updating

This commit is contained in:
Martin Rotter 2021-09-08 10:03:41 +02:00
parent 1d056a07a1
commit ceb88b3c27
5 changed files with 53 additions and 33 deletions

View File

@ -1274,18 +1274,19 @@ QPair<int, int> DatabaseQueries::updateMessages(QSqlDatabase db,
//
// 4) FOR ALL SERVICES: Message update is forced, we want to overwrite message as some arbitrary atribute was changed,
// this particularly happens when manual message filter execution happens.
bool ignore_contents_changes = qApp->settings()->value(GROUP(Messages), SETTING(Messages::IgnoreContentsChanges)).toBool();
bool cond_1 = !message.m_customId.isEmpty() && feed->getParentServiceRoot()->isSyncable() &&
(message.m_created.toMSecsSinceEpoch() != date_existing_message ||
message.m_isRead != is_read_existing_message ||
message.m_isImportant != is_important_existing_message ||
message.m_feedId != feed_id_existing_message ||
message.m_title != title_existing_message ||
message.m_contents != contents_existing_message);
(!ignore_contents_changes && message.m_contents != contents_existing_message));
bool cond_2 = !message.m_customId.isEmpty() && !feed->getParentServiceRoot()->isSyncable() &&
(message.m_title != title_existing_message ||
message.m_contents != contents_existing_message);
bool cond_3 = message.m_createdFromFeed && message.m_created.toMSecsSinceEpoch() != date_existing_message &&
message.m_contents != contents_existing_message;
(!ignore_contents_changes && message.m_contents != contents_existing_message));
bool cond_3 = (message.m_createdFromFeed && message.m_created.toMSecsSinceEpoch() != date_existing_message) ||
(!ignore_contents_changes && message.m_contents != contents_existing_message);
if (cond_1 || cond_2 || cond_3 || force_update) {
// Message exists and is changed, update it.

View File

@ -47,6 +47,7 @@ SettingsFeedsMessages::SettingsFeedsMessages(Settings* settings, QWidget* parent
connect(m_ui->m_spinHeightRowsFeeds, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
this, &SettingsFeedsMessages::requireRestart);
connect(m_ui->m_cmbIgnoreContentsChanges, &QCheckBox::toggled, this, &SettingsFeedsMessages::dirtifySettings);
connect(m_ui->m_cbHideCountsIfNoUnread, &QCheckBox::toggled, this, &SettingsFeedsMessages::dirtifySettings);
connect(m_ui->m_checkAutoUpdate, &QCheckBox::toggled, this, &SettingsFeedsMessages::dirtifySettings);
connect(m_ui->m_checkAutoUpdateOnlyUnfocused, &QCheckBox::toggled, this, &SettingsFeedsMessages::dirtifySettings);
@ -148,9 +149,12 @@ void SettingsFeedsMessages::loadSettings() {
m_ui->m_spinFeedUpdateTimeout->setValue(settings()->value(GROUP(Feeds), SETTING(Feeds::UpdateTimeout)).toInt());
m_ui->m_checkUpdateAllFeedsOnStartup->setChecked(settings()->value(GROUP(Feeds), SETTING(Feeds::FeedsUpdateOnStartup)).toBool());
m_ui->m_spinStartupUpdateDelay->setValue(settings()->value(GROUP(Feeds), SETTING(Feeds::FeedsUpdateStartupDelay)).toDouble());
m_ui->m_cmbCountsFeedList->addItems(QStringList() << "(%unread)" << "[%unread]" << "%unread/%all" << "%unread-%all" << "[%unread|%all]");
m_ui->m_cmbCountsFeedList->addItems({ QSL("(%unread)"), QSL("[%unread]"), QSL("%unread/%all"),
QSL("%unread-%all"), QSL("[%unread|%all]") });
m_ui->m_cmbCountsFeedList->setEditText(settings()->value(GROUP(Feeds), SETTING(Feeds::CountFormat)).toString());
m_ui->m_checkShowTooltips->setChecked(settings()->value(GROUP(Feeds), SETTING(Feeds::EnableTooltipsFeedsMessages)).toBool());
m_ui->m_cmbIgnoreContentsChanges->setChecked(settings()->value(GROUP(Messages),
SETTING(Messages::IgnoreContentsChanges)).toBool());
#if !defined (USE_WEBENGINE)
m_ui->m_checkDisplayPlaceholders->setChecked(settings()->value(GROUP(Messages), SETTING(Messages::DisplayImagePlaceholders)).toBool());
@ -215,6 +219,7 @@ void SettingsFeedsMessages::saveSettings() {
settings()->setValue(GROUP(Feeds), Feeds::CountFormat, m_ui->m_cmbCountsFeedList->currentText());
settings()->setValue(GROUP(Messages), Messages::UseCustomDate, m_ui->m_checkMessagesDateTimeFormat->isChecked());
settings()->setValue(GROUP(Feeds), Feeds::EnableTooltipsFeedsMessages, m_ui->m_checkShowTooltips->isChecked());
settings()->setValue(GROUP(Messages), Messages::IgnoreContentsChanges, m_ui->m_cmbIgnoreContentsChanges->isChecked());
#if !defined (USE_WEBENGINE)
settings()->setValue(GROUP(Messages), Messages::DisplayImagePlaceholders, m_ui->m_checkDisplayPlaceholders->isChecked());

View File

@ -240,7 +240,7 @@
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<item row="2" column="0" colspan="2">
<widget class="QCheckBox" name="m_checkDisplayPlaceholders">
<property name="text">
<string>Display placeholders to indicate locations of pictures</string>
@ -248,27 +248,34 @@
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QCheckBox" name="m_cbShowEnclosuresDirectly">
<property name="text">
<string>Display attached pictures directly in article</string>
</property>
</widget>
</item>
<item row="4" column="0" colspan="2">
<widget class="QCheckBox" name="m_checkDisplayFeedIcons">
<property name="text">
<string>Display real icons of feeds in list of articles instead of read/unread icons</string>
</property>
</widget>
</item>
<item row="4" column="0" colspan="2">
<item row="5" column="0" colspan="2">
<widget class="QCheckBox" name="m_checkBringToForegroundAfterMsgOpened">
<property name="text">
<string>Bring application window to front once article is opened in external web browser</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<item row="6" column="0" colspan="2">
<widget class="QCheckBox" name="m_checkKeppMessagesInTheMiddle">
<property name="text">
<string>Keep article selection in the middle of the article list viewport</string>
</property>
</widget>
</item>
<item row="6" column="0">
<item row="7" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Height or rows in article list (-1 = default height)</string>
@ -278,7 +285,7 @@
</property>
</widget>
</item>
<item row="6" column="1">
<item row="7" column="1">
<widget class="QSpinBox" name="m_spinHeightRowsMessages">
<property name="minimum">
<number>-1</number>
@ -288,7 +295,7 @@
</property>
</widget>
</item>
<item row="7" column="0">
<item row="8" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Height of image attachments</string>
@ -298,7 +305,7 @@
</property>
</widget>
</item>
<item row="7" column="1">
<item row="8" column="1">
<widget class="QSpinBox" name="m_spinHeightImageAttachments">
<property name="minimum">
<number>22</number>
@ -308,7 +315,23 @@
</property>
</widget>
</item>
<item row="9" column="0" colspan="2">
<item row="9" column="0">
<widget class="QCheckBox" name="m_checkMessagesDateTimeFormat">
<property name="text">
<string>Use custom date/time format (overrides format loaded from active localization)</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="QComboBox" name="m_cmbMessagesDateTimeFormat"/>
</item>
<item row="10" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QGroupBox" name="groupBox_5">
@ -377,23 +400,7 @@
</item>
</layout>
</item>
<item row="8" column="0">
<widget class="QCheckBox" name="m_checkMessagesDateTimeFormat">
<property name="text">
<string>Use custom date/time format (overrides format loaded from active localization)</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QComboBox" name="m_cmbMessagesDateTimeFormat"/>
</item>
<item row="11" column="0" colspan="2">
<item row="12" column="0" colspan="2">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
@ -406,10 +413,10 @@
</property>
</spacer>
</item>
<item row="2" column="0" colspan="2">
<widget class="QCheckBox" name="m_cbShowEnclosuresDirectly">
<item row="1" column="0" colspan="2">
<widget class="QCheckBox" name="m_cmbIgnoreContentsChanges">
<property name="text">
<string>Display attached pictures directly in article</string>
<string>Ignore changes in article contents when determining if article is &quot;new&quot;</string>
</property>
</widget>
</item>
@ -440,6 +447,7 @@
<tabstop>m_cbHideCountsIfNoUnread</tabstop>
<tabstop>m_checkShowTooltips</tabstop>
<tabstop>m_checkRemoveReadMessagesOnExit</tabstop>
<tabstop>m_cmbIgnoreContentsChanges</tabstop>
<tabstop>m_checkDisplayPlaceholders</tabstop>
<tabstop>m_cbShowEnclosuresDirectly</tabstop>
<tabstop>m_checkDisplayFeedIcons</tabstop>

View File

@ -105,6 +105,9 @@ DVALUE(char*) Messages::CustomDateFormatDef = "";
DKEY Messages::ClearReadOnExit = "clear_read_on_exit";
DVALUE(bool) Messages::ClearReadOnExitDef = false;
DKEY Messages::IgnoreContentsChanges = "ignore_contents_changes";
DVALUE(bool) Messages::IgnoreContentsChangesDef = true;
DKEY Messages::DisplayFeedIconsInList = "display_feed_icons_in_message_list";
DVALUE(bool) Messages::DisplayFeedIconsInListDef = false;

View File

@ -122,6 +122,9 @@ namespace Messages {
KEY ClearReadOnExit;
VALUE(bool) ClearReadOnExitDef;
KEY IgnoreContentsChanges;
VALUE(bool) IgnoreContentsChangesDef;
KEY DisplayFeedIconsInList;
VALUE(bool) DisplayFeedIconsInListDef;