Translate, change 'Start time' to 'Game created', add debug log
This commit is contained in:
parent
4972d227d9
commit
a3dc403f75
1 changed files with 11 additions and 7 deletions
|
@ -1,5 +1,6 @@
|
||||||
#include "gamesmodel.h"
|
#include "gamesmodel.h"
|
||||||
#include "pb/serverinfo_game.pb.h"
|
#include "pb/serverinfo_game.pb.h"
|
||||||
|
#include <QDebug>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
@ -12,7 +13,7 @@ namespace {
|
||||||
const unsigned SECS_PER_DAY = 86400; // 60 * 60 * 24
|
const unsigned SECS_PER_DAY = 86400; // 60 * 60 * 24
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pretty print an integer number of seconds ago. Accurate to only one unit,
|
* Pretty print an integer number of seconds ago. Accurate to only one unit,
|
||||||
* rounded.
|
* rounded.
|
||||||
*
|
*
|
||||||
* For example...
|
* For example...
|
||||||
|
@ -34,17 +35,17 @@ namespace {
|
||||||
mins++;
|
mins++;
|
||||||
str_stream << mins;
|
str_stream << mins;
|
||||||
str_stream << "m ago";
|
str_stream << "m ago";
|
||||||
} else if (secs < SECS_PER_DAY) {
|
} else if (secs < SECS_PER_HOUR * 5) {
|
||||||
uint32_t hours = secs / SECS_PER_HOUR;
|
uint32_t hours = secs / SECS_PER_HOUR;
|
||||||
if (secs % SECS_PER_HOUR >= SECS_PER_HALF_HOUR)
|
if (secs % SECS_PER_HOUR >= SECS_PER_HALF_HOUR)
|
||||||
hours++;
|
hours++;
|
||||||
str_stream << hours;
|
str_stream << hours;
|
||||||
str_stream << "h ago";
|
str_stream << "hr ago";
|
||||||
} else {
|
} else {
|
||||||
str_stream << "a long time ago";
|
str_stream << "5+ hours ago";
|
||||||
}
|
}
|
||||||
|
|
||||||
return str_stream.str();
|
return tr(str_stream.str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,7 +76,10 @@ QVariant GamesModel::data(const QModelIndex &index, int role) const
|
||||||
switch (role) {
|
switch (role) {
|
||||||
case Qt::DisplayRole: return QString::fromStdString(prettyPrintSecsAgo(secs));
|
case Qt::DisplayRole: return QString::fromStdString(prettyPrintSecsAgo(secs));
|
||||||
case SORT_ROLE: return QVariant(secs);
|
case SORT_ROLE: return QVariant(secs);
|
||||||
default: return QVariant(); // Shouldn't ever be reached.
|
default: {
|
||||||
|
qDebug() << "Returning data for col 1 of games model when role != display, role != sort";
|
||||||
|
return QVariant(); // Shouldn't ever be reached.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case 2: return QString::fromStdString(g.description());
|
case 2: return QString::fromStdString(g.description());
|
||||||
|
@ -108,7 +112,7 @@ QVariant GamesModel::headerData(int section, Qt::Orientation orientation, int ro
|
||||||
return QVariant();
|
return QVariant();
|
||||||
switch (section) {
|
switch (section) {
|
||||||
case 0: return tr("Room");
|
case 0: return tr("Room");
|
||||||
case 1: return tr("Start time");
|
case 1: return tr("Game created");
|
||||||
case 2: return tr("Description");
|
case 2: return tr("Description");
|
||||||
case 3: return tr("Creator");
|
case 3: return tr("Creator");
|
||||||
case 4: return tr("Game type");
|
case 4: return tr("Game type");
|
||||||
|
|
Loading…
Reference in a new issue