refactor: rename column enum

Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
This commit is contained in:
Sefa Eyeoglu
2022-10-01 22:07:38 +02:00
parent 39c582297e
commit 61f938546d
5 changed files with 30 additions and 30 deletions

View File

@ -24,7 +24,7 @@ InstanceDelegate::InstanceDelegate(QObject* parent) : QStyledItemDelegate(parent
void InstanceDelegate::initStyleOption(QStyleOptionViewItem* option, const QModelIndex& index) const
{
QStyledItemDelegate::initStyleOption(option, index);
if (index.column() == InstanceList::Icon) {
if (index.column() == InstanceList::IconColumn) {
// make decoration fill cell, subtract default margins
option->decorationSize = option->rect.size().shrunkBy(QMargins(3, 1, 3, 1));
}

View File

@ -36,7 +36,7 @@ QVariant InstanceProxyModel::data(const QModelIndex& index, int role) const
}
switch (index.column()) {
case InstanceList::LastPlayed: {
case InstanceList::LastPlayedColumn: {
if (role == Qt::DisplayRole) {
QDateTime foo = data.toDateTime();
if (foo.isNull() || !foo.isValid() || foo.toMSecsSinceEpoch() == 0)

View File

@ -80,16 +80,16 @@ void InstanceView::createTable()
header->restoreState(QByteArray::fromBase64(APPLICATION->settings()->get("InstanceViewTableHeaderState").toByteArray()));
header->setSectionsMovable(true);
header->setSectionResizeMode(InstanceList::Icon, QHeaderView::Fixed);
header->setSectionResizeMode(InstanceList::Name, QHeaderView::Stretch);
header->setSectionResizeMode(InstanceList::GameVersion, 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
header->setSectionResizeMode(InstanceList::IconColumn, QHeaderView::Fixed);
header->setSectionResizeMode(InstanceList::NameColumn, QHeaderView::Stretch);
header->setSectionResizeMode(InstanceList::GameVersionColumn, QHeaderView::Interactive);
header->setSectionResizeMode(InstanceList::PlayTimeColumn, QHeaderView::Interactive);
header->setSectionResizeMode(InstanceList::LastPlayedColumn, QHeaderView::Interactive);
m_table->setColumnWidth(InstanceList::IconColumn, m_rowHeight + 3 + 3); // padding left and right
m_table->verticalHeader()->setDefaultSectionSize(m_rowHeight + 1 + 1); // padding top and bottom
if (!APPLICATION->settings()->contains("InstanceViewTableHeaderState"))
m_table->sortByColumn(InstanceList::LastPlayed, Qt::AscendingOrder);
m_table->sortByColumn(InstanceList::LastPlayedColumn, Qt::AscendingOrder);
connect(m_table, &QTableView::doubleClicked, this, &InstanceView::activateInstance);
connect(m_table->selectionModel(), &QItemSelectionModel::currentRowChanged, this, &InstanceView::currentRowChanged);
@ -132,7 +132,7 @@ void InstanceView::currentRowChanged(const QModelIndex& current, const QModelInd
void InstanceView::selectNameColumn(const QModelIndex& current, const QModelIndex& previous)
{
// Make sure Name column is always selected
m_table->setCurrentIndex(current.siblingAtColumn(InstanceList::Name));
m_table->setCurrentIndex(current.siblingAtColumn(InstanceList::NameColumn));
}
void InstanceView::dataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight)