diff options
author | McCabe Maxsted | 2010-09-17 03:14:00 -0700 |
---|---|---|
committer | McCabe Maxsted | 2010-09-17 03:19:30 -0700 |
commit | 15112113f159d5efbb6d96c549ce7c83fe443541 (patch) | |
tree | e164b7811e0a1f9b2bf5536bb1adf765d07ba19d | |
parent | Let's not put so many spaces in front of (none) (diff) | |
download | meta-impy-15112113f159d5efbb6d96c549ce7c83fe443541.zip meta-impy-15112113f159d5efbb6d96c549ce7c83fe443541.tar.gz meta-impy-15112113f159d5efbb6d96c549ce7c83fe443541.tar.bz2 meta-impy-15112113f159d5efbb6d96c549ce7c83fe443541.tar.xz |
Made searching contacts suck a lot less
-rw-r--r-- | linden/indra/newview/llfloaterfriends.cpp | 82 | ||||
-rw-r--r-- | linden/indra/newview/llfloaterfriends.h | 2 |
2 files changed, 47 insertions, 37 deletions
diff --git a/linden/indra/newview/llfloaterfriends.cpp b/linden/indra/newview/llfloaterfriends.cpp index a151a33..67d9626 100644 --- a/linden/indra/newview/llfloaterfriends.cpp +++ b/linden/indra/newview/llfloaterfriends.cpp | |||
@@ -151,7 +151,7 @@ void LLPanelFriends::updateFriends(U32 changed_mask) | |||
151 | LLDynamicArray<LLUUID> selected_friends = getSelectedIDs(); | 151 | LLDynamicArray<LLUUID> selected_friends = getSelectedIDs(); |
152 | if(changed_mask & (LLFriendObserver::ADD | LLFriendObserver::REMOVE | LLFriendObserver::ONLINE)) | 152 | if(changed_mask & (LLFriendObserver::ADD | LLFriendObserver::REMOVE | LLFriendObserver::ONLINE)) |
153 | { | 153 | { |
154 | refreshNames(changed_mask); | 154 | refreshNames(changed_mask, ""); |
155 | } | 155 | } |
156 | else if(changed_mask & LLFriendObserver::POWERS) | 156 | else if(changed_mask & LLFriendObserver::POWERS) |
157 | { | 157 | { |
@@ -185,39 +185,14 @@ void LLPanelFriends::updateFriends(U32 changed_mask) | |||
185 | 185 | ||
186 | void LLPanelFriends::filterContacts(const std::string& search_string) | 186 | void LLPanelFriends::filterContacts(const std::string& search_string) |
187 | { | 187 | { |
188 | std::string search = search_string; | 188 | if (search_string.empty()) |
189 | LLStringUtil::toLower(search); | ||
190 | |||
191 | if (search.empty()) | ||
192 | { | 189 | { |
193 | // repopulate | 190 | refreshNames(LLFriendObserver::ADD, ""); |
194 | refreshNames(LLFriendObserver::ADD); | ||
195 | } | 191 | } |
196 | else | 192 | else |
197 | { | 193 | { |
198 | // just in case someone else emptied us, tsk | 194 | refreshNames(LLFriendObserver::ADD, search_string); |
199 | if (mFriendsList->isEmpty() && LLAvatarTracker::instance().getBuddyCount() > 0) | ||
200 | { | ||
201 | refreshNames(LLFriendObserver::ADD); | ||
202 | } | ||
203 | |||
204 | // don't worry about maintaining selection since we're searching | ||
205 | std::vector<LLScrollListItem*> vFriends(mFriendsList->getAllData()); | ||
206 | |||
207 | // this should really REALLY use deleteAllItems() to rebuild the list instead | ||
208 | std::string friend_name; | ||
209 | for (std::vector<LLScrollListItem*>::iterator itr = vFriends.begin(); itr != vFriends.end(); ++itr) | ||
210 | { | ||
211 | friend_name = (*itr)->getColumn(LIST_FRIEND_NAME)->getValue().asString(); | ||
212 | LLStringUtil::toLower(friend_name); | ||
213 | BOOL show_entry = (friend_name.find(search) != std::string::npos); | ||
214 | if (!show_entry) | ||
215 | { | ||
216 | mFriendsList->deleteItems((*itr)->getValue()); | ||
217 | } | ||
218 | } | ||
219 | } | 195 | } |
220 | mFriendsList->setScrollPos(0); | ||
221 | refreshUI(); | 196 | refreshUI(); |
222 | } | 197 | } |
223 | 198 | ||
@@ -247,7 +222,7 @@ BOOL LLPanelFriends::postBuild() | |||
247 | } | 222 | } |
248 | 223 | ||
249 | U32 changed_mask = LLFriendObserver::ADD | LLFriendObserver::REMOVE | LLFriendObserver::ONLINE; | 224 | U32 changed_mask = LLFriendObserver::ADD | LLFriendObserver::REMOVE | LLFriendObserver::ONLINE; |
250 | refreshNames(changed_mask); | 225 | refreshNames(changed_mask, ""); |
251 | 226 | ||
252 | childSetAction("im_btn", onClickIM, this); | 227 | childSetAction("im_btn", onClickIM, this); |
253 | childSetAction("profile_btn", onClickProfile, this); | 228 | childSetAction("profile_btn", onClickProfile, this); |
@@ -454,7 +429,7 @@ struct SortFriendsByID | |||
454 | } | 429 | } |
455 | }; | 430 | }; |
456 | 431 | ||
457 | void LLPanelFriends::refreshNames(U32 changed_mask) | 432 | void LLPanelFriends::refreshNames(U32 changed_mask, const std::string& filter_string) |
458 | { | 433 | { |
459 | LLDynamicArray<LLUUID> selected_ids = getSelectedIDs(); | 434 | LLDynamicArray<LLUUID> selected_ids = getSelectedIDs(); |
460 | S32 pos = mFriendsList->getScrollPos(); | 435 | S32 pos = mFriendsList->getScrollPos(); |
@@ -465,14 +440,49 @@ void LLPanelFriends::refreshNames(U32 changed_mask) | |||
465 | 440 | ||
466 | BOOL have_names = TRUE; | 441 | BOOL have_names = TRUE; |
467 | 442 | ||
468 | if(changed_mask & (LLFriendObserver::ADD | LLFriendObserver::REMOVE)) | 443 | // I hate doing it this way. There's no need for it. I blame LL -- MC |
444 | if (filter_string.empty()) | ||
469 | { | 445 | { |
470 | have_names &= refreshNamesSync(all_buddies); | 446 | if(changed_mask & (LLFriendObserver::ADD | LLFriendObserver::REMOVE)) |
471 | } | 447 | { |
448 | have_names &= refreshNamesSync(all_buddies); | ||
449 | } | ||
472 | 450 | ||
473 | if(changed_mask & LLFriendObserver::ONLINE) | 451 | if(changed_mask & LLFriendObserver::ONLINE) |
452 | { | ||
453 | have_names &= refreshNamesPresence(all_buddies); | ||
454 | } | ||
455 | } | ||
456 | else | ||
474 | { | 457 | { |
475 | have_names &= refreshNamesPresence(all_buddies); | 458 | std::string firstname; |
459 | std::string lastname; | ||
460 | utf8str_tolower(filter_string); | ||
461 | LLAvatarTracker::buddy_map_t temp_buddies; | ||
462 | |||
463 | for (LLAvatarTracker::buddy_map_t::reverse_iterator bIt = all_buddies.rbegin(); | ||
464 | bIt != all_buddies.rend(); ++bIt) | ||
465 | { | ||
466 | llinfos << (*bIt).first << llendl; | ||
467 | if (gCacheName->getName((*bIt).first, firstname, lastname)) | ||
468 | { | ||
469 | std::string test_name(firstname + " " + lastname); | ||
470 | if ((utf8str_tolower(test_name)).find(filter_string) != std::string::npos) | ||
471 | { | ||
472 | llinfos << "inserting: " << test_name << " from filter: " << filter_string << llendl; | ||
473 | temp_buddies.insert(temp_buddies.begin(), *bIt); | ||
474 | } | ||
475 | } | ||
476 | } | ||
477 | if(changed_mask & (LLFriendObserver::ADD | LLFriendObserver::REMOVE)) | ||
478 | { | ||
479 | have_names &= refreshNamesSync(temp_buddies); | ||
480 | } | ||
481 | |||
482 | if(changed_mask & LLFriendObserver::ONLINE) | ||
483 | { | ||
484 | have_names &= refreshNamesPresence(temp_buddies); | ||
485 | } | ||
476 | } | 486 | } |
477 | 487 | ||
478 | if (!have_names) | 488 | if (!have_names) |
diff --git a/linden/indra/newview/llfloaterfriends.h b/linden/indra/newview/llfloaterfriends.h index 9a1feba..8206362 100644 --- a/linden/indra/newview/llfloaterfriends.h +++ b/linden/indra/newview/llfloaterfriends.h | |||
@@ -100,7 +100,7 @@ private: | |||
100 | 100 | ||
101 | // protected members | 101 | // protected members |
102 | typedef std::map<LLUUID, S32> rights_map_t; | 102 | typedef std::map<LLUUID, S32> rights_map_t; |
103 | void refreshNames(U32 changed_mask); | 103 | void refreshNames(U32 changed_mask, const std::string& filter_string); |
104 | void filterContacts(const std::string& search_string); | 104 | void filterContacts(const std::string& search_string); |
105 | 105 | ||
106 | BOOL refreshNamesSync(const LLAvatarTracker::buddy_map_t & all_buddies); | 106 | BOOL refreshNamesSync(const LLAvatarTracker::buddy_map_t & all_buddies); |