This commit is contained in:
Martin Rotter 2023-11-16 11:19:38 +01:00
parent 76c7dd1703
commit fa990b2610
12 changed files with 76 additions and 5 deletions

View File

@ -211,6 +211,15 @@ void FeedDownloader::updateOneFeed(ServiceRoot* acc,
Feed* feed,
const QHash<ServiceRoot::BagOfMessages, QStringList>& stated_messages,
const QHash<QString, QStringList>& 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() << ").";
}

View File

@ -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);
}

View File

@ -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<QString> m_headerData;
QList<QString> m_tooltipData;

View File

@ -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<int>::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();

View File

@ -284,20 +284,27 @@
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<item row="6" column="0" colspan="2">
<widget class="QCheckBox" name="m_cbListsRestrictedShortcuts">
<property name="text">
<string>Allow only basic keyboard shortcuts for feed/article list</string>
</property>
</widget>
</item>
<item row="6" column="0" colspan="2">
<item row="7" column="0" colspan="2">
<widget class="QCheckBox" name="m_checkShowTooltips">
<property name="text">
<string>Display tooltips for feeds and articles</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<widget class="QCheckBox" name="m_cbUpdateFeedListDuringFetching">
<property name="text">
<string>Update feed list during feed fetching</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="m_tabMessages">
@ -673,6 +680,7 @@
<tabstop>m_btnChangeFeedListFont</tabstop>
<tabstop>m_cmbCountsFeedList</tabstop>
<tabstop>m_cbHideCountsIfNoUnread</tabstop>
<tabstop>m_cbUpdateFeedListDuringFetching</tabstop>
<tabstop>m_cbListsRestrictedShortcuts</tabstop>
<tabstop>m_checkShowTooltips</tabstop>
<tabstop>m_checkRemoveReadMessagesOnExit</tabstop>
@ -697,6 +705,8 @@
<tabstop>m_tabFeedsMessages</tabstop>
<tabstop>m_gbFeedListFont</tabstop>
<tabstop>m_gbArticleListFont</tabstop>
<tabstop>m_gbAvoidOldArticles</tabstop>
<tabstop>m_dtDateTimeToAvoid</tabstop>
</tabstops>
<resources/>
<connections/>

View File

@ -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;

View File

@ -108,6 +108,9 @@ namespace Feeds {
KEY HideCountsIfNoUnread;
VALUE(bool) HideCountsIfNoUnreadDef;
KEY UpdateFeedListDuringFetching;
VALUE(bool) UpdateFeedListDuringFetchingDef;
KEY AutoExpandOnSelection;
VALUE(bool) AutoExpandOnSelectionDef;

View File

@ -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.

View File

@ -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);

View File

@ -67,6 +67,10 @@ bool RootItem::deleteItem() {
return false;
}
bool RootItem::isFetching() const {
return false;
}
bool RootItem::markAsReadUnread(ReadStatus status) {
bool result = true;

View File

@ -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);

View File

@ -1296,6 +1296,7 @@ UpdatedArticles ServiceRoot::updateMessages(QList<Message>& 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;
}