Display custom header values according to type
This commit is contained in:
parent
6ffcb58e5e
commit
ec626a59a7
4 changed files with 23 additions and 5 deletions
|
@ -53,7 +53,7 @@ public:
|
|||
QString battle_scene;
|
||||
QString sharedEventsMap = "";
|
||||
QString sharedScriptsMap = "";
|
||||
QMap<QString, QString> customHeaders;
|
||||
QMap<QString, QJsonValue> customHeaders;
|
||||
MapLayout *layout;
|
||||
bool isPersistedToFile = true;
|
||||
bool hasUnsavedDataChanges = false;
|
||||
|
|
|
@ -1958,7 +1958,7 @@ void Editor::updateCustomMapHeaderValues(QTableWidget *table)
|
|||
if (value) valueStr = value->text();
|
||||
fields[keyStr] = valueStr;
|
||||
}
|
||||
map->customHeaders = fields;
|
||||
//map->customHeaders = fields;
|
||||
emit editedMapData();
|
||||
}
|
||||
|
||||
|
|
|
@ -803,11 +803,29 @@ void MainWindow::displayMapProperties() {
|
|||
ui->tableWidget_CustomHeaderFields->blockSignals(true);
|
||||
ui->tableWidget_CustomHeaderFields->setRowCount(0);
|
||||
for (auto it = map->customHeaders.begin(); it != map->customHeaders.end(); it++) {
|
||||
QTableWidgetItem * tableItem;
|
||||
QJsonValue value = it.value();
|
||||
switch (value.type())
|
||||
{
|
||||
case QJsonValue::String:
|
||||
case QJsonValue::Double:
|
||||
tableItem = new QTableWidgetItem(ParseUtil::jsonToQString(value));
|
||||
break;
|
||||
case QJsonValue::Bool:
|
||||
tableItem = new QTableWidgetItem("");
|
||||
tableItem->setCheckState(value.toBool() ? Qt::Checked : Qt::Unchecked);
|
||||
break;
|
||||
default:
|
||||
tableItem = new QTableWidgetItem("This value cannot be edited from this table");
|
||||
tableItem->setFlags(Qt::NoItemFlags);
|
||||
break;
|
||||
}
|
||||
int rowIndex = ui->tableWidget_CustomHeaderFields->rowCount();
|
||||
ui->tableWidget_CustomHeaderFields->insertRow(rowIndex);
|
||||
ui->tableWidget_CustomHeaderFields->setItem(rowIndex, 0, new QTableWidgetItem(it.key()));
|
||||
ui->tableWidget_CustomHeaderFields->setItem(rowIndex, 1, new QTableWidgetItem(it.value()));
|
||||
ui->tableWidget_CustomHeaderFields->setItem(rowIndex, 1, tableItem);
|
||||
}
|
||||
ui->tableWidget_CustomHeaderFields->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
||||
ui->tableWidget_CustomHeaderFields->blockSignals(false);
|
||||
}
|
||||
|
||||
|
|
|
@ -412,7 +412,7 @@ bool Project::loadMapData(Map* map) {
|
|||
QSet<QString> baseFields = this->getTopLevelMapFields();
|
||||
for (QString key : mapObj.keys()) {
|
||||
if (!baseFields.contains(key)) {
|
||||
map->customHeaders.insert(key, ParseUtil::jsonToQString(mapObj[key]));
|
||||
map->customHeaders.insert(key, mapObj[key]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1440,7 +1440,7 @@ void Project::saveMap(Map *map) {
|
|||
|
||||
// Custom header fields.
|
||||
for (QString key : map->customHeaders.keys()) {
|
||||
mapObj[key] = map->customHeaders[key];
|
||||
//mapObj[key] = map->customHeaders[key];
|
||||
}
|
||||
|
||||
OrderedJson mapJson(mapObj);
|
||||
|
|
Loading…
Reference in a new issue