diff --git a/src/librssguard/core/feeddownloader.cpp b/src/librssguard/core/feeddownloader.cpp index 0c1cbdc0e..2727e8167 100644 --- a/src/librssguard/core/feeddownloader.cpp +++ b/src/librssguard/core/feeddownloader.cpp @@ -211,6 +211,15 @@ void FeedDownloader::updateOneFeed(ServiceRoot* acc, Feed* feed, const QHash& stated_messages, const QHash& tagged_messages) { + feed->setStatus(Feed::Status::Fetching); + + const bool update_feed_list = + qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::UpdateFeedListDuringFetching)).toBool(); + + if (update_feed_list) { + acc->itemChanged({feed}); + } + qlonglong thread_id = qlonglong(QThread::currentThreadId()); qDebugNN << LOGSEC_FEEDDOWNLOADER << "Downloading new messages for feed ID" << QUOTE_W_SPACE(feed->customId()) @@ -439,6 +448,10 @@ void FeedDownloader::updateOneFeed(ServiceRoot* acc, feed->setStatus(Feed::Status::OtherError, app_ex.message()); } + if (update_feed_list) { + acc->itemChanged({feed}); + } + qDebugNN << LOGSEC_FEEDDOWNLOADER << "Made progress in feed updates, total feeds count " << m_watcherLookup.progressValue() + 1 << "/" << m_feeds.size() << " (id of feed is " << feed->id() << ")."; } diff --git a/src/librssguard/core/feedsmodel.cpp b/src/librssguard/core/feedsmodel.cpp index 6cdf16e53..53187e4d4 100644 --- a/src/librssguard/core/feedsmodel.cpp +++ b/src/librssguard/core/feedsmodel.cpp @@ -40,6 +40,7 @@ FeedsModel::FeedsModel(QObject* parent) : QAbstractItemModel(parent), m_rootItem << /*: Feed list header "counts" column tooltip.*/ tr("Counts of unread/all mesages."); setupFonts(); + setupBehaviorDuringFetching(); } FeedsModel::~FeedsModel() { @@ -329,6 +330,14 @@ RootItem* FeedsModel::rootItem() const { return m_rootItem; } +void FeedsModel::setupBehaviorDuringFetching() { + m_updateDuringFetching = qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::UpdateFeedListDuringFetching)).toBool(); + + if (m_updateDuringFetching) { + m_updateItemIcon = qApp->icons()->fromTheme(QSL("view-refresh")); + } +} + void FeedsModel::reloadChangedLayout(QModelIndexList list) { while (!list.isEmpty()) { QModelIndex indx = list.takeFirst(); @@ -345,7 +354,7 @@ void FeedsModel::reloadChangedLayout(QModelIndexList list) { } void FeedsModel::reloadChangedItem(RootItem* item) { - reloadChangedLayout(QModelIndexList() << indexForItem(item)); + reloadChangedLayout({indexForItem(item)}); } void FeedsModel::notifyWithCounts() { @@ -544,6 +553,16 @@ QVariant FeedsModel::data(const QModelIndex& index, int role) const { return QVariant(); } + case Qt::ItemDataRole::DecorationRole: { + if (index.column() == FDS_MODEL_TITLE_INDEX && m_updateDuringFetching) { + RootItem* it = itemForIndex(index); + + if (it->isFetching()) { + return m_updateItemIcon; + } + } + } + default: return itemForIndex(index)->data(index.column(), role); } diff --git a/src/librssguard/core/feedsmodel.h b/src/librssguard/core/feedsmodel.h index effdaf731..45d0ce36e 100644 --- a/src/librssguard/core/feedsmodel.h +++ b/src/librssguard/core/feedsmodel.h @@ -78,6 +78,7 @@ class RSSGUARD_DLLSPEC FeedsModel : public QAbstractItemModel { // Access to root item. RootItem* rootItem() const; + void setupBehaviorDuringFetching(); void setupFonts(); void informAboutDatabaseCleanup(); @@ -149,6 +150,8 @@ class RSSGUARD_DLLSPEC FeedsModel : public QAbstractItemModel { void reloadMessageListRequested(bool mark_selected_messages_read); private: + bool m_updateDuringFetching; + QIcon m_updateItemIcon; RootItem* m_rootItem; QList m_headerData; QList m_tooltipData; diff --git a/src/librssguard/gui/settings/settingsfeedsmessages.cpp b/src/librssguard/gui/settings/settingsfeedsmessages.cpp index 5332223a1..f271cffac 100644 --- a/src/librssguard/gui/settings/settingsfeedsmessages.cpp +++ b/src/librssguard/gui/settings/settingsfeedsmessages.cpp @@ -74,6 +74,7 @@ SettingsFeedsMessages::SettingsFeedsMessages(Settings* settings, QWidget* parent 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_cbUpdateFeedListDuringFetching, &QCheckBox::toggled, this, &SettingsFeedsMessages::dirtifySettings); connect(m_ui->m_checkAutoUpdateOnlyUnfocused, &QCheckBox::toggled, this, &SettingsFeedsMessages::dirtifySettings); connect(m_ui->m_cmbUnreadIconType, QOverload::of(&QComboBox::currentIndexChanged), @@ -247,6 +248,8 @@ void SettingsFeedsMessages::loadSettings() { m_ui->m_spinHeightRowsMessages->setValue(settings()->value(GROUP(GUI), SETTING(GUI::HeightRowMessages)).toInt()); m_ui->m_spinHeightRowsFeeds->setValue(settings()->value(GROUP(GUI), SETTING(GUI::HeightRowFeeds)).toInt()); + m_ui->m_cbUpdateFeedListDuringFetching + ->setChecked(settings()->value(GROUP(Feeds), SETTING(Feeds::UpdateFeedListDuringFetching)).toBool()); m_ui->m_cbListsRestrictedShortcuts ->setChecked(settings()->value(GROUP(Feeds), SETTING(Feeds::OnlyBasicShortcutsInLists)).toBool()); m_ui->m_cbHideCountsIfNoUnread @@ -342,6 +345,9 @@ void SettingsFeedsMessages::saveSettings() { settings()->setValue(GROUP(GUI), GUI::HeightRowMessages, m_ui->m_spinHeightRowsMessages->value()); settings()->setValue(GROUP(GUI), GUI::HeightRowFeeds, m_ui->m_spinHeightRowsFeeds->value()); + settings()->setValue(GROUP(Feeds), + Feeds::UpdateFeedListDuringFetching, + m_ui->m_cbUpdateFeedListDuringFetching->isChecked()); settings()->setValue(GROUP(Feeds), Feeds::OnlyBasicShortcutsInLists, m_ui->m_cbListsRestrictedShortcuts->isChecked()); settings()->setValue(GROUP(Feeds), Feeds::HideCountsIfNoUnread, m_ui->m_cbHideCountsIfNoUnread->isChecked()); @@ -415,6 +421,7 @@ void SettingsFeedsMessages::saveSettings() { qApp->mainForm()->tabWidget()->feedMessageViewer()->loadMessageViewerFonts(); qApp->feedReader()->updateAutoUpdateStatus(); + qApp->feedReader()->feedsModel()->setupBehaviorDuringFetching(); qApp->feedReader()->feedsModel()->reloadWholeLayout(); qApp->feedReader()->messagesModel()->updateDateFormat(); diff --git a/src/librssguard/gui/settings/settingsfeedsmessages.ui b/src/librssguard/gui/settings/settingsfeedsmessages.ui index 99f24208e..fdec97655 100644 --- a/src/librssguard/gui/settings/settingsfeedsmessages.ui +++ b/src/librssguard/gui/settings/settingsfeedsmessages.ui @@ -284,20 +284,27 @@ - + Allow only basic keyboard shortcuts for feed/article list - + Display tooltips for feeds and articles + + + + Update feed list during feed fetching + + + @@ -673,6 +680,7 @@ m_btnChangeFeedListFont m_cmbCountsFeedList m_cbHideCountsIfNoUnread + m_cbUpdateFeedListDuringFetching m_cbListsRestrictedShortcuts m_checkShowTooltips m_checkRemoveReadMessagesOnExit @@ -697,6 +705,8 @@ m_tabFeedsMessages m_gbFeedListFont m_gbArticleListFont + m_gbAvoidOldArticles + m_dtDateTimeToAvoid diff --git a/src/librssguard/miscellaneous/settings.cpp b/src/librssguard/miscellaneous/settings.cpp index 3143aab0a..4cc98afea 100644 --- a/src/librssguard/miscellaneous/settings.cpp +++ b/src/librssguard/miscellaneous/settings.cpp @@ -111,6 +111,9 @@ DVALUE(bool) Feeds::ShowTreeBranchesDef = true; DKEY Feeds::HideCountsIfNoUnread = "hide_counts_if_no_unread"; DVALUE(bool) Feeds::HideCountsIfNoUnreadDef = false; +DKEY Feeds::UpdateFeedListDuringFetching = "update_feed_list_during_fetching"; +DVALUE(bool) Feeds::UpdateFeedListDuringFetchingDef = false; + DKEY Feeds::AutoExpandOnSelection = "auto_expand_on_selection"; DVALUE(bool) Feeds::AutoExpandOnSelectionDef = false; diff --git a/src/librssguard/miscellaneous/settings.h b/src/librssguard/miscellaneous/settings.h index 5ce9fa908..c312c954d 100644 --- a/src/librssguard/miscellaneous/settings.h +++ b/src/librssguard/miscellaneous/settings.h @@ -108,6 +108,9 @@ namespace Feeds { KEY HideCountsIfNoUnread; VALUE(bool) HideCountsIfNoUnreadDef; + KEY UpdateFeedListDuringFetching; + VALUE(bool) UpdateFeedListDuringFetchingDef; + KEY AutoExpandOnSelection; VALUE(bool) AutoExpandOnSelectionDef; diff --git a/src/librssguard/services/abstract/feed.cpp b/src/librssguard/services/abstract/feed.cpp index 7943b506c..1957cb347 100644 --- a/src/librssguard/services/abstract/feed.cpp +++ b/src/librssguard/services/abstract/feed.cpp @@ -150,6 +150,10 @@ bool Feed::canBeEdited() const { return true; } +bool Feed::isFetching() const { + return m_status == Status::Fetching; +} + void Feed::setAutoUpdateInterval(int auto_update_interval) { // If new initial auto-update interval is set, then // we should reset time that remains to the next auto-update. diff --git a/src/librssguard/services/abstract/feed.h b/src/librssguard/services/abstract/feed.h index 4cbf1f432..5a68b68f5 100644 --- a/src/librssguard/services/abstract/feed.h +++ b/src/librssguard/services/abstract/feed.h @@ -32,7 +32,8 @@ class Feed : public RootItem { NetworkError = 2, AuthError = 3, ParsingError = 4, - OtherError = 5 + OtherError = 5, + Fetching = 6 }; Q_ENUM(Status) @@ -51,6 +52,7 @@ class Feed : public RootItem { virtual QVariantHash customDatabaseData() const; virtual void setCustomDatabaseData(const QVariantHash& data); virtual bool canBeEdited() const; + virtual bool isFetching() const; virtual QVariant data(int column, int role) const; void setCountOfAllMessages(int count_all_messages); diff --git a/src/librssguard/services/abstract/rootitem.cpp b/src/librssguard/services/abstract/rootitem.cpp index ccf3ace82..1528c945e 100644 --- a/src/librssguard/services/abstract/rootitem.cpp +++ b/src/librssguard/services/abstract/rootitem.cpp @@ -67,6 +67,10 @@ bool RootItem::deleteItem() { return false; } +bool RootItem::isFetching() const { + return false; +} + bool RootItem::markAsReadUnread(ReadStatus status) { bool result = true; diff --git a/src/librssguard/services/abstract/rootitem.h b/src/librssguard/services/abstract/rootitem.h index 362dbf957..3ee3061a3 100644 --- a/src/librssguard/services/abstract/rootitem.h +++ b/src/librssguard/services/abstract/rootitem.h @@ -82,6 +82,8 @@ class RSSGUARD_DLLSPEC RootItem : public QObject { // Returns result status. virtual bool deleteItem(); + virtual bool isFetching() const; + // Performs all needed steps (DB update, remote server update) // to mark this item as read/unread. virtual bool markAsReadUnread(ReadStatus status); diff --git a/src/librssguard/services/abstract/serviceroot.cpp b/src/librssguard/services/abstract/serviceroot.cpp index 3e6ea48bb..d12a7aac9 100644 --- a/src/librssguard/services/abstract/serviceroot.cpp +++ b/src/librssguard/services/abstract/serviceroot.cpp @@ -1296,6 +1296,7 @@ UpdatedArticles ServiceRoot::updateMessages(QList& messages, Feed* feed } } - // NOTE: Do not update model items here. We update only once when all feeds are fetched. + // NOTE: Do not update model items here. We update only once when all feeds are fetched + // or separately in downloader, if user has this enabled. return updated_messages; }