diff options
author | ouwou <26526779+ouwou@users.noreply.github.com> | 2021-07-03 21:11:51 -0400 |
---|---|---|
committer | ouwou <26526779+ouwou@users.noreply.github.com> | 2021-07-03 21:11:51 -0400 |
commit | f1504eca15b25431cfc58d2f5805495e342aecf4 (patch) | |
tree | 33fd7b4f49351a4120db941a534cf3d707c5cb27 /components | |
parent | 67c944f219003e8632a887d85a81d92b307ecdce (diff) | |
download | abaddon-portaudio-f1504eca15b25431cfc58d2f5805495e342aecf4.tar.gz abaddon-portaudio-f1504eca15b25431cfc58d2f5805495e342aecf4.zip |
handle channel remove
Diffstat (limited to 'components')
-rw-r--r-- | components/channels.cpp | 20 | ||||
-rw-r--r-- | components/channels.hpp | 1 |
2 files changed, 21 insertions, 0 deletions
diff --git a/components/channels.cpp b/components/channels.cpp index 56534ba..cc23bb5 100644 --- a/components/channels.cpp +++ b/components/channels.cpp @@ -94,6 +94,9 @@ void ChannelList::UpdateRemoveGuild(Snowflake id) { } void ChannelList::UpdateRemoveChannel(Snowflake id) { + auto iter = GetIteratorForChannelFromID(id); + if (!iter) return; + m_model->erase(iter); } void ChannelList::UpdateChannel(Snowflake id) { @@ -184,6 +187,23 @@ Gtk::TreeModel::iterator ChannelList::GetIteratorForGuildFromID(Snowflake id) { return {}; } +Gtk::TreeModel::iterator ChannelList::GetIteratorForChannelFromID(Snowflake id) { + std::queue<Gtk::TreeModel::iterator> queue; + for (const auto child : m_model->children()) + for (const auto child2 : child.children()) + queue.push(child2); + + while (!queue.empty()) { + auto item = queue.front(); + if ((*item)[m_columns.m_id] == id) return item; + for (const auto child : item->children()) + queue.push(child); + queue.pop(); + } + + return {}; +} + ChannelList::type_signal_action_channel_item_select ChannelList::signal_action_channel_item_select() { return m_signal_action_channel_item_select; } diff --git a/components/channels.hpp b/components/channels.hpp index 4907124..bbe0369 100644 --- a/components/channels.hpp +++ b/components/channels.hpp @@ -121,6 +121,7 @@ protected: Gtk::TreeModel::iterator AddGuild(const GuildData &guild); Gtk::TreeModel::iterator GetIteratorForGuildFromID(Snowflake id); + Gtk::TreeModel::iterator GetIteratorForChannelFromID(Snowflake id); public: typedef sigc::signal<void, Snowflake> type_signal_action_channel_item_select; |