mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
minor improvements
This commit is contained in:
parent
3388804e8f
commit
99ff7fd15f
23 changed files with 114 additions and 95 deletions
|
|
@ -13,14 +13,14 @@ int GamesModel::rowCount(const QModelIndex &parent) const
|
|||
|
||||
int GamesModel::columnCount(const QModelIndex &parent) const
|
||||
{
|
||||
return 4;
|
||||
return 5;
|
||||
}
|
||||
|
||||
QVariant GamesModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return QVariant();
|
||||
if ((index.row() >= gameList.size()) || (index.column() >= 4))
|
||||
if ((index.row() >= gameList.size()) || (index.column() >= columnCount()))
|
||||
return QVariant();
|
||||
|
||||
if (role != Qt::DisplayRole)
|
||||
|
|
@ -28,10 +28,11 @@ QVariant GamesModel::data(const QModelIndex &index, int role) const
|
|||
|
||||
ServerGame *g = gameList.at(index.row());
|
||||
switch (index.column()) {
|
||||
case 0: return g->getName();
|
||||
case 1: return g->getDescription();
|
||||
case 2: return QString(g->getHasPassword() ? "yes" : "no");
|
||||
case 3: return QString("%1/%2").arg(g->getPlayerCount()).arg(g->getMaxPlayers());
|
||||
case 0: return g->getGameId();
|
||||
case 1: return g->getCreator();
|
||||
case 2: return g->getDescription();
|
||||
case 3: return QString(g->getHasPassword() ? "yes" : "no");
|
||||
case 4: return QString("%1/%2").arg(g->getPlayerCount()).arg(g->getMaxPlayers());
|
||||
default: return QVariant();
|
||||
}
|
||||
}
|
||||
|
|
@ -43,10 +44,11 @@ QVariant GamesModel::headerData(int section, Qt::Orientation orientation, int ro
|
|||
if (orientation != Qt::Horizontal)
|
||||
return QVariant();
|
||||
switch (section) {
|
||||
case 0: return QString("Name");
|
||||
case 1: return QString("Description");
|
||||
case 2: return QString("Password");
|
||||
case 3: return QString("Players");
|
||||
case 0: return QString("Game ID");
|
||||
case 1: return QString("Creator");
|
||||
case 2: return QString("Description");
|
||||
case 3: return QString("Password");
|
||||
case 4: return QString("Players");
|
||||
default: return QVariant();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue