-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAbstractContactList.py
executable file
·45 lines (36 loc) · 1.06 KB
/
AbstractContactList.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
from PyQt4.QtGui import QTreeWidget
from PyQt4.QtCore import Qt
from BuddyGroup import BuddyGroup
class AbstractContactList(QTreeWidget):
def __init__(self, parent):
QTreeWidget.__init__(self, parent)
self.connection = None
self.header().hide()
self.setSortingEnabled(True)
self.sortItems(0, Qt.AscendingOrder)
self.buddies = {}
self.muc = {}
self.groups = {}
self.tree = {}
def setRoster(self, rosterKeys):
self.rosterKeys = rosterKeys
def setConnection(self, con):
self.connection = con
def addGroup(self, group):
if group:
if group not in self.groups.keys():
self.groups[group] = BuddyGroup(group)
self.tree[group] = {}
self.addTopLevelItem(self.groups[group])
def removeGroup(self, group):
if group:
self.takeTopLevelItem(self.indexOfTopLevelItem(self.groups[group]))
del self.groups[group]
def presence(self, data):
jid, show, subscription = data
if str(jid) is not self.connection.jabberID:
try:
self.buddies[str(jid)].setStatus(show, subscription)
self.hideGroups()
except:
pass