QTfrontend/model/playerslistmodel.cpp
changeset 9503 8f9b04138456
parent 8891 bf67b4d7d7b4
child 9725 68b5d87cfdb0
equal deleted inserted replaced
9501:dc3d658de350 9503:8f9b04138456
     9 #include "hwconsts.h"
     9 #include "hwconsts.h"
    10 
    10 
    11 PlayersListModel::PlayersListModel(QObject *parent) :
    11 PlayersListModel::PlayersListModel(QObject *parent) :
    12     QAbstractListModel(parent)
    12     QAbstractListModel(parent)
    13 {
    13 {
    14 
    14     m_fontInRoom = QFont();
       
    15     m_fontInRoom.setItalic(true);
    15 }
    16 }
    16 
    17 
    17 
    18 
    18 int PlayersListModel::rowCount(const QModelIndex &parent) const
    19 int PlayersListModel::rowCount(const QModelIndex &parent) const
    19 {
    20 {
   221         << index.data(Registered).toBool()
   222         << index.data(Registered).toBool()
   222         << index.data(Friend).toBool()
   223         << index.data(Friend).toBool()
   223         << index.data(Ignore).toBool()
   224         << index.data(Ignore).toBool()
   224         << index.data(InGame).toBool()
   225         << index.data(InGame).toBool()
   225         << index.data(RoomFilterRole).toBool()
   226         << index.data(RoomFilterRole).toBool()
       
   227         << index.data(InRoom).toBool()
   226         ;
   228         ;
   227 
   229 
   228     for(int i = flags.size() - 1; i >= 0; --i)
   230     for(int i = flags.size() - 1; i >= 0; --i)
   229         if(flags[i])
   231         if(flags[i])
   230             iconNum |= 1 << i;
   232             iconNum |= 1 << i;
   251                 if(index.data(Ready).toBool())
   253                 if(index.data(Ready).toBool())
   252                     painter.drawPixmap(0, 0, 16, 16, QPixmap(":/res/chat/lamp.png"));
   254                     painter.drawPixmap(0, 0, 16, 16, QPixmap(":/res/chat/lamp.png"));
   253                 else
   255                 else
   254                     painter.drawPixmap(0, 0, 16, 16, QPixmap(":/res/chat/lamp_off.png"));
   256                     painter.drawPixmap(0, 0, 16, 16, QPixmap(":/res/chat/lamp_off.png"));
   255             }
   257             }
       
   258         } else
       
   259         { // we're in lobby
       
   260             if(!index.data(InRoom).toBool())
       
   261                 painter.drawPixmap(0, 0, 16, 16, QPixmap(":/res/Flake.png"));
   256         }
   262         }
   257 
   263 
   258         QString mainIconName(":/res/chat/");
   264         QString mainIconName(":/res/chat/");
   259 
   265 
   260         if(index.data(RoomAdmin).toBool())
   266         if(index.data(ServerAdmin).toBool())
   261             mainIconName += "roomadmin";
       
   262         else if(index.data(ServerAdmin).toBool())
       
   263             mainIconName += "serveradmin";
   267             mainIconName += "serveradmin";
   264         else
   268         else
   265             mainIconName += "hedgehog";
   269         {
       
   270             if(index.data(RoomAdmin).toBool())
       
   271                 mainIconName += "roomadmin";
       
   272             else
       
   273                 mainIconName += "hedgehog";
       
   274 
       
   275             if(index.data(Contributor).toBool())
       
   276                 mainIconName += "contributor";
       
   277         }
   266 
   278 
   267         if(!index.data(Registered).toBool())
   279         if(!index.data(Registered).toBool())
   268             mainIconName += "_gray";
   280             mainIconName += "_gray";
   269 
   281 
   270         painter.drawPixmap(8, 0, 16, 16, QPixmap(mainIconName + ".png"));
   282         painter.drawPixmap(8, 0, 16, 16, QPixmap(mainIconName + ".png"));