Skip to content

Commit 1318a97

Browse files
committed
array翻译导入的改进
1 parent 9d5cacf commit 1318a97

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/QResArscEditor.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ void QResArscEditor::onImportLocaleTriggered_slot(void)
519519
};
520520
//先将翻译文件读入map中
521521
QMap<QString, TValue> t_StringMap;
522-
QMap<QString, QVector<TValue>> t_arrayMap;
522+
QMap<QString, QMap<uint32_t, TValue>> t_arrayMap;
523523
QDomElement t_root = t_domTree.documentElement();
524524
for (QDomElement t_childDom = t_root.firstChildElement(); !t_childDom.isNull(); t_childDom = t_childDom.nextSiblingElement())
525525
{
@@ -529,7 +529,7 @@ void QResArscEditor::onImportLocaleTriggered_slot(void)
529529
t_StringMap.insert(t_name, TValue((Res_value::_DataType)t_childDom.attribute("type").toUInt(), t_childDom.text()));
530530
else if (t_tagName == "string-array")
531531
for (QDomElement t_valueDom = t_childDom.firstChildElement("item"); !t_valueDom.isNull(); t_valueDom = t_valueDom.nextSiblingElement("item"))
532-
t_arrayMap[t_name].append(TValue((Res_value::_DataType)t_valueDom.attribute("type").toUInt(), t_valueDom.text()));
532+
t_arrayMap[t_name].insert(QStringToUint(t_valueDom.attribute("name")), TValue((Res_value::_DataType)t_valueDom.attribute("type").toUInt(), t_valueDom.text()));
533533
}
534534
t_ReadFile.close();
535535
//然后根据值的名字来查找翻译,这样即使后续版本值的ID发生了变化(ID是编译器自动产生的,不同版本,同一个值的ID不能保证不变),
@@ -561,12 +561,14 @@ void QResArscEditor::onImportLocaleTriggered_slot(void)
561561
{
562562
TTableMapEntry* t_pMapValue = reinterpret_cast<TTableMapEntry*>(t_ptrEntry.get());
563563
QString t_name = t_tablePackage.getKeyString(t_pMapValue->key.index);
564-
if (!t_arrayMap.contains(t_name) || t_arrayMap[t_name].size() != t_pMapValue->tablemap.size())
564+
if (!t_arrayMap.contains(t_name))// || t_arrayMap[t_name].size() != t_pMapValue->tablemap.size())
565565
continue;
566-
QVector<TValue> t_values = t_arrayMap[t_name];
566+
const QMap<uint32_t, TValue>& t_values = t_arrayMap[t_name];
567567
for (int j = 0; j < t_pMapValue->tablemap.size(); ++j)
568568
{
569-
TValue& t_value = t_values[j];
569+
if (!t_values.contains(t_pMapValue->tablemap[j].name.indent))
570+
continue;
571+
const TValue& t_value = t_values[t_pMapValue->tablemap[j].name.indent];
570572
if (t_value.type == Res_value::_DataType::TYPE_STRING)
571573
m_Parser->setValue(t_tablePackage, t_typeid, t_specid, uint32_t(i), uint32_t(j), t_value.data, false);
572574
else

0 commit comments

Comments
 (0)