From b1fb029e6681669e4be8d6eca9ff45532d1d850f Mon Sep 17 00:00:00 2001 From: Kiooeht Date: Fri, 8 Apr 2011 01:27:17 -0700 Subject: [PATCH] Update online numbers on drag-drop --- pesterchum.py | 53 +++++++++++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/pesterchum.py b/pesterchum.py index 4bf176c..d5d77c9 100644 --- a/pesterchum.py +++ b/pesterchum.py @@ -568,6 +568,8 @@ class chumArea(RightClickTree): self.mainwindow.chumdb.setGroup(chumLabel.chum.handle, group) self.takeItem(chumLabel) self.addItem(chumLabel) + if self.mainwindow.config.showOnlineNumbers(): + self.showOnlineNumbers() def chumoptionsmenu(self): self.optionsMenu = self.chumoptions @@ -651,31 +653,32 @@ class chumArea(RightClickTree): if self.openGroups[i]: child_1.setExpanded(True) def showOnlineNumbers(self): - self.hideOnlineNumbers() - totals = {'Chums': 0} - online = {'Chums': 0} - for g in self.groups: - totals[str(g)] = 0 - online[str(g)] = 0 - for c in self.chums: - yes = c.mood.name() != "offline" - if c.group == "Chums": - totals[str(c.group)] = totals[str(c.group)]+1 - if yes: - online[str(c.group)] = online[str(c.group)]+1 - elif c.group in totals: - totals[str(c.group)] = totals[str(c.group)]+1 - if yes: - online[str(c.group)] = online[str(c.group)]+1 - else: - totals["Chums"] = totals["Chums"]+1 - if yes: - online["Chums"] = online["Chums"]+1 - for i in range(self.topLevelItemCount()): - text = str(self.topLevelItem(i).text(0)) - if text.rfind(" ") != -1: - text = text[0:text.rfind(" ")] - self.topLevelItem(i).setText(0, "%s (%i/%i)" % (text, online[text], totals[text])) + if hasattr(self, 'groups'): + self.hideOnlineNumbers() + totals = {'Chums': 0} + online = {'Chums': 0} + for g in self.groups: + totals[str(g)] = 0 + online[str(g)] = 0 + for c in self.chums: + yes = c.mood.name() != "offline" + if c.group == "Chums": + totals[str(c.group)] = totals[str(c.group)]+1 + if yes: + online[str(c.group)] = online[str(c.group)]+1 + elif c.group in totals: + totals[str(c.group)] = totals[str(c.group)]+1 + if yes: + online[str(c.group)] = online[str(c.group)]+1 + else: + totals["Chums"] = totals["Chums"]+1 + if yes: + online["Chums"] = online["Chums"]+1 + for i in range(self.topLevelItemCount()): + text = str(self.topLevelItem(i).text(0)) + if text.rfind(" ") != -1: + text = text[0:text.rfind(" ")] + self.topLevelItem(i).setText(0, "%s (%i/%i)" % (text, online[text], totals[text])) def hideOnlineNumbers(self): for i in range(self.topLevelItemCount()): text = str(self.topLevelItem(i).text(0))