Skip to content
Snippets Groups Projects
Commit 98786ba3 authored by Peter Albrecht's avatar Peter Albrecht
Browse files

Add wildcard functionality to skill search

parent 3b0b9174
No related branches found
No related tags found
1 merge request!428Implement wildcard for skill search
......@@ -54,6 +54,24 @@ namespace armarx::skills::gui
}
}
// check if search strings occur in the skill name in order
bool
matches(std::string skillName, std::vector<std::string>& searches)
{
size_t index = 0;
for (std::string& substring : searches)
{
size_t occurance = skillName.find(substring, index);
if (occurance == std::string::npos)
return false;
// we found an occurance
index = occurance;
}
return true;
}
void
SkillManagerWrapper::filterSkillUpdate(
std::map<skills::manager::dto::SkillID, skills::manager::dto::SkillDescription>& update)
......@@ -64,13 +82,16 @@ namespace armarx::skills::gui
return;
}
// TODO: whitespace to wildcard
std::vector<std::string> substrings = simox::alg::split(currentSkillSearch);
for (auto& string : substrings)
{
simox::alg::to_lower(string);
}
std::string key = simox::alg::to_lower(this->currentSkillSearch);
for (auto it = update.begin(); it != update.end();)
{
if (simox::alg::to_lower(skills::SkillID::FromIce(it->first).skillName).find(key))
if (not matches(skills::SkillID::FromIce(it->first).skillName, substrings))
{
it = update.erase(it);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment