From 3b4b2c66a5ad7f24b14b7dda86e9aa5c4ed13e4a Mon Sep 17 00:00:00 2001 From: Olaf Wintermann Date: Fri, 20 Mar 2026 18:26:36 +0100 Subject: [PATCH] keep sidebar selection when moving feeds/groups --- .../kotlin/de/unixwork/rssreader/FeedSourceList.kt | 10 ++++++++-- .../main/kotlin/de/unixwork/rssreader/MainWindow.kt | 8 ++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/rss-application/src/main/kotlin/de/unixwork/rssreader/FeedSourceList.kt b/rss-application/src/main/kotlin/de/unixwork/rssreader/FeedSourceList.kt index 8c8fd09..0e479a6 100644 --- a/rss-application/src/main/kotlin/de/unixwork/rssreader/FeedSourceList.kt +++ b/rss-application/src/main/kotlin/de/unixwork/rssreader/FeedSourceList.kt @@ -38,7 +38,7 @@ class FeedSourceList : Document() { feeds.update() } - fun swapFeedCollections(group: Int, feed1: Int, feed2: Int) { + fun swapFeedCollections(group: Int, feed1: Int, feed2: Int, select: Int = -1) { if(group < 0 || group >= groups.size) { return } @@ -56,13 +56,16 @@ class FeedSourceList : Document() { gr.feeds[feed1] = f2 gr.feeds[feed2] = f1 gr.feeds.update() + if(select >= 0) { + gr.feeds.selectedIndex = select + } GlobalScope.launch(Dispatchers.IO) { Database.swapFeedCollectionPos(f1, f2) } } - fun swapFeedGroups(group1: Int, group2: Int) { + fun swapFeedGroups(group1: Int, group2: Int, select: Int = -1) { if(group1 < 0 || group1 >= groups.size) { return } @@ -77,6 +80,9 @@ class FeedSourceList : Document() { groups[group1] = g2 groups[group2] = g1 feeds.update() + if(select >= 0) { + feeds.selectedIndex = select + } GlobalScope.launch(Dispatchers.IO) { Database.swapFeedGroupPos(g1, g2) diff --git a/rss-application/src/main/kotlin/de/unixwork/rssreader/MainWindow.kt b/rss-application/src/main/kotlin/de/unixwork/rssreader/MainWindow.kt index 6519313..fb9de0e 100644 --- a/rss-application/src/main/kotlin/de/unixwork/rssreader/MainWindow.kt +++ b/rss-application/src/main/kotlin/de/unixwork/rssreader/MainWindow.kt @@ -84,17 +84,17 @@ class MainWindow() { menuItem("Move Up") { event -> val evt = event.subListEventData if(evt.rowIndex >= 0) { - sourceList.swapFeedCollections(evt.sublistIndex, evt.rowIndex, evt.rowIndex-1) + sourceList.swapFeedCollections(evt.sublistIndex, evt.rowIndex, evt.rowIndex-1, evt.rowIndex) } else { - sourceList.swapFeedGroups(evt.sublistIndex, evt.sublistIndex-1) + sourceList.swapFeedGroups(evt.sublistIndex, evt.sublistIndex-1, evt.sublistIndex-1) } } menuItem("Move Down") { event -> val evt = event.subListEventData if(evt.rowIndex >= 0) { - sourceList.swapFeedCollections(evt.sublistIndex, evt.rowIndex, evt.rowIndex+1) + sourceList.swapFeedCollections(evt.sublistIndex, evt.rowIndex, evt.rowIndex+1, evt.rowIndex+2) } else { - sourceList.swapFeedGroups(evt.sublistIndex, evt.sublistIndex+1) + sourceList.swapFeedGroups(evt.sublistIndex, evt.sublistIndex+1, evt.sublistIndex+1) } } menuItem("Delete") { event -> -- 2.47.3