QTfrontend/model/playerslistmodel.cpp
author unc0rr
Sun, 07 Oct 2012 23:59:55 +0400
changeset 7728 664738870325
parent 7727 bd252cacabe8
child 7731 262228c64f15
permissions -rw-r--r--
Bring back sorting
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7725
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
     1
#include <QModelIndexList>
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
     2
#include <QModelIndex>
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
     3
#include <QPainter>
7727
bd252cacabe8 Bring icons back
unc0rr
parents: 7725
diff changeset
     4
#include <QDebug>
7725
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
     5
7723
ca05b576ec74 Start moving to players list model.
unc0rr
parents:
diff changeset
     6
#include "playerslistmodel.h"
ca05b576ec74 Start moving to players list model.
unc0rr
parents:
diff changeset
     7
ca05b576ec74 Start moving to players list model.
unc0rr
parents:
diff changeset
     8
PlayersListModel::PlayersListModel(QObject *parent) :
7725
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
     9
    QAbstractListModel(parent)
7723
ca05b576ec74 Start moving to players list model.
unc0rr
parents:
diff changeset
    10
{
ca05b576ec74 Start moving to players list model.
unc0rr
parents:
diff changeset
    11
ca05b576ec74 Start moving to players list model.
unc0rr
parents:
diff changeset
    12
}
ca05b576ec74 Start moving to players list model.
unc0rr
parents:
diff changeset
    13
7725
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    14
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    15
int PlayersListModel::rowCount(const QModelIndex &parent) const
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    16
{
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    17
    if(parent.isValid())
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    18
        return 0;
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    19
    else
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    20
        return m_data.size();
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    21
}
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    22
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    23
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    24
QVariant PlayersListModel::data(const QModelIndex &index, int role) const
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    25
{
7727
bd252cacabe8 Bring icons back
unc0rr
parents: 7725
diff changeset
    26
    if(!index.isValid() || index.row() < 0 || index.row() >= rowCount() || index.column() != 0)
7725
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    27
        return QVariant(QVariant::Invalid);
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    28
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    29
    return m_data.at(index.row()).value(role);
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    30
}
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    31
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    32
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    33
bool PlayersListModel::setData(const QModelIndex &index, const QVariant &value, int role)
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    34
{
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    35
    if(!index.isValid() || index.row() < 0 || index.row() >= rowCount() || index.column() != 0)
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    36
        return false;
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    37
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    38
    m_data[index.row()].insert(role, value);
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    39
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    40
    emit dataChanged(index, index);
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    41
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    42
    return true;
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    43
}
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    44
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    45
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    46
bool PlayersListModel::insertRow(int row, const QModelIndex &parent)
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    47
{
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    48
    return insertRows(row, 1, parent);
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    49
}
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    50
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    51
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    52
bool PlayersListModel::insertRows(int row, int count, const QModelIndex &parent)
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    53
{
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    54
    if(parent.isValid() || row > rowCount() || row < 0 || count < 1)
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    55
        return false;
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    56
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    57
    beginInsertRows(parent, row, row + count - 1);
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    58
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    59
    for(int i = 0; i < count; ++i)
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    60
        m_data.insert(row, DataEntry());
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    61
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    62
    endInsertRows();
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    63
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    64
    return true;
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    65
}
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    66
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    67
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    68
bool PlayersListModel::removeRows(int row, int count, const QModelIndex &parent)
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    69
{
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    70
    if(parent.isValid() || row + count > rowCount() || row < 0 || count < 1)
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    71
        return false;
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    72
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    73
    beginRemoveRows(parent, row, row + count - 1);
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    74
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    75
    for(int i = 0; i < count; ++i)
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    76
        m_data.removeAt(row);
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    77
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    78
    endRemoveRows();
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    79
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    80
    return true;
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    81
}
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    82
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    83
7723
ca05b576ec74 Start moving to players list model.
unc0rr
parents:
diff changeset
    84
void PlayersListModel::addPlayer(const QString & nickname)
ca05b576ec74 Start moving to players list model.
unc0rr
parents:
diff changeset
    85
{
7725
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    86
    insertRow(rowCount());
7723
ca05b576ec74 Start moving to players list model.
unc0rr
parents:
diff changeset
    87
7728
664738870325 Bring back sorting
unc0rr
parents: 7727
diff changeset
    88
    QModelIndex mi = index(rowCount() - 1);
664738870325 Bring back sorting
unc0rr
parents: 7727
diff changeset
    89
    setData(mi, nickname);
7725
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    90
7728
664738870325 Bring back sorting
unc0rr
parents: 7727
diff changeset
    91
    updateSortData(mi);
664738870325 Bring back sorting
unc0rr
parents: 7727
diff changeset
    92
    updateIcon(mi);
7723
ca05b576ec74 Start moving to players list model.
unc0rr
parents:
diff changeset
    93
}
7725
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    94
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    95
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    96
void PlayersListModel::removePlayer(const QString & nickname)
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    97
{
7727
bd252cacabe8 Bring icons back
unc0rr
parents: 7725
diff changeset
    98
    QModelIndexList mil = match(index(0), Qt::DisplayRole, nickname);
7725
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
    99
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   100
    if(mil.size())
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   101
        removeRow(mil[0].row());
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   102
}
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   103
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   104
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   105
void PlayersListModel::setFlag(const QString &nickname, StateFlag flagType, bool isSet)
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   106
{
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   107
    QModelIndexList mil = match(index(0), Qt::DisplayRole, nickname);
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   108
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   109
    if(mil.size())
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   110
    {
7727
bd252cacabe8 Bring icons back
unc0rr
parents: 7725
diff changeset
   111
        setData(mil[0], isSet, flagType);
7728
664738870325 Bring back sorting
unc0rr
parents: 7727
diff changeset
   112
664738870325 Bring back sorting
unc0rr
parents: 7727
diff changeset
   113
        if(flagType == Friend || flagType == ServerAdmin
664738870325 Bring back sorting
unc0rr
parents: 7727
diff changeset
   114
                || flagType == Ignore || flagType == RoomAdmin)
664738870325 Bring back sorting
unc0rr
parents: 7727
diff changeset
   115
            updateSortData(mil[0]);
664738870325 Bring back sorting
unc0rr
parents: 7727
diff changeset
   116
7725
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   117
        updateIcon(mil[0]);
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   118
    }
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   119
}
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   120
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   121
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   122
void PlayersListModel::updateIcon(const QModelIndex & index)
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   123
{
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   124
    quint32 iconNum = 0;
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   125
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   126
    QList<bool> flags;
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   127
    flags
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   128
        << index.data(Ready).toBool()
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   129
        << index.data(ServerAdmin).toBool()
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   130
        << index.data(RoomAdmin).toBool()
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   131
        << index.data(Registered).toBool()
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   132
        << index.data(Friend).toBool()
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   133
        << index.data(Ignore).toBool()
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   134
        ;
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   135
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   136
    for(int i = flags.size() - 1; i >= 0; --i)
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   137
        if(flags[i])
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   138
            iconNum |= 1 << i;
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   139
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   140
    if(m_icons().contains(iconNum))
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   141
    {
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   142
        setData(index, m_icons().value(iconNum), Qt::DecorationRole);
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   143
    }
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   144
    else
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   145
    {
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   146
        QPixmap result(24, 16);
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   147
        result.fill(Qt::transparent);
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   148
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   149
        QPainter painter(&result);
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   150
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   151
        if(index.data(Ready).toBool())
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   152
            painter.drawPixmap(0, 0, 16, 16, QPixmap(":/res/chat/lamp.png"));
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   153
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   154
        QString mainIconName(":/res/chat/");
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   155
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   156
        if(index.data(RoomAdmin).toBool())
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   157
            mainIconName += "roomadmin";
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   158
        else if(index.data(ServerAdmin).toBool())
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   159
            mainIconName += "serveradmin";
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   160
        else
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   161
            mainIconName += "hedgehog";
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   162
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   163
        if(!index.data(Registered).toBool())
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   164
            mainIconName += "_gray";
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   165
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   166
        painter.drawPixmap(8, 0, 16, 16, QPixmap(mainIconName + ".png"));
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   167
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   168
        if(index.data(Ignore).toBool())
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   169
            painter.drawPixmap(8, 0, 16, 16, QPixmap(":/res/chat/ignore.png"));
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   170
        else
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   171
        if(index.data(Friend).toBool())
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   172
            painter.drawPixmap(8, 0, 16, 16, QPixmap(":/res/chat/friend.png"));
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   173
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   174
        painter.end();
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   175
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   176
        QIcon icon(result);
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   177
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   178
        setData(index, icon, Qt::DecorationRole);
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   179
        m_icons().insert(iconNum, icon);
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   180
    }
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   181
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   182
    if(index.data(Ignore).toBool())
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   183
        setData(index, Qt::gray, Qt::ForegroundRole);
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   184
    else
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   185
    if(index.data(Friend).toBool())
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   186
        setData(index, Qt::green, Qt::ForegroundRole);
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   187
    else
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   188
        setData(index, QBrush(QColor(0xff, 0xcc, 0x00)), Qt::ForegroundRole);
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   189
}
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   190
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   191
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   192
QHash<quint32, QIcon> & PlayersListModel::m_icons()
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   193
{
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   194
    static QHash<quint32, QIcon> iconsCache;
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   195
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   196
    return iconsCache;
4ad05a478c6c Further work on moving to players list model
unc0rr
parents: 7723
diff changeset
   197
}
7728
664738870325 Bring back sorting
unc0rr
parents: 7727
diff changeset
   198
664738870325 Bring back sorting
unc0rr
parents: 7727
diff changeset
   199
void PlayersListModel::updateSortData(const QModelIndex & index)
664738870325 Bring back sorting
unc0rr
parents: 7727
diff changeset
   200
{
664738870325 Bring back sorting
unc0rr
parents: 7727
diff changeset
   201
    QString result = QString("%1%2%3%4%5")
664738870325 Bring back sorting
unc0rr
parents: 7727
diff changeset
   202
            .arg(1 - index.data(RoomAdmin).toInt())
664738870325 Bring back sorting
unc0rr
parents: 7727
diff changeset
   203
            .arg(1 - index.data(ServerAdmin).toInt())
664738870325 Bring back sorting
unc0rr
parents: 7727
diff changeset
   204
            .arg(1 - index.data(Friend).toInt())
664738870325 Bring back sorting
unc0rr
parents: 7727
diff changeset
   205
            .arg(index.data(Ignore).toInt())
664738870325 Bring back sorting
unc0rr
parents: 7727
diff changeset
   206
            .arg(index.data(Qt::DisplayRole).toString().toLower())
664738870325 Bring back sorting
unc0rr
parents: 7727
diff changeset
   207
            ;
664738870325 Bring back sorting
unc0rr
parents: 7727
diff changeset
   208
664738870325 Bring back sorting
unc0rr
parents: 7727
diff changeset
   209
    setData(index, result, SortRole);
664738870325 Bring back sorting
unc0rr
parents: 7727
diff changeset
   210
}