handle merged account in iter cache. Fixes #5849

This commit is contained in:
Yann Leboulanger 2010-08-14 22:42:47 +02:00
parent c56e5ce163
commit 6a6143f8fb
1 changed files with 25 additions and 8 deletions

View File

@ -106,10 +106,7 @@ class RosterWindow:
return return
if self.regroup: if self.regroup:
if 'account' not in self._iters: name = 'MERGED'
return None
it = self._iters['account']
else:
it = self._iters[name]['account'] it = self._iters[name]['account']
if model == self.model or it is None: if model == self.model or it is None:
@ -134,6 +131,9 @@ class RosterWindow:
if model is None: if model is None:
return return
if self.regroup:
account = 'MERGED'
if name not in self._iters[account]['groups']: if name not in self._iters[account]['groups']:
return None return None
@ -183,6 +183,9 @@ class RosterWindow:
# We don't know this contact # We don't know this contact
return [] return []
if account not in self._iters:
return []
if jid not in self._iters[account]['contacts']: if jid not in self._iters[account]['contacts']:
return [] return []
@ -257,7 +260,7 @@ class RosterWindow:
gajim.interface.jabber_state_images['16'][show], gajim.interface.jabber_state_images['16'][show],
_('Merged accounts'), 'account', '', 'all', None, None, None, _('Merged accounts'), 'account', '', 'all', None, None, None,
None, None, None]) None, None, None])
self._iters['account'] = it self._iters['MERGED']['account'] = it
else: else:
show = gajim.SHOW_LIST[gajim.connections[account].connected] show = gajim.SHOW_LIST[gajim.connections[account].connected]
our_jid = gajim.get_jid_from_account(account) our_jid = gajim.get_jid_from_account(account)
@ -344,6 +347,10 @@ class RosterWindow:
# We are a normal contact. Add us to our groups. # We are a normal contact. Add us to our groups.
if not groups: if not groups:
groups = contact.get_shown_groups() groups = contact.get_shown_groups()
if self.regroup:
account_group = 'MERGED'
else:
account_group = account
for group in groups: for group in groups:
child_iterG = self._get_group_iter(group, account, child_iterG = self._get_group_iter(group, account,
model=self.model) model=self.model)
@ -356,7 +363,7 @@ class RosterWindow:
'group', group, account, None, None, None, None, None, 'group', group, account, None, None, None, None, None,
None]) None])
self.draw_group(group, account) self.draw_group(group, account)
self._iters[account]['groups'][group] = child_iterG self._iters[account_group]['groups'][group] = child_iterG
if contact.is_transport(): if contact.is_transport():
typestr = 'agent' typestr = 'agent'
@ -434,11 +441,15 @@ class RosterWindow:
if parent_type == 'group' and \ if parent_type == 'group' and \
self.model.iter_n_children(parent_i) == 1: self.model.iter_n_children(parent_i) == 1:
if self.regroup:
account_group = 'MERGED'
else:
account_group = account
group = self.model[parent_i][C_JID].decode('utf-8') group = self.model[parent_i][C_JID].decode('utf-8')
if group in gajim.groups[account]: if group in gajim.groups[account]:
del gajim.groups[account][group] del gajim.groups[account][group]
self.model.remove(parent_i) self.model.remove(parent_i)
del self._iters[account]['groups'][group] del self._iters[account_group]['groups'][group]
else: else:
self.model.remove(i) self.model.remove(i)
del self._iters[account]['contacts'][contact.jid] del self._iters[account]['contacts'][contact.jid]
@ -1396,10 +1407,14 @@ class RosterWindow:
self.tree.set_model(self.modelfilter) self.tree.set_model(self.modelfilter)
self._iters = {} self._iters = {}
# for merged mode
self._iters['MERGED'] = {'account': None, 'groups': {}}
for acct in gajim.contacts.get_accounts(): for acct in gajim.contacts.get_accounts():
self._iters[acct] = {'account': None, 'groups': {}, 'contacts': {}} self._iters[acct] = {'account': None, 'groups': {}, 'contacts': {}}
self.add_account(acct) self.add_account(acct)
self.add_account_contacts(acct) self.add_account_contacts(acct)
# Recalculate column width for ellipsizing # Recalculate column width for ellipsizing
self.tree.columns_autosize() self.tree.columns_autosize()
@ -5883,6 +5898,8 @@ class RosterWindow:
# self.on_treeview_selection_changed) # self.on_treeview_selection_changed)
self._iters = {} self._iters = {}
# for merged mode
self._iters['MERGED'] = {'account': None, 'groups': {}}
# holds a list of (jid, account) tupples # holds a list of (jid, account) tupples
self._last_selected_contact = [] self._last_selected_contact = []
self.transports_state_images = {'16': {}, '32': {}, 'opened': {}, self.transports_state_images = {'16': {}, '32': {}, 'opened': {},