Skip to content
This repository was archived by the owner on Aug 13, 2019. It is now read-only.

Cleanup #1

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*.pyc
.project
.pydevproject
.settings

114 changes: 58 additions & 56 deletions pytalk/BuddyItem.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,71 +8,73 @@
from jabber import STATUS_IMAGE

class BuddyItem(QTreeWidgetItem):
"""
BuddyItem implements the view of a Buddy from the Roster
"""
"""
BuddyItem implements the view of a Buddy from the Roster
"""

dialog = None
msg = None
dialog = None
msg = None

def __init__(self, parent, jid, con):
QTreeWidgetItem.__init__(self, parent, [jid], QTreeWidgetItem.UserType+1)
def __init__(self, parent, jid, con):
QTreeWidgetItem.__init__(self, parent, [jid], QTreeWidgetItem.UserType+1)

# QTreeWidgetItem configuration
self.setFlags(Qt.ItemIsDragEnabled | Qt.ItemIsEnabled) # we can move a contact
self.parent = parent
self.jid = jid
self.name = jid
self.setStatus(STATUS.unavailable)
self.connectionThread = con
def setStatus(self, status):
self.status = status
if self.status.index not in range(6):
self.status = STATUS.unavailable
settings = QSettings("Trunat", "PyTalk")
settings.beginGroup("preferences")
repStatus = settings.value("images_status", QVariant("images/status/")).toString()
fileStatus = settings.value(str(self.status), QVariant(STATUS_IMAGE[self.status.index])).toString()
settings.endGroup()
self.setIcon(0, QIcon(repStatus+fileStatus))
# QTreeWidgetItem configuration
self.setFlags(Qt.ItemIsDragEnabled | Qt.ItemIsEnabled) # we can move a contact
self.parent = parent
self.jid = jid
self.name = jid
self.setStatus(STATUS.unavailable)
self.connectionThread = con
def setStatus(self, status):
self.status = status
if self.status not in range(6):
self.status = STATUS.unavailable
settings = QSettings("Trunat", "PyTalk")
settings.beginGroup("preferences")
repStatus = settings.value("images_status", QVariant("images/status/")).toString()
fileStatus = settings.value(str(self.status), QVariant(STATUS_IMAGE[self.status])).toString()
settings.endGroup()
self.setIcon(0, QIcon(repStatus+fileStatus))

def setName(self, name):
if name:
self.name = name
self.setText(0, name)
def setName(self, name):
if name:
self.name = name
self.setText(0, name)

def status(self):
return status
def DEAstatus(self):
return status

def isAway(self):
return (self.status == STATUS.away or self.status == STATUS.xa)
def isAway(self):
return (self.status == STATUS.away or self.status == STATUS.xa)

def isOffline(self):
if self.status == STATUS.unavailable:
return True
else:
return False
def isOffline(self):
if self.status == STATUS.unavailable:
return True
else:
return False

def createDialog(self):
if not self.dialog:
self.dialog = QDialog()
self.dialog.setWindowIcon(QIcon("images/mail.png"))
def createDialog(self):
if not self.dialog:
self.dialog = QDialog()
self.dialog.setWindowIcon(QIcon("images/mail.png"))

self.msg = MessageBox(self.dialog, self.connectionThread, self.jid, self.name)
layout = QVBoxLayout(self.dialog)
layout.addWidget(self.msg)
self.dialog.setLayout(layout)
self.dialog.setWindowTitle(self.dialog.tr("Chat with ") + self.name)
self.dialog.show()
self.dialog.raise_()
self.msg = MessageBox(self.dialog, self.connectionThread, self.jid, self.name)
layout = QVBoxLayout(self.dialog)
layout.addWidget(self.msg)
self.dialog.setLayout(layout)
self.dialog.setWindowTitle(self.dialog.tr("Chat with ") + self.name)
self.dialog.show()
self.dialog.raise_()

def receiveMessage(self, event):
self.createDialog()
self.msg.receiveMessage(event)
def receiveMessage(self, event):
print "recieveMessage"
self.createDialog()
self.msg.receiveMessage(event)

def sendMessage(self):
self.createDialog()
def sendMessage(self):
print "sendMessage"
self.createDialog()

def __str__(self):
return u'%s' % self.name
def __str__(self):
return u'%s' % self.name
7 changes: 4 additions & 3 deletions pytalk/BuddyList.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class BuddyList(QTreeWidget):

def __init__(self, parent):
QTreeWidget.__init__(self, parent)

self.connection = None
# QTreeWidgetItem configuration
self.header().hide()
Expand All @@ -33,17 +34,17 @@ def __init__(self, parent):
def setConnection(self, con):
self.connection = con

def addItem(self, jid):
def add_item(self, jid):
if self.connection:
group = self.connection.getGroups(jid)[0]
self.addGroup(group)
self.add_group(group)
if jid not in self.buddies.keys():
self.buddies[jid] = BuddyItem(self.groups[group],jid, self.connection)
self.buddies[jid].setName(self.connection.getName(jid))
self.groups[group].addChild(self.buddies[jid])
self.tree[group][jid] = self.buddies[jid]

def addGroup(self, group):
def add_group(self, group):
if group:
if group not in self.groups.keys():
self.groups[group] = BuddyGroup(group)
Expand Down
3 changes: 2 additions & 1 deletion pytalk/ConnectionDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
from PyQt4.QtCore import QSettings, QVariant, SIGNAL
from ui.ui_ConnectionDialog import Ui_ConnectionDialog

class ConnectionDialog(QDialog, Ui_ConnectionDialog):

class DEADConnectionDialog(QDialog, Ui_ConnectionDialog):
def __init__(self, parent):
QDialog.__init__(self, parent)
self.setupUi(self)
Expand Down
Loading