QTfrontend/ui/widget/chatwidget.cpp
changeset 6229 4c834af76c3b
parent 6227 ce60b734fff1
child 6231 810b9ced2b67
--- a/QTfrontend/ui/widget/chatwidget.cpp	Sat Oct 29 11:47:37 2011 +0200
+++ b/QTfrontend/ui/widget/chatwidget.cpp	Sat Oct 29 15:31:45 2011 +0200
@@ -34,6 +34,8 @@
 #include <QDateTime>
 #include <QTime>
 
+#include <QMessageBox>
+
 
 #include "HWDataManager.h"
 #include "hwconsts.h"
@@ -103,6 +105,7 @@
 QString * HWChatWidget::s_styleSheet = NULL;
 QStringList * HWChatWidget::s_displayNone = NULL;
 bool HWChatWidget::s_isTimeStamped = true;
+QString HWChatWidget::s_tsFormat = ":mm:ss";
 
 const QString & HWChatWidget::styleSheet()
 {
@@ -173,6 +176,7 @@
 
     QStringList victims = QString(style).
                                 remove(displayed). // remove visible stuff
+                                trimmed().
                                 split(split). // get a list of the names
                                 filter(nohierarchy). // only direct class names
                                 replaceInStrings(QRegExp("^."),""); // crop .
@@ -183,6 +187,17 @@
         s_isTimeStamped = false;
         victims.removeAll("timestamp");
     }
+    else
+    {
+        s_isTimeStamped = true;
+        s_tsFormat =
+            ((victims.contains("timestamp:hours"))?"":"hh") +
+            QString(":mm:") +
+            ((victims.contains("timestamp:seconds"))?"":"ss");
+    }
+
+    victims.removeAll("timestamp:hours");
+    victims.removeAll("timestamp:seconds");
 
     victims.removeDuplicates();
 
@@ -540,7 +555,7 @@
     bool isHL = false;
 
     if ((c != 3) && (!nick.isEmpty()) &&
-        (nick != m_userNick) && (m_userNick.isEmpty()))
+        (nick != m_userNick) && (!m_userNick.isEmpty()))
     {
         QString lcStr = str.toLower();
 
@@ -569,7 +584,7 @@
     {
         QString tsMarkUp = "<span class=\"timestamp\">[%1]</span> ";
         QTime now = QDateTime::currentDateTime().time();
-        line = tsMarkUp.arg(now.toString(":mm:ss")) + line;
+        line = tsMarkUp.arg(now.toString(s_tsFormat)) + line;
     }
 
     line = QString("<span class=\"%1\">%2</span>").arg(cssClass).arg(line);