refactor: merge icon into name column
Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
This commit is contained in:
parent
35b993c248
commit
822c98469f
@ -144,8 +144,6 @@ QVariant InstanceList::headerData(int section, Qt::Orientation orientation, int
|
||||
}
|
||||
|
||||
switch (section) {
|
||||
case IconColumn:
|
||||
return tr("Icon");
|
||||
case NameColumn:
|
||||
return tr("Name");
|
||||
case GameVersionColumn:
|
||||
@ -167,7 +165,7 @@ QVariant InstanceList::data(const QModelIndex& index, int role) const
|
||||
|
||||
switch (role) {
|
||||
case Qt::DecorationRole: {
|
||||
if (index.column() == IconColumn)
|
||||
if (index.column() == NameColumn)
|
||||
return inst->iconKey();
|
||||
break;
|
||||
}
|
||||
@ -620,7 +618,7 @@ void InstanceList::propertiesChanged(BaseInstance* inst)
|
||||
{
|
||||
int i = getInstIndex(inst);
|
||||
if (i != -1) {
|
||||
emit dataChanged(index(i, IconColumn), index(i, ColumnCount - 1));
|
||||
emit dataChanged(index(i, NameColumn), index(i, ColumnCount - 1));
|
||||
updateTotalPlayTime();
|
||||
}
|
||||
}
|
||||
|
@ -57,7 +57,6 @@ class InstanceList : public QAbstractTableModel {
|
||||
int columnCount(const QModelIndex& parent = QModelIndex()) const override;
|
||||
|
||||
enum Column {
|
||||
IconColumn = 0,
|
||||
NameColumn,
|
||||
GameVersionColumn,
|
||||
PlayTimeColumn,
|
||||
|
@ -24,8 +24,10 @@ InstanceDelegate::InstanceDelegate(QObject* parent) : QStyledItemDelegate(parent
|
||||
void InstanceDelegate::initStyleOption(QStyleOptionViewItem* option, const QModelIndex& index) const
|
||||
{
|
||||
QStyledItemDelegate::initStyleOption(option, index);
|
||||
if (index.column() == InstanceList::IconColumn) {
|
||||
if (index.column() == InstanceList::NameColumn) {
|
||||
// make decoration fill cell, subtract default margins
|
||||
option->decorationSize = option->rect.size().shrunkBy(QMargins(3, 1, 3, 1));
|
||||
QSize decorationSize = QSize(option->rect.height(), option->rect.height());
|
||||
decorationSize -= QSize(2, 2); // subtract 1px margin
|
||||
option->decorationSize = decorationSize;
|
||||
}
|
||||
}
|
@ -80,13 +80,11 @@ void InstanceView::createTable()
|
||||
header->restoreState(QByteArray::fromBase64(APPLICATION->settings()->get("InstanceViewTableHeaderState").toByteArray()));
|
||||
|
||||
header->setSectionsMovable(true);
|
||||
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
|
||||
m_table->verticalHeader()->setDefaultSectionSize(m_rowHeight + 1 + 1); // padding top and bottom
|
||||
|
||||
if (!APPLICATION->settings()->contains("InstanceViewTableHeaderState"))
|
||||
m_table->sortByColumn(InstanceList::LastPlayedColumn, Qt::AscendingOrder);
|
||||
|
Loading…
x
Reference in New Issue
Block a user