FIX: fix the plate cannot be searched
JIRA: STUDIO-6283 Signed-off-by: Kunlong Ma <kunlong.ma@bambulab.com> Change-Id: I88206c91ea24c6a41a0bd06f05f0f3c2fdc58a36
This commit is contained in:
parent
c9249e5952
commit
65d4dcc861
|
@ -1514,6 +1514,9 @@ void ObjectDataViewModel::assembly_name(ObjectDataViewModelNode* item, wxString
|
|||
wxString str = name + ":" + item->GetName();
|
||||
assembly_name_list.push_back(std::make_pair(item, str));
|
||||
}
|
||||
else {
|
||||
assembly_name_list.push_back(std::make_pair(item, name));
|
||||
}
|
||||
for (size_t i = 0; i < item->GetChildCount(); ++i) {
|
||||
wxString str_name = name + ":" + item->GetName();
|
||||
if (type == itPlate) {
|
||||
|
@ -1532,18 +1535,27 @@ void ObjectDataViewModel::search_object(wxString search_text)
|
|||
search_found_list.clear();
|
||||
search_text = search_text.MakeLower();
|
||||
|
||||
for (auto pair : assembly_name_list) {
|
||||
wxString need_str = pair.second.AfterFirst(':');
|
||||
need_str = need_str.MakeLower();
|
||||
size_t pos = need_str.find(search_text);
|
||||
if ( pos != wxString::npos) {
|
||||
size_t len = search_text.length();
|
||||
size_t before_size = pair.second.BeforeFirst(':').length();
|
||||
wxString new_search_str = "<b>" + pair.second.Mid(before_size + pos + 1, len) + "</b>";
|
||||
wxString new_str = pair.second.Mid(0, before_size + pos + 1) + new_search_str + pair.second.Mid(before_size + pos + len + 1, wxString::npos);
|
||||
for (const auto& pair : assembly_name_list) {
|
||||
wxString sub_str = pair.second;
|
||||
sub_str = sub_str.MakeLower();
|
||||
|
||||
search_found_list.push_back(std::make_pair(pair.first, new_str));
|
||||
wxString new_str = "";
|
||||
size_t search_text_len = search_text.length();
|
||||
size_t curr_str_len = 0;
|
||||
size_t pos = sub_str.find(search_text);
|
||||
while (pos != wxString::npos) {
|
||||
wxString new_search_str = "<b>" + pair.second.Mid(curr_str_len + pos, search_text_len) + "</b>";
|
||||
new_str += pair.second.Mid(curr_str_len, pos) + new_search_str;
|
||||
curr_str_len += search_text_len + pos;
|
||||
sub_str = sub_str.substr(pos + 1);
|
||||
pos = sub_str.find(search_text);
|
||||
}
|
||||
|
||||
if (curr_str_len > 0 && curr_str_len < pair.second.length()) {
|
||||
new_str += pair.second.substr(curr_str_len);
|
||||
}
|
||||
if (!new_str.empty())
|
||||
search_found_list.push_back(std::make_pair(pair.first, new_str));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue