From c75216fa9f53b9f86e7c57c4addc87dc50fe28cc Mon Sep 17 00:00:00 2001 From: Nicholas Alton Date: Thu, 2 Jan 2025 13:28:16 -0600 Subject: [PATCH 1/2] force topic list to use actual displayed list of topics --- mapviz_plugins/src/topic_select.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/mapviz_plugins/src/topic_select.cpp b/mapviz_plugins/src/topic_select.cpp index f01e728b..9413914e 100644 --- a/mapviz_plugins/src/topic_select.cpp +++ b/mapviz_plugins/src/topic_select.cpp @@ -335,17 +335,19 @@ std::vector SelectTopicDialog::filterTopics( void SelectTopicDialog::updateDisplayedTopics() { std::vector next_displayed_topics = filterTopics(known_topics_); - // It's a lot more work to keep track of the additions/removals like // this compared to resetting the QListWidget's items each time, but // it allows Qt to properly track the selection and current items // across updates, which results in much less frustration for the user. + displayed_topics_.clear(); std::set prev_names; - for (const auto & displayed_topic : displayed_topics_) { - prev_names.insert(displayed_topic); - } + for (int i = 0; i < ui_->topicList->count(); i++) + { + prev_names.insert(ui_->topicList->item(i)->text().toStdString()); + displayed_topics_.push_back(ui_->topicList->item(i)->text().toStdString()); + } std::set next_names; for (const auto & next_displayed_topic : next_displayed_topics) { next_names.insert(next_displayed_topic); @@ -375,6 +377,7 @@ void SelectTopicDialog::updateDisplayedTopics() } // Now we can add the new items. + for (size_t i = 0; i < next_displayed_topics.size(); i++) { if (added_names.count(next_displayed_topics[i]) == 0) { continue; From 3d0e471c5527aae8d4392056d915e20a5c243ed5 Mon Sep 17 00:00:00 2001 From: Nicholas Alton Date: Thu, 2 Jan 2025 13:35:11 -0600 Subject: [PATCH 2/2] revert spaces --- mapviz_plugins/src/topic_select.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mapviz_plugins/src/topic_select.cpp b/mapviz_plugins/src/topic_select.cpp index 9413914e..20953601 100644 --- a/mapviz_plugins/src/topic_select.cpp +++ b/mapviz_plugins/src/topic_select.cpp @@ -335,6 +335,7 @@ std::vector SelectTopicDialog::filterTopics( void SelectTopicDialog::updateDisplayedTopics() { std::vector next_displayed_topics = filterTopics(known_topics_); + // It's a lot more work to keep track of the additions/removals like // this compared to resetting the QListWidget's items each time, but // it allows Qt to properly track the selection and current items @@ -377,7 +378,6 @@ void SelectTopicDialog::updateDisplayedTopics() } // Now we can add the new items. - for (size_t i = 0; i < next_displayed_topics.size(); i++) { if (added_names.count(next_displayed_topics[i]) == 0) { continue;