Re-add: Show number of online chums in each group
This commit is contained in:
parent
ca8ec454ad
commit
1e4268ebcb
2 changed files with 69 additions and 8 deletions
3
menus.py
3
menus.py
|
@ -581,6 +581,8 @@ class PesterOptions(QtGui.QDialog):
|
||||||
#self.groupscheck.setChecked(self.config.useGroups())
|
#self.groupscheck.setChecked(self.config.useGroups())
|
||||||
self.showemptycheck = QtGui.QCheckBox("Show Empty Groups", self)
|
self.showemptycheck = QtGui.QCheckBox("Show Empty Groups", self)
|
||||||
self.showemptycheck.setChecked(self.config.showEmptyGroups())
|
self.showemptycheck.setChecked(self.config.showEmptyGroups())
|
||||||
|
self.showonlinenumbers = QtGui.QCheckBox("Show Number of Online Chums", self)
|
||||||
|
self.showonlinenumbers.setChecked(self.config.showOnlineNumbers())
|
||||||
|
|
||||||
self.ok = QtGui.QPushButton("OK", self)
|
self.ok = QtGui.QPushButton("OK", self)
|
||||||
self.ok.setDefault(True)
|
self.ok.setDefault(True)
|
||||||
|
@ -599,6 +601,7 @@ class PesterOptions(QtGui.QDialog):
|
||||||
layout_0.addWidget(self.hideOffline)
|
layout_0.addWidget(self.hideOffline)
|
||||||
#layout_0.addWidget(self.groupscheck)
|
#layout_0.addWidget(self.groupscheck)
|
||||||
layout_0.addWidget(self.showemptycheck)
|
layout_0.addWidget(self.showemptycheck)
|
||||||
|
layout_0.addWidget(self.showonlinenumbers)
|
||||||
layout_0.addWidget(hr)
|
layout_0.addWidget(hr)
|
||||||
layout_0.addWidget(self.timestampcheck)
|
layout_0.addWidget(self.timestampcheck)
|
||||||
layout_0.addWidget(self.timestampBox)
|
layout_0.addWidget(self.timestampBox)
|
||||||
|
|
|
@ -298,6 +298,10 @@ class userConfig(object):
|
||||||
if not self.config.has_key('emptyGroups'):
|
if not self.config.has_key('emptyGroups'):
|
||||||
self.set("emptyGroups", False)
|
self.set("emptyGroups", False)
|
||||||
return self.config.get('emptyGroups', False)
|
return self.config.get('emptyGroups', False)
|
||||||
|
def showOnlineNumbers(self):
|
||||||
|
if not self.config.has_key('onlineNumbers'):
|
||||||
|
self.set("onlineNumbers", False)
|
||||||
|
return self.config.get('onlineNumbers', False)
|
||||||
def addChum(self, chum):
|
def addChum(self, chum):
|
||||||
if chum.handle not in self.chums():
|
if chum.handle not in self.chums():
|
||||||
fp = open(self.filename) # what if we have two clients open??
|
fp = open(self.filename) # what if we have two clients open??
|
||||||
|
@ -511,6 +515,8 @@ class chumArea(RightClickTree):
|
||||||
self.showAllChums()
|
self.showAllChums()
|
||||||
if not self.mainwindow.config.showEmptyGroups():
|
if not self.mainwindow.config.showEmptyGroups():
|
||||||
self.hideEmptyGroups()
|
self.hideEmptyGroups()
|
||||||
|
if self.mainwindow.config.showOnlineNumbers():
|
||||||
|
self.showOnlineNumbers()
|
||||||
self.chumoptions = QtGui.QMenu(self)
|
self.chumoptions = QtGui.QMenu(self)
|
||||||
self.groupoptions = QtGui.QMenu(self)
|
self.groupoptions = QtGui.QMenu(self)
|
||||||
self.canonMenu = QtGui.QMenu(self)
|
self.canonMenu = QtGui.QMenu(self)
|
||||||
|
@ -671,6 +677,38 @@ class chumArea(RightClickTree):
|
||||||
self.addTopLevelItem(child_1)
|
self.addTopLevelItem(child_1)
|
||||||
if self.openGroups[i]:
|
if self.openGroups[i]:
|
||||||
child_1.setExpanded(True)
|
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]))
|
||||||
|
def hideOnlineNumbers(self):
|
||||||
|
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" % (text))
|
||||||
def hideEmptyGroups(self):
|
def hideEmptyGroups(self):
|
||||||
i = 0
|
i = 0
|
||||||
listing = self.topLevelItem(i)
|
listing = self.topLevelItem(i)
|
||||||
|
@ -683,11 +721,15 @@ class chumArea(RightClickTree):
|
||||||
@QtCore.pyqtSlot()
|
@QtCore.pyqtSlot()
|
||||||
def expandGroup(self):
|
def expandGroup(self):
|
||||||
item = self.currentItem()
|
item = self.currentItem()
|
||||||
if item.text(0) in self.groups:
|
text = str(item.text(0))
|
||||||
self.mainwindow.config.delGroup(str(item.text(0)))
|
if text.find(" ") != -1:
|
||||||
|
text = text[0:text.rfind(" ")]
|
||||||
|
|
||||||
|
if text in self.groups:
|
||||||
|
self.mainwindow.config.delGroup(text)
|
||||||
expand = item.isExpanded()
|
expand = item.isExpanded()
|
||||||
self.mainwindow.config.addGroup(str(item.text(0)), not expand)
|
self.mainwindow.config.addGroup(text, not expand)
|
||||||
elif item.text(0) == "Chums":
|
elif text == "Chums":
|
||||||
self.mainwindow.config.set("openDefaultGroup", not item.isExpanded())
|
self.mainwindow.config.set("openDefaultGroup", not item.isExpanded())
|
||||||
def addItem(self, chumLabel):
|
def addItem(self, chumLabel):
|
||||||
if hasattr(self, 'groups'):
|
if hasattr(self, 'groups'):
|
||||||
|
@ -696,13 +738,16 @@ class chumArea(RightClickTree):
|
||||||
self.topLevelItem(0).sortChildren(0, QtCore.Qt.AscendingOrder)
|
self.topLevelItem(0).sortChildren(0, QtCore.Qt.AscendingOrder)
|
||||||
else:
|
else:
|
||||||
if not self.findItems(chumLabel.handle, QtCore.Qt.MatchContains | QtCore.Qt.MatchRecursive):
|
if not self.findItems(chumLabel.handle, QtCore.Qt.MatchContains | QtCore.Qt.MatchRecursive):
|
||||||
if not self.findItems(chumLabel.chum.group, QtCore.Qt.MatchFlags(0)):
|
if not self.findItems(chumLabel.chum.group, QtCore.Qt.MatchContains):
|
||||||
child_1 = QtGui.QTreeWidgetItem(["%s" % (chumLabel.chum.group)])
|
child_1 = QtGui.QTreeWidgetItem(["%s" % (chumLabel.chum.group)])
|
||||||
self.addTopLevelItem(child_1)
|
self.addTopLevelItem(child_1)
|
||||||
if self.openGroups[self.groups.index("%s" % (chumLabel.chum.group))]:
|
if self.openGroups[self.groups.index("%s" % (chumLabel.chum.group))]:
|
||||||
child_1.setExpanded(True)
|
child_1.setExpanded(True)
|
||||||
for i in range(self.topLevelItemCount()):
|
for i in range(self.topLevelItemCount()):
|
||||||
if self.topLevelItem(i).text(0) == chumLabel.chum.group:
|
text = str(self.topLevelItem(i).text(0))
|
||||||
|
if text.rfind(" ") != -1:
|
||||||
|
text = text[0:text.rfind(" ")]
|
||||||
|
if text == chumLabel.chum.group:
|
||||||
break
|
break
|
||||||
self.topLevelItem(i).addChild(chumLabel)
|
self.topLevelItem(i).addChild(chumLabel)
|
||||||
self.topLevelItem(i).sortChildren(0, QtCore.Qt.AscendingOrder)
|
self.topLevelItem(i).sortChildren(0, QtCore.Qt.AscendingOrder)
|
||||||
|
@ -740,6 +785,8 @@ class chumArea(RightClickTree):
|
||||||
for c in chums:
|
for c in chums:
|
||||||
oldmood = c.mood
|
oldmood = c.mood
|
||||||
c.setMood(mood)
|
c.setMood(mood)
|
||||||
|
if self.mainwindow.config.showOnlineNumbers():
|
||||||
|
self.showOnlineNumbers()
|
||||||
return oldmood
|
return oldmood
|
||||||
def updateColor(self, handle, color):
|
def updateColor(self, handle, color):
|
||||||
chums = self.findItems(handle, QtCore.Qt.MatchFlags(0))
|
chums = self.findItems(handle, QtCore.Qt.MatchFlags(0))
|
||||||
|
@ -1638,8 +1685,11 @@ class PesterWindow(MovingWindow):
|
||||||
def pesterSelectedChum(self):
|
def pesterSelectedChum(self):
|
||||||
curChum = self.chumList.currentItem()
|
curChum = self.chumList.currentItem()
|
||||||
if curChum:
|
if curChum:
|
||||||
if curChum.text(0) not in self.chumList.groups and \
|
text = str(curChum.text(0))
|
||||||
curChum.text(0) != "Chums":
|
if text.find(" ") != -1:
|
||||||
|
text = text[0:text.rfind(" ")]
|
||||||
|
if text not in self.chumList.groups and \
|
||||||
|
text != "Chums":
|
||||||
self.newConversationWindow(curChum)
|
self.newConversationWindow(curChum)
|
||||||
@QtCore.pyqtSlot(QtGui.QListWidgetItem)
|
@QtCore.pyqtSlot(QtGui.QListWidgetItem)
|
||||||
def newConversationWindow(self, chumlisting):
|
def newConversationWindow(self, chumlisting):
|
||||||
|
@ -2102,6 +2152,14 @@ class PesterWindow(MovingWindow):
|
||||||
elif emptygroupssetting and not curemptygroup:
|
elif emptygroupssetting and not curemptygroup:
|
||||||
self.chumList.showAllGroups()
|
self.chumList.showAllGroups()
|
||||||
self.config.set("emptyGroups", emptygroupssetting)
|
self.config.set("emptyGroups", emptygroupssetting)
|
||||||
|
# online numbers
|
||||||
|
onlinenumsetting = self.optionmenu.showonlinenumbers.isChecked()
|
||||||
|
curonlinenum = self.config.showOnlineNumbers()
|
||||||
|
if onlinenumsetting and not curonlinenum:
|
||||||
|
self.chumList.showOnlineNumbers()
|
||||||
|
elif curonlinenum and not onlinenumsetting:
|
||||||
|
self.chumList.hideOnlineNumbers()
|
||||||
|
self.config.set("onlineNumbers", onlinenumsetting)
|
||||||
self.optionmenu = None
|
self.optionmenu = None
|
||||||
|
|
||||||
@QtCore.pyqtSlot()
|
@QtCore.pyqtSlot()
|
||||||
|
|
Loading…
Reference in a new issue