@@ -82,10 +82,13 @@ void QResArscEditor::refreshResTableType(const TTablePackage& _tablePackage, qui
8282 QSharedPointer<ResTable_entry> t_ptrEntry = t_type.entryValue [i];
8383 if (t_ptrEntry.isNull ())
8484 continue ;
85+ QVariant t_vEntry;
86+ t_vEntry.setValue (t_ptrEntry);
8587 if ((*t_ptrEntry).size == sizeof (ResTable_entry))
8688 {
8789 TTableValueEntry* t_pValueEntry = reinterpret_cast <TTableValueEntry*>(t_ptrEntry.get ());
8890 QTreeWidgetItem* t_valueItem = new QTreeWidgetItem (m_TW_value);
91+ t_valueItem->setData (0 , eValueItemRole_entry, t_vEntry);
8992 widgetItemSetData (t_valueItem, eValueItemType_value, t_pValueEntry->value .data ,
9093 (uint32_t )t_pValueEntry->value .dataType , i, QString (" 0x7f%1%2" ).arg (_typeid, 2 , 16 , QChar (' 0' )).arg (i, 4 , 16 , QChar (' 0' )));
9194 t_valueItem->setText (1 , _tablePackage.getKeyString (t_pValueEntry->key .index ));
@@ -100,6 +103,7 @@ void QResArscEditor::refreshResTableType(const TTablePackage& _tablePackage, qui
100103 {
101104 TTableMapEntry* t_pMapValue = reinterpret_cast <TTableMapEntry*>(t_ptrEntry.get ());
102105 QTreeWidgetItem* t_mapItem = new QTreeWidgetItem (m_TW_value);
106+ t_mapItem->setData (0 , eValueItemRole_entry, t_vEntry);
103107 widgetItemSetData (t_mapItem, eValueItemType_array, t_pMapValue->key .index ,
104108 (uint32_t )Res_value::_DataType::TYPE_NULL, i, QString (" 0x7f%1%2" ).arg (_typeid, 2 , 16 , QChar (' 0' )).arg (i, 4 , 16 , QChar (' 0' )));
105109 t_mapItem->setText (1 , _tablePackage.getKeyString (t_pMapValue->key .index ));
@@ -122,6 +126,39 @@ void QResArscEditor::refreshResTableType(const TTablePackage& _tablePackage, qui
122126 }
123127 }
124128}
129+ void QResArscEditor::refreshAllValueDataTooltip (void )
130+ {
131+ for (int i = 0 ; i < m_TW_value->topLevelItemCount (); ++i)
132+ {
133+ QTreeWidgetItem* t_entryItem = m_TW_value->topLevelItem (i);
134+ if (t_entryItem->data (0 , eValueItemRole_type).toUInt () == eValueItemType_value)
135+ {
136+ TTableValueEntry* t_pValueEntry = reinterpret_cast <TTableValueEntry*>(t_entryItem->data (0 , eValueItemRole_entry).value <QSharedPointer<ResTable_entry>>().get ());
137+ if (t_pValueEntry->value .dataType == Res_value::_DataType::TYPE_STRING)
138+ {
139+ t_entryItem->setData (0 , eValueItemRole_data, t_pValueEntry->value .data );
140+ t_entryItem->setToolTip (2 , QString (" 0x%1(refCount:%2)" ).arg (t_pValueEntry->value .data , 8 , 16 , QChar (' 0' )).
141+ arg (QString::number (m_Parser->getReferenceCount (t_pValueEntry->value .data ))));
142+ }
143+ }
144+ else
145+ {
146+ TTableMapEntry* t_pMapValue = reinterpret_cast <TTableMapEntry*>(t_entryItem->data (0 , eValueItemRole_entry).value <QSharedPointer<ResTable_entry>>().get ());
147+ Q_ASSERT (t_pMapValue->count == t_entryItem->childCount ());
148+ for (quint32 j = 0 ; j < t_pMapValue->count ; ++j)
149+ {
150+ ResTable_map& t_tableMap = t_pMapValue->tablemap [j];
151+ QTreeWidgetItem* t_mapValueItem = t_entryItem->child (j);
152+ if (t_tableMap.value .dataType == Res_value::_DataType::TYPE_STRING)
153+ {
154+ t_mapValueItem->setData (0 , eValueItemRole_data, t_tableMap.value .data );
155+ t_mapValueItem->setToolTip (2 , QString (" 0x%1(refCount:%2)" ).arg (t_tableMap.value .data , 8 , 16 , QChar (' 0' )).
156+ arg (QString::number (m_Parser->getReferenceCount (t_tableMap.value .data ))));
157+ }
158+ }
159+ }
160+ }
161+ }
125162void QResArscEditor::onOpenReleased_Slot (void )
126163{
127164 QString t_FileName = QFileDialog::getOpenFileName (this , tr (" Open ARSC File" ), m_BasePath,
@@ -370,8 +407,10 @@ void QResArscEditor::onEditValueTriggered_slot(void)
370407 else
371408 t_newValue = m_Parser->setValue (t_tablePackage, t_typeid, t_specid, t_item->data (0 , eValueItemRole_id).toUInt (), t_newType, t_value);
372409 }
373- t_item->setData (0 , eValueItemRole_datatype, (uint32_t )t_newValue->dataType );
374410 t_item->setText (2 , t_tablePackage.resValue2String (*t_newValue));
411+ // 如果改的是字符串,则需要重新刷新当前页的字符串的data和tooltip,因为插入删除字符串后,这两个的数据都有可能改变
412+ if (t_dataType == (uint32_t )Res_value::_DataType::TYPE_STRING || t_newType == Res_value::_DataType::TYPE_STRING)
413+ refreshAllValueDataTooltip ();
375414}
376415void QResArscEditor::onAddLocaleTriggered_slot (void )
377416{
@@ -561,7 +600,7 @@ void QResArscEditor::onImportLocaleTriggered_slot(void)
561600 {
562601 TTableMapEntry* t_pMapValue = reinterpret_cast <TTableMapEntry*>(t_ptrEntry.get ());
563602 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())
603+ if (!t_arrayMap.contains (t_name))
565604 continue ;
566605 const QMap<uint32_t , TValue>& t_values = t_arrayMap[t_name];
567606 for (int j = 0 ; j < t_pMapValue->tablemap .size (); ++j)
0 commit comments