diff options
| author | in1tiate <32779090+in1tiate@users.noreply.github.com> | 2025-03-09 08:15:45 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-09 08:15:45 -0500 |
| commit | 36ad63b0c026a0c95d47571d8e4c6f35a6854d65 (patch) | |
| tree | cc69140c0c6433e813a28d00f8df0dc7ed2165e1 | |
| parent | 50075c755386ff9714bdb6386ac3ff98201aceb0 (diff) | |
Remember category expansion state when regenerating music list (#1083)
* remember category expansion state when regenerating musiclist
* don't do file i/o here actually
---------
Co-authored-by: stonedDiscord <Tukz@gmx.de>
| -rw-r--r-- | src/courtroom.cpp | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/src/courtroom.cpp b/src/courtroom.cpp index fd6b4c55..0f899364 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -1678,6 +1678,17 @@ void Courtroom::enter_courtroom() // Todo: multithread this due to some servers having large as hell music list void Courtroom::list_music() { + // remember collapsed categories + QStringList collapsed_categories; + for (int i = 0; i < ui_music_list->topLevelItemCount(); ++i) + { + const auto pCategory = ui_music_list->topLevelItem(i); + if (!pCategory->isExpanded()) + { + collapsed_categories.append(pCategory->text(0)); + } + } + ui_music_list->clear(); // ui_music_search->setText(""); @@ -1767,9 +1778,23 @@ void Courtroom::list_music() } } - ui_music_list->expandAll(); // Needs to somehow remember which categories were - // expanded/collapsed if the music list didn't - // change since last time + ui_music_list->expandAll(); + + // restore expanded state from before the list was reset + // disable animations while we do this + bool was_animated = ui_music_list->isAnimated(); + ui_music_list->setAnimated(false); + for (int i = 0; i < ui_music_list->topLevelItemCount(); ++i) + { + const auto pCategory = ui_music_list->topLevelItem(i); + if (collapsed_categories.contains(pCategory->text(0))) + { + pCategory->setExpanded(false); + } + } + // restore animated state + ui_music_list->setAnimated(was_animated); + if (ui_music_search->text() != "") { on_music_search_edited(ui_music_search->text()); |
