QTfrontend/chatwidget.cpp
changeset 4877 746ddd590dee
parent 4876 813ef4e8e385
child 4884 b2006a9f0fbc
equal deleted inserted replaced
4876:813ef4e8e385 4877:746ddd590dee
    35 ListWidgetNickItem::ListWidgetNickItem(const QString& nick) : QListWidgetItem(nick) {}
    35 ListWidgetNickItem::ListWidgetNickItem(const QString& nick) : QListWidgetItem(nick) {}
    36 
    36 
    37 bool ListWidgetNickItem::operator< (const QListWidgetItem & other) const
    37 bool ListWidgetNickItem::operator< (const QListWidgetItem & other) const
    38 {
    38 {
    39     // case in-sensitive comparison of the associated strings
    39     // case in-sensitive comparison of the associated strings
    40     return (text().compare(other.text(), Qt::CaseInsensitive) < 0);
    40     // chars that are no letters are sorted at the end of the list
       
    41 
       
    42     QString txt1 = text().toLower();
       
    43     QString txt2 = other.text().toLower();
       
    44 
       
    45     bool firstIsShorter = (txt1.size() < txt2.size());
       
    46     int len = firstIsShorter?txt1.size():txt2.size();
       
    47 
       
    48     for (int i = 0; i < len; i++)
       
    49     {
       
    50         if (txt1[i] == txt2[i])
       
    51             continue;
       
    52         if (txt1[i].isLetter() != txt2[i].isLetter())
       
    53             return txt1[i].isLetter();
       
    54         return (txt1[i] < txt2[i]);
       
    55     }
       
    56 
       
    57     return firstIsShorter;
    41 }
    58 }
    42 
    59 
    43 HWChatWidget::HWChatWidget(QWidget* parent, QSettings * gameSettings, SDLInteraction * sdli, bool notify) :
    60 HWChatWidget::HWChatWidget(QWidget* parent, QSettings * gameSettings, SDLInteraction * sdli, bool notify) :
    44   QWidget(parent),
    61   QWidget(parent),
    45   mainLayout(this)
    62   mainLayout(this)