Manually rearrange chumroll

This commit is contained in:
Kiooeht 2011-11-25 18:45:20 -08:00
parent d1ecdb2a38
commit e9e97ab49c
5 changed files with 71 additions and 5 deletions

View file

@ -39,6 +39,7 @@ CHANGELOG
* New smilies - Kiooeht [evacipatedBox]
* Refresh theme in options - Kiooeht [evacipatedBox]
* Separate tabbed/untabbed windows for conversaions and memos - Kiooeht [evacipatedBox]
* Manually rearrange chumroll - Kiooeht [evacipatedBox] (Idea: [turntableAbbess (aka. TA or SGRILL)])
* Bug fixes
* Don't delete random chum when blocking someone not on chumroll - Kiooeht [evacipatedBox]
* Openning global userlist doesn't reset OP status of memo users - Kiooeht [evacipatedBox]
@ -46,6 +47,7 @@ CHANGELOG
* Trollian 2.5 tray icon is now Trollian icon - Kiooeht [evacipatedBox]
* Don't screw up <c> tags with the mispeller - Kiooeht [evacipatedBox]
* Don't break if profile uses non-existant theme - Kiooeht [evacipatedBox]
* Properly rearrange groups when not displaying number of online chums - Kiooeht [evacipatedBox]
* Mac Bug fixes
* Create all datadir stuff - Lexi [lexicalNuance]

View file

@ -24,6 +24,8 @@ Features
* "Pester" menu option to just pester a handle
* Auto-login Nickserv
* Make toast notifications only on certain chums
* Local alisas for chums
* Italics/uderline - needed for canon
Bugs
----

View file

@ -1112,6 +1112,7 @@ class PesterOptions(QtGui.QDialog):
self.sortBox = QtGui.QComboBox(self)
self.sortBox.addItem("Alphabetically")
self.sortBox.addItem("By Mood")
self.sortBox.addItem("Manually")
method = self.config.sortMethod()
if method >= 0 and method < self.sortBox.count():
self.sortBox.setCurrentIndex(method)

View file

@ -329,8 +329,9 @@ class chumArea(RightClickTree):
event.ignore()
return
thisitem = str(event.source().currentItem().text(0))
if thisitem.rfind(" ") != -1:
thisitem = thisitem[0:thisitem.rfind(" ")]
if thisitem.rfind(" (") != -1:
thisitem = thisitem[0:thisitem.rfind(" (")]
# Drop item is a group
if thisitem == "Chums" or thisitem in self.groups:
droppos = self.itemAt(event.pos())
if not droppos: return
@ -352,24 +353,46 @@ class chumArea(RightClickTree):
text = text[0:text.rfind(" (")]
gTemp.append([unicode(text), self.topLevelItem(i).isExpanded()])
self.mainwindow.config.saveGroups(gTemp)
# Drop item is a chum
else:
item = self.itemAt(event.pos())
if item:
text = str(item.text(0))
# Figure out which group to drop into
if text.rfind(" (") != -1:
text = text[0:text.rfind(" (")]
if text == "Chums" or text in self.groups:
group = text
gitem = item
else:
ptext = str(item.parent().text(0))
if ptext.rfind(" ") != -1:
ptext = ptext[0:ptext.rfind(" ")]
group = ptext
gitem = item.parent()
chumLabel = event.source().currentItem()
chumLabel.chum.group = group
self.mainwindow.chumdb.setGroup(chumLabel.chum.handle, group)
self.takeItem(chumLabel)
self.addItem(chumLabel)
# Using manual chum reordering
if self.mainwindow.config.sortMethod() == 2:
insertIndex = gitem.indexOfChild(item)
if insertIndex == -1:
insertIndex = 0
gitem.insertChild(insertIndex, chumLabel)
chums = self.mainwindow.config.chums()
if item == gitem:
item = gitem.child(0)
inPos = chums.index(str(item.text(0)))
if chums.index(thisitem) < inPos:
inPos -= 1
chums.remove(thisitem)
chums.insert(inPos, unicode(thisitem))
self.mainwindow.config.setChums(chums)
else:
self.addItem(chumLabel)
if self.mainwindow.config.showOnlineNumbers():
self.showOnlineNumbers()
@ -538,7 +561,33 @@ class chumArea(RightClickTree):
text = text[0:text.rfind(" (")]
if text == chumLabel.chum.group:
break
self.topLevelItem(i).addChild(chumLabel)
# Manual sorting
if self.mainwindow.config.sortMethod() == 2:
chums = self.mainwindow.config.chums()
fi = chums.index(chumLabel.chum.handle)
c = 1
# TODO: Rearrange chums list on drag-n-drop
bestj = 0
bestname = ""
if fi > 0:
while not bestj:
for j in xrange(self.topLevelItem(i).childCount()):
if chums[fi-c] == str(self.topLevelItem(i).child(j).text(0)):
bestj = j
bestname = chums[fi-c]
break
c += 1
if fi-c < 0:
break
if bestname:
self.topLevelItem(i).insertChild(bestj+1, chumLabel)
else:
self.topLevelItem(i).insertChild(bestj, chumLabel)
#sys.exit(0)
self.topLevelItem(i).addChild(chumLabel)
else: # All other sorting
self.topLevelItem(i).addChild(chumLabel)
self.sort()
if self.mainwindow.config.showOnlineNumbers():
self.showOnlineNumbers()
@ -628,7 +677,9 @@ class chumArea(RightClickTree):
return c
def sort(self):
if self.mainwindow.config.sortMethod() == 1:
if self.mainwindow.config.sortMethod() == 2:
pass # Do nothing!!!!! :OOOOOOO It's manual, bitches
elif self.mainwindow.config.sortMethod() == 1:
for i in range(self.topLevelItemCount()):
self.moodSort(i)
else:

View file

@ -121,6 +121,16 @@ class userConfig(object):
if not self.config.has_key('chums'):
self.set("chums", [])
return self.config.get('chums', [])
def setChums(self, newchums):
fp = open(self.filename) # what if we have two clients open??
newconfig = json.load(fp)
fp.close()
oldchums = newconfig['chums']
# Time to merge these two! :OOO
for c in list(set(oldchums) - set(newchums)):
newchums.append(c)
self.set("chums", newchums)
def hideOfflineChums(self):
return self.config.get('hideOfflineChums', False)
def defaultprofile(self):