- Show unready status in icon
authorunc0rr
Wed, 17 Oct 2012 23:09:16 +0400
changeset 7764 28613382e3f3
parent 7763 6ab7307fcec3
child 7765 1e162c1d6dc7
- Show unready status in icon - Fix bug with search for player in model by nick performing "starts with" test
QTfrontend/hedgewars.qrc
QTfrontend/model/playerslistmodel.cpp
QTfrontend/res/chat/lamp_off.png
--- a/QTfrontend/hedgewars.qrc	Tue Oct 16 22:57:48 2012 -0400
+++ b/QTfrontend/hedgewars.qrc	Wed Oct 17 23:09:16 2012 +0400
@@ -143,5 +143,6 @@
         <file>res/chat/roomadmin_gray.png</file>
         <file>res/chat/serveradmin.png</file>
         <file>res/chat/serveradmin_gray.png</file>
+        <file>res/chat/lamp_off.png</file>
     </qresource>
 </RCC>
--- a/QTfrontend/model/playerslistmodel.cpp	Tue Oct 16 22:57:48 2012 -0400
+++ b/QTfrontend/model/playerslistmodel.cpp	Wed Oct 17 23:09:16 2012 +0400
@@ -97,7 +97,7 @@
 
 void PlayersListModel::removePlayer(const QString & nickname)
 {
-    QModelIndexList mil = match(index(0), Qt::DisplayRole, nickname);
+    QModelIndexList mil = match(index(0), Qt::DisplayRole, nickname, 1, Qt::MatchExactly);
 
     if(mil.size())
         removeRow(mil[0].row());
@@ -106,25 +106,31 @@
 
 void PlayersListModel::playerJoinedRoom(const QString & nickname)
 {
-    QModelIndexList mil = match(index(0), Qt::DisplayRole, nickname);
+    QModelIndexList mil = match(index(0), Qt::DisplayRole, nickname, 1, Qt::MatchExactly);
 
     if(mil.size())
+    {
         setData(mil[0], "1", RoomFilterRole);
+        updateIcon(mil[0]);
+    }
 }
 
 
 void PlayersListModel::playerLeftRoom(const QString & nickname)
 {
-    QModelIndexList mil = match(index(0), Qt::DisplayRole, nickname);
+    QModelIndexList mil = match(index(0), Qt::DisplayRole, nickname, 1, Qt::MatchExactly);
 
     if(mil.size())
+    {
         setData(mil[0], "0", RoomFilterRole);
+        updateIcon(mil[0]);
+    }
 }
 
 
 void PlayersListModel::setFlag(const QString &nickname, StateFlag flagType, bool isSet)
 {
-    QModelIndexList mil = match(index(0), Qt::DisplayRole, nickname);
+    QModelIndexList mil = match(index(0), Qt::DisplayRole, nickname, 1, Qt::MatchExactly);
 
     if(mil.size())
     {
@@ -161,7 +167,7 @@
 
 bool PlayersListModel::isFlagSet(const QString & nickname, StateFlag flagType)
 {
-    QModelIndexList mil = match(index(0), Qt::DisplayRole, nickname);
+    QModelIndexList mil = match(index(0), Qt::DisplayRole, nickname, 1, Qt::MatchExactly);
 
     if(mil.size())
         return mil[0].data(flagType).toBool();
@@ -199,6 +205,7 @@
         << index.data(Registered).toBool()
         << index.data(Friend).toBool()
         << index.data(Ignore).toBool()
+        << (index.data(RoomFilterRole).toString() == "1")
         ;
 
     for(int i = flags.size() - 1; i >= 0; --i)
@@ -216,8 +223,11 @@
 
         QPainter painter(&result);
 
-        if(index.data(Ready).toBool())
-            painter.drawPixmap(0, 0, 16, 16, QPixmap(":/res/chat/lamp.png"));
+        if(index.data(RoomFilterRole).toString() == "1")
+            if(index.data(Ready).toBool())
+                painter.drawPixmap(0, 0, 16, 16, QPixmap(":/res/chat/lamp.png"));
+            else
+                painter.drawPixmap(0, 0, 16, 16, QPixmap(":/res/chat/lamp_off.png"));
 
         QString mainIconName(":/res/chat/");
 
Binary file QTfrontend/res/chat/lamp_off.png has changed