add menu buttons to batch add direct/recursive feeds

This commit is contained in:
Martin Rotter 2023-10-30 11:25:10 +01:00
parent 623caa7631
commit 5d7cb9dfcd
4 changed files with 67 additions and 15 deletions

View file

@ -207,6 +207,8 @@ QList<QAction*> FormMain::allActions() const {
actions << m_ui->m_actionUpdateSelectedItemsWithCustomTimers;
actions << m_ui->m_actionStopRunningItemsUpdate;
actions << m_ui->m_actionEditSelectedItem;
actions << m_ui->m_actionEditChildFeeds;
actions << m_ui->m_actionEditChildFeedsRecursive;
actions << m_ui->m_actionCopyUrlSelectedFeed;
actions << m_ui->m_actionCopyUrlSelectedArticles;
actions << m_ui->m_actionFocusSearchFeeds;
@ -489,6 +491,9 @@ void FormMain::updateFeedButtonsAvailability() {
m_ui->m_actionClearSelectedItems->setEnabled(anything_selected);
m_ui->m_actionDeleteSelectedItem->setEnabled(!critical_action_running && anything_selected);
m_ui->m_actionEditSelectedItem->setEnabled(!critical_action_running && anything_selected);
m_ui->m_actionEditChildFeeds->setEnabled(!critical_action_running && (service_selected || category_selected));
m_ui->m_actionEditChildFeedsRecursive->setEnabled(!critical_action_running &&
(service_selected || category_selected));
m_ui->m_actionCopyUrlSelectedFeed->setEnabled(service_selected || feed_selected || category_selected);
m_ui->m_actionMarkSelectedItemsAsRead->setEnabled(anything_selected);
m_ui->m_actionMarkSelectedItemsAsUnread->setEnabled(anything_selected);
@ -593,6 +598,8 @@ void FormMain::setupIcons() {
m_ui->m_actionDeleteSelectedItem->setIcon(icon_theme_factory->fromTheme(QSL("list-remove")));
m_ui->m_actionDeleteSelectedMessages->setIcon(icon_theme_factory->fromTheme(QSL("mail-mark-junk")));
m_ui->m_actionEditSelectedItem->setIcon(icon_theme_factory->fromTheme(QSL("document-edit")));
m_ui->m_actionEditChildFeeds->setIcon(icon_theme_factory->fromTheme(QSL("document-edit")));
m_ui->m_actionEditChildFeedsRecursive->setIcon(icon_theme_factory->fromTheme(QSL("document-edit")));
m_ui->m_actionCopyUrlSelectedFeed->setIcon(icon_theme_factory->fromTheme(QSL("edit-copy")));
m_ui->m_actionCopyUrlSelectedArticles->setIcon(icon_theme_factory->fromTheme(QSL("edit-copy")));
m_ui->m_actionMarkAllItemsRead->setIcon(icon_theme_factory->fromTheme(QSL("mail-mark-read")));
@ -931,7 +938,15 @@ void FormMain::createConnections() {
connect(m_ui->m_actionEditSelectedItem,
&QAction::triggered,
tabWidget()->feedMessageViewer()->feedsView(),
&FeedsView::editSelectedItem);
&FeedsView::editSelectedItems);
connect(m_ui->m_actionEditChildFeeds,
&QAction::triggered,
tabWidget()->feedMessageViewer()->feedsView(),
&FeedsView::editChildFeeds);
connect(m_ui->m_actionEditChildFeedsRecursive,
&QAction::triggered,
tabWidget()->feedMessageViewer()->feedsView(),
&FeedsView::editRecursiveFeeds);
connect(m_ui->m_actionViewSelectedItemsNewspaperMode,
&QAction::triggered,
tabWidget()->feedMessageViewer()->feedsView(),

View file

@ -126,6 +126,8 @@
<addaction name="separator"/>
<addaction name="m_menuAddItem"/>
<addaction name="m_actionEditSelectedItem"/>
<addaction name="m_actionEditChildFeeds"/>
<addaction name="m_actionEditChildFeedsRecursive"/>
<addaction name="m_actionDeleteSelectedItem"/>
<addaction name="separator"/>
<addaction name="m_actionSortFeedsAlphabetically"/>
@ -297,10 +299,7 @@
</action>
<action name="m_actionEditSelectedItem">
<property name="text">
<string>&amp;Edit selected item</string>
</property>
<property name="shortcut">
<string notr="true"/>
<string>&amp;Edit selected items</string>
</property>
</action>
<action name="m_actionDeleteSelectedItem">
@ -948,6 +947,16 @@
<string>You must add new account first.</string>
</property>
</action>
<action name="m_actionEditChildFeeds">
<property name="text">
<string>Edit &amp;child feeds</string>
</property>
</action>
<action name="m_actionEditChildFeedsRecursive">
<property name="text">
<string>Edit child feeds (&amp;recursive)</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>

View file

@ -238,7 +238,7 @@ void FeedsView::clearAllFeeds() {
m_sourceModel->markItemCleared(m_sourceModel->rootItem(), false, true);
}
void FeedsView::editSelectedItem() {
void FeedsView::editItems(const QList<RootItem*>& items) {
if (!qApp->feedUpdateLock()->tryLock()) {
// Lock was not obtained because
// it is used probably by feed updater or application
@ -252,14 +252,12 @@ void FeedsView::editSelectedItem() {
return;
}
auto selected_items = selectedItems();
if (selected_items.isEmpty()) {
if (items.isEmpty()) {
qApp->feedUpdateLock()->unlock();
return;
}
auto std_editable_items = boolinq::from(selected_items)
auto std_editable_items = boolinq::from(items)
.where([](RootItem* it) {
return it->canBeEdited();
})
@ -320,7 +318,7 @@ void FeedsView::editSelectedItem() {
return;
}
if (qsizetype(std_editable_items.size()) < selected_items.size()) {
if (qsizetype(std_editable_items.size()) < items.size()) {
// Some items are not editable.
qApp->showGuiMessage(Notification::Event::GeneralEvent,
{tr("Cannot edit some items"),
@ -332,10 +330,33 @@ void FeedsView::editSelectedItem() {
// Changes are done, unlock the update master lock.
qApp->feedUpdateLock()->unlock();
}
// TODO: NOTE: Make sure to refresh article list if RTL is changed?
// RootItem* selected_item = selectedItem();
// emit itemSelected(selected_item);
void FeedsView::editChildFeeds() {
auto* item = selectedItem();
if (item != nullptr) {
auto children = item->childItems();
auto std_feeds = boolinq::from(children)
.where([](RootItem* ch) {
return ch->kind() == RootItem::Kind::Feed;
})
.toStdList();
editItems(FROM_STD_LIST(QList<RootItem*>, std_feeds));
}
}
void FeedsView::editRecursiveFeeds() {
auto* item = selectedItem();
if (item != nullptr) {
editItems(item->getSubTree(RootItem::Kind::Feed));
}
}
void FeedsView::editSelectedItems() {
editItems(selectedItems());
}
void FeedsView::deleteSelectedItem() {
@ -579,6 +600,8 @@ QMenu* FeedsView::initializeContextMenuService(RootItem* clicked_item) {
m_contextMenuService->addActions({qApp->mainForm()->m_ui->m_actionUpdateSelectedItems,
qApp->mainForm()->m_ui->m_actionEditSelectedItem,
qApp->mainForm()->m_ui->m_actionEditChildFeeds,
qApp->mainForm()->m_ui->m_actionEditChildFeedsRecursive,
qApp->mainForm()->m_ui->m_actionCopyUrlSelectedFeed,
qApp->mainForm()->m_ui->m_actionViewSelectedItemsNewspaperMode,
qApp->mainForm()->m_ui->m_actionExpandCollapseItem,
@ -803,6 +826,8 @@ QMenu* FeedsView::initializeContextMenuCategories(RootItem* clicked_item) {
m_contextMenuCategories->addActions({qApp->mainForm()->m_ui->m_actionUpdateSelectedItems,
qApp->mainForm()->m_ui->m_actionEditSelectedItem,
qApp->mainForm()->m_ui->m_actionEditChildFeeds,
qApp->mainForm()->m_ui->m_actionEditChildFeedsRecursive,
qApp->mainForm()->m_ui->m_actionCopyUrlSelectedFeed,
qApp->mainForm()->m_ui->m_actionViewSelectedItemsNewspaperMode,
qApp->mainForm()->m_ui->m_actionExpandCollapseItem,

View file

@ -66,7 +66,10 @@ class RSSGUARD_DLLSPEC FeedsView : public BaseTreeView {
void clearAllFeeds();
// Base manipulators.
void editSelectedItem();
void editItems(const QList<RootItem*>& items);
void editSelectedItems();
void editChildFeeds();
void editRecursiveFeeds();
void deleteSelectedItem();
// Sort order manipulations.