def __init__(self, db, conversation): ViewMessage.__init__(self, db, conversation) self.message = conversation self.message.getEntries(db) self.resize(800, 700) self.nextColour = None senders = {} maxDate = self.message.sentDate body = QTextEdit() for entry in self.message.entries: senderId = entry['intSenderId'] if senderId in senders: sender, colour = senders[senderId] else: sender = contact.getContactFromId(db, senderId) colour = self.getNextColour() senders[senderId] = (sender, colour) dateSent = entry['datSent'] if dateSent > maxDate: maxDate = dateSent dateSent = time.strftime('%Y-%m-%d %H:%M:%S', self.message.sentDate) sender = u"<b style='color: " + unicode(colour) + u"'>" + unicode(sender) + u'</b>: ' sent = u'<i>' + unicode(dateSent) + u'</i>:' row = sender + sent + u'<br/>' + entry['strText'] + u'<br/>' row += u"<div style='height:20px; clear: both'></div>" body.insertHtml(row) participants = u'Participants: ' for id in senders: participants += unicode(senders[id][0]) + u', ' self.senderLabel.setText(participants[:-2]) self.sentLabel.setText('Between ' + time.strftime('%Y-%m-%d %H:%M:%S', self.message.sentDate) + \ ' and ' + time.strftime('%Y-%m-%d %H:%M:%S', maxDate)) body.setReadOnly(True) self.recipientsWidget.hide() grid = QGridLayout() grid.setSpacing(10) grid.addWidget(body, 0, 0) self.mainView.setLayout(grid)
def __init__(self, db, sms): ViewMessage.__init__(self, db, sms) self.message = sms self.resize(400, 250) text = QTextEdit(self.message.text) text.setReadOnly(True) grid = QGridLayout() grid.setSpacing(10) grid.addWidget(text, 0, 0) self.mainView.setLayout(grid)
def __init__(self, db, email): ViewMessage.__init__(self, db, email) self.message = email self.resize(600, 700) subjectLabel = QLabel(u'Subject: ' + self.message.subject) #bodyLabel = QTextEdit(self.message.bodyPlain) body = QTextEdit() if self.message.bodyHtml: body.insertHtml(self.message.bodyHtml) else: body.insertPlainText(self.message.bodyPlain) body.textCursor().setPosition(0) body.setReadOnly(True) grid = QGridLayout() grid.setSpacing(10) grid.addWidget(subjectLabel, 0, 0) grid.addWidget(body, 1, 0) self.mainView.setLayout(grid)