remove empty group when we make latest contact of that group a child of another contact in another group. Fixes #1711
This commit is contained in:
parent
96b3984b59
commit
19ad69e3dd
1 changed files with 25 additions and 9 deletions
|
@ -2796,8 +2796,24 @@ _('If "%s" accepts this request you will know his or her status.') % jid)
|
||||||
etime):
|
etime):
|
||||||
# remove the source row
|
# remove the source row
|
||||||
model = self.tree.get_model()
|
model = self.tree.get_model()
|
||||||
for i in self.get_contact_iter(c_source.jid, account):
|
for iter in self.get_contact_iter(c_source.jid, account):
|
||||||
model.remove(i)
|
# get group iter
|
||||||
|
iter_group = iter
|
||||||
|
while model[iter_group][C_TYPE] == 'contact':
|
||||||
|
iter_group = model.iter_parent(iter_group)
|
||||||
|
group = model[iter_group][C_JID].decode('utf-8')
|
||||||
|
model.remove(iter)
|
||||||
|
if model.iter_n_children(iter_group) == 0:
|
||||||
|
# this was the only child
|
||||||
|
model.remove(iter_group)
|
||||||
|
# delete the group if it is empty (need to look for offline users
|
||||||
|
# too)
|
||||||
|
for jid in gajim.contacts.get_jid_list(account):
|
||||||
|
if group in gajim.contacts.get_contact_with_highest_priority(
|
||||||
|
account, jid).groups:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
del gajim.groups[account][group]
|
||||||
gajim.contacts.add_subcontact(account, c_dest.jid, c_source.jid)
|
gajim.contacts.add_subcontact(account, c_dest.jid, c_source.jid)
|
||||||
# Add it under parent contact
|
# Add it under parent contact
|
||||||
self.add_contact_to_roster(c_source.jid, account)
|
self.add_contact_to_roster(c_source.jid, account)
|
||||||
|
@ -2834,13 +2850,13 @@ _('If "%s" accepts this request you will know his or her status.') % jid)
|
||||||
if model.iter_n_children(group_iter) == 1:
|
if model.iter_n_children(group_iter) == 1:
|
||||||
# this was the only child
|
# this was the only child
|
||||||
model.remove(group_iter)
|
model.remove(group_iter)
|
||||||
# delete the group if it is empty (need to look for offline users too)
|
# delete the group if it is empty (need to look for offline users too)
|
||||||
for jid in gajim.contacts.get_jid_list(account):
|
for jid in gajim.contacts.get_jid_list(account):
|
||||||
if group in gajim.contacts.get_contact_with_highest_priority(
|
if group in gajim.contacts.get_contact_with_highest_priority(
|
||||||
account, jid).groups:
|
account, jid).groups:
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
del gajim.groups[account][group]
|
del gajim.groups[account][group]
|
||||||
|
|
||||||
def drag_data_received_data(self, treeview, context, x, y, selection, info,
|
def drag_data_received_data(self, treeview, context, x, y, selection, info,
|
||||||
etime):
|
etime):
|
||||||
|
|
Loading…
Add table
Reference in a new issue