refactor: make last played last column

Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
This commit is contained in:
Sefa Eyeoglu 2022-10-01 19:21:24 +02:00
parent 319b816d79
commit e786f2ea62
No known key found for this signature in database
GPG Key ID: C10411294912A422
3 changed files with 11 additions and 11 deletions

View File

@ -141,8 +141,8 @@ QVariant InstanceList::headerData(int section, Qt::Orientation orientation, int
case Icon: return tr("Icon");
case Name: return tr("Name");
case GameVersion: return tr("Game Version");
case LastPlayed: return tr("Last played");
case PlayTime: return tr("Play time");
case LastPlayed: return tr("Last played");
default: return QVariant();
}
}
@ -172,6 +172,14 @@ QVariant InstanceList::data(const QModelIndex& index, int role) const {
return inst->getMainVersion();
break;
}
case PlayTime: {
QString foo = Time::prettifyDuration(inst->totalTimePlayed());
if (role == Qt::DisplayRole)
return foo;
if (role == Qt::ToolTipRole)
return tr("Total played for %1").arg(foo);
break;
}
case LastPlayed: {
QString foo = Time::prettifyDuration(inst->lastTimePlayed());
QDateTime bar = QDateTime::fromMSecsSinceEpoch(inst->lastLaunch());
@ -181,14 +189,6 @@ QVariant InstanceList::data(const QModelIndex& index, int role) const {
return tr("Last played for %1").arg(foo);
break;
}
case PlayTime: {
QString foo = Time::prettifyDuration(inst->totalTimePlayed());
if (role == Qt::DisplayRole)
return foo;
if (role == Qt::ToolTipRole)
return tr("Total played for %1").arg(foo);
break;
}
default:
break;
}

View File

@ -78,8 +78,8 @@ public:
Icon = 0,
Name,
GameVersion,
LastPlayed,
PlayTime,
LastPlayed,
ColumnCount
};

View File

@ -78,8 +78,8 @@ void InstanceView::createTable() {
header->setSectionResizeMode(InstanceList::Icon, QHeaderView::Fixed);
header->setSectionResizeMode(InstanceList::Name, QHeaderView::Stretch);
header->setSectionResizeMode(InstanceList::GameVersion, QHeaderView::Interactive);
header->setSectionResizeMode(InstanceList::LastPlayed, QHeaderView::Interactive);
header->setSectionResizeMode(InstanceList::PlayTime, QHeaderView::Interactive);
header->setSectionResizeMode(InstanceList::LastPlayed, QHeaderView::Interactive);
m_table->setColumnWidth(InstanceList::Icon, m_rowHeight + 3 + 3); // padding left and right
m_table->verticalHeader()->setDefaultSectionSize(m_rowHeight + 1 + 1); // padding top and bottom