Annotation of /trunk/indra/newview/llfloateravatarpicker.cpp
Parent Directory
|
Revision Log
Revision 135 - (view) (download)
| 1 : | mjm | 135 | /** |
| 2 : | * @file llfloateravatarpicker.cpp | ||
| 3 : | * | ||
| 4 : | * $LicenseInfo:firstyear=2003&license=viewergpl$ | ||
| 5 : | * | ||
| 6 : | * Copyright (c) 2003-2009, Linden Research, Inc. | ||
| 7 : | * | ||
| 8 : | * Second Life Viewer Source Code | ||
| 9 : | * The source code in this file ("Source Code") is provided by Linden Lab | ||
| 10 : | * to you under the terms of the GNU General Public License, version 2.0 | ||
| 11 : | * ("GPL"), unless you have obtained a separate licensing agreement | ||
| 12 : | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
| 13 : | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
| 14 : | * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 | ||
| 15 : | * | ||
| 16 : | * There are special exceptions to the terms and conditions of the GPL as | ||
| 17 : | * it is applied to this Source Code. View the full text of the exception | ||
| 18 : | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
| 19 : | * online at | ||
| 20 : | * http://secondlifegrid.net/programs/open_source/licensing/flossexception | ||
| 21 : | * | ||
| 22 : | * By copying, modifying or distributing this software, you acknowledge | ||
| 23 : | * that you have read and understood your obligations described above, | ||
| 24 : | * and agree to abide by those obligations. | ||
| 25 : | * | ||
| 26 : | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
| 27 : | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
| 28 : | * COMPLETENESS OR PERFORMANCE. | ||
| 29 : | * $/LicenseInfo$ | ||
| 30 : | */ | ||
| 31 : | |||
| 32 : | #include "llviewerprecompiledheaders.h" | ||
| 33 : | |||
| 34 : | #include "llfloateravatarpicker.h" | ||
| 35 : | |||
| 36 : | #include "message.h" | ||
| 37 : | |||
| 38 : | #include "llagent.h" | ||
| 39 : | #include "llbutton.h" | ||
| 40 : | #include "llfocusmgr.h" | ||
| 41 : | #include "llinventoryview.h" | ||
| 42 : | #include "llinventorymodel.h" | ||
| 43 : | #include "lllineeditor.h" | ||
| 44 : | #include "llscrolllistctrl.h" | ||
| 45 : | #include "lltextbox.h" | ||
| 46 : | #include "lluictrlfactory.h" | ||
| 47 : | #include "llviewercontrol.h" | ||
| 48 : | #include "llworld.h" | ||
| 49 : | |||
| 50 : | const S32 MIN_WIDTH = 200; | ||
| 51 : | const S32 MIN_HEIGHT = 340; | ||
| 52 : | const LLRect FLOATER_RECT(0, 380, 240, 0); | ||
| 53 : | const std::string FLOATER_TITLE = "Choose Resident"; | ||
| 54 : | |||
| 55 : | // static | ||
| 56 : | LLFloaterAvatarPicker* LLFloaterAvatarPicker::sInstance = NULL; | ||
| 57 : | |||
| 58 : | |||
| 59 : | LLFloaterAvatarPicker* LLFloaterAvatarPicker::show(callback_t callback, | ||
| 60 : | void* userdata, | ||
| 61 : | BOOL allow_multiple, | ||
| 62 : | BOOL closeOnSelect) | ||
| 63 : | { | ||
| 64 : | // TODO: This class should not be a singleton as it's used in multiple places | ||
| 65 : | // and therefore can't be used simultaneously. -MG | ||
| 66 : | if (!sInstance) | ||
| 67 : | { | ||
| 68 : | sInstance = new LLFloaterAvatarPicker(); | ||
| 69 : | sInstance->mCallback = callback; | ||
| 70 : | sInstance->mCallbackUserdata = userdata; | ||
| 71 : | sInstance->mCloseOnSelect = FALSE; | ||
| 72 : | |||
| 73 : | sInstance->open(); /* Flawfinder: ignore */ | ||
| 74 : | sInstance->center(); | ||
| 75 : | sInstance->setAllowMultiple(allow_multiple); | ||
| 76 : | } | ||
| 77 : | else | ||
| 78 : | { | ||
| 79 : | sInstance->open(); /*Flawfinder: ignore*/ | ||
| 80 : | sInstance->mCallback = callback; | ||
| 81 : | sInstance->mCallbackUserdata = userdata; | ||
| 82 : | sInstance->setAllowMultiple(allow_multiple); | ||
| 83 : | } | ||
| 84 : | |||
| 85 : | sInstance->mNearMeListComplete = FALSE; | ||
| 86 : | sInstance->mCloseOnSelect = closeOnSelect; | ||
| 87 : | return sInstance; | ||
| 88 : | } | ||
| 89 : | |||
| 90 : | // Default constructor | ||
| 91 : | LLFloaterAvatarPicker::LLFloaterAvatarPicker() : | ||
| 92 : | LLFloater(std::string("avatarpicker"), FLOATER_RECT, FLOATER_TITLE, TRUE, MIN_WIDTH, MIN_HEIGHT), | ||
| 93 : | mResultsReturned(FALSE), | ||
| 94 : | mCallback(NULL), | ||
| 95 : | mCallbackUserdata(NULL) | ||
| 96 : | { | ||
| 97 : | LLUICtrlFactory::getInstance()->buildFloater(this, "floater_avatar_picker.xml", NULL); | ||
| 98 : | } | ||
| 99 : | |||
| 100 : | BOOL LLFloaterAvatarPicker::postBuild() | ||
| 101 : | { | ||
| 102 : | childSetKeystrokeCallback("Edit", editKeystroke, this); | ||
| 103 : | |||
| 104 : | childSetAction("Find", onBtnFind, this); | ||
| 105 : | childDisable("Find"); | ||
| 106 : | childSetAction("Refresh", onBtnRefresh, this); | ||
| 107 : | childSetCommitCallback("near_me_range", onRangeAdjust, this); | ||
| 108 : | |||
| 109 : | childSetDoubleClickCallback("SearchResults", onBtnSelect); | ||
| 110 : | childSetDoubleClickCallback("NearMe", onBtnSelect); | ||
| 111 : | childSetCommitCallback("SearchResults", onList, this); | ||
| 112 : | childSetCommitCallback("NearMe", onList, this); | ||
| 113 : | childDisable("SearchResults"); | ||
| 114 : | |||
| 115 : | childSetAction("Select", onBtnSelect, this); | ||
| 116 : | childDisable("Select"); | ||
| 117 : | |||
| 118 : | childSetAction("Cancel", onBtnClose, this); | ||
| 119 : | |||
| 120 : | childSetFocus("Edit"); | ||
| 121 : | |||
| 122 : | LLPanel* search_panel = getChild<LLPanel>("SearchPanel"); | ||
| 123 : | if (search_panel) | ||
| 124 : | { | ||
| 125 : | // Start searching when Return is pressed in the line editor. | ||
| 126 : | search_panel->setDefaultBtn("Find"); | ||
| 127 : | } | ||
| 128 : | |||
| 129 : | getChild<LLScrollListCtrl>("SearchResults")->addCommentText(getString("no_results")); | ||
| 130 : | |||
| 131 : | LLInventoryPanel* inventory_panel = getChild<LLInventoryPanel>("InventoryPanel"); | ||
| 132 : | inventory_panel->setFilterTypes(0x1 << LLInventoryType::IT_CALLINGCARD); | ||
| 133 : | inventory_panel->setFollowsAll(); | ||
| 134 : | inventory_panel->setShowFolderState(LLInventoryFilter::SHOW_NON_EMPTY_FOLDERS); | ||
| 135 : | inventory_panel->openDefaultFolderForType(LLAssetType::AT_CALLINGCARD); | ||
| 136 : | inventory_panel->setSelectCallback(LLFloaterAvatarPicker::onCallingCardSelectionChange, this); | ||
| 137 : | |||
| 138 : | childSetTabChangeCallback("ResidentChooserTabs", "SearchPanel", onTabChanged, this); | ||
| 139 : | childSetTabChangeCallback("ResidentChooserTabs", "CallingCardsPanel", onTabChanged, this); | ||
| 140 : | childSetTabChangeCallback("ResidentChooserTabs", "NearMePanel", onTabChanged, this); | ||
| 141 : | |||
| 142 : | setAllowMultiple(FALSE); | ||
| 143 : | |||
| 144 : | return TRUE; | ||
| 145 : | } | ||
| 146 : | |||
| 147 : | void LLFloaterAvatarPicker::onTabChanged(void* userdata, bool from_click) | ||
| 148 : | { | ||
| 149 : | LLFloaterAvatarPicker* self = (LLFloaterAvatarPicker*)userdata; | ||
| 150 : | if (!self) | ||
| 151 : | { | ||
| 152 : | return; | ||
| 153 : | } | ||
| 154 : | |||
| 155 : | self->childSetEnabled("Select", self->visibleItemsSelected()); | ||
| 156 : | } | ||
| 157 : | |||
| 158 : | // Destroys the object | ||
| 159 : | LLFloaterAvatarPicker::~LLFloaterAvatarPicker() | ||
| 160 : | { | ||
| 161 : | gFocusMgr.releaseFocusIfNeeded( this ); | ||
| 162 : | |||
| 163 : | sInstance = NULL; | ||
| 164 : | } | ||
| 165 : | |||
| 166 : | void LLFloaterAvatarPicker::onBtnFind(void* userdata) | ||
| 167 : | { | ||
| 168 : | LLFloaterAvatarPicker* self = (LLFloaterAvatarPicker*)userdata; | ||
| 169 : | if(self) self->find(); | ||
| 170 : | } | ||
| 171 : | |||
| 172 : | static void getSelectedAvatarData(const LLScrollListCtrl* from, std::vector<std::string>& avatar_names, std::vector<LLUUID>& avatar_ids) | ||
| 173 : | { | ||
| 174 : | std::vector<LLScrollListItem*> items = from->getAllSelected(); | ||
| 175 : | for (std::vector<LLScrollListItem*>::iterator iter = items.begin(); iter != items.end(); ++iter) | ||
| 176 : | { | ||
| 177 : | LLScrollListItem* item = *iter; | ||
| 178 : | if (item->getUUID().notNull()) | ||
| 179 : | { | ||
| 180 : | avatar_names.push_back(item->getColumn(0)->getValue().asString()); | ||
| 181 : | avatar_ids.push_back(item->getUUID()); | ||
| 182 : | } | ||
| 183 : | } | ||
| 184 : | } | ||
| 185 : | |||
| 186 : | void LLFloaterAvatarPicker::onBtnSelect(void* userdata) | ||
| 187 : | { | ||
| 188 : | LLFloaterAvatarPicker* self = (LLFloaterAvatarPicker*)userdata; | ||
| 189 : | |||
| 190 : | if(self->mCallback) | ||
| 191 : | { | ||
| 192 : | LLPanel* active_panel = self->childGetVisibleTab("ResidentChooserTabs"); | ||
| 193 : | |||
| 194 : | if(active_panel == self->getChild<LLPanel>("CallingCardsPanel")) | ||
| 195 : | { | ||
| 196 : | self->mCallback(self->mSelectedInventoryAvatarNames, self->mSelectedInventoryAvatarIDs, self->mCallbackUserdata); | ||
| 197 : | } | ||
| 198 : | else if(active_panel == self->getChild<LLPanel>("SearchPanel")) | ||
| 199 : | { | ||
| 200 : | std::vector<std::string> avatar_names; | ||
| 201 : | std::vector<LLUUID> avatar_ids; | ||
| 202 : | getSelectedAvatarData(self->getChild<LLScrollListCtrl>("SearchResults"), avatar_names, avatar_ids); | ||
| 203 : | self->mCallback(avatar_names, avatar_ids, self->mCallbackUserdata); | ||
| 204 : | } | ||
| 205 : | else if(active_panel == self->getChild<LLPanel>("NearMePanel")) | ||
| 206 : | { | ||
| 207 : | std::vector<std::string> avatar_names; | ||
| 208 : | std::vector<LLUUID> avatar_ids; | ||
| 209 : | getSelectedAvatarData(self->getChild<LLScrollListCtrl>("NearMe"), avatar_names, avatar_ids); | ||
| 210 : | self->mCallback(avatar_names, avatar_ids, self->mCallbackUserdata); | ||
| 211 : | } | ||
| 212 : | } | ||
| 213 : | self->getChild<LLInventoryPanel>("InventoryPanel")->setSelection(LLUUID::null, FALSE); | ||
| 214 : | self->getChild<LLScrollListCtrl>("SearchResults")->deselectAllItems(TRUE); | ||
| 215 : | self->getChild<LLScrollListCtrl>("NearMe")->deselectAllItems(TRUE); | ||
| 216 : | if(self->mCloseOnSelect) | ||
| 217 : | { | ||
| 218 : | self->mCloseOnSelect = FALSE; | ||
| 219 : | self->close(); | ||
| 220 : | } | ||
| 221 : | } | ||
| 222 : | |||
| 223 : | void LLFloaterAvatarPicker::onBtnRefresh(void* userdata) | ||
| 224 : | { | ||
| 225 : | LLFloaterAvatarPicker* self = (LLFloaterAvatarPicker*)userdata; | ||
| 226 : | if (!self) | ||
| 227 : | { | ||
| 228 : | return; | ||
| 229 : | } | ||
| 230 : | |||
| 231 : | self->getChild<LLScrollListCtrl>("NearMe")->deleteAllItems(); | ||
| 232 : | self->getChild<LLScrollListCtrl>("NearMe")->addCommentText(self->getString("searching")); | ||
| 233 : | self->mNearMeListComplete = FALSE; | ||
| 234 : | } | ||
| 235 : | |||
| 236 : | void LLFloaterAvatarPicker::onBtnClose(void* userdata) | ||
| 237 : | { | ||
| 238 : | LLFloaterAvatarPicker* self = (LLFloaterAvatarPicker*)userdata; | ||
| 239 : | if(self) self->close(); | ||
| 240 : | } | ||
| 241 : | |||
| 242 : | void LLFloaterAvatarPicker::onRangeAdjust(LLUICtrl* source, void* data) | ||
| 243 : | { | ||
| 244 : | LLFloaterAvatarPicker::onBtnRefresh(data); | ||
| 245 : | } | ||
| 246 : | |||
| 247 : | void LLFloaterAvatarPicker::onList(LLUICtrl* ctrl, void* userdata) | ||
| 248 : | { | ||
| 249 : | LLFloaterAvatarPicker* self = (LLFloaterAvatarPicker*)userdata; | ||
| 250 : | if (self) | ||
| 251 : | { | ||
| 252 : | self->childSetEnabled("Select", self->visibleItemsSelected()); | ||
| 253 : | } | ||
| 254 : | } | ||
| 255 : | |||
| 256 : | // static callback for inventory picker (select from calling cards) | ||
| 257 : | void LLFloaterAvatarPicker::onCallingCardSelectionChange(const std::deque<LLFolderViewItem*> &items, BOOL user_action, void* data) | ||
| 258 : | { | ||
| 259 : | LLFloaterAvatarPicker* self = (LLFloaterAvatarPicker*)data; | ||
| 260 : | if (self) | ||
| 261 : | { | ||
| 262 : | self->doCallingCardSelectionChange( items, user_action, data ); | ||
| 263 : | } | ||
| 264 : | } | ||
| 265 : | |||
| 266 : | // Callback for inventory picker (select from calling cards) | ||
| 267 : | void LLFloaterAvatarPicker::doCallingCardSelectionChange(const std::deque<LLFolderViewItem*> &items, BOOL user_action, void* data) | ||
| 268 : | { | ||
| 269 : | bool panel_active = (childGetVisibleTab("ResidentChooserTabs") == getChild<LLPanel>("CallingCardsPanel")); | ||
| 270 : | |||
| 271 : | mSelectedInventoryAvatarIDs.clear(); | ||
| 272 : | mSelectedInventoryAvatarNames.clear(); | ||
| 273 : | |||
| 274 : | if (panel_active) | ||
| 275 : | { | ||
| 276 : | childSetEnabled("Select", FALSE); | ||
| 277 : | } | ||
| 278 : | |||
| 279 : | std::deque<LLFolderViewItem*>::const_iterator item_it; | ||
| 280 : | for (item_it = items.begin(); item_it != items.end(); ++item_it) | ||
| 281 : | { | ||
| 282 : | LLFolderViewEventListener* listenerp = (*item_it)->getListener(); | ||
| 283 : | if (listenerp->getInventoryType() == LLInventoryType::IT_CALLINGCARD) | ||
| 284 : | { | ||
| 285 : | LLInventoryItem* item = gInventory.getItem(listenerp->getUUID()); | ||
| 286 : | if (item) | ||
| 287 : | { | ||
| 288 : | mSelectedInventoryAvatarIDs.push_back(item->getCreatorUUID()); | ||
| 289 : | mSelectedInventoryAvatarNames.push_back(listenerp->getName()); | ||
| 290 : | } | ||
| 291 : | } | ||
| 292 : | } | ||
| 293 : | |||
| 294 : | if (panel_active) | ||
| 295 : | { | ||
| 296 : | childSetEnabled("Select", visibleItemsSelected()); | ||
| 297 : | } | ||
| 298 : | } | ||
| 299 : | |||
| 300 : | void LLFloaterAvatarPicker::populateNearMe() | ||
| 301 : | { | ||
| 302 : | BOOL all_loaded = TRUE; | ||
| 303 : | BOOL empty = TRUE; | ||
| 304 : | LLScrollListCtrl* near_me_scroller = getChild<LLScrollListCtrl>("NearMe"); | ||
| 305 : | near_me_scroller->deleteAllItems(); | ||
| 306 : | |||
| 307 : | //MK | ||
| 308 : | if (gRRenabled && gAgent.mRRInterface.mContainsShownames) | ||
| 309 : | { | ||
| 310 : | return; | ||
| 311 : | } | ||
| 312 : | //mk | ||
| 313 : | |||
| 314 : | std::vector<LLUUID> avatar_ids; | ||
| 315 : | LLWorld::getInstance()->getAvatars(&avatar_ids, NULL, gAgent.getPositionGlobal(), gSavedSettings.getF32("NearMeRange")); | ||
| 316 : | for(U32 i=0; i<avatar_ids.size(); i++) | ||
| 317 : | { | ||
| 318 : | LLUUID& av = avatar_ids[i]; | ||
| 319 : | if(av == gAgent.getID()) continue; | ||
| 320 : | LLSD element; | ||
| 321 : | element["id"] = av; // value | ||
| 322 : | std::string fullname; | ||
| 323 : | if(!gCacheName->getFullName(av, fullname)) | ||
| 324 : | { | ||
| 325 : | element["columns"][0]["value"] = LLCacheName::getDefaultName(); | ||
| 326 : | all_loaded = FALSE; | ||
| 327 : | } | ||
| 328 : | else | ||
| 329 : | { | ||
| 330 : | element["columns"][0]["value"] = fullname; | ||
| 331 : | } | ||
| 332 : | near_me_scroller->addElement(element); | ||
| 333 : | empty = FALSE; | ||
| 334 : | } | ||
| 335 : | |||
| 336 : | if (empty) | ||
| 337 : | { | ||
| 338 : | childDisable("NearMe"); | ||
| 339 : | childDisable("Select"); | ||
| 340 : | near_me_scroller->addCommentText(getString("no_one_near")); | ||
| 341 : | } | ||
| 342 : | else | ||
| 343 : | { | ||
| 344 : | childEnable("NearMe"); | ||
| 345 : | childEnable("Select"); | ||
| 346 : | near_me_scroller->selectFirstItem(); | ||
| 347 : | onList(near_me_scroller, this); | ||
| 348 : | near_me_scroller->setFocus(TRUE); | ||
| 349 : | } | ||
| 350 : | |||
| 351 : | if (all_loaded) | ||
| 352 : | { | ||
| 353 : | mNearMeListComplete = TRUE; | ||
| 354 : | } | ||
| 355 : | } | ||
| 356 : | |||
| 357 : | void LLFloaterAvatarPicker::draw() | ||
| 358 : | { | ||
| 359 : | LLFloater::draw(); | ||
| 360 : | if (!mNearMeListComplete && childGetVisibleTab("ResidentChooserTabs") == getChild<LLPanel>("NearMePanel")) | ||
| 361 : | { | ||
| 362 : | populateNearMe(); | ||
| 363 : | } | ||
| 364 : | } | ||
| 365 : | |||
| 366 : | BOOL LLFloaterAvatarPicker::visibleItemsSelected() const | ||
| 367 : | { | ||
| 368 : | LLPanel* active_panel = childGetVisibleTab("ResidentChooserTabs"); | ||
| 369 : | |||
| 370 : | if(active_panel == getChild<LLPanel>("SearchPanel")) | ||
| 371 : | { | ||
| 372 : | return getChild<LLScrollListCtrl>("SearchResults")->getFirstSelectedIndex() >= 0; | ||
| 373 : | } | ||
| 374 : | else if(active_panel == getChild<LLPanel>("CallingCardsPanel")) | ||
| 375 : | { | ||
| 376 : | return mSelectedInventoryAvatarIDs.size() > 0; | ||
| 377 : | } | ||
| 378 : | else if(active_panel == getChild<LLPanel>("NearMePanel")) | ||
| 379 : | { | ||
| 380 : | return getChild<LLScrollListCtrl>("NearMe")->getFirstSelectedIndex() >= 0; | ||
| 381 : | } | ||
| 382 : | return FALSE; | ||
| 383 : | } | ||
| 384 : | |||
| 385 : | void LLFloaterAvatarPicker::find() | ||
| 386 : | { | ||
| 387 : | const std::string& text = childGetValue("Edit").asString(); | ||
| 388 : | |||
| 389 : | mQueryID.generate(); | ||
| 390 : | |||
| 391 : | LLMessageSystem* msg = gMessageSystem; | ||
| 392 : | |||
| 393 : | msg->newMessage("AvatarPickerRequest"); | ||
| 394 : | msg->nextBlock("AgentData"); | ||
| 395 : | msg->addUUID("AgentID", gAgent.getID()); | ||
| 396 : | msg->addUUID("SessionID", gAgent.getSessionID()); | ||
| 397 : | msg->addUUID("QueryID", mQueryID); // not used right now | ||
| 398 : | msg->nextBlock("Data"); | ||
| 399 : | msg->addString("Name", text); | ||
| 400 : | |||
| 401 : | gAgent.sendReliableMessage(); | ||
| 402 : | |||
| 403 : | getChild<LLScrollListCtrl>("SearchResults")->deleteAllItems(); | ||
| 404 : | getChild<LLScrollListCtrl>("SearchResults")->addCommentText(getString("searching")); | ||
| 405 : | |||
| 406 : | childSetEnabled("Select", FALSE); | ||
| 407 : | mResultsReturned = FALSE; | ||
| 408 : | } | ||
| 409 : | |||
| 410 : | void LLFloaterAvatarPicker::setAllowMultiple(BOOL allow_multiple) | ||
| 411 : | { | ||
| 412 : | getChild<LLScrollListCtrl>("SearchResults")->setAllowMultipleSelection(allow_multiple); | ||
| 413 : | getChild<LLInventoryPanel>("InventoryPanel")->setAllowMultiSelect(allow_multiple); | ||
| 414 : | getChild<LLScrollListCtrl>("NearMe")->setAllowMultipleSelection(allow_multiple); | ||
| 415 : | } | ||
| 416 : | |||
| 417 : | // static | ||
| 418 : | void LLFloaterAvatarPicker::processAvatarPickerReply(LLMessageSystem* msg, void**) | ||
| 419 : | { | ||
| 420 : | LLUUID agent_id; | ||
| 421 : | LLUUID query_id; | ||
| 422 : | LLUUID avatar_id; | ||
| 423 : | std::string first_name; | ||
| 424 : | std::string last_name; | ||
| 425 : | |||
| 426 : | msg->getUUID("AgentData", "AgentID", agent_id); | ||
| 427 : | msg->getUUID("AgentData", "QueryID", query_id); | ||
| 428 : | |||
| 429 : | // Not for us | ||
| 430 : | if (agent_id != gAgent.getID()) return; | ||
| 431 : | |||
| 432 : | // Dialog already closed | ||
| 433 : | LLFloaterAvatarPicker *self = sInstance; | ||
| 434 : | if (!self) return; | ||
| 435 : | |||
| 436 : | // these are not results from our last request | ||
| 437 : | if (query_id != self->mQueryID) | ||
| 438 : | { | ||
| 439 : | return; | ||
| 440 : | } | ||
| 441 : | |||
| 442 : | LLScrollListCtrl* search_results = self->getChild<LLScrollListCtrl>("SearchResults"); | ||
| 443 : | |||
| 444 : | // clear "Searching" label on first results | ||
| 445 : | search_results->deleteAllItems(); | ||
| 446 : | |||
| 447 : | self->mResultsReturned = TRUE; | ||
| 448 : | |||
| 449 : | BOOL found_one = FALSE; | ||
| 450 : | S32 num_new_rows = msg->getNumberOfBlocks("Data"); | ||
| 451 : | for (S32 i = 0; i < num_new_rows; i++) | ||
| 452 : | { | ||
| 453 : | msg->getUUIDFast( _PREHASH_Data,_PREHASH_AvatarID, avatar_id, i); | ||
| 454 : | msg->getStringFast(_PREHASH_Data,_PREHASH_FirstName, first_name, i); | ||
| 455 : | msg->getStringFast(_PREHASH_Data,_PREHASH_LastName, last_name, i); | ||
| 456 : | |||
| 457 : | std::string avatar_name; | ||
| 458 : | if (avatar_id.isNull()) | ||
| 459 : | { | ||
| 460 : | LLStringUtil::format_map_t map; | ||
| 461 : | map["[TEXT]"] = self->childGetText("Edit"); | ||
| 462 : | avatar_name = self->getString("not_found", map); | ||
| 463 : | search_results->setEnabled(FALSE); | ||
| 464 : | self->childDisable("Select"); | ||
| 465 : | } | ||
| 466 : | else | ||
| 467 : | { | ||
| 468 : | avatar_name = first_name + " " + last_name; | ||
| 469 : | search_results->setEnabled(TRUE); | ||
| 470 : | found_one = TRUE; | ||
| 471 : | } | ||
| 472 : | LLSD element; | ||
| 473 : | element["id"] = avatar_id; // value | ||
| 474 : | element["columns"][0]["value"] = avatar_name; | ||
| 475 : | search_results->addElement(element); | ||
| 476 : | } | ||
| 477 : | |||
| 478 : | if (found_one) | ||
| 479 : | { | ||
| 480 : | self->childEnable("Select"); | ||
| 481 : | search_results->selectFirstItem(); | ||
| 482 : | self->onList(search_results, self); | ||
| 483 : | search_results->setFocus(TRUE); | ||
| 484 : | } | ||
| 485 : | } | ||
| 486 : | |||
| 487 : | //static | ||
| 488 : | void LLFloaterAvatarPicker::editKeystroke(LLLineEditor* caller, void* user_data) | ||
| 489 : | { | ||
| 490 : | LLFloaterAvatarPicker* self = (LLFloaterAvatarPicker*)user_data; | ||
| 491 : | self->childSetEnabled("Find", caller->getText().size() >= 3); | ||
| 492 : | } | ||
| 493 : | |||
| 494 : | // virtual | ||
| 495 : | BOOL LLFloaterAvatarPicker::handleKeyHere(KEY key, MASK mask) | ||
| 496 : | { | ||
| 497 : | if (key == KEY_RETURN && mask == MASK_NONE) | ||
| 498 : | { | ||
| 499 : | if (childHasFocus("Edit")) | ||
| 500 : | { | ||
| 501 : | onBtnFind(this); | ||
| 502 : | } | ||
| 503 : | else | ||
| 504 : | { | ||
| 505 : | onBtnSelect(this); | ||
| 506 : | } | ||
| 507 : | return TRUE; | ||
| 508 : | } | ||
| 509 : | else if (key == KEY_ESCAPE && mask == MASK_NONE) | ||
| 510 : | { | ||
| 511 : | close(); | ||
| 512 : | return TRUE; | ||
| 513 : | } | ||
| 514 : | |||
| 515 : | return LLFloater::handleKeyHere(key, mask); | ||
| 516 : | } |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |

