Enable searching combobox items using a fulltext search instead of only a prefix search; Can be disabled by FSComboboxSubstringSearch setting in case of complains
parent
f824dbe40f
commit
2ab176d705
|
|
@ -937,7 +937,10 @@ void LLComboBox::updateSelection()
|
|||
mTextEntry->setTentative(FALSE);
|
||||
mLastSelectedIndex = mList->getFirstSelectedIndex();
|
||||
}
|
||||
else if (mList->selectItemByPrefix(left_wstring, FALSE))
|
||||
// <FS:Ansariel> Allow fulltext search in comboboxes
|
||||
//else if (mList->selectItemByPrefix(left_wstring, FALSE))
|
||||
else if (!LLControlGroup::getInstance("Global")->getBOOL("FSComboboxSubstringSearch") && mList->selectItemByPrefix(left_wstring, FALSE))
|
||||
// </FS:Ansariel>
|
||||
{
|
||||
LLWString selected_item = utf8str_to_wstring(getSelectedItemLabel());
|
||||
LLWString wtext = left_wstring + selected_item.substr(left_wstring.size(), selected_item.size());
|
||||
|
|
@ -948,6 +951,18 @@ void LLComboBox::updateSelection()
|
|||
mHasAutocompletedText = TRUE;
|
||||
mLastSelectedIndex = mList->getFirstSelectedIndex();
|
||||
}
|
||||
// <FS:Ansariel> Allow fulltext search in comboboxes
|
||||
else if (LLControlGroup::getInstance("Global")->getBOOL("FSComboboxSubstringSearch") && mList->selectItemBySubstring(left_wstring, FALSE))
|
||||
{
|
||||
LLWString selected_item = utf8str_to_wstring(getSelectedItemLabel());
|
||||
mTextEntry->setText(wstring_to_utf8str(left_wstring) + " (" + getSelectedItemLabel() + ")");
|
||||
mTextEntry->setSelection(left_wstring.size(), mTextEntry->getWText().size());
|
||||
mTextEntry->endSelection();
|
||||
mTextEntry->setTentative(FALSE);
|
||||
mHasAutocompletedText = TRUE;
|
||||
mLastSelectedIndex = mList->getFirstSelectedIndex();
|
||||
}
|
||||
// </FS:Ansariel>
|
||||
else // no matching items found
|
||||
{
|
||||
mList->deselectAllItems();
|
||||
|
|
|
|||
|
|
@ -1318,6 +1318,13 @@ BOOL LLScrollListCtrl::selectItemByPrefix(const std::string& target, BOOL case_s
|
|||
// Selects first enabled item that has a name where the name's first part matched the target string.
|
||||
// Returns false if item not found.
|
||||
BOOL LLScrollListCtrl::selectItemByPrefix(const LLWString& target, BOOL case_sensitive)
|
||||
// <FS:Ansariel> Allow selection by substring match
|
||||
{
|
||||
return selectItemByStringMatch(target, true, case_sensitive);
|
||||
}
|
||||
|
||||
BOOL LLScrollListCtrl::selectItemByStringMatch(const LLWString& target, bool prefix_match, BOOL case_sensitive)
|
||||
// </FS:Ansariel>
|
||||
{
|
||||
BOOL found = FALSE;
|
||||
|
||||
|
|
@ -1369,7 +1376,18 @@ BOOL LLScrollListCtrl::selectItemByPrefix(const LLWString& target, BOOL case_sen
|
|||
LLWString trimmed_label = item_label;
|
||||
LLWStringUtil::trim(trimmed_label);
|
||||
|
||||
BOOL select = item->getEnabled() && trimmed_label.compare(0, target_trimmed.size(), target_trimmed) == 0;
|
||||
// <FS:Ansariel> Allow selection by substring match
|
||||
//BOOL select = item->getEnabled() && trimmed_label.compare(0, target_trimmed.size(), target_trimmed) == 0;
|
||||
BOOL select;
|
||||
if (prefix_match)
|
||||
{
|
||||
select = item->getEnabled() && trimmed_label.compare(0, target_trimmed.size(), target_trimmed) == 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
select = item->getEnabled() && trimmed_label.find(target_trimmed) != std::string::npos;
|
||||
}
|
||||
// </FS:Ansariel>
|
||||
|
||||
if (select)
|
||||
{
|
||||
|
|
@ -1391,6 +1409,19 @@ BOOL LLScrollListCtrl::selectItemByPrefix(const LLWString& target, BOOL case_sen
|
|||
return found;
|
||||
}
|
||||
|
||||
// <FS:Ansariel> Allow selection by substring match
|
||||
BOOL LLScrollListCtrl::selectItemBySubstring(const std::string& target, BOOL case_sensitive)
|
||||
{
|
||||
return selectItemBySubstring(utf8str_to_wstring(target), case_sensitive);
|
||||
}
|
||||
|
||||
// Returns false if item not found.
|
||||
BOOL LLScrollListCtrl::selectItemBySubstring(const LLWString& target, BOOL case_sensitive)
|
||||
{
|
||||
return selectItemByStringMatch(target, false, case_sensitive);
|
||||
}
|
||||
// </FS:Ansariel>
|
||||
|
||||
const std::string LLScrollListCtrl::getSelectedItemLabel(S32 column) const
|
||||
{
|
||||
LLScrollListItem* item;
|
||||
|
|
|
|||
|
|
@ -249,6 +249,11 @@ public:
|
|||
BOOL selectItemByLabel( const std::string& item, BOOL case_sensitive = TRUE, S32 column = 0 ); // FALSE if item not found
|
||||
BOOL selectItemByPrefix(const std::string& target, BOOL case_sensitive = TRUE);
|
||||
BOOL selectItemByPrefix(const LLWString& target, BOOL case_sensitive = TRUE);
|
||||
// <FS:Ansariel> Allow selection by substring match
|
||||
BOOL selectItemBySubstring(const std::string& target, BOOL case_sensitive = TRUE);
|
||||
BOOL selectItemBySubstring(const LLWString& target, BOOL case_sensitive = TRUE);
|
||||
BOOL selectItemByStringMatch(const LLWString& target, bool prefix_match, BOOL case_sensitive = TRUE);
|
||||
// </FS:Ansariel>
|
||||
LLScrollListItem* getItemByLabel( const std::string& item, BOOL case_sensitive = TRUE, S32 column = 0 );
|
||||
const std::string getSelectedItemLabel(S32 column = 0) const;
|
||||
LLSD getSelectedValue();
|
||||
|
|
|
|||
|
|
@ -22844,6 +22844,17 @@ Change of this parameter will affect the layout of buttons in notification toast
|
|||
<key>Value</key>
|
||||
<integer>1</integer>
|
||||
</map>
|
||||
<key>FSComboboxSubstringSearch</key>
|
||||
<map>
|
||||
<key>Comment</key>
|
||||
<string>Allows fulltext search on comboboxes</string>
|
||||
<key>Persist</key>
|
||||
<integer>1</integer>
|
||||
<key>Type</key>
|
||||
<string>Boolean</string>
|
||||
<key>Value</key>
|
||||
<integer>1</integer>
|
||||
</map>
|
||||
</map>
|
||||
</llsd>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue