QTfrontend/model/roomslistmodel.cpp
author sheepluva
Tue, 01 May 2012 14:57:40 +0200
changeset 6973 582ca7e8e338
parent 6966 eda4f63bec41
child 6983 ede55af89e78
permissions -rw-r--r--
RoomsListModel: + in progress icon * fixed room delete and update (name match lookup was done in wrong column)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6966
eda4f63bec41 add missing copyright headers to roomslistmodel
sheepluva
parents: 6757
diff changeset
     1
/*
eda4f63bec41 add missing copyright headers to roomslistmodel
sheepluva
parents: 6757
diff changeset
     2
 * Hedgewars, a free turn based strategy game
eda4f63bec41 add missing copyright headers to roomslistmodel
sheepluva
parents: 6757
diff changeset
     3
 * Copyright (c) 2004-2012 Andrey Korotaev <unC0Rr@gmail.com>
eda4f63bec41 add missing copyright headers to roomslistmodel
sheepluva
parents: 6757
diff changeset
     4
 *
eda4f63bec41 add missing copyright headers to roomslistmodel
sheepluva
parents: 6757
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
eda4f63bec41 add missing copyright headers to roomslistmodel
sheepluva
parents: 6757
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
eda4f63bec41 add missing copyright headers to roomslistmodel
sheepluva
parents: 6757
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
eda4f63bec41 add missing copyright headers to roomslistmodel
sheepluva
parents: 6757
diff changeset
     8
 *
eda4f63bec41 add missing copyright headers to roomslistmodel
sheepluva
parents: 6757
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
eda4f63bec41 add missing copyright headers to roomslistmodel
sheepluva
parents: 6757
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
eda4f63bec41 add missing copyright headers to roomslistmodel
sheepluva
parents: 6757
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
eda4f63bec41 add missing copyright headers to roomslistmodel
sheepluva
parents: 6757
diff changeset
    12
 * GNU General Public License for more details.
eda4f63bec41 add missing copyright headers to roomslistmodel
sheepluva
parents: 6757
diff changeset
    13
 *
eda4f63bec41 add missing copyright headers to roomslistmodel
sheepluva
parents: 6757
diff changeset
    14
 * You should have received a copy of the GNU General Public License
eda4f63bec41 add missing copyright headers to roomslistmodel
sheepluva
parents: 6757
diff changeset
    15
 * along with this program; if not, write to the Free Software
eda4f63bec41 add missing copyright headers to roomslistmodel
sheepluva
parents: 6757
diff changeset
    16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
eda4f63bec41 add missing copyright headers to roomslistmodel
sheepluva
parents: 6757
diff changeset
    17
 */
eda4f63bec41 add missing copyright headers to roomslistmodel
sheepluva
parents: 6757
diff changeset
    18
eda4f63bec41 add missing copyright headers to roomslistmodel
sheepluva
parents: 6757
diff changeset
    19
/**
eda4f63bec41 add missing copyright headers to roomslistmodel
sheepluva
parents: 6757
diff changeset
    20
 * @file
eda4f63bec41 add missing copyright headers to roomslistmodel
sheepluva
parents: 6757
diff changeset
    21
 * @brief RoomsListModel class implementation
eda4f63bec41 add missing copyright headers to roomslistmodel
sheepluva
parents: 6757
diff changeset
    22
 */
eda4f63bec41 add missing copyright headers to roomslistmodel
sheepluva
parents: 6757
diff changeset
    23
6732
c906dc78091f Start switching to rooms list model. To be continued.
unc0rr
parents:
diff changeset
    24
#include "roomslistmodel.h"
c906dc78091f Start switching to rooms list model. To be continued.
unc0rr
parents:
diff changeset
    25
6973
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
    26
#include <QIcon>
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
    27
6732
c906dc78091f Start switching to rooms list model. To be continued.
unc0rr
parents:
diff changeset
    28
RoomsListModel::RoomsListModel(QObject *parent) :
6973
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
    29
    QAbstractTableModel(parent),
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
    30
    c_nColumns(8)
6732
c906dc78091f Start switching to rooms list model. To be continued.
unc0rr
parents:
diff changeset
    31
{
c906dc78091f Start switching to rooms list model. To be continued.
unc0rr
parents:
diff changeset
    32
    m_headerData =
c906dc78091f Start switching to rooms list model. To be continued.
unc0rr
parents:
diff changeset
    33
    QStringList()
6973
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
    34
     << tr("In progress")
6732
c906dc78091f Start switching to rooms list model. To be continued.
unc0rr
parents:
diff changeset
    35
     << tr("Room Name")
c906dc78091f Start switching to rooms list model. To be continued.
unc0rr
parents:
diff changeset
    36
     << tr("C")
c906dc78091f Start switching to rooms list model. To be continued.
unc0rr
parents:
diff changeset
    37
     << tr("T")
c906dc78091f Start switching to rooms list model. To be continued.
unc0rr
parents:
diff changeset
    38
     << tr("Owner")
c906dc78091f Start switching to rooms list model. To be continued.
unc0rr
parents:
diff changeset
    39
     << tr("Map")
c906dc78091f Start switching to rooms list model. To be continued.
unc0rr
parents:
diff changeset
    40
     << tr("Rules")
c906dc78091f Start switching to rooms list model. To be continued.
unc0rr
parents:
diff changeset
    41
     << tr("Weapons");
c906dc78091f Start switching to rooms list model. To be continued.
unc0rr
parents:
diff changeset
    42
}
c906dc78091f Start switching to rooms list model. To be continued.
unc0rr
parents:
diff changeset
    43
6973
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
    44
6732
c906dc78091f Start switching to rooms list model. To be continued.
unc0rr
parents:
diff changeset
    45
QVariant RoomsListModel::headerData(int section, Qt::Orientation orientation, int role) const
c906dc78091f Start switching to rooms list model. To be continued.
unc0rr
parents:
diff changeset
    46
{
c906dc78091f Start switching to rooms list model. To be continued.
unc0rr
parents:
diff changeset
    47
    if(orientation == Qt::Vertical || role != Qt::DisplayRole)
c906dc78091f Start switching to rooms list model. To be continued.
unc0rr
parents:
diff changeset
    48
        return QVariant();
c906dc78091f Start switching to rooms list model. To be continued.
unc0rr
parents:
diff changeset
    49
    else
c906dc78091f Start switching to rooms list model. To be continued.
unc0rr
parents:
diff changeset
    50
        return QVariant(m_headerData.at(section));
c906dc78091f Start switching to rooms list model. To be continued.
unc0rr
parents:
diff changeset
    51
}
c906dc78091f Start switching to rooms list model. To be continued.
unc0rr
parents:
diff changeset
    52
6973
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
    53
6732
c906dc78091f Start switching to rooms list model. To be continued.
unc0rr
parents:
diff changeset
    54
int RoomsListModel::rowCount(const QModelIndex & parent) const
c906dc78091f Start switching to rooms list model. To be continued.
unc0rr
parents:
diff changeset
    55
{
c906dc78091f Start switching to rooms list model. To be continued.
unc0rr
parents:
diff changeset
    56
    if(parent.isValid())
c906dc78091f Start switching to rooms list model. To be continued.
unc0rr
parents:
diff changeset
    57
        return 0;
c906dc78091f Start switching to rooms list model. To be continued.
unc0rr
parents:
diff changeset
    58
    else
c906dc78091f Start switching to rooms list model. To be continued.
unc0rr
parents:
diff changeset
    59
        return m_data.size();
c906dc78091f Start switching to rooms list model. To be continued.
unc0rr
parents:
diff changeset
    60
}
c906dc78091f Start switching to rooms list model. To be continued.
unc0rr
parents:
diff changeset
    61
6973
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
    62
6732
c906dc78091f Start switching to rooms list model. To be continued.
unc0rr
parents:
diff changeset
    63
int RoomsListModel::columnCount(const QModelIndex & parent) const
c906dc78091f Start switching to rooms list model. To be continued.
unc0rr
parents:
diff changeset
    64
{
c906dc78091f Start switching to rooms list model. To be continued.
unc0rr
parents:
diff changeset
    65
    if(parent.isValid())
c906dc78091f Start switching to rooms list model. To be continued.
unc0rr
parents:
diff changeset
    66
        return 0;
c906dc78091f Start switching to rooms list model. To be continued.
unc0rr
parents:
diff changeset
    67
    else
6973
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
    68
        return c_nColumns;
6732
c906dc78091f Start switching to rooms list model. To be continued.
unc0rr
parents:
diff changeset
    69
}
c906dc78091f Start switching to rooms list model. To be continued.
unc0rr
parents:
diff changeset
    70
6973
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
    71
6732
c906dc78091f Start switching to rooms list model. To be continued.
unc0rr
parents:
diff changeset
    72
QVariant RoomsListModel::data(const QModelIndex &index, int role) const
c906dc78091f Start switching to rooms list model. To be continued.
unc0rr
parents:
diff changeset
    73
{
6973
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
    74
    int column = index.column();
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
    75
    int row = index.row();
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
    76
    
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
    77
    if (!index.isValid() || (row < 0)
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
    78
            || (row >= m_data.size())
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
    79
            || (column >= c_nColumns)
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
    80
            || ((role != Qt::DecorationRole) && (role != Qt::DisplayRole))
6732
c906dc78091f Start switching to rooms list model. To be continued.
unc0rr
parents:
diff changeset
    81
       )
c906dc78091f Start switching to rooms list model. To be continued.
unc0rr
parents:
diff changeset
    82
        return QVariant();
c906dc78091f Start switching to rooms list model. To be continued.
unc0rr
parents:
diff changeset
    83
6973
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
    84
    // decorate room name based on room state
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
    85
    if (role == Qt::DecorationRole)
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
    86
    {
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
    87
        if (column != 1)
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
    88
            return QVariant();
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
    89
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
    90
        const QIcon roomBusyIcon(":/res/iconDamage.png");
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
    91
        const QIcon roomWaitingIcon(":/res/iconTime.png");
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
    92
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
    93
        if (m_data.at(row).at(0).isEmpty())
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
    94
            return QVariant(roomWaitingIcon);
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
    95
        else
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
    96
            return QVariant(roomBusyIcon);
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
    97
    }
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
    98
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
    99
    QString content = m_data.at(row).at(column);
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
   100
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
   101
    if (column == 0)
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
   102
        return QVariant(!content.isEmpty());
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
   103
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
   104
    return content;
6732
c906dc78091f Start switching to rooms list model. To be continued.
unc0rr
parents:
diff changeset
   105
}
6733
5abbc345a82f Handle ROOM* commands in rooms list model
unc0rr
parents: 6732
diff changeset
   106
6973
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
   107
6733
5abbc345a82f Handle ROOM* commands in rooms list model
unc0rr
parents: 6732
diff changeset
   108
void RoomsListModel::setRoomsList(const QStringList & rooms)
5abbc345a82f Handle ROOM* commands in rooms list model
unc0rr
parents: 6732
diff changeset
   109
{
6973
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
   110
    beginResetModel();
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
   111
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
   112
    m_data.clear();
6733
5abbc345a82f Handle ROOM* commands in rooms list model
unc0rr
parents: 6732
diff changeset
   113
6973
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
   114
    int nRooms = rooms.size();
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
   115
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
   116
    for (int i = 0; i < nRooms; i += c_nColumns)
6733
5abbc345a82f Handle ROOM* commands in rooms list model
unc0rr
parents: 6732
diff changeset
   117
    {
5abbc345a82f Handle ROOM* commands in rooms list model
unc0rr
parents: 6732
diff changeset
   118
        QStringList l;
6973
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
   119
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
   120
#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
   121
        l.reserve(c_nColumns);  // small optimisation not supported in old Qt
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
   122
#endif
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
   123
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
   124
        for (int t = 0; t < c_nColumns; t++)
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
   125
        {
6733
5abbc345a82f Handle ROOM* commands in rooms list model
unc0rr
parents: 6732
diff changeset
   126
            l.append(rooms[i + t]);
6973
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
   127
        }
6733
5abbc345a82f Handle ROOM* commands in rooms list model
unc0rr
parents: 6732
diff changeset
   128
5abbc345a82f Handle ROOM* commands in rooms list model
unc0rr
parents: 6732
diff changeset
   129
        m_data.append(roomInfo2RoomRecord(l));
5abbc345a82f Handle ROOM* commands in rooms list model
unc0rr
parents: 6732
diff changeset
   130
    }
5abbc345a82f Handle ROOM* commands in rooms list model
unc0rr
parents: 6732
diff changeset
   131
6973
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
   132
    endResetModel();
6733
5abbc345a82f Handle ROOM* commands in rooms list model
unc0rr
parents: 6732
diff changeset
   133
}
5abbc345a82f Handle ROOM* commands in rooms list model
unc0rr
parents: 6732
diff changeset
   134
6973
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
   135
6733
5abbc345a82f Handle ROOM* commands in rooms list model
unc0rr
parents: 6732
diff changeset
   136
void RoomsListModel::addRoom(const QStringList & info)
5abbc345a82f Handle ROOM* commands in rooms list model
unc0rr
parents: 6732
diff changeset
   137
{
5abbc345a82f Handle ROOM* commands in rooms list model
unc0rr
parents: 6732
diff changeset
   138
    beginInsertRows(QModelIndex(), 0, 0);
5abbc345a82f Handle ROOM* commands in rooms list model
unc0rr
parents: 6732
diff changeset
   139
5abbc345a82f Handle ROOM* commands in rooms list model
unc0rr
parents: 6732
diff changeset
   140
    m_data.prepend(roomInfo2RoomRecord(info));
5abbc345a82f Handle ROOM* commands in rooms list model
unc0rr
parents: 6732
diff changeset
   141
5abbc345a82f Handle ROOM* commands in rooms list model
unc0rr
parents: 6732
diff changeset
   142
    endInsertRows();
5abbc345a82f Handle ROOM* commands in rooms list model
unc0rr
parents: 6732
diff changeset
   143
}
5abbc345a82f Handle ROOM* commands in rooms list model
unc0rr
parents: 6732
diff changeset
   144
6973
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
   145
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
   146
int RoomsListModel::rowOfRoom(const QString & name)
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
   147
{
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
   148
    int size = m_data.size();
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
   149
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
   150
    if (size < 1)
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
   151
        return -1;
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
   152
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
   153
    int i = 0;
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
   154
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
   155
    // search for record with matching room name
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
   156
    while(m_data[i].at(1) != name)
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
   157
    {
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
   158
        i++;
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
   159
        if(i >= size)
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
   160
            return -1;
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
   161
    }
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
   162
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
   163
    return i;
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
   164
}
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
   165
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
   166
6733
5abbc345a82f Handle ROOM* commands in rooms list model
unc0rr
parents: 6732
diff changeset
   167
void RoomsListModel::removeRoom(const QString & name)
5abbc345a82f Handle ROOM* commands in rooms list model
unc0rr
parents: 6732
diff changeset
   168
{
6973
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
   169
    int i = rowOfRoom(name);
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
   170
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
   171
    if (i < 0)
6733
5abbc345a82f Handle ROOM* commands in rooms list model
unc0rr
parents: 6732
diff changeset
   172
        return;
5abbc345a82f Handle ROOM* commands in rooms list model
unc0rr
parents: 6732
diff changeset
   173
5abbc345a82f Handle ROOM* commands in rooms list model
unc0rr
parents: 6732
diff changeset
   174
    beginRemoveRows(QModelIndex(), i, i);
5abbc345a82f Handle ROOM* commands in rooms list model
unc0rr
parents: 6732
diff changeset
   175
5abbc345a82f Handle ROOM* commands in rooms list model
unc0rr
parents: 6732
diff changeset
   176
    m_data.removeAt(i);
5abbc345a82f Handle ROOM* commands in rooms list model
unc0rr
parents: 6732
diff changeset
   177
5abbc345a82f Handle ROOM* commands in rooms list model
unc0rr
parents: 6732
diff changeset
   178
    endRemoveRows();
5abbc345a82f Handle ROOM* commands in rooms list model
unc0rr
parents: 6732
diff changeset
   179
}
5abbc345a82f Handle ROOM* commands in rooms list model
unc0rr
parents: 6732
diff changeset
   180
6973
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
   181
6733
5abbc345a82f Handle ROOM* commands in rooms list model
unc0rr
parents: 6732
diff changeset
   182
void RoomsListModel::updateRoom(const QString & name, const QStringList & info)
5abbc345a82f Handle ROOM* commands in rooms list model
unc0rr
parents: 6732
diff changeset
   183
{
6973
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
   184
    int i = rowOfRoom(name);
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
   185
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
   186
    if (i < 0)
6733
5abbc345a82f Handle ROOM* commands in rooms list model
unc0rr
parents: 6732
diff changeset
   187
        return;
5abbc345a82f Handle ROOM* commands in rooms list model
unc0rr
parents: 6732
diff changeset
   188
5abbc345a82f Handle ROOM* commands in rooms list model
unc0rr
parents: 6732
diff changeset
   189
    m_data[i] = roomInfo2RoomRecord(info);
5abbc345a82f Handle ROOM* commands in rooms list model
unc0rr
parents: 6732
diff changeset
   190
5abbc345a82f Handle ROOM* commands in rooms list model
unc0rr
parents: 6732
diff changeset
   191
    emit dataChanged(index(i, 0), index(i, columnCount(QModelIndex()) - 1));
5abbc345a82f Handle ROOM* commands in rooms list model
unc0rr
parents: 6732
diff changeset
   192
}
5abbc345a82f Handle ROOM* commands in rooms list model
unc0rr
parents: 6732
diff changeset
   193
6973
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
   194
6733
5abbc345a82f Handle ROOM* commands in rooms list model
unc0rr
parents: 6732
diff changeset
   195
QStringList RoomsListModel::roomInfo2RoomRecord(const QStringList & info)
5abbc345a82f Handle ROOM* commands in rooms list model
unc0rr
parents: 6732
diff changeset
   196
{
5abbc345a82f Handle ROOM* commands in rooms list model
unc0rr
parents: 6732
diff changeset
   197
    QStringList result;
5abbc345a82f Handle ROOM* commands in rooms list model
unc0rr
parents: 6732
diff changeset
   198
5abbc345a82f Handle ROOM* commands in rooms list model
unc0rr
parents: 6732
diff changeset
   199
    result = info;
5abbc345a82f Handle ROOM* commands in rooms list model
unc0rr
parents: 6732
diff changeset
   200
6973
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
   201
    // for matters of less memory usage and quicker access store
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
   202
    // the boolean string as either "t" or empty
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
   203
    if (info[0].toLower() == "true")
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
   204
        result[0] = "t";
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
   205
    else
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
   206
        result[0] = QString();
582ca7e8e338 RoomsListModel:
sheepluva
parents: 6966
diff changeset
   207
6733
5abbc345a82f Handle ROOM* commands in rooms list model
unc0rr
parents: 6732
diff changeset
   208
    return result;
5abbc345a82f Handle ROOM* commands in rooms list model
unc0rr
parents: 6732
diff changeset
   209
}