Tue, 09 Dec 2014 15:27:04 +0100
Enable searching combobox items using a fulltext search instead of only a prefix search; Can be disabled by FSComboboxSubstringSearch setting in case of complains
1.1 --- a/indra/llui/llcombobox.cpp Tue Dec 09 13:56:33 2014 +0100 1.2 +++ b/indra/llui/llcombobox.cpp Tue Dec 09 15:27:04 2014 +0100 1.3 @@ -937,7 +937,10 @@ 1.4 mTextEntry->setTentative(FALSE); 1.5 mLastSelectedIndex = mList->getFirstSelectedIndex(); 1.6 } 1.7 - else if (mList->selectItemByPrefix(left_wstring, FALSE)) 1.8 + // <FS:Ansariel> Allow fulltext search in comboboxes 1.9 + //else if (mList->selectItemByPrefix(left_wstring, FALSE)) 1.10 + else if (!LLControlGroup::getInstance("Global")->getBOOL("FSComboboxSubstringSearch") && mList->selectItemByPrefix(left_wstring, FALSE)) 1.11 + // </FS:Ansariel> 1.12 { 1.13 LLWString selected_item = utf8str_to_wstring(getSelectedItemLabel()); 1.14 LLWString wtext = left_wstring + selected_item.substr(left_wstring.size(), selected_item.size()); 1.15 @@ -948,6 +951,18 @@ 1.16 mHasAutocompletedText = TRUE; 1.17 mLastSelectedIndex = mList->getFirstSelectedIndex(); 1.18 } 1.19 + // <FS:Ansariel> Allow fulltext search in comboboxes 1.20 + else if (LLControlGroup::getInstance("Global")->getBOOL("FSComboboxSubstringSearch") && mList->selectItemBySubstring(left_wstring, FALSE)) 1.21 + { 1.22 + LLWString selected_item = utf8str_to_wstring(getSelectedItemLabel()); 1.23 + mTextEntry->setText(wstring_to_utf8str(left_wstring) + " (" + getSelectedItemLabel() + ")"); 1.24 + mTextEntry->setSelection(left_wstring.size(), mTextEntry->getWText().size()); 1.25 + mTextEntry->endSelection(); 1.26 + mTextEntry->setTentative(FALSE); 1.27 + mHasAutocompletedText = TRUE; 1.28 + mLastSelectedIndex = mList->getFirstSelectedIndex(); 1.29 + } 1.30 + // </FS:Ansariel> 1.31 else // no matching items found 1.32 { 1.33 mList->deselectAllItems();
2.1 --- a/indra/llui/llscrolllistctrl.cpp Tue Dec 09 13:56:33 2014 +0100 2.2 +++ b/indra/llui/llscrolllistctrl.cpp Tue Dec 09 15:27:04 2014 +0100 2.3 @@ -1318,6 +1318,13 @@ 2.4 // Selects first enabled item that has a name where the name's first part matched the target string. 2.5 // Returns false if item not found. 2.6 BOOL LLScrollListCtrl::selectItemByPrefix(const LLWString& target, BOOL case_sensitive) 2.7 +// <FS:Ansariel> Allow selection by substring match 2.8 +{ 2.9 + return selectItemByStringMatch(target, true, case_sensitive); 2.10 +} 2.11 + 2.12 +BOOL LLScrollListCtrl::selectItemByStringMatch(const LLWString& target, bool prefix_match, BOOL case_sensitive) 2.13 +// </FS:Ansariel> 2.14 { 2.15 BOOL found = FALSE; 2.16 2.17 @@ -1369,7 +1376,18 @@ 2.18 LLWString trimmed_label = item_label; 2.19 LLWStringUtil::trim(trimmed_label); 2.20 2.21 - BOOL select = item->getEnabled() && trimmed_label.compare(0, target_trimmed.size(), target_trimmed) == 0; 2.22 + // <FS:Ansariel> Allow selection by substring match 2.23 + //BOOL select = item->getEnabled() && trimmed_label.compare(0, target_trimmed.size(), target_trimmed) == 0; 2.24 + BOOL select; 2.25 + if (prefix_match) 2.26 + { 2.27 + select = item->getEnabled() && trimmed_label.compare(0, target_trimmed.size(), target_trimmed) == 0; 2.28 + } 2.29 + else 2.30 + { 2.31 + select = item->getEnabled() && trimmed_label.find(target_trimmed) != std::string::npos; 2.32 + } 2.33 + // </FS:Ansariel> 2.34 2.35 if (select) 2.36 { 2.37 @@ -1391,6 +1409,19 @@ 2.38 return found; 2.39 } 2.40 2.41 +// <FS:Ansariel> Allow selection by substring match 2.42 +BOOL LLScrollListCtrl::selectItemBySubstring(const std::string& target, BOOL case_sensitive) 2.43 +{ 2.44 + return selectItemBySubstring(utf8str_to_wstring(target), case_sensitive); 2.45 +} 2.46 + 2.47 +// Returns false if item not found. 2.48 +BOOL LLScrollListCtrl::selectItemBySubstring(const LLWString& target, BOOL case_sensitive) 2.49 +{ 2.50 + return selectItemByStringMatch(target, false, case_sensitive); 2.51 +} 2.52 +// </FS:Ansariel> 2.53 + 2.54 const std::string LLScrollListCtrl::getSelectedItemLabel(S32 column) const 2.55 { 2.56 LLScrollListItem* item;
3.1 --- a/indra/llui/llscrolllistctrl.h Tue Dec 09 13:56:33 2014 +0100 3.2 +++ b/indra/llui/llscrolllistctrl.h Tue Dec 09 15:27:04 2014 +0100 3.3 @@ -249,6 +249,11 @@ 3.4 BOOL selectItemByLabel( const std::string& item, BOOL case_sensitive = TRUE, S32 column = 0 ); // FALSE if item not found 3.5 BOOL selectItemByPrefix(const std::string& target, BOOL case_sensitive = TRUE); 3.6 BOOL selectItemByPrefix(const LLWString& target, BOOL case_sensitive = TRUE); 3.7 + // <FS:Ansariel> Allow selection by substring match 3.8 + BOOL selectItemBySubstring(const std::string& target, BOOL case_sensitive = TRUE); 3.9 + BOOL selectItemBySubstring(const LLWString& target, BOOL case_sensitive = TRUE); 3.10 + BOOL selectItemByStringMatch(const LLWString& target, bool prefix_match, BOOL case_sensitive = TRUE); 3.11 + // </FS:Ansariel> 3.12 LLScrollListItem* getItemByLabel( const std::string& item, BOOL case_sensitive = TRUE, S32 column = 0 ); 3.13 const std::string getSelectedItemLabel(S32 column = 0) const; 3.14 LLSD getSelectedValue();
4.1 --- a/indra/newview/app_settings/settings.xml Tue Dec 09 13:56:33 2014 +0100 4.2 +++ b/indra/newview/app_settings/settings.xml Tue Dec 09 15:27:04 2014 +0100 4.3 @@ -22844,6 +22844,17 @@ 4.4 <key>Value</key> 4.5 <integer>1</integer> 4.6 </map> 4.7 + <key>FSComboboxSubstringSearch</key> 4.8 + <map> 4.9 + <key>Comment</key> 4.10 + <string>Allows fulltext search on comboboxes</string> 4.11 + <key>Persist</key> 4.12 + <integer>1</integer> 4.13 + <key>Type</key> 4.14 + <string>Boolean</string> 4.15 + <key>Value</key> 4.16 + <integer>1</integer> 4.17 + </map> 4.18 </map> 4.19 </llsd> 4.20