Ability to update only items with custom auto-update interval. #88

This commit is contained in:
Martin Rotter 2020-08-31 08:30:56 +02:00
parent f6b7ad6d71
commit 8a42fd43e5
6 changed files with 38 additions and 0 deletions

View File

@ -165,6 +165,7 @@ QList<QAction*> FormMain::allActions() const {
actions << m_ui->m_actionDeleteSelectedMessages;
actions << m_ui->m_actionUpdateAllItems;
actions << m_ui->m_actionUpdateSelectedItems;
actions << m_ui->m_actionUpdateSelectedItemsWithCustomTimers;
actions << m_ui->m_actionStopRunningItemsUpdate;
actions << m_ui->m_actionEditSelectedItem;
actions << m_ui->m_actionCopyUrlSelectedFeed;
@ -421,6 +422,7 @@ void FormMain::updateFeedButtonsAvailability() {
m_ui->m_actionMarkSelectedItemsAsRead->setEnabled(anything_selected);
m_ui->m_actionMarkSelectedItemsAsUnread->setEnabled(anything_selected);
m_ui->m_actionUpdateAllItems->setEnabled(!critical_action_running);
m_ui->m_actionUpdateSelectedItemsWithCustomTimers->setEnabled(!critical_action_running);
m_ui->m_actionUpdateSelectedItems->setEnabled(!critical_action_running && (feed_selected || category_selected || service_selected));
m_ui->m_actionViewSelectedItemsNewspaperMode->setEnabled(anything_selected);
m_ui->m_actionExpandCollapseItem->setEnabled(anything_selected);
@ -494,6 +496,7 @@ void FormMain::setupIcons() {
m_ui->m_actionStopRunningItemsUpdate->setIcon(icon_theme_factory->fromTheme(QSL("process-stop")));
m_ui->m_actionUpdateAllItems->setIcon(icon_theme_factory->fromTheme(QSL("view-refresh")));
m_ui->m_actionUpdateSelectedItems->setIcon(icon_theme_factory->fromTheme(QSL("view-refresh")));
m_ui->m_actionUpdateSelectedItemsWithCustomTimers->setIcon(icon_theme_factory->fromTheme(QSL("view-refresh")));
m_ui->m_actionClearSelectedItems->setIcon(icon_theme_factory->fromTheme(QSL("mail-mark-junk")));
m_ui->m_actionClearAllItems->setIcon(icon_theme_factory->fromTheme(QSL("mail-mark-junk")));
m_ui->m_actionDeleteSelectedItem->setIcon(icon_theme_factory->fromTheme(QSL("list-remove")));
@ -719,6 +722,8 @@ void FormMain::createConnections() {
&QAction::triggered, tabWidget()->feedMessageViewer()->feedsView(), &FeedsView::updateSelectedItems);
connect(m_ui->m_actionUpdateAllItems,
&QAction::triggered, qApp->feedReader(), &FeedReader::updateAllFeeds);
connect(m_ui->m_actionUpdateSelectedItemsWithCustomTimers,
&QAction::triggered, qApp->feedReader(), &FeedReader::updateManuallyIntervaledFeeds);
connect(m_ui->m_actionStopRunningItemsUpdate,
&QAction::triggered, qApp->feedReader(), &FeedReader::stopRunningFeedUpdate);
connect(m_ui->m_actionCopyUrlSelectedFeed,

View File

@ -107,6 +107,7 @@
</widget>
<addaction name="m_actionUpdateAllItems"/>
<addaction name="m_actionUpdateSelectedItems"/>
<addaction name="m_actionUpdateSelectedItemsWithCustomTimers"/>
<addaction name="m_actionStopRunningItemsUpdate"/>
<addaction name="separator"/>
<addaction name="m_menuAddItem"/>
@ -775,6 +776,11 @@
<string>&amp;Show tree branches</string>
</property>
</action>
<action name="m_actionUpdateSelectedItemsWithCustomTimers">
<property name="text">
<string>Update items with custom &amp;timers</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>

View File

@ -201,6 +201,10 @@ void FeedReader::updateAllFeeds() {
updateFeeds(m_feedsModel->rootItem()->getSubTreeFeeds());
}
void FeedReader::updateManuallyIntervaledFeeds() {
updateFeeds(m_feedsModel->rootItem()->getSubTreeManuallyIntervaledFeeds());
}
void FeedReader::stopRunningFeedUpdate() {
if (m_feedDownloader != nullptr) {
m_feedDownloader->stopRunningUpdate();

View File

@ -62,6 +62,7 @@ class RSSGUARD_DLLSPEC FeedReader : public QObject {
public slots:
void updateAllFeeds();
void updateManuallyIntervaledFeeds();
void stopRunningFeedUpdate();
void quit();

View File

@ -356,6 +356,27 @@ QList<Feed*> RootItem::getSubTreeFeeds() const {
return children;
}
QList<Feed*> RootItem::getSubTreeManuallyIntervaledFeeds() const {
QList<Feed*> children;
QList<RootItem*> traversable_items;
traversable_items.append(const_cast<RootItem* const>(this));
// Iterate all nested items.
while (!traversable_items.isEmpty()) {
RootItem* active_item = traversable_items.takeFirst();
if (active_item->kind() == RootItem::Kind::Feed &&
active_item->toFeed()->autoUpdateType() == Feed::AutoUpdateType::SpecificAutoUpdate) {
children.append(active_item->toFeed());
}
traversable_items.append(active_item->childItems());
}
return children;
}
ServiceRoot* RootItem::getParentServiceRoot() const {
const RootItem* working_parent = this;

View File

@ -161,6 +161,7 @@ class RSSGUARD_DLLSPEC RootItem : public QObject {
// Returns list of feeds complemented by their own string CUSTOM ID.
QHash<QString, Feed*> getHashedSubTreeFeeds() const;
QList<Feed*> getSubTreeFeeds() const;
QList<Feed*> getSubTreeManuallyIntervaledFeeds() const;
// Returns the service root node which is direct or indirect parent of current item.
ServiceRoot* getParentServiceRoot() const;