ui: sorting search results

* search results are sorted by: score > length > name
* fixed crash that occurred when trying to get a node by id with id == 0
This commit is contained in:
malte_langkabel
2016-04-18 14:05:27 +02:00
parent 325bc6ac83
commit c7940eb34f
7 changed files with 69 additions and 9 deletions
+16
View File
@@ -133,6 +133,22 @@ namespace utility
return text.size() >= postfix.size() && text.rfind(postfix) == (text.size() - postfix.size());
}
std::string switchCases(std::string s)
{
for (char& c: s)
{
if (islower(c))
{
c = toupper(c);
}
else if (isupper(c))
{
c = tolower(c);
}
}
return s;
}
std::string toUpperCase(const std::string& in)
{
std::string out;
+1
View File
@@ -37,6 +37,7 @@ namespace utility
bool isPrefix(const std::string& prefix, const std::string& text);
bool isPostfix(const std::string& postfix, const std::string& text);
std::string switchCases(std::string s);
std::string toUpperCase(const std::string& in);
std::string toLowerCase(const std::string& in);
bool equalsCaseInsensitive(const std::string& a, const std::string& b);