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