Bug fix: Allow groups with spaces in the name, validate group names before use
This commit is contained in:
parent
9fa18352db
commit
8a9a0231fc
1 changed files with 32 additions and 23 deletions
|
@ -643,8 +643,8 @@ class chumArea(RightClickTree):
|
||||||
|
|
||||||
def getOptionsMenu(self):
|
def getOptionsMenu(self):
|
||||||
text = str(self.currentItem().text(0))
|
text = str(self.currentItem().text(0))
|
||||||
if text.rfind(" ") != -1:
|
if text.rfind(" (") != -1:
|
||||||
text = text[0:text.rfind(" ")]
|
text = text[0:text.rfind(" (")]
|
||||||
if text == "Chums":
|
if text == "Chums":
|
||||||
return None
|
return None
|
||||||
elif text in self.groups:
|
elif text in self.groups:
|
||||||
|
@ -675,16 +675,16 @@ class chumArea(RightClickTree):
|
||||||
gTemp = []
|
gTemp = []
|
||||||
for i in range(self.topLevelItemCount()):
|
for i in range(self.topLevelItemCount()):
|
||||||
text = str(self.topLevelItem(i).text(0))
|
text = str(self.topLevelItem(i).text(0))
|
||||||
if text.rfind(" ") != -1:
|
if text.rfind(" (") != -1:
|
||||||
text = text[0:text.rfind(" ")]
|
text = text[0:text.rfind(" (")]
|
||||||
gTemp.append([unicode(text), self.topLevelItem(i).isExpanded()])
|
gTemp.append([unicode(text), self.topLevelItem(i).isExpanded()])
|
||||||
self.mainwindow.config.saveGroups(gTemp)
|
self.mainwindow.config.saveGroups(gTemp)
|
||||||
else:
|
else:
|
||||||
item = self.itemAt(event.pos())
|
item = self.itemAt(event.pos())
|
||||||
if item:
|
if item:
|
||||||
text = str(item.text(0))
|
text = str(item.text(0))
|
||||||
if text.rfind(" ") != -1:
|
if text.rfind(" (") != -1:
|
||||||
text = text[0:text.rfind(" ")]
|
text = text[0:text.rfind(" (")]
|
||||||
if text == "Chums" or text in self.groups:
|
if text == "Chums" or text in self.groups:
|
||||||
group = text
|
group = text
|
||||||
else:
|
else:
|
||||||
|
@ -704,8 +704,8 @@ class chumArea(RightClickTree):
|
||||||
currentGroup = self.currentItem()
|
currentGroup = self.currentItem()
|
||||||
if currentGroup:
|
if currentGroup:
|
||||||
text = str(currentGroup.parent().text(0))
|
text = str(currentGroup.parent().text(0))
|
||||||
if text.rfind(" ") != -1:
|
if text.rfind(" (") != -1:
|
||||||
text = text[0:text.rfind(" ")]
|
text = text[0:text.rfind(" (")]
|
||||||
currentGroup = text
|
currentGroup = text
|
||||||
self.moveMenu.clear()
|
self.moveMenu.clear()
|
||||||
actGroup = QtGui.QActionGroup(self)
|
actGroup = QtGui.QActionGroup(self)
|
||||||
|
@ -756,8 +756,8 @@ class chumArea(RightClickTree):
|
||||||
curgroups = []
|
curgroups = []
|
||||||
for i in range(self.topLevelItemCount()):
|
for i in range(self.topLevelItemCount()):
|
||||||
text = str(self.topLevelItem(i).text(0))
|
text = str(self.topLevelItem(i).text(0))
|
||||||
if text.rfind(" ") != -1:
|
if text.rfind(" (") != -1:
|
||||||
text = text[0:text.rfind(" ")]
|
text = text[0:text.rfind(" (")]
|
||||||
curgroups.append(text)
|
curgroups.append(text)
|
||||||
for i,g in enumerate(self.groups):
|
for i,g in enumerate(self.groups):
|
||||||
if g not in curgroups:
|
if g not in curgroups:
|
||||||
|
@ -789,14 +789,14 @@ class chumArea(RightClickTree):
|
||||||
online["Chums"] = online["Chums"]+1
|
online["Chums"] = online["Chums"]+1
|
||||||
for i in range(self.topLevelItemCount()):
|
for i in range(self.topLevelItemCount()):
|
||||||
text = str(self.topLevelItem(i).text(0))
|
text = str(self.topLevelItem(i).text(0))
|
||||||
if text.rfind(" ") != -1:
|
if text.rfind(" (") != -1:
|
||||||
text = text[0:text.rfind(" ")]
|
text = text[0:text.rfind(" (")]
|
||||||
self.topLevelItem(i).setText(0, "%s (%i/%i)" % (text, online[text], totals[text]))
|
self.topLevelItem(i).setText(0, "%s (%i/%i)" % (text, online[text], totals[text]))
|
||||||
def hideOnlineNumbers(self):
|
def hideOnlineNumbers(self):
|
||||||
for i in range(self.topLevelItemCount()):
|
for i in range(self.topLevelItemCount()):
|
||||||
text = str(self.topLevelItem(i).text(0))
|
text = str(self.topLevelItem(i).text(0))
|
||||||
if text.rfind(" ") != -1:
|
if text.rfind(" (") != -1:
|
||||||
text = text[0:text.rfind(" ")]
|
text = text[0:text.rfind(" (")]
|
||||||
self.topLevelItem(i).setText(0, "%s" % (text))
|
self.topLevelItem(i).setText(0, "%s" % (text))
|
||||||
def hideEmptyGroups(self):
|
def hideEmptyGroups(self):
|
||||||
i = 0
|
i = 0
|
||||||
|
@ -812,7 +812,7 @@ class chumArea(RightClickTree):
|
||||||
item = self.currentItem()
|
item = self.currentItem()
|
||||||
text = str(item.text(0))
|
text = str(item.text(0))
|
||||||
if text.find(" ") != -1:
|
if text.find(" ") != -1:
|
||||||
text = text[0:text.rfind(" ")]
|
text = text[0:text.rfind(" (")]
|
||||||
|
|
||||||
if text in self.groups:
|
if text in self.groups:
|
||||||
self.mainwindow.config.delGroup(text)
|
self.mainwindow.config.delGroup(text)
|
||||||
|
@ -831,7 +831,7 @@ class chumArea(RightClickTree):
|
||||||
else:
|
else:
|
||||||
text = str(self.topLevelItem(0).text(0))
|
text = str(self.topLevelItem(0).text(0))
|
||||||
if text.find(" ") != -1:
|
if text.find(" ") != -1:
|
||||||
text = text[0:text.rfind(" ")]
|
text = text[0:text.rfind(" (")]
|
||||||
if text != "Chums":
|
if text != "Chums":
|
||||||
child_1 = QtGui.QTreeWidgetItem(["Chums"])
|
child_1 = QtGui.QTreeWidgetItem(["Chums"])
|
||||||
self.insertTopLevelItems(0, [child_1])
|
self.insertTopLevelItems(0, [child_1])
|
||||||
|
@ -848,8 +848,8 @@ class chumArea(RightClickTree):
|
||||||
child_1.setExpanded(True)
|
child_1.setExpanded(True)
|
||||||
for i in range(self.topLevelItemCount()):
|
for i in range(self.topLevelItemCount()):
|
||||||
text = str(self.topLevelItem(i).text(0))
|
text = str(self.topLevelItem(i).text(0))
|
||||||
if text.rfind(" ") != -1:
|
if text.rfind(" (") != -1:
|
||||||
text = text[0:text.rfind(" ")]
|
text = text[0:text.rfind(" (")]
|
||||||
if text == chumLabel.chum.group:
|
if text == chumLabel.chum.group:
|
||||||
break
|
break
|
||||||
self.topLevelItem(i).addChild(chumLabel)
|
self.topLevelItem(i).addChild(chumLabel)
|
||||||
|
@ -1012,8 +1012,8 @@ class chumArea(RightClickTree):
|
||||||
if index != -1:
|
if index != -1:
|
||||||
expanded = currentGroup.isExpanded()
|
expanded = currentGroup.isExpanded()
|
||||||
text = str(currentGroup.text(0))
|
text = str(currentGroup.text(0))
|
||||||
if text.rfind(" ") != -1:
|
if text.rfind(" (") != -1:
|
||||||
text = text[0:text.rfind(" ")]
|
text = text[0:text.rfind(" (")]
|
||||||
self.mainwindow.config.delGroup(text)
|
self.mainwindow.config.delGroup(text)
|
||||||
self.mainwindow.config.addGroup(gname, expanded)
|
self.mainwindow.config.addGroup(gname, expanded)
|
||||||
gTemp = self.mainwindow.config.getGroups()
|
gTemp = self.mainwindow.config.getGroups()
|
||||||
|
@ -1032,8 +1032,8 @@ class chumArea(RightClickTree):
|
||||||
if not currentGroup:
|
if not currentGroup:
|
||||||
return
|
return
|
||||||
text = str(currentGroup.text(0))
|
text = str(currentGroup.text(0))
|
||||||
if text.rfind(" ") != -1:
|
if text.rfind(" (") != -1:
|
||||||
text = text[0:text.rfind(" ")]
|
text = text[0:text.rfind(" (")]
|
||||||
self.mainwindow.config.delGroup(text)
|
self.mainwindow.config.delGroup(text)
|
||||||
gTemp = self.mainwindow.config.getGroups()
|
gTemp = self.mainwindow.config.getGroups()
|
||||||
self.groups = [g[0] for g in gTemp]
|
self.groups = [g[0] for g in gTemp]
|
||||||
|
@ -1819,7 +1819,7 @@ class PesterWindow(MovingWindow):
|
||||||
if curChum:
|
if curChum:
|
||||||
text = str(curChum.text(0))
|
text = str(curChum.text(0))
|
||||||
if text.find(" ") != -1:
|
if text.find(" ") != -1:
|
||||||
text = text[0:text.rfind(" ")]
|
text = text[0:text.rfind(" (")]
|
||||||
if text not in self.chumList.groups and \
|
if text not in self.chumList.groups and \
|
||||||
text != "Chums":
|
text != "Chums":
|
||||||
self.newConversationWindow(curChum)
|
self.newConversationWindow(curChum)
|
||||||
|
@ -2183,6 +2183,13 @@ class PesterWindow(MovingWindow):
|
||||||
(gname, ok) = QtGui.QInputDialog.getText(self, "Add Group", "Enter a name for the new group:")
|
(gname, ok) = QtGui.QInputDialog.getText(self, "Add Group", "Enter a name for the new group:")
|
||||||
if ok:
|
if ok:
|
||||||
gname = unicode(gname)
|
gname = unicode(gname)
|
||||||
|
if re.search("[^A-Za-z0-9\s]", gname) is not None:
|
||||||
|
msgbox = QtGui.QMessageBox()
|
||||||
|
msgbox.setInformativeText("THIS IS NOT A VALID GROUP NAME")
|
||||||
|
msgbox.setStandardButtons(QtGui.QMessageBox.Ok)
|
||||||
|
ret = msgbox.exec_()
|
||||||
|
self.addgroupdialog = None
|
||||||
|
return
|
||||||
self.config.addGroup(gname)
|
self.config.addGroup(gname)
|
||||||
gTemp = self.config.getGroups()
|
gTemp = self.config.getGroups()
|
||||||
self.chumList.groups = [g[0] for g in gTemp]
|
self.chumList.groups = [g[0] for g in gTemp]
|
||||||
|
@ -2191,6 +2198,8 @@ class PesterWindow(MovingWindow):
|
||||||
self.chumList.showAllGroups()
|
self.chumList.showAllGroups()
|
||||||
if not self.config.showEmptyGroups():
|
if not self.config.showEmptyGroups():
|
||||||
self.chumList.hideEmptyGroups()
|
self.chumList.hideEmptyGroups()
|
||||||
|
if self.config.showOnlineNumbers():
|
||||||
|
self.chumList.showOnlineNumbers()
|
||||||
|
|
||||||
self.addgroupdialog = None
|
self.addgroupdialog = None
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue