Refactorings
This commit is contained in:
parent
1406a27775
commit
8ac58259b4
1 changed files with 13 additions and 15 deletions
|
@ -9,6 +9,7 @@
|
||||||
#include <QCryptographicHash>
|
#include <QCryptographicHash>
|
||||||
|
|
||||||
static const enum {ROOM, CREATED, DESCRIPTION, CREATOR, GAME_TYPE, RESTRICTIONS, PLAYERS, SPECTATORS};
|
static const enum {ROOM, CREATED, DESCRIPTION, CREATOR, GAME_TYPE, RESTRICTIONS, PLAYERS, SPECTATORS};
|
||||||
|
static const enum {UNREGISTERED, REGISTERED};
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
const unsigned SECS_PER_MIN = 60;
|
const unsigned SECS_PER_MIN = 60;
|
||||||
|
@ -116,11 +117,8 @@ QVariant GamesModel::data(const QModelIndex &index, int role) const
|
||||||
return QString::fromStdString(g.creator_info().name());
|
return QString::fromStdString(g.creator_info().name());
|
||||||
case Qt::DecorationRole:
|
case Qt::DecorationRole:
|
||||||
switch(g.creator_info().user_level()) {
|
switch(g.creator_info().user_level()) {
|
||||||
case 1: {
|
case UNREGISTERED:
|
||||||
QPixmap avatarPixmap = UserLevelPixmapGenerator::generatePixmap(13, (UserLevelFlags)g.creator_info().user_level());
|
case REGISTERED:{
|
||||||
return QIcon(avatarPixmap);
|
|
||||||
}
|
|
||||||
case 3:{
|
|
||||||
QPixmap avatarPixmap = UserLevelPixmapGenerator::generatePixmap(13, (UserLevelFlags)g.creator_info().user_level());
|
QPixmap avatarPixmap = UserLevelPixmapGenerator::generatePixmap(13, (UserLevelFlags)g.creator_info().user_level());
|
||||||
return QIcon(avatarPixmap);
|
return QIcon(avatarPixmap);
|
||||||
}
|
}
|
||||||
|
@ -151,12 +149,12 @@ QVariant GamesModel::data(const QModelIndex &index, int role) const
|
||||||
case SORT_ROLE:
|
case SORT_ROLE:
|
||||||
case Qt::DisplayRole: {
|
case Qt::DisplayRole: {
|
||||||
QStringList result;
|
QStringList result;
|
||||||
|
if (g.with_password())
|
||||||
|
result.append(tr("password"));
|
||||||
if (g.only_buddies())
|
if (g.only_buddies())
|
||||||
result.append(tr("buddies only"));
|
result.append(tr("buddies only"));
|
||||||
if (g.only_registered())
|
if (g.only_registered())
|
||||||
result.append(tr("reg. users only"));
|
result.append(tr("reg. users only"));
|
||||||
if (g.with_password())
|
|
||||||
result.append(tr("password"));
|
|
||||||
return result.join(", ");
|
return result.join(", ");
|
||||||
}
|
}
|
||||||
case Qt::DecorationRole:{
|
case Qt::DecorationRole:{
|
||||||
|
@ -197,14 +195,14 @@ QVariant GamesModel::headerData(int section, Qt::Orientation orientation, int ro
|
||||||
if ((role != Qt::DisplayRole) || (orientation != Qt::Horizontal))
|
if ((role != Qt::DisplayRole) || (orientation != Qt::Horizontal))
|
||||||
return QVariant();
|
return QVariant();
|
||||||
switch (section) {
|
switch (section) {
|
||||||
case 0: return tr("Room");
|
case ROOM: return tr("Room");
|
||||||
case 1: return tr("Game Created");
|
case CREATED: return tr("Game Created");
|
||||||
case 2: return tr("Description");
|
case DESCRIPTION: return tr("Description");
|
||||||
case 3: return tr("Creator");
|
case CREATOR: return tr("Creator");
|
||||||
case 4: return tr("Game Type");
|
case GAME_TYPE: return tr("Game Type");
|
||||||
case 5: return tr("Restrictions");
|
case RESTRICTIONS: return tr("Restrictions");
|
||||||
case 6: return tr("Players");
|
case PLAYERS: return tr("Players");
|
||||||
case 7: return tr("Spectators");
|
case SPECTATORS: return tr("Spectators");
|
||||||
default: return QVariant();
|
default: return QVariant();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue