# HG changeset patch # User sheepluva # Date 1296275964 -3600 # Node ID 746ddd590deed0725d9f192d428ce8ef6d05437e # Parent 813ef4e8e385fbfa9b4de502c0fb27442a57fa12 nick sorting: give letters priority over all other chars diff -r 813ef4e8e385 -r 746ddd590dee QTfrontend/chatwidget.cpp --- 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) :