WIP Adjust custom attributes table

This commit is contained in:
GriffinR 2022-10-17 14:52:12 -04:00
parent a0eff32f36
commit 5e83c1f716
3 changed files with 5 additions and 3 deletions

View file

@ -2125,7 +2125,7 @@
<string>Custom fields will be added to the map.json file for the current map.</string>
</property>
<attribute name="horizontalHeaderVisible">
<bool>false</bool>
<bool>true</bool>
</attribute>
<attribute name="horizontalHeaderCascadingSectionResizes">
<bool>false</bool>

View file

@ -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<QJsonValue::Type>(typeItem->data(Qt::UserRole).toInt());
QJsonValue value;
switch (type)

View file

@ -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);