Author: steve-e Date: 2008-07-04 23:29:46 +0200 (Fri, 04 Jul 2008) New Revision: 9883
Modified: trunk/src/common/contacts.py trunk/src/roster_window.py Log: Count metacontacts only once.
Remove timing information for roster drawing.
Modified: trunk/src/common/contacts.py =================================================================== --- trunk/src/common/contacts.py 2008-07-04 10:18:40 UTC (rev 9882) +++ trunk/src/common/contacts.py 2008-07-04 21:29:46 UTC (rev 9883) @@ -323,9 +323,13 @@ if jid == our_jid: continue if common.gajim.jid_is_transport(jid) and not \ - _('Transports') in groups: + _('Transports') in groups: # do not count transports continue + if self.has_brother(account, jid) and not \ + self.is_big_brother(account, jid): + # count metacontacts only once + continue contact = self.get_contact_with_highest_priority(account, jid) if _('Not in roster') in contact.groups: continue @@ -355,7 +359,7 @@
def get_metacontacts_tag(self, account, jid): '''Returns the tag of a jid''' - if not self._metacontacts_tags.has_key(account): + if not account in self._metacontacts_tags: return None for tag in self._metacontacts_tags[account]: for data in self._metacontacts_tags[account][tag]: @@ -399,20 +403,17 @@ break
def has_brother(self, account, jid): - for account in self._metacontacts_tags: - tag = self.get_metacontacts_tag(account, jid) - if tag and len(self._metacontacts_tags[account][tag]) > 1: - return True - return False + tag = self.get_metacontacts_tag(account, jid) + if not tag: + return False + meta_jids = self.get_metacontacts_jids(tag) + return len(meta_jids) > 1 or len(meta_jids[account]) > 1
def is_big_brother(self, account, jid): - tag = self.get_metacontacts_tag(account, jid) - if tag: - family = self.get_metacontacts_family(account, jid) + family = self.get_metacontacts_family(account, jid) + if family: bb_data = self.get_metacontacts_big_brother(family) - bb_jid = bb_data['jid'] - bb_account = bb_data['account'] - if bb_jid == jid and bb_account == account: + if bb_data['jid'] == jid and bb_data['account'] == account: return True return False
@@ -420,7 +421,7 @@ '''Returns all jid for the given tag in the form {acct: [jid1, jid2],.}''' answers = {} for account in self._metacontacts_tags: - if self._metacontacts_tags[account].has_key(tag): + if tag in self._metacontacts_tags[account]: answers[account] = [] for data in self._metacontacts_tags[account][tag]: answers[account].append(data['jid']) @@ -435,7 +436,7 @@ return [] answers = [] for account in self._metacontacts_tags: - if self._metacontacts_tags[account].has_key(tag): + if tag in self._metacontacts_tags[account]: for data in self._metacontacts_tags[account][tag]: data['account'] = account answers.append(data)
Modified: trunk/src/roster_window.py =================================================================== --- trunk/src/roster_window.py 2008-07-04 10:18:40 UTC (rev 9882) +++ trunk/src/roster_window.py 2008-07-04 21:29:46 UTC (rev 9883) @@ -285,15 +285,12 @@ '''Add all contacts and groups of the given account to roster, draw them and account. ''' - c1 = time.clock() self.starting = True jids = gajim.contacts.get_jid_list(account)
self.tree.freeze_child_notify() - c5 = time.clock() for jid in jids: self.add_contact(jid, account) - c6 = time.clock() self.tree.thaw_child_notify()
# Do not freeze the GUI when drawing the contacts @@ -301,26 +298,13 @@ # Overhead is big, only invoke when needed self._idle_draw_jids_of_account(jids, account)
- c9 = time.clock() # Draw all known groups for group in gajim.groups[account].keys(): self.draw_group(group, account) self.draw_account(account) self.starting = False - c10 = time.clock()
- if jids: - c4 = time.clock()
- print "" - print "--- Add account contacts of %s ---------" % account - print "Total Time", c4-c1 - print "Add contact without draw", c6-c5 - print "Draw groups and account", c10-c9 - print "--- contacts added -----------------------------" - print "" - - def _add_entity(self, contact, account, groups = None, big_brother_contact = None, big_brother_account = None): '''Add the given contact to roster data model. @@ -479,7 +463,7 @@ continue
assert len(self._get_contact_iter(_jid, _account, _contact, self.model) - ) == 0, "%s already in roster. \n Family: " % (_jid, nearby_family) + ) == 0, "%s already in roster. \n Family: %s" % (_jid, nearby_family) self._add_entity(_contact, _account, big_brother_contact = \ big_brother_contact, big_brother_account=big_brother_account) brothers.append((_contact, _account)) @@ -1152,18 +1136,14 @@ jids -- a list of jids to draw account -- the corresponding account ''' - def _draw_all_contacts(jids, account, t): + def _draw_all_contacts(jids, account): for jid in jids: self.draw_contact(jid, account) self.draw_avatar(jid, account) yield True - print "--- Idle draw of %s -----------" % account - print "Draw contact and avatar", time.clock() - t - print "-------------------------------" yield False
- t = time.clock() - task = _draw_all_contacts(jids, account, t) + task = _draw_all_contacts(jids, account) gobject.idle_add(task.next)
def setup_and_draw_roster(self):