fix feed batch edit behavior for some corner cases
This commit is contained in:
parent
79d7147c36
commit
4c412ace5e
@ -71,12 +71,12 @@ void FeedsView::setSortingEnabled(bool enable) {
|
||||
connect(header(), &QHeaderView::sortIndicatorChanged, this, &FeedsView::saveSortState);
|
||||
}
|
||||
|
||||
QList<Feed*> FeedsView::selectedFeeds() const {
|
||||
QList<Feed*> FeedsView::selectedFeeds(bool recursive) const {
|
||||
auto its = selectedItems();
|
||||
QList<Feed*> feeds;
|
||||
|
||||
for (RootItem* it : its) {
|
||||
feeds.append(it->getSubTreeFeeds());
|
||||
feeds.append(it->getSubTreeFeeds(recursive));
|
||||
}
|
||||
|
||||
auto std_feeds = boolinq::from(feeds).distinct().toStdList();
|
||||
@ -128,7 +128,7 @@ QList<RootItem*> FeedsView::selectedItems() const {
|
||||
}
|
||||
|
||||
void FeedsView::copyUrlOfSelectedFeeds() const {
|
||||
auto feeds = selectedFeeds();
|
||||
auto feeds = selectedFeeds(true);
|
||||
QStringList urls;
|
||||
|
||||
for (const auto* feed : feeds) {
|
||||
@ -229,7 +229,7 @@ void FeedsView::expandCollapseCurrentItem(bool recursive) {
|
||||
}
|
||||
|
||||
void FeedsView::updateSelectedItems() {
|
||||
qApp->feedReader()->updateFeeds(selectedFeeds());
|
||||
qApp->feedReader()->updateFeeds(selectedFeeds(true));
|
||||
}
|
||||
|
||||
void FeedsView::clearSelectedItems() {
|
||||
@ -285,6 +285,7 @@ void FeedsView::editItems(const QList<RootItem*>& items) {
|
||||
.where([](RootItem* it) {
|
||||
return it->canBeEdited();
|
||||
})
|
||||
.distinct()
|
||||
.toStdList();
|
||||
|
||||
if (std_editable_items.empty()) {
|
||||
@ -357,25 +358,30 @@ void FeedsView::editItems(const QList<RootItem*>& items) {
|
||||
}
|
||||
|
||||
void FeedsView::editChildFeeds() {
|
||||
auto* item = selectedItem();
|
||||
auto items = selectedFeeds(false);
|
||||
|
||||
if (item != nullptr) {
|
||||
auto children = item->childItems();
|
||||
auto std_feeds = boolinq::from(children)
|
||||
.where([](RootItem* ch) {
|
||||
return ch->kind() == RootItem::Kind::Feed;
|
||||
})
|
||||
.toStdList();
|
||||
if (!items.isEmpty()) {
|
||||
auto root_items = boolinq::from(items)
|
||||
.select([](Feed* fd) {
|
||||
return fd;
|
||||
})
|
||||
.toStdList();
|
||||
|
||||
editItems(FROM_STD_LIST(QList<RootItem*>, std_feeds));
|
||||
editItems(FROM_STD_LIST(QList<RootItem*>, root_items));
|
||||
}
|
||||
}
|
||||
|
||||
void FeedsView::editRecursiveFeeds() {
|
||||
auto* item = selectedItem();
|
||||
auto items = selectedFeeds(true);
|
||||
|
||||
if (item != nullptr) {
|
||||
editItems(item->getSubTree(RootItem::Kind::Feed));
|
||||
if (!items.isEmpty()) {
|
||||
auto root_items = boolinq::from(items)
|
||||
.select([](Feed* fd) {
|
||||
return fd;
|
||||
})
|
||||
.toStdList();
|
||||
|
||||
editItems(FROM_STD_LIST(QList<RootItem*>, root_items));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ class RSSGUARD_DLLSPEC FeedsView : public BaseTreeView {
|
||||
|
||||
// Returns list of selected/all feeds.
|
||||
// NOTE: This is recursive method which returns all descendants.
|
||||
QList<Feed*> selectedFeeds() const;
|
||||
QList<Feed*> selectedFeeds(bool recursive) const;
|
||||
|
||||
// Returns selected item. If multiple items are selected, returns
|
||||
// the one of them which is also "current". If none of them is
|
||||
|
@ -397,9 +397,10 @@ QHash<QString, Feed*> RootItem::getHashedSubTreeFeeds() const {
|
||||
return children;
|
||||
}
|
||||
|
||||
QList<Feed*> RootItem::getSubTreeFeeds() const {
|
||||
QList<Feed*> RootItem::getSubTreeFeeds(bool recursive) const {
|
||||
QList<Feed*> children;
|
||||
QList<RootItem*> traversable_items;
|
||||
bool traversed = false;
|
||||
|
||||
traversable_items.append(const_cast<RootItem* const>(this));
|
||||
|
||||
@ -411,7 +412,10 @@ QList<Feed*> RootItem::getSubTreeFeeds() const {
|
||||
children.append(active_item->toFeed());
|
||||
}
|
||||
|
||||
traversable_items.append(active_item->childItems());
|
||||
if (recursive || !traversed) {
|
||||
traversed = true;
|
||||
traversable_items.append(active_item->childItems());
|
||||
}
|
||||
}
|
||||
|
||||
return children;
|
||||
|
@ -156,7 +156,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*> getSubTreeFeeds(bool recursive = true) const;
|
||||
QList<Feed*> getSubTreeAutoFetchingWithManualIntervalsFeeds() const;
|
||||
QList<Feed*> getSubAutoFetchingEnabledFeeds() const;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user