refactor: make last played last column
Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
This commit is contained in:
parent
319b816d79
commit
e786f2ea62
@ -141,8 +141,8 @@ QVariant InstanceList::headerData(int section, Qt::Orientation orientation, int
|
|||||||
case Icon: return tr("Icon");
|
case Icon: return tr("Icon");
|
||||||
case Name: return tr("Name");
|
case Name: return tr("Name");
|
||||||
case GameVersion: return tr("Game Version");
|
case GameVersion: return tr("Game Version");
|
||||||
case LastPlayed: return tr("Last played");
|
|
||||||
case PlayTime: return tr("Play time");
|
case PlayTime: return tr("Play time");
|
||||||
|
case LastPlayed: return tr("Last played");
|
||||||
default: return QVariant();
|
default: return QVariant();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -172,6 +172,14 @@ QVariant InstanceList::data(const QModelIndex& index, int role) const {
|
|||||||
return inst->getMainVersion();
|
return inst->getMainVersion();
|
||||||
break;
|
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: {
|
case LastPlayed: {
|
||||||
QString foo = Time::prettifyDuration(inst->lastTimePlayed());
|
QString foo = Time::prettifyDuration(inst->lastTimePlayed());
|
||||||
QDateTime bar = QDateTime::fromMSecsSinceEpoch(inst->lastLaunch());
|
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);
|
return tr("Last played for %1").arg(foo);
|
||||||
break;
|
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:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -78,8 +78,8 @@ public:
|
|||||||
Icon = 0,
|
Icon = 0,
|
||||||
Name,
|
Name,
|
||||||
GameVersion,
|
GameVersion,
|
||||||
LastPlayed,
|
|
||||||
PlayTime,
|
PlayTime,
|
||||||
|
LastPlayed,
|
||||||
|
|
||||||
ColumnCount
|
ColumnCount
|
||||||
};
|
};
|
||||||
|
@ -78,8 +78,8 @@ void InstanceView::createTable() {
|
|||||||
header->setSectionResizeMode(InstanceList::Icon, QHeaderView::Fixed);
|
header->setSectionResizeMode(InstanceList::Icon, QHeaderView::Fixed);
|
||||||
header->setSectionResizeMode(InstanceList::Name, QHeaderView::Stretch);
|
header->setSectionResizeMode(InstanceList::Name, QHeaderView::Stretch);
|
||||||
header->setSectionResizeMode(InstanceList::GameVersion, QHeaderView::Interactive);
|
header->setSectionResizeMode(InstanceList::GameVersion, QHeaderView::Interactive);
|
||||||
header->setSectionResizeMode(InstanceList::LastPlayed, QHeaderView::Interactive);
|
|
||||||
header->setSectionResizeMode(InstanceList::PlayTime, 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->setColumnWidth(InstanceList::Icon, m_rowHeight + 3 + 3); // padding left and right
|
||||||
m_table->verticalHeader()->setDefaultSectionSize(m_rowHeight + 1 + 1); // padding top and bottom
|
m_table->verticalHeader()->setDefaultSectionSize(m_rowHeight + 1 + 1); // padding top and bottom
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user