From 5e83c1f716b192de2f6d3a15ede868d678389f0e Mon Sep 17 00:00:00 2001 From: GriffinR Date: Mon, 17 Oct 2022 14:52:12 -0400 Subject: [PATCH] WIP Adjust custom attributes table --- forms/mainwindow.ui | 2 +- src/editor.cpp | 2 +- src/mainwindow.cpp | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/forms/mainwindow.ui b/forms/mainwindow.ui index 1a2268a2..05ece2f1 100644 --- a/forms/mainwindow.ui +++ b/forms/mainwindow.ui @@ -2125,7 +2125,7 @@ Custom fields will be added to the map.json file for the current map. - false + true false diff --git a/src/editor.cpp b/src/editor.cpp index b00a5539..46a729fc 100644 --- a/src/editor.cpp +++ b/src/editor.cpp @@ -1959,7 +1959,7 @@ void Editor::updateCustomMapHeaderValues(QTableWidget *table) if (key.isEmpty() || !typeItem || !valueItem) continue; - // Read which JSON type to save the value as from the table data + // Read from the table data which JSON type to save the value as QJsonValue::Type type = static_cast(typeItem->data(Qt::UserRole).toInt()); QJsonValue value; switch (type) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index e8787184..451a5216 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -3088,10 +3088,11 @@ void MainWindow::addCustomHeaderValue(QString key, QJsonValue value, bool isNew) case QJsonValue::Bool: valueItem = new QTableWidgetItem(""); valueItem->setCheckState(value.toBool() ? Qt::Checked : Qt::Unchecked); + valueItem->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsSelectable); break; default: valueItem = new QTableWidgetItem("This value cannot be edited from this table"); - valueItem->setFlags(Qt::NoItemFlags); + valueItem->setFlags(Qt::ItemIsSelectable); valueItem->setData(Qt::UserRole, value); // Preserve the value for writing to the file break; } @@ -3108,6 +3109,7 @@ void MainWindow::addCustomHeaderValue(QString key, QJsonValue value, bool isNew) QTableWidgetItem * typeItem = new QTableWidgetItem(typeToName[type]); typeItem->setFlags(Qt::ItemIsEnabled); typeItem->setData(Qt::UserRole, type); // Record the type for writing to the file + typeItem->setTextAlignment(Qt::AlignCenter); int rowIndex = this->ui->tableWidget_CustomHeaderFields->rowCount(); this->ui->tableWidget_CustomHeaderFields->insertRow(rowIndex);