QTfrontend/chatwidget.cpp
changeset 4877 746ddd590dee
parent 4876 813ef4e8e385
child 4884 b2006a9f0fbc
--- a/QTfrontend/chatwidget.cpp	Sat Jan 29 01:08:39 2011 +0100
+++ b/QTfrontend/chatwidget.cpp	Sat Jan 29 05:39:24 2011 +0100
@@ -37,7 +37,24 @@
 bool ListWidgetNickItem::operator< (const QListWidgetItem & other) const
 {
     // case in-sensitive comparison of the associated strings
-    return (text().compare(other.text(), Qt::CaseInsensitive) < 0);
+    // chars that are no letters are sorted at the end of the list
+
+    QString txt1 = text().toLower();
+    QString txt2 = other.text().toLower();
+
+    bool firstIsShorter = (txt1.size() < txt2.size());
+    int len = firstIsShorter?txt1.size():txt2.size();
+
+    for (int i = 0; i < len; i++)
+    {
+        if (txt1[i] == txt2[i])
+            continue;
+        if (txt1[i].isLetter() != txt2[i].isLetter())
+            return txt1[i].isLetter();
+        return (txt1[i] < txt2[i]);
+    }
+
+    return firstIsShorter;
 }
 
 HWChatWidget::HWChatWidget(QWidget* parent, QSettings * gameSettings, SDLInteraction * sdli, bool notify) :