mirror of
https://github.com/huderlem/porymap.git
synced 2026-08-25 18:16:57 -05:00
WIP Adjust custom attributes table
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user