WIP Adjust custom attributes table
This commit is contained in:
parent
a0eff32f36
commit
5e83c1f716
3 changed files with 5 additions and 3 deletions
|
@ -2125,7 +2125,7 @@
|
||||||
<string>Custom fields will be added to the map.json file for the current map.</string>
|
<string>Custom fields will be added to the map.json file for the current map.</string>
|
||||||
</property>
|
</property>
|
||||||
<attribute name="horizontalHeaderVisible">
|
<attribute name="horizontalHeaderVisible">
|
||||||
<bool>false</bool>
|
<bool>true</bool>
|
||||||
</attribute>
|
</attribute>
|
||||||
<attribute name="horizontalHeaderCascadingSectionResizes">
|
<attribute name="horizontalHeaderCascadingSectionResizes">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
|
|
|
@ -1959,7 +1959,7 @@ void Editor::updateCustomMapHeaderValues(QTableWidget *table)
|
||||||
if (key.isEmpty() || !typeItem || !valueItem)
|
if (key.isEmpty() || !typeItem || !valueItem)
|
||||||
continue;
|
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::Type type = static_cast<QJsonValue::Type>(typeItem->data(Qt::UserRole).toInt());
|
||||||
QJsonValue value;
|
QJsonValue value;
|
||||||
switch (type)
|
switch (type)
|
||||||
|
|
|
@ -3088,10 +3088,11 @@ void MainWindow::addCustomHeaderValue(QString key, QJsonValue value, bool isNew)
|
||||||
case QJsonValue::Bool:
|
case QJsonValue::Bool:
|
||||||
valueItem = new QTableWidgetItem("");
|
valueItem = new QTableWidgetItem("");
|
||||||
valueItem->setCheckState(value.toBool() ? Qt::Checked : Qt::Unchecked);
|
valueItem->setCheckState(value.toBool() ? Qt::Checked : Qt::Unchecked);
|
||||||
|
valueItem->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsSelectable);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
valueItem = new QTableWidgetItem("This value cannot be edited from this table");
|
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
|
valueItem->setData(Qt::UserRole, value); // Preserve the value for writing to the file
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -3108,6 +3109,7 @@ void MainWindow::addCustomHeaderValue(QString key, QJsonValue value, bool isNew)
|
||||||
QTableWidgetItem * typeItem = new QTableWidgetItem(typeToName[type]);
|
QTableWidgetItem * typeItem = new QTableWidgetItem(typeToName[type]);
|
||||||
typeItem->setFlags(Qt::ItemIsEnabled);
|
typeItem->setFlags(Qt::ItemIsEnabled);
|
||||||
typeItem->setData(Qt::UserRole, type); // Record the type for writing to the file
|
typeItem->setData(Qt::UserRole, type); // Record the type for writing to the file
|
||||||
|
typeItem->setTextAlignment(Qt::AlignCenter);
|
||||||
|
|
||||||
int rowIndex = this->ui->tableWidget_CustomHeaderFields->rowCount();
|
int rowIndex = this->ui->tableWidget_CustomHeaderFields->rowCount();
|
||||||
this->ui->tableWidget_CustomHeaderFields->insertRow(rowIndex);
|
this->ui->tableWidget_CustomHeaderFields->insertRow(rowIndex);
|
||||||
|
|
Loading…
Reference in a new issue