QTfrontend/model/playerslistmodel.cpp
changeset 7728 664738870325
parent 7727 bd252cacabe8
child 7731 262228c64f15
--- a/QTfrontend/model/playerslistmodel.cpp	Sun Oct 07 23:33:09 2012 +0400
+++ b/QTfrontend/model/playerslistmodel.cpp	Sun Oct 07 23:59:55 2012 +0400
@@ -85,9 +85,11 @@
 {
     insertRow(rowCount());
 
-    setData(index(rowCount() - 1), nickname);
+    QModelIndex mi = index(rowCount() - 1);
+    setData(mi, nickname);
 
-    updateIcon(index(rowCount() - 1));
+    updateSortData(mi);
+    updateIcon(mi);
 }
 
 
@@ -107,6 +109,11 @@
     if(mil.size())
     {
         setData(mil[0], isSet, flagType);
+
+        if(flagType == Friend || flagType == ServerAdmin
+                || flagType == Ignore || flagType == RoomAdmin)
+            updateSortData(mil[0]);
+
         updateIcon(mil[0]);
     }
 }
@@ -188,3 +195,16 @@
 
     return iconsCache;
 }
+
+void PlayersListModel::updateSortData(const QModelIndex & index)
+{
+    QString result = QString("%1%2%3%4%5")
+            .arg(1 - index.data(RoomAdmin).toInt())
+            .arg(1 - index.data(ServerAdmin).toInt())
+            .arg(1 - index.data(Friend).toInt())
+            .arg(index.data(Ignore).toInt())
+            .arg(index.data(Qt::DisplayRole).toString().toLower())
+            ;
+
+    setData(index, result, SortRole);
+}