Permalink
Browse files

changed storage of messages and formating

  • Loading branch information...
1 parent 33a6752 commit 5373d0a6f434d30c6680fd2236752b0f744b3615 Kai Bouché committed Jan 24, 2012
Showing with 12 additions and 5 deletions.
  1. +2 −2 src/instantsoupdata.py
  2. +10 −3 src/instantsoupmain.pyw
View
@@ -231,11 +231,11 @@ def handle_say_command(self, data, tcp_socket):
if client_id in self.users:
nickname = self.users[client_id]
- time = strftime("%Y-%m-%d %H:%M:%S", gmtime())
+ time = QtCore.QDateTime.currentDateTime()
message = QtCore.QString(" ".join(data.split("\x00")[2:]))
if message.trimmed().length():
- entry = ("[%s] %s: %s" % (time, nickname, message))
+ entry = (time, nickname, message)
if key not in self.channel_history:
self.channel_history[key] = list()
View
@@ -114,18 +114,25 @@ class MainWindow(QtGui.QMainWindow):
if key in self.client.channel_history:
if key in self.tabs:
tab = self.tabs[key]
+
tab.chatHistory.clear()
tab.chatHistory.setOpenExternalLinks(True)
- for message in self.client.channel_history[key]:
+
+ for current_message in self.client.channel_history[key]:
+ (time, nickname, message) = current_message
+
# see http://stackoverflow.com/questions/3321256/how-to
# -use-regex-to-replace-urls-with-an-html-link-in-qt
- qmessage = QString(message)
+ qmessage = QtCore.QString(message)
+ # convert urls to hyperlinks
search = QRegExp("((?:https?|ftp)://\\S+)")
replace = QString("<a href=\"\\1\">\\1</a>")
qmessage.replace(search, replace)
- tab.chatHistory.append(qmessage)
+ line = ("<p><b>%s</b> <em>%s</em></p><p>%s</p>" % (nickname, time.toString(), qmessage))
+
+ tab.chatHistory.append(line)
def get_invite_client_ids(self, tree_items):
client_ids = set()

0 comments on commit 5373d0a

Please sign in to comment.