summaryrefslogtreecommitdiff
path: root/indra/newview/llpanelexperiencepicker.cpp
diff options
context:
space:
mode:
authorAnsariel <ansariel.hiller@phoenixviewer.com>2024-05-22 19:04:52 +0200
committerAnsariel <ansariel.hiller@phoenixviewer.com>2024-05-22 19:04:52 +0200
commit1b67dd855c41f5a0cda7ec2a68d98071986ca703 (patch)
treeab243607f74f78200787bba5b9b88f07ef1b966f /indra/newview/llpanelexperiencepicker.cpp
parent6d6eabca44d08d5b97bfe3e941d2b9687c2246ea (diff)
parente1623bb276f83a43ce7a197e388720c05bdefe61 (diff)
Merge remote-tracking branch 'origin/main' into DRTVWR-600-maint-A
# Conflicts: # autobuild.xml # indra/cmake/CMakeLists.txt # indra/cmake/GoogleMock.cmake # indra/llaudio/llaudioengine_fmodstudio.cpp # indra/llaudio/llaudioengine_fmodstudio.h # indra/llaudio/lllistener_fmodstudio.cpp # indra/llaudio/lllistener_fmodstudio.h # indra/llaudio/llstreamingaudio_fmodstudio.cpp # indra/llaudio/llstreamingaudio_fmodstudio.h # indra/llcharacter/llmultigesture.cpp # indra/llcharacter/llmultigesture.h # indra/llimage/llimage.cpp # indra/llimage/llimagepng.cpp # indra/llimage/llimageworker.cpp # indra/llimage/tests/llimageworker_test.cpp # indra/llmessage/tests/llmockhttpclient.h # indra/llprimitive/llgltfmaterial.h # indra/llrender/llfontfreetype.cpp # indra/llui/llcombobox.cpp # indra/llui/llfolderview.cpp # indra/llui/llfolderviewmodel.h # indra/llui/lllineeditor.cpp # indra/llui/lllineeditor.h # indra/llui/lltextbase.cpp # indra/llui/lltextbase.h # indra/llui/lltexteditor.cpp # indra/llui/lltextvalidate.cpp # indra/llui/lltextvalidate.h # indra/llui/lluictrl.h # indra/llui/llview.cpp # indra/llwindow/llwindowmacosx.cpp # indra/newview/app_settings/settings.xml # indra/newview/llappearancemgr.cpp # indra/newview/llappearancemgr.h # indra/newview/llavatarpropertiesprocessor.cpp # indra/newview/llavatarpropertiesprocessor.h # indra/newview/llbreadcrumbview.cpp # indra/newview/llbreadcrumbview.h # indra/newview/llbreastmotion.cpp # indra/newview/llbreastmotion.h # indra/newview/llconversationmodel.h # indra/newview/lldensityctrl.cpp # indra/newview/lldensityctrl.h # indra/newview/llface.inl # indra/newview/llfloatereditsky.cpp # indra/newview/llfloatereditwater.cpp # indra/newview/llfloateremojipicker.h # indra/newview/llfloaterimsessiontab.cpp # indra/newview/llfloaterprofiletexture.cpp # indra/newview/llfloaterprofiletexture.h # indra/newview/llgesturemgr.cpp # indra/newview/llgesturemgr.h # indra/newview/llimpanel.cpp # indra/newview/llimpanel.h # indra/newview/llinventorybridge.cpp # indra/newview/llinventorybridge.h # indra/newview/llinventoryclipboard.cpp # indra/newview/llinventoryclipboard.h # indra/newview/llinventoryfunctions.cpp # indra/newview/llinventoryfunctions.h # indra/newview/llinventorygallery.cpp # indra/newview/lllistbrowser.cpp # indra/newview/lllistbrowser.h # indra/newview/llpanelobjectinventory.cpp # indra/newview/llpanelprofile.cpp # indra/newview/llpanelprofile.h # indra/newview/llpreviewgesture.cpp # indra/newview/llsavedsettingsglue.cpp # indra/newview/llsavedsettingsglue.h # indra/newview/lltooldraganddrop.cpp # indra/newview/llurllineeditorctrl.cpp # indra/newview/llvectorperfoptions.cpp # indra/newview/llvectorperfoptions.h # indra/newview/llviewerparceloverlay.cpp # indra/newview/llviewertexlayer.cpp # indra/newview/llviewertexturelist.cpp # indra/newview/macmain.h # indra/test/test.cpp
Diffstat (limited to 'indra/newview/llpanelexperiencepicker.cpp')
-rw-r--r--indra/newview/llpanelexperiencepicker.cpp898
1 files changed, 449 insertions, 449 deletions
diff --git a/indra/newview/llpanelexperiencepicker.cpp b/indra/newview/llpanelexperiencepicker.cpp
index b28df7c371..0142523ef6 100644
--- a/indra/newview/llpanelexperiencepicker.cpp
+++ b/indra/newview/llpanelexperiencepicker.cpp
@@ -1,449 +1,449 @@
-/**
-* @file llpanelexperiencepicker.cpp
-* @brief Implementation of llpanelexperiencepicker
-* @author dolphin@lindenlab.com
-*
-* $LicenseInfo:firstyear=2014&license=viewerlgpl$
-* Second Life Viewer Source Code
-* Copyright (C) 2014, Linden Research, Inc.
-*
-* This library is free software; you can redistribute it and/or
-* modify it under the terms of the GNU Lesser General Public
-* License as published by the Free Software Foundation;
-* version 2.1 of the License only.
-*
-* This library is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this library; if not, write to the Free Software
-* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*
-* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
-* $/LicenseInfo$
-*/
-
-#include "llviewerprecompiledheaders.h"
-
-#include "llpanelexperiencepicker.h"
-
-
-#include "lllineeditor.h"
-#include "llfloaterreg.h"
-#include "llscrolllistctrl.h"
-#include "llviewerregion.h"
-#include "llagent.h"
-#include "llexperiencecache.h"
-#include "llslurl.h"
-#include "llavatarnamecache.h"
-#include "llcombobox.h"
-#include "llviewercontrol.h"
-#include "llfloater.h"
-#include "llregex.h"
-#include "lltrans.h"
-
-#define BTN_FIND "find"
-#define BTN_OK "ok_btn"
-#define BTN_CANCEL "cancel_btn"
-#define BTN_PROFILE "profile_btn"
-#define BTN_LEFT "left_btn"
-#define BTN_RIGHT "right_btn"
-#define TEXT_EDIT "edit"
-#define TEXT_MATURITY "maturity"
-#define LIST_RESULTS "search_results"
-#define PANEL_SEARCH "search_panel"
-
-const static std::string columnSpace = " ";
-
-static LLPanelInjector<LLPanelExperiencePicker> t_panel_status("llpanelexperiencepicker");
-
-LLPanelExperiencePicker::LLPanelExperiencePicker()
- :LLPanel()
-{
- buildFromFile("panel_experience_search.xml");
- setDefaultFilters();
-}
-
-LLPanelExperiencePicker::~LLPanelExperiencePicker()
-{
-}
-
-bool LLPanelExperiencePicker::postBuild()
-{
- getChild<LLLineEditor>(TEXT_EDIT)->setKeystrokeCallback( boost::bind(&LLPanelExperiencePicker::editKeystroke, this, _1, _2),NULL);
-
- childSetAction(BTN_FIND, boost::bind(&LLPanelExperiencePicker::onBtnFind, this));
- getChildView(BTN_FIND)->setEnabled(true);
-
- LLScrollListCtrl* searchresults = getChild<LLScrollListCtrl>(LIST_RESULTS);
- searchresults->setDoubleClickCallback( boost::bind(&LLPanelExperiencePicker::onBtnSelect, this));
- searchresults->setCommitCallback(boost::bind(&LLPanelExperiencePicker::onList, this));
- getChildView(LIST_RESULTS)->setEnabled(false);
- getChild<LLScrollListCtrl>(LIST_RESULTS)->setCommentText(getString("no_results"));
-
- childSetAction(BTN_OK, boost::bind(&LLPanelExperiencePicker::onBtnSelect, this));
- getChildView(BTN_OK)->setEnabled(false);
- childSetAction(BTN_CANCEL, boost::bind(&LLPanelExperiencePicker::onBtnClose, this));
- childSetAction(BTN_PROFILE, boost::bind(&LLPanelExperiencePicker::onBtnProfile, this));
- getChildView(BTN_PROFILE)->setEnabled(false);
-
- getChild<LLComboBox>(TEXT_MATURITY)->setCurrentByIndex(gSavedPerAccountSettings.getU32("ExperienceSearchMaturity"));
- getChild<LLComboBox>(TEXT_MATURITY)->setCommitCallback(boost::bind(&LLPanelExperiencePicker::onMaturity, this));
- getChild<LLUICtrl>(TEXT_EDIT)->setFocus(true);
-
- childSetAction(BTN_LEFT, boost::bind(&LLPanelExperiencePicker::onPage, this, -1));
- childSetAction(BTN_RIGHT, boost::bind(&LLPanelExperiencePicker::onPage, this, 1));
-
- LLPanel* search_panel = getChild<LLPanel>(PANEL_SEARCH);
- if (search_panel)
- {
- // Start searching when Return is pressed in the line editor.
- search_panel->setDefaultBtn(BTN_FIND);
- }
- return true;
-}
-
-void LLPanelExperiencePicker::editKeystroke( class LLLineEditor* caller, void* user_data )
-{
- getChildView(BTN_FIND)->setEnabled(true);
-}
-
-void LLPanelExperiencePicker::onBtnFind()
-{
- mCurrentPage=1;
- boost::cmatch what;
- std::string text = getChild<LLUICtrl>(TEXT_EDIT)->getValue().asString();
- const boost::regex expression("secondlife:///app/experience/[\\da-f-]+/profile");
- if (ll_regex_match(text.c_str(), what, expression))
- {
- LLURI uri(text);
- LLSD path_array = uri.pathArray();
- if (path_array.size() == 4)
- {
- std::string exp_id = path_array.get(2).asString();
- LLUUID experience_id(exp_id);
- if (!experience_id.isNull())
- {
- const LLSD& experience_details = LLExperienceCache::instance().get(experience_id);
- if(!experience_details.isUndefined())
- {
- std::string experience_name_string = experience_details[LLExperienceCache::NAME].asString();
- if(!experience_name_string.empty())
- {
- getChild<LLUICtrl>(TEXT_EDIT)->setValue(experience_name_string);
- }
- }
- else
- {
- getChild<LLScrollListCtrl>(LIST_RESULTS)->deleteAllItems();
- getChild<LLScrollListCtrl>(LIST_RESULTS)->setCommentText(getString("searching"));
-
- getChildView(BTN_OK)->setEnabled(false);
- getChildView(BTN_PROFILE)->setEnabled(false);
-
- getChildView(BTN_RIGHT)->setEnabled(false);
- getChildView(BTN_LEFT)->setEnabled(false);
- LLExperienceCache::instance().get(experience_id, boost::bind(&LLPanelExperiencePicker::onBtnFind, this));
- return;
- }
- }
- }
- }
-
-
- find();
-}
-
-void LLPanelExperiencePicker::onList()
-{
- bool enabled = isSelectButtonEnabled();
- getChildView(BTN_OK)->setEnabled(enabled);
-
- enabled = enabled && getChild<LLScrollListCtrl>(LIST_RESULTS)->getNumSelected() == 1;
- getChildView(BTN_PROFILE)->setEnabled(enabled);
-}
-
-void LLPanelExperiencePicker::find()
-{
- std::string text = getChild<LLUICtrl>(TEXT_EDIT)->getValue().asString();
- mQueryID.generate();
-
- LLExperienceCache::instance().findExperienceByName(text, mCurrentPage,
- boost::bind(&LLPanelExperiencePicker::findResults, getDerivedHandle<LLPanelExperiencePicker>(), mQueryID, _1));
-
- getChild<LLScrollListCtrl>(LIST_RESULTS)->deleteAllItems();
- getChild<LLScrollListCtrl>(LIST_RESULTS)->setCommentText(getString("searching"));
-
- getChildView(BTN_OK)->setEnabled(false);
- getChildView(BTN_PROFILE)->setEnabled(false);
-
- getChildView(BTN_RIGHT)->setEnabled(false);
- getChildView(BTN_LEFT)->setEnabled(false);
-}
-
-/*static*/
-void LLPanelExperiencePicker::findResults(LLHandle<LLPanelExperiencePicker> hparent, LLUUID queryId, LLSD foundResult)
-{
- if (hparent.isDead())
- return;
-
- LLPanelExperiencePicker* panel = hparent.get();
- if (panel)
- {
- panel->processResponse(queryId, foundResult);
- }
-}
-
-bool LLPanelExperiencePicker::isSelectButtonEnabled()
-{
- LLScrollListCtrl* list=getChild<LLScrollListCtrl>(LIST_RESULTS);
- return list->getFirstSelectedIndex() >=0;
-}
-
-void LLPanelExperiencePicker::getSelectedExperienceIds( const LLScrollListCtrl* results, uuid_vec_t &experience_ids )
-{
- std::vector<LLScrollListItem*> items = results->getAllSelected();
- for(std::vector<LLScrollListItem*>::iterator it = items.begin(); it != items.end(); ++it)
- {
- LLScrollListItem* item = *it;
- if (item->getUUID().notNull())
- {
- experience_ids.push_back(item->getUUID());
- }
- }
-}
-
-void LLPanelExperiencePicker::setAllowMultiple( bool allow_multiple )
-{
- getChild<LLScrollListCtrl>(LIST_RESULTS)->setAllowMultipleSelection(allow_multiple);
-}
-
-
-void name_callback(const LLHandle<LLPanelExperiencePicker>& floater, const LLUUID& experience_id, const LLUUID& agent_id, const LLAvatarName& av_name)
-{
- if(floater.isDead())
- return;
- LLPanelExperiencePicker* picker = floater.get();
- LLScrollListCtrl* search_results = picker->getChild<LLScrollListCtrl>(LIST_RESULTS);
-
- LLScrollListItem* item = search_results->getItem(experience_id);
- if(!item)
- return;
-
- item->getColumn(2)->setValue(columnSpace+av_name.getDisplayName());
-
-}
-
-void LLPanelExperiencePicker::processResponse( const LLUUID& query_id, const LLSD& content )
-{
- if(query_id != mQueryID)
- {
- return;
- }
-
- mResponse = content;
-
- getChildView(BTN_RIGHT)->setEnabled(content.has("next_page_url"));
- getChildView(BTN_LEFT)->setEnabled(content.has("previous_page_url"));
-
- filterContent();
-
-}
-
-void LLPanelExperiencePicker::onBtnSelect()
-{
- if(!isSelectButtonEnabled())
- {
- return;
- }
-
- if(mSelectionCallback)
- {
- const LLScrollListCtrl* results = getChild<LLScrollListCtrl>(LIST_RESULTS);
- uuid_vec_t experience_ids;
-
- getSelectedExperienceIds(results, experience_ids);
- mSelectionCallback(experience_ids);
- getChild<LLScrollListCtrl>(LIST_RESULTS)->deselectAllItems(true);
- if(mCloseOnSelect)
- {
- mCloseOnSelect = false;
- onBtnClose();
- }
- }
- else
- {
- onBtnProfile();
- }
-}
-
-void LLPanelExperiencePicker::onBtnClose()
-{
- LLFloater* floater = getParentByType<LLFloater>();
- if (floater)
- {
- floater->closeFloater();
- }
-}
-
-void LLPanelExperiencePicker::onBtnProfile()
-{
- LLScrollListItem* item = getChild<LLScrollListCtrl>(LIST_RESULTS)->getFirstSelected();
- if(item)
- {
- LLFloaterReg::showInstance("experience_profile", item->getUUID(), true);
- }
-}
-
-std::string LLPanelExperiencePicker::getMaturityString(int maturity)
-{
- if(maturity <= SIM_ACCESS_PG)
- {
- return getString("maturity_icon_general");
- }
- else if(maturity <= SIM_ACCESS_MATURE)
- {
- return getString("maturity_icon_moderate");
- }
- return getString("maturity_icon_adult");
-}
-
-void LLPanelExperiencePicker::filterContent()
-{
- LLScrollListCtrl* search_results = getChild<LLScrollListCtrl>(LIST_RESULTS);
-
- const LLSD& experiences=mResponse["experience_keys"];
-
- search_results->deleteAllItems();
-
- LLSD item;
- LLSD::array_const_iterator it = experiences.beginArray();
- for ( ; it != experiences.endArray(); ++it)
- {
- const LLSD& experience = *it;
-
- if(isExperienceHidden(experience))
- continue;
-
- std::string experience_name_string = experience[LLExperienceCache::NAME].asString();
- if (experience_name_string.empty())
- {
- experience_name_string = LLTrans::getString("ExperienceNameUntitled");
- }
-
- item["id"]=experience[LLExperienceCache::EXPERIENCE_ID];
- LLSD& columns = item["columns"];
- columns[0]["column"] = "maturity";
- columns[0]["value"] = getMaturityString(experience[LLExperienceCache::MATURITY].asInteger());
- columns[0]["type"]="icon";
- columns[0]["halign"]="right";
- columns[1]["column"] = "experience_name";
- columns[1]["value"] = columnSpace+experience_name_string;
- columns[2]["column"] = "owner";
- columns[2]["value"] = columnSpace+getString("loading");
- search_results->addElement(item);
- LLAvatarNameCache::get(experience[LLExperienceCache::AGENT_ID], boost::bind(name_callback, getDerivedHandle<LLPanelExperiencePicker>(), experience[LLExperienceCache::EXPERIENCE_ID], _1, _2));
- }
-
- if (search_results->isEmpty())
- {
- LLStringUtil::format_map_t map;
- std::string search_text = getChild<LLUICtrl>(TEXT_EDIT)->getValue().asString();
- map["[TEXT]"] = search_text;
- if (search_text.empty())
- {
- getChild<LLScrollListCtrl>(LIST_RESULTS)->setCommentText(getString("no_results"));
- }
- else
- {
- getChild<LLScrollListCtrl>(LIST_RESULTS)->setCommentText(getString("not_found", map));
- }
- search_results->setEnabled(false);
- getChildView(BTN_OK)->setEnabled(false);
- getChildView(BTN_PROFILE)->setEnabled(false);
- }
- else
- {
- getChildView(BTN_OK)->setEnabled(true);
- search_results->setEnabled(true);
- search_results->sortByColumnIndex(1, true);
- std::string text = getChild<LLUICtrl>(TEXT_EDIT)->getValue().asString();
- if (!search_results->selectItemByLabel(text, true, 1))
- {
- search_results->selectFirstItem();
- }
- onList();
- search_results->setFocus(true);
- }
-}
-
-void LLPanelExperiencePicker::onMaturity()
-{
- gSavedPerAccountSettings.setU32("ExperienceSearchMaturity", getChild<LLComboBox>(TEXT_MATURITY)->getCurrentIndex());
- if(mResponse.has("experience_keys") && mResponse["experience_keys"].beginArray() != mResponse["experience_keys"].endArray())
- {
- filterContent();
- }
-}
-
-bool LLPanelExperiencePicker::isExperienceHidden( const LLSD& experience) const
-{
- bool hide=false;
- filter_list::const_iterator it = mFilters.begin();
- for(/**/;it != mFilters.end(); ++it)
- {
- if((*it)(experience)){
- return true;
- }
- }
-
- return hide;
-}
-
-bool LLPanelExperiencePicker::FilterOverRating( const LLSD& experience )
-{
- int maturity = getChild<LLComboBox>(TEXT_MATURITY)->getSelectedValue().asInteger();
- return experience[LLExperienceCache::MATURITY].asInteger() > maturity;
-}
-
-bool LLPanelExperiencePicker::FilterWithProperty( const LLSD& experience, S32 prop)
-{
- return (experience[LLExperienceCache::PROPERTIES].asInteger() & prop) != 0;
-}
-
-bool LLPanelExperiencePicker::FilterWithoutProperties( const LLSD& experience, S32 prop)
-{
- return ((experience[LLExperienceCache::PROPERTIES].asInteger() & prop) == prop);
-}
-
-bool LLPanelExperiencePicker::FilterWithoutProperty( const LLSD& experience, S32 prop )
-{
- return (experience[LLExperienceCache::PROPERTIES].asInteger() & prop) == 0;
-}
-
-void LLPanelExperiencePicker::setDefaultFilters()
-{
- mFilters.clear();
- addFilter(boost::bind(&LLPanelExperiencePicker::FilterOverRating, this, _1));
-}
-
-bool LLPanelExperiencePicker::FilterMatching( const LLSD& experience, const LLUUID& id )
-{
- if(experience.isUUID())
- {
- return experience.asUUID() == id;
- }
- return experience[LLExperienceCache::EXPERIENCE_ID].asUUID() == id;
-}
-
-void LLPanelExperiencePicker::onPage( S32 direction )
-{
- mCurrentPage += direction;
- if(mCurrentPage < 1)
- {
- mCurrentPage = 1;
- }
- find();
-}
+/**
+* @file llpanelexperiencepicker.cpp
+* @brief Implementation of llpanelexperiencepicker
+* @author dolphin@lindenlab.com
+*
+* $LicenseInfo:firstyear=2014&license=viewerlgpl$
+* Second Life Viewer Source Code
+* Copyright (C) 2014, Linden Research, Inc.
+*
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU Lesser General Public
+* License as published by the Free Software Foundation;
+* version 2.1 of the License only.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this library; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*
+* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
+* $/LicenseInfo$
+*/
+
+#include "llviewerprecompiledheaders.h"
+
+#include "llpanelexperiencepicker.h"
+
+
+#include "lllineeditor.h"
+#include "llfloaterreg.h"
+#include "llscrolllistctrl.h"
+#include "llviewerregion.h"
+#include "llagent.h"
+#include "llexperiencecache.h"
+#include "llslurl.h"
+#include "llavatarnamecache.h"
+#include "llcombobox.h"
+#include "llviewercontrol.h"
+#include "llfloater.h"
+#include "llregex.h"
+#include "lltrans.h"
+
+#define BTN_FIND "find"
+#define BTN_OK "ok_btn"
+#define BTN_CANCEL "cancel_btn"
+#define BTN_PROFILE "profile_btn"
+#define BTN_LEFT "left_btn"
+#define BTN_RIGHT "right_btn"
+#define TEXT_EDIT "edit"
+#define TEXT_MATURITY "maturity"
+#define LIST_RESULTS "search_results"
+#define PANEL_SEARCH "search_panel"
+
+const static std::string columnSpace = " ";
+
+static LLPanelInjector<LLPanelExperiencePicker> t_panel_status("llpanelexperiencepicker");
+
+LLPanelExperiencePicker::LLPanelExperiencePicker()
+ :LLPanel()
+{
+ buildFromFile("panel_experience_search.xml");
+ setDefaultFilters();
+}
+
+LLPanelExperiencePicker::~LLPanelExperiencePicker()
+{
+}
+
+bool LLPanelExperiencePicker::postBuild()
+{
+ getChild<LLLineEditor>(TEXT_EDIT)->setKeystrokeCallback( boost::bind(&LLPanelExperiencePicker::editKeystroke, this, _1, _2),NULL);
+
+ childSetAction(BTN_FIND, boost::bind(&LLPanelExperiencePicker::onBtnFind, this));
+ getChildView(BTN_FIND)->setEnabled(true);
+
+ LLScrollListCtrl* searchresults = getChild<LLScrollListCtrl>(LIST_RESULTS);
+ searchresults->setDoubleClickCallback( boost::bind(&LLPanelExperiencePicker::onBtnSelect, this));
+ searchresults->setCommitCallback(boost::bind(&LLPanelExperiencePicker::onList, this));
+ getChildView(LIST_RESULTS)->setEnabled(false);
+ getChild<LLScrollListCtrl>(LIST_RESULTS)->setCommentText(getString("no_results"));
+
+ childSetAction(BTN_OK, boost::bind(&LLPanelExperiencePicker::onBtnSelect, this));
+ getChildView(BTN_OK)->setEnabled(false);
+ childSetAction(BTN_CANCEL, boost::bind(&LLPanelExperiencePicker::onBtnClose, this));
+ childSetAction(BTN_PROFILE, boost::bind(&LLPanelExperiencePicker::onBtnProfile, this));
+ getChildView(BTN_PROFILE)->setEnabled(false);
+
+ getChild<LLComboBox>(TEXT_MATURITY)->setCurrentByIndex(gSavedPerAccountSettings.getU32("ExperienceSearchMaturity"));
+ getChild<LLComboBox>(TEXT_MATURITY)->setCommitCallback(boost::bind(&LLPanelExperiencePicker::onMaturity, this));
+ getChild<LLUICtrl>(TEXT_EDIT)->setFocus(true);
+
+ childSetAction(BTN_LEFT, boost::bind(&LLPanelExperiencePicker::onPage, this, -1));
+ childSetAction(BTN_RIGHT, boost::bind(&LLPanelExperiencePicker::onPage, this, 1));
+
+ LLPanel* search_panel = getChild<LLPanel>(PANEL_SEARCH);
+ if (search_panel)
+ {
+ // Start searching when Return is pressed in the line editor.
+ search_panel->setDefaultBtn(BTN_FIND);
+ }
+ return true;
+}
+
+void LLPanelExperiencePicker::editKeystroke( class LLLineEditor* caller, void* user_data )
+{
+ getChildView(BTN_FIND)->setEnabled(true);
+}
+
+void LLPanelExperiencePicker::onBtnFind()
+{
+ mCurrentPage=1;
+ boost::cmatch what;
+ std::string text = getChild<LLUICtrl>(TEXT_EDIT)->getValue().asString();
+ const boost::regex expression("secondlife:///app/experience/[\\da-f-]+/profile");
+ if (ll_regex_match(text.c_str(), what, expression))
+ {
+ LLURI uri(text);
+ LLSD path_array = uri.pathArray();
+ if (path_array.size() == 4)
+ {
+ std::string exp_id = path_array.get(2).asString();
+ LLUUID experience_id(exp_id);
+ if (!experience_id.isNull())
+ {
+ const LLSD& experience_details = LLExperienceCache::instance().get(experience_id);
+ if(!experience_details.isUndefined())
+ {
+ std::string experience_name_string = experience_details[LLExperienceCache::NAME].asString();
+ if(!experience_name_string.empty())
+ {
+ getChild<LLUICtrl>(TEXT_EDIT)->setValue(experience_name_string);
+ }
+ }
+ else
+ {
+ getChild<LLScrollListCtrl>(LIST_RESULTS)->deleteAllItems();
+ getChild<LLScrollListCtrl>(LIST_RESULTS)->setCommentText(getString("searching"));
+
+ getChildView(BTN_OK)->setEnabled(false);
+ getChildView(BTN_PROFILE)->setEnabled(false);
+
+ getChildView(BTN_RIGHT)->setEnabled(false);
+ getChildView(BTN_LEFT)->setEnabled(false);
+ LLExperienceCache::instance().get(experience_id, boost::bind(&LLPanelExperiencePicker::onBtnFind, this));
+ return;
+ }
+ }
+ }
+ }
+
+
+ find();
+}
+
+void LLPanelExperiencePicker::onList()
+{
+ bool enabled = isSelectButtonEnabled();
+ getChildView(BTN_OK)->setEnabled(enabled);
+
+ enabled = enabled && getChild<LLScrollListCtrl>(LIST_RESULTS)->getNumSelected() == 1;
+ getChildView(BTN_PROFILE)->setEnabled(enabled);
+}
+
+void LLPanelExperiencePicker::find()
+{
+ std::string text = getChild<LLUICtrl>(TEXT_EDIT)->getValue().asString();
+ mQueryID.generate();
+
+ LLExperienceCache::instance().findExperienceByName(text, mCurrentPage,
+ boost::bind(&LLPanelExperiencePicker::findResults, getDerivedHandle<LLPanelExperiencePicker>(), mQueryID, _1));
+
+ getChild<LLScrollListCtrl>(LIST_RESULTS)->deleteAllItems();
+ getChild<LLScrollListCtrl>(LIST_RESULTS)->setCommentText(getString("searching"));
+
+ getChildView(BTN_OK)->setEnabled(false);
+ getChildView(BTN_PROFILE)->setEnabled(false);
+
+ getChildView(BTN_RIGHT)->setEnabled(false);
+ getChildView(BTN_LEFT)->setEnabled(false);
+}
+
+/*static*/
+void LLPanelExperiencePicker::findResults(LLHandle<LLPanelExperiencePicker> hparent, LLUUID queryId, LLSD foundResult)
+{
+ if (hparent.isDead())
+ return;
+
+ LLPanelExperiencePicker* panel = hparent.get();
+ if (panel)
+ {
+ panel->processResponse(queryId, foundResult);
+ }
+}
+
+bool LLPanelExperiencePicker::isSelectButtonEnabled()
+{
+ LLScrollListCtrl* list=getChild<LLScrollListCtrl>(LIST_RESULTS);
+ return list->getFirstSelectedIndex() >=0;
+}
+
+void LLPanelExperiencePicker::getSelectedExperienceIds( const LLScrollListCtrl* results, uuid_vec_t &experience_ids )
+{
+ std::vector<LLScrollListItem*> items = results->getAllSelected();
+ for(std::vector<LLScrollListItem*>::iterator it = items.begin(); it != items.end(); ++it)
+ {
+ LLScrollListItem* item = *it;
+ if (item->getUUID().notNull())
+ {
+ experience_ids.push_back(item->getUUID());
+ }
+ }
+}
+
+void LLPanelExperiencePicker::setAllowMultiple( bool allow_multiple )
+{
+ getChild<LLScrollListCtrl>(LIST_RESULTS)->setAllowMultipleSelection(allow_multiple);
+}
+
+
+void name_callback(const LLHandle<LLPanelExperiencePicker>& floater, const LLUUID& experience_id, const LLUUID& agent_id, const LLAvatarName& av_name)
+{
+ if(floater.isDead())
+ return;
+ LLPanelExperiencePicker* picker = floater.get();
+ LLScrollListCtrl* search_results = picker->getChild<LLScrollListCtrl>(LIST_RESULTS);
+
+ LLScrollListItem* item = search_results->getItem(experience_id);
+ if(!item)
+ return;
+
+ item->getColumn(2)->setValue(columnSpace+av_name.getDisplayName());
+
+}
+
+void LLPanelExperiencePicker::processResponse( const LLUUID& query_id, const LLSD& content )
+{
+ if(query_id != mQueryID)
+ {
+ return;
+ }
+
+ mResponse = content;
+
+ getChildView(BTN_RIGHT)->setEnabled(content.has("next_page_url"));
+ getChildView(BTN_LEFT)->setEnabled(content.has("previous_page_url"));
+
+ filterContent();
+
+}
+
+void LLPanelExperiencePicker::onBtnSelect()
+{
+ if(!isSelectButtonEnabled())
+ {
+ return;
+ }
+
+ if(mSelectionCallback)
+ {
+ const LLScrollListCtrl* results = getChild<LLScrollListCtrl>(LIST_RESULTS);
+ uuid_vec_t experience_ids;
+
+ getSelectedExperienceIds(results, experience_ids);
+ mSelectionCallback(experience_ids);
+ getChild<LLScrollListCtrl>(LIST_RESULTS)->deselectAllItems(true);
+ if(mCloseOnSelect)
+ {
+ mCloseOnSelect = false;
+ onBtnClose();
+ }
+ }
+ else
+ {
+ onBtnProfile();
+ }
+}
+
+void LLPanelExperiencePicker::onBtnClose()
+{
+ LLFloater* floater = getParentByType<LLFloater>();
+ if (floater)
+ {
+ floater->closeFloater();
+ }
+}
+
+void LLPanelExperiencePicker::onBtnProfile()
+{
+ LLScrollListItem* item = getChild<LLScrollListCtrl>(LIST_RESULTS)->getFirstSelected();
+ if(item)
+ {
+ LLFloaterReg::showInstance("experience_profile", item->getUUID(), true);
+ }
+}
+
+std::string LLPanelExperiencePicker::getMaturityString(int maturity)
+{
+ if(maturity <= SIM_ACCESS_PG)
+ {
+ return getString("maturity_icon_general");
+ }
+ else if(maturity <= SIM_ACCESS_MATURE)
+ {
+ return getString("maturity_icon_moderate");
+ }
+ return getString("maturity_icon_adult");
+}
+
+void LLPanelExperiencePicker::filterContent()
+{
+ LLScrollListCtrl* search_results = getChild<LLScrollListCtrl>(LIST_RESULTS);
+
+ const LLSD& experiences=mResponse["experience_keys"];
+
+ search_results->deleteAllItems();
+
+ LLSD item;
+ LLSD::array_const_iterator it = experiences.beginArray();
+ for ( ; it != experiences.endArray(); ++it)
+ {
+ const LLSD& experience = *it;
+
+ if(isExperienceHidden(experience))
+ continue;
+
+ std::string experience_name_string = experience[LLExperienceCache::NAME].asString();
+ if (experience_name_string.empty())
+ {
+ experience_name_string = LLTrans::getString("ExperienceNameUntitled");
+ }
+
+ item["id"]=experience[LLExperienceCache::EXPERIENCE_ID];
+ LLSD& columns = item["columns"];
+ columns[0]["column"] = "maturity";
+ columns[0]["value"] = getMaturityString(experience[LLExperienceCache::MATURITY].asInteger());
+ columns[0]["type"]="icon";
+ columns[0]["halign"]="right";
+ columns[1]["column"] = "experience_name";
+ columns[1]["value"] = columnSpace+experience_name_string;
+ columns[2]["column"] = "owner";
+ columns[2]["value"] = columnSpace+getString("loading");
+ search_results->addElement(item);
+ LLAvatarNameCache::get(experience[LLExperienceCache::AGENT_ID], boost::bind(name_callback, getDerivedHandle<LLPanelExperiencePicker>(), experience[LLExperienceCache::EXPERIENCE_ID], _1, _2));
+ }
+
+ if (search_results->isEmpty())
+ {
+ LLStringUtil::format_map_t map;
+ std::string search_text = getChild<LLUICtrl>(TEXT_EDIT)->getValue().asString();
+ map["[TEXT]"] = search_text;
+ if (search_text.empty())
+ {
+ getChild<LLScrollListCtrl>(LIST_RESULTS)->setCommentText(getString("no_results"));
+ }
+ else
+ {
+ getChild<LLScrollListCtrl>(LIST_RESULTS)->setCommentText(getString("not_found", map));
+ }
+ search_results->setEnabled(false);
+ getChildView(BTN_OK)->setEnabled(false);
+ getChildView(BTN_PROFILE)->setEnabled(false);
+ }
+ else
+ {
+ getChildView(BTN_OK)->setEnabled(true);
+ search_results->setEnabled(true);
+ search_results->sortByColumnIndex(1, true);
+ std::string text = getChild<LLUICtrl>(TEXT_EDIT)->getValue().asString();
+ if (!search_results->selectItemByLabel(text, true, 1))
+ {
+ search_results->selectFirstItem();
+ }
+ onList();
+ search_results->setFocus(true);
+ }
+}
+
+void LLPanelExperiencePicker::onMaturity()
+{
+ gSavedPerAccountSettings.setU32("ExperienceSearchMaturity", getChild<LLComboBox>(TEXT_MATURITY)->getCurrentIndex());
+ if(mResponse.has("experience_keys") && mResponse["experience_keys"].beginArray() != mResponse["experience_keys"].endArray())
+ {
+ filterContent();
+ }
+}
+
+bool LLPanelExperiencePicker::isExperienceHidden( const LLSD& experience) const
+{
+ bool hide=false;
+ filter_list::const_iterator it = mFilters.begin();
+ for(/**/;it != mFilters.end(); ++it)
+ {
+ if((*it)(experience)){
+ return true;
+ }
+ }
+
+ return hide;
+}
+
+bool LLPanelExperiencePicker::FilterOverRating( const LLSD& experience )
+{
+ int maturity = getChild<LLComboBox>(TEXT_MATURITY)->getSelectedValue().asInteger();
+ return experience[LLExperienceCache::MATURITY].asInteger() > maturity;
+}
+
+bool LLPanelExperiencePicker::FilterWithProperty( const LLSD& experience, S32 prop)
+{
+ return (experience[LLExperienceCache::PROPERTIES].asInteger() & prop) != 0;
+}
+
+bool LLPanelExperiencePicker::FilterWithoutProperties( const LLSD& experience, S32 prop)
+{
+ return ((experience[LLExperienceCache::PROPERTIES].asInteger() & prop) == prop);
+}
+
+bool LLPanelExperiencePicker::FilterWithoutProperty( const LLSD& experience, S32 prop )
+{
+ return (experience[LLExperienceCache::PROPERTIES].asInteger() & prop) == 0;
+}
+
+void LLPanelExperiencePicker::setDefaultFilters()
+{
+ mFilters.clear();
+ addFilter(boost::bind(&LLPanelExperiencePicker::FilterOverRating, this, _1));
+}
+
+bool LLPanelExperiencePicker::FilterMatching( const LLSD& experience, const LLUUID& id )
+{
+ if(experience.isUUID())
+ {
+ return experience.asUUID() == id;
+ }
+ return experience[LLExperienceCache::EXPERIENCE_ID].asUUID() == id;
+}
+
+void LLPanelExperiencePicker::onPage( S32 direction )
+{
+ mCurrentPage += direction;
+ if(mCurrentPage < 1)
+ {
+ mCurrentPage = 1;
+ }
+ find();
+}