handle channel remove

This commit is contained in:
ouwou 2021-07-03 21:11:51 -04:00
parent 67c944f219
commit f1504eca15
2 changed files with 21 additions and 0 deletions

View File

@ -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;
}

View File

@ -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;