diff options
Diffstat (limited to 'indra/newview/llpanelpicks.cpp')
-rw-r--r-- | indra/newview/llpanelpicks.cpp | 1245 |
1 files changed, 1016 insertions, 229 deletions
diff --git a/indra/newview/llpanelpicks.cpp b/indra/newview/llpanelpicks.cpp index 1a3aa8a33a..27787ac211 100644 --- a/indra/newview/llpanelpicks.cpp +++ b/indra/newview/llpanelpicks.cpp @@ -2,71 +2,198 @@ * @file llpanelpicks.cpp * @brief LLPanelPicks and related class implementations * - * $LicenseInfo:firstyear=2009&license=viewergpl$ - * - * Copyright (c) 2004-2009, Linden Research, Inc. - * + * $LicenseInfo:firstyear=2009&license=viewerlgpl$ * Second Life Viewer Source Code - * The source code in this file ("Source Code") is provided by Linden Lab - * to you under the terms of the GNU General Public License, version 2.0 - * ("GPL"), unless you have obtained a separate licensing agreement - * ("Other License"), formally executed by you and Linden Lab. Terms of - * the GPL can be found in doc/GPL-license.txt in this distribution, or - * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * Copyright (C) 2010, Linden Research, Inc. * - * There are special exceptions to the terms and conditions of the GPL as - * it is applied to this Source Code. View the full text of the exception - * in the file doc/FLOSS-exception.txt in this software distribution, or - * online at - * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * 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. * - * By copying, modifying or distributing this software, you acknowledge - * that you have read and understood your obligations described above, - * and agree to abide by those obligations. + * 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. * - * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO - * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, - * COMPLETENESS OR PERFORMANCE. + * 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 "llpanelpicks.h" + #include "llagent.h" +#include "llagentpicksinfo.h" #include "llavatarconstants.h" +#include "llcommandhandler.h" +#include "lldispatcher.h" +#include "llflatlistview.h" +#include "llfloaterreg.h" +#include "llfloaterworldmap.h" +#include "llnotificationsutil.h" #include "lltexturectrl.h" +#include "lltoggleablemenu.h" +#include "lltrans.h" #include "llviewergenericmessage.h" // send_generic_message -#include "llworldmap.h" -#include "llfloaterworldmap.h" -#include "llpanelmeprofile.h" -#include "llfloaterreg.h" -#include "llpanelpicks.h" +#include "llmenugl.h" +#include "llviewermenu.h" +#include "llregistry.h" + +#include "llaccordionctrl.h" +#include "llaccordionctrltab.h" #include "llavatarpropertiesprocessor.h" +#include "llpanelavatar.h" +#include "llpanelprofile.h" #include "llpanelpick.h" +#include "llpanelclassified.h" +#include "llsidetray.h" + +static const std::string XML_BTN_NEW = "new_btn"; +static const std::string XML_BTN_DELETE = "trash_btn"; +static const std::string XML_BTN_INFO = "info_btn"; +static const std::string XML_BTN_TELEPORT = "teleport_btn"; +static const std::string XML_BTN_SHOW_ON_MAP = "show_on_map_btn"; + +static const std::string PICK_ID("pick_id"); +static const std::string PICK_CREATOR_ID("pick_creator_id"); +static const std::string PICK_NAME("pick_name"); + +static const std::string CLASSIFIED_ID("classified_id"); +static const std::string CLASSIFIED_NAME("classified_name"); + + +static LLRegisterPanelClassWrapper<LLPanelPicks> t_panel_picks("panel_picks"); + +class LLClassifiedHandler : + public LLCommandHandler, + public LLAvatarPropertiesObserver +{ +public: + // throttle calls from untrusted browsers + LLClassifiedHandler() : LLCommandHandler("classified", UNTRUSTED_THROTTLE) {} + + std::set<LLUUID> mClassifiedIds; + + bool handle(const LLSD& params, const LLSD& query_map, LLMediaCtrl* web) + { + // handle app/classified/create urls first + if (params.size() == 1 && params[0].asString() == "create") + { + createClassified(); + return true; + } + + // then handle the general app/classified/{UUID}/{CMD} urls + if (params.size() < 2) + { + return false; + } + + // get the ID for the classified + LLUUID classified_id; + if (!classified_id.set(params[0], FALSE)) + { + return false; + } + + // show the classified in the side tray. + // need to ask the server for more info first though... + const std::string verb = params[1].asString(); + if (verb == "about") + { + mClassifiedIds.insert(classified_id); + LLAvatarPropertiesProcessor::getInstance()->addObserver(LLUUID(), this); + LLAvatarPropertiesProcessor::getInstance()->sendClassifiedInfoRequest(classified_id); + return true; + } + + return false; + } + + void createClassified() + { + // open the new classified panel on the Me > Picks sidetray + LLSD params; + params["id"] = gAgent.getID(); + params["open_tab_name"] = "panel_picks"; + params["show_tab_panel"] = "create_classified"; + LLSideTray::getInstance()->showPanel("panel_me", params); + } + + void openClassified(LLAvatarClassifiedInfo* c_info) + { + // open the classified info panel on the Me > Picks sidetray + LLSD params; + params["id"] = c_info->creator_id; + params["open_tab_name"] = "panel_picks"; + params["show_tab_panel"] = "classified_details"; + params["classified_id"] = c_info->classified_id; + params["classified_creator_id"] = c_info->creator_id; + params["classified_snapshot_id"] = c_info->snapshot_id; + params["classified_name"] = c_info->name; + params["classified_desc"] = c_info->description; + params["from_search"] = true; + LLSideTray::getInstance()->showPanel("panel_profile_view", params); + } + + /*virtual*/ void processProperties(void* data, EAvatarProcessorType type) + { + if (APT_CLASSIFIED_INFO != type) + { + return; + } + + // is this the classified that we asked for? + LLAvatarClassifiedInfo* c_info = static_cast<LLAvatarClassifiedInfo*>(data); + if (!c_info || mClassifiedIds.find(c_info->classified_id) == mClassifiedIds.end()) + { + return; + } + + // open the detail side tray for this classified + openClassified(c_info); + + // remove our observer now that we're done + mClassifiedIds.erase(c_info->classified_id); + LLAvatarPropertiesProcessor::getInstance()->removeObserver(LLUUID(), this); + } + +}; +LLClassifiedHandler gClassifiedHandler; -#define XML_BTN_NEW "new_btn" -#define XML_BTN_DELETE "trash_btn" -#define XML_BTN_INFO "info_btn" +////////////////////////////////////////////////////////////////////////// //----------------------------------------------------------------------------- // LLPanelPicks //----------------------------------------------------------------------------- -LLPanelPicks::LLPanelPicks(const LLUUID& avatar_id /* = LLUUID::null */) -:LLPanelProfileTab(avatar_id), mMeProfilePanel(NULL) +LLPanelPicks::LLPanelPicks() +: LLPanelProfileTab(), + mPopupMenu(NULL), + mProfilePanel(NULL), + mPickPanel(NULL), + mPicksList(NULL), + mClassifiedsList(NULL), + mPanelPickInfo(NULL), + mPanelPickEdit(NULL), + mPlusMenu(NULL), + mPicksAccTab(NULL), + mClassifiedsAccTab(NULL), + mPanelClassifiedInfo(NULL), + mNoClassifieds(false), + mNoPicks(false) { - updateData(); -} - -LLPanelPicks::LLPanelPicks(const Params& params) -:LLPanelProfileTab(params), mMeProfilePanel(NULL) -{ - } LLPanelPicks::~LLPanelPicks() { - if(!getAvatarId().isNull()) + if(getAvatarId().notNull()) { LLAvatarPropertiesProcessor::getInstance()->removeObserver(getAvatarId(),this); } @@ -74,18 +201,25 @@ LLPanelPicks::~LLPanelPicks() void* LLPanelPicks::create(void* data /* = NULL */) { - LLSD* id = NULL; - if(data) - { - id = static_cast<LLSD*>(data); - return new LLPanelPicks(LLUUID(id->asUUID())); - } return new LLPanelPicks(); } void LLPanelPicks::updateData() { - LLAvatarPropertiesProcessor::getInstance()->sendDataRequest(getAvatarId(),APT_PICKS); + // Send Picks request only when we need to, not on every onOpen(during tab switch). + if(isDirty()) + { + mNoPicks = false; + mNoClassifieds = false; + + getChild<LLUICtrl>("picks_panel_text")->setValue(LLTrans::getString("PicksClassifiedsLoadingText")); + + mPicksList->clear(); + LLAvatarPropertiesProcessor::getInstance()->sendAvatarPicksRequest(getAvatarId()); + + mClassifiedsList->clear(); + LLAvatarPropertiesProcessor::getInstance()->sendAvatarClassifiedsRequest(getAvatarId()); + } } void LLPanelPicks::processProperties(void* data, EAvatarProcessorType type) @@ -97,23 +231,12 @@ void LLPanelPicks::processProperties(void* data, EAvatarProcessorType type) { std::string name, second_name; gCacheName->getName(getAvatarId(),name,second_name); - childSetTextArg("pick_title", "[NAME]",name); - - LLView* picks_list = getChild<LLView>("back_panel",TRUE,FALSE); - if(!picks_list) return; - clear(); - - //*TODO move it somewhere else? - picks_list->setEnabled(FALSE); - childSetEnabled(XML_BTN_NEW, false); - childSetEnabled(XML_BTN_DELETE, false); - childSetEnabled(XML_BTN_INFO, false); - - S32 height = avatar_picks->picks_list.size() * 85; - LLRect rc = picks_list->getRect(); - rc.setLeftTopAndSize(rc.mLeft,rc.mTop,rc.getWidth(),height); - picks_list->setRect(rc); - picks_list->reshape(rc.getWidth(),rc.getHeight()); + getChild<LLUICtrl>("pick_title")->setTextArg("[NAME]", name); + + // Save selection, to be able to edit same item after saving changes. See EXT-3023. + LLUUID selected_id = mPicksList->getSelectedValue()[PICK_ID]; + + mPicksList->clear(); LLAvatarPicks::picks_list_t::const_iterator it = avatar_picks->picks_list.begin(); for(; avatar_picks->picks_list.end() != it; ++it) @@ -122,249 +245,806 @@ void LLPanelPicks::processProperties(void* data, EAvatarProcessorType type) std::string pick_name = it->second; LLPickItem* picture = LLPickItem::create(); - picks_list->addChild(picture); - - picture->setPictureName(pick_name); - picture->setPictureId(pick_id); + picture->childSetAction("info_chevron", boost::bind(&LLPanelPicks::onClickInfo, this)); + picture->setPickName(pick_name); + picture->setPickId(pick_id); picture->setCreatorId(getAvatarId()); - S32 last_bottom = picks_list->getRect().getHeight(); - if(mPickItemList.size() > 0) - { - last_bottom = mPickItemList[mPickItemList.size()-1]->getRect().mBottom; - last_bottom -= 5; - } - LLRect rc = picture->getRect(); - rc.mBottom = last_bottom - rc.getHeight(); - rc.mTop = last_bottom; - picture->reshape(rc.getWidth(),rc.getHeight()); - picture->setRect(rc); - - - LLAvatarPropertiesProcessor::instance().addObserver(mAvatarId, picture); + LLAvatarPropertiesProcessor::instance().addObserver(getAvatarId(), picture); picture->update(); - mPickItemList.push_back(picture); + + LLSD pick_value = LLSD(); + pick_value.insert(PICK_ID, pick_id); + pick_value.insert(PICK_NAME, pick_name); + pick_value.insert(PICK_CREATOR_ID, getAvatarId()); + + mPicksList->addItem(picture, pick_value); + + // Restore selection by item id. + if ( pick_id == selected_id ) + mPicksList->selectItemByValue(pick_value); + + picture->setDoubleClickCallback(boost::bind(&LLPanelPicks::onDoubleClickPickItem, this, _1)); + picture->setRightMouseUpCallback(boost::bind(&LLPanelPicks::onRightMouseUpItem, this, _1, _2, _3, _4)); + picture->setMouseUpCallback(boost::bind(&LLPanelPicks::updateButtons, this)); } - LLAvatarPropertiesProcessor::getInstance()->removeObserver(getAvatarId(),this); + showAccordion("tab_picks", mPicksList->size()); + + resetDirty(); updateButtons(); - picks_list->setEnabled(TRUE); + } + + mNoPicks = !mPicksList->size(); + } + else if(APT_CLASSIFIEDS == type) + { + LLAvatarClassifieds* c_info = static_cast<LLAvatarClassifieds*>(data); + if(c_info && getAvatarId() == c_info->target_id) + { + // do not clear classified list in case we will receive two or more data packets. + // list has been cleared in updateData(). (fix for EXT-6436) + + LLAvatarClassifieds::classifieds_list_t::const_iterator it = c_info->classifieds_list.begin(); + for(; c_info->classifieds_list.end() != it; ++it) + { + LLAvatarClassifieds::classified_data c_data = *it; + + LLClassifiedItem* c_item = new LLClassifiedItem(getAvatarId(), c_data.classified_id); + c_item->childSetAction("info_chevron", boost::bind(&LLPanelPicks::onClickInfo, this)); + c_item->setClassifiedName(c_data.name); + LLSD pick_value = LLSD(); + pick_value.insert(CLASSIFIED_ID, c_data.classified_id); + pick_value.insert(CLASSIFIED_NAME, c_data.name); + + mClassifiedsList->addItem(c_item, pick_value); + + c_item->setDoubleClickCallback(boost::bind(&LLPanelPicks::onDoubleClickClassifiedItem, this, _1)); + c_item->setRightMouseUpCallback(boost::bind(&LLPanelPicks::onRightMouseUpItem, this, _1, _2, _3, _4)); + c_item->setMouseUpCallback(boost::bind(&LLPanelPicks::updateButtons, this)); + } + + showAccordion("tab_classifieds", mClassifiedsList->size()); + + resetDirty(); + updateButtons(); } + + mNoClassifieds = !mClassifiedsList->size(); } + + if (mNoPicks && mNoClassifieds) + { + if(getAvatarId() == gAgentID) + { + getChild<LLUICtrl>("picks_panel_text")->setValue(LLTrans::getString("NoPicksClassifiedsText")); + } + else + { + getChild<LLUICtrl>("picks_panel_text")->setValue(LLTrans::getString("NoAvatarPicksClassifiedsText")); + } + } +} + +LLPickItem* LLPanelPicks::getSelectedPickItem() +{ + LLPanel* selected_item = mPicksList->getSelectedItem(); + if (!selected_item) return NULL; + + return dynamic_cast<LLPickItem*>(selected_item); } -void LLPanelPicks::clear() +LLClassifiedItem* LLPanelPicks::getSelectedClassifiedItem() { - LLView* scroll = getChild<LLView>("back_panel",TRUE,FALSE); - if(scroll) + LLPanel* selected_item = mClassifiedsList->getSelectedItem(); + if (!selected_item) { - picture_list_t::const_iterator it = mPickItemList.begin(); - for(; mPickItemList.end() != it; ++it) + return NULL; + } + return dynamic_cast<LLClassifiedItem*>(selected_item); +} + +BOOL LLPanelPicks::postBuild() +{ + mPicksList = getChild<LLFlatListView>("picks_list"); + mClassifiedsList = getChild<LLFlatListView>("classifieds_list"); + + mPicksList->setCommitOnSelectionChange(true); + mClassifiedsList->setCommitOnSelectionChange(true); + + mPicksList->setCommitCallback(boost::bind(&LLPanelPicks::onListCommit, this, mPicksList)); + mClassifiedsList->setCommitCallback(boost::bind(&LLPanelPicks::onListCommit, this, mClassifiedsList)); + + mPicksList->setNoItemsCommentText(getString("no_picks")); + mClassifiedsList->setNoItemsCommentText(getString("no_classifieds")); + + childSetAction(XML_BTN_NEW, boost::bind(&LLPanelPicks::onClickPlusBtn, this)); + childSetAction(XML_BTN_DELETE, boost::bind(&LLPanelPicks::onClickDelete, this)); + childSetAction(XML_BTN_TELEPORT, boost::bind(&LLPanelPicks::onClickTeleport, this)); + childSetAction(XML_BTN_SHOW_ON_MAP, boost::bind(&LLPanelPicks::onClickMap, this)); + childSetAction(XML_BTN_INFO, boost::bind(&LLPanelPicks::onClickInfo, this)); + + mPicksAccTab = getChild<LLAccordionCtrlTab>("tab_picks"); + mPicksAccTab->setDropDownStateChangedCallback(boost::bind(&LLPanelPicks::onAccordionStateChanged, this, mPicksAccTab)); + mPicksAccTab->setDisplayChildren(true); + + mClassifiedsAccTab = getChild<LLAccordionCtrlTab>("tab_classifieds"); + mClassifiedsAccTab->setDropDownStateChangedCallback(boost::bind(&LLPanelPicks::onAccordionStateChanged, this, mClassifiedsAccTab)); + mClassifiedsAccTab->setDisplayChildren(false); + + LLUICtrl::CommitCallbackRegistry::ScopedRegistrar registar; + registar.add("Pick.Info", boost::bind(&LLPanelPicks::onClickInfo, this)); + registar.add("Pick.Edit", boost::bind(&LLPanelPicks::onClickMenuEdit, this)); + registar.add("Pick.Teleport", boost::bind(&LLPanelPicks::onClickTeleport, this)); + registar.add("Pick.Map", boost::bind(&LLPanelPicks::onClickMap, this)); + registar.add("Pick.Delete", boost::bind(&LLPanelPicks::onClickDelete, this)); + LLUICtrl::EnableCallbackRegistry::ScopedRegistrar enable_registar; + enable_registar.add("Pick.Enable", boost::bind(&LLPanelPicks::onEnableMenuItem, this, _2)); + + mPopupMenu = LLUICtrlFactory::getInstance()->createFromFile<LLContextMenu>("menu_picks.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance()); + + LLUICtrl::CommitCallbackRegistry::ScopedRegistrar plus_registar; + plus_registar.add("Picks.Plus.Action", boost::bind(&LLPanelPicks::onPlusMenuItemClicked, this, _2)); + mEnableCallbackRegistrar.add("Picks.Plus.Enable", boost::bind(&LLPanelPicks::isActionEnabled, this, _2)); + mPlusMenu = LLUICtrlFactory::getInstance()->createFromFile<LLToggleableMenu>("menu_picks_plus.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance()); + + return TRUE; +} + +void LLPanelPicks::onPlusMenuItemClicked(const LLSD& param) +{ + std::string value = param.asString(); + + if("new_pick" == value) + { + createNewPick(); + } + else if("new_classified" == value) + { + createNewClassified(); + } +} + +bool LLPanelPicks::isActionEnabled(const LLSD& userdata) const +{ + std::string command_name = userdata.asString(); + + if (command_name == "new_pick" && LLAgentPicksInfo::getInstance()->isPickLimitReached()) + { + return false; + } + + return true; +} + +bool LLPanelPicks::isClassifiedPublished(LLClassifiedItem* c_item) +{ + if(c_item) + { + LLPanelClassifiedEdit* panel = mEditClassifiedPanels[c_item->getClassifiedId()]; + if(panel) { - scroll->removeChild(*it); - delete *it; + return !panel->isNewWithErrors(); } + + // we've got this classified from server - it's published + return true; } - mPickItemList.clear(); + return false; } -BOOL LLPanelPicks::postBuild(void) +void LLPanelPicks::onAccordionStateChanged(const LLAccordionCtrlTab* acc_tab) { - childSetAction(XML_BTN_INFO, onClickInfo, this); - childSetAction(XML_BTN_NEW, onClickNew, this); - childSetAction(XML_BTN_DELETE, onClickDelete, this); + if(!mPicksAccTab->getDisplayChildren()) + { + mPicksList->resetSelection(true); + } + if(!mClassifiedsAccTab->getDisplayChildren()) + { + mClassifiedsList->resetSelection(true); + } - childSetAction("teleport_btn", onClickTeleport, this); - childSetAction("show_on_map_btn", onClickMap, this); - return TRUE; + updateButtons(); } -void LLPanelPicks::onActivate(const LLUUID& id) +void LLPanelPicks::onOpen(const LLSD& key) { + const LLUUID id(key.asUUID()); BOOL self = (gAgent.getID() == id); // only agent can edit her picks - childSetEnabled("edit_panel", self); - childSetVisible("edit_panel", self); + getChildView("edit_panel")->setEnabled(self); + getChildView("edit_panel")->setVisible( self); + + // Disable buttons when viewing profile for first time + if(getAvatarId() != id) + { + getChildView(XML_BTN_INFO)->setEnabled(FALSE); + getChildView(XML_BTN_TELEPORT)->setEnabled(FALSE); + getChildView(XML_BTN_SHOW_ON_MAP)->setEnabled(FALSE); + } // and see a special title - set as invisible by default in xml file if (self) { - childSetVisible("pick_title", !self); - childSetVisible("pick_title_agent", self); + getChildView("pick_title")->setVisible( !self); + getChildView("pick_title_agent")->setVisible( self); + + mPopupMenu->setItemVisible("pick_delete", TRUE); + mPopupMenu->setItemVisible("pick_edit", TRUE); + mPopupMenu->setItemVisible("pick_separator", TRUE); + } + + if(getAvatarId() != id) + { + showAccordion("tab_picks", false); + showAccordion("tab_classifieds", false); + + mPicksList->goToTop(); + // Set dummy value to make panel dirty and make it reload picks + setValue(LLSD()); } - LLPanelProfileTab::onActivate(id); + LLPanelProfileTab::onOpen(key); } +void LLPanelPicks::onClosePanel() +{ + if (mPanelClassifiedInfo) + { + onPanelClassifiedClose(mPanelClassifiedInfo); + } + if (mPanelPickInfo) + { + onPanelPickClose(mPanelPickInfo); + } +} + +void LLPanelPicks::onListCommit(const LLFlatListView* f_list) +{ + // Make sure only one of the lists has selection. + if(f_list == mPicksList) + { + mClassifiedsList->resetSelection(true); + } + else if(f_list == mClassifiedsList) + { + mPicksList->resetSelection(true); + } + else + { + llwarns << "Unknown list" << llendl; + } + + updateButtons(); +} //static -void LLPanelPicks::onClickInfo(void *data) +void LLPanelPicks::onClickDelete() { - LLPanelPicks* self = (LLPanelPicks*) data; - if (self) + LLSD value = mPicksList->getSelectedValue(); + if (value.isDefined()) { - LLPanelPick* panel_pick_info = new LLPanelPick(); - - //*TODO redo, use the selected pick from List View, but not the first (last) one - LLView* scroll = self->getChild<LLView>("back_panel", TRUE, FALSE); - LLPickItem* pick = static_cast<LLPickItem*>(scroll->getFirstChild()); - if (!pick) return; + LLSD args; + args["PICK"] = value[PICK_NAME]; + LLNotificationsUtil::add("DeleteAvatarPick", args, LLSD(), boost::bind(&LLPanelPicks::callbackDeletePick, this, _1, _2)); + return; + } - panel_pick_info->init(pick->getCreatorId(), pick->getPickId()); + value = mClassifiedsList->getSelectedValue(); + if(value.isDefined()) + { + LLSD args; + args["NAME"] = value[CLASSIFIED_NAME]; + LLNotificationsUtil::add("DeleteClassified", args, LLSD(), boost::bind(&LLPanelPicks::callbackDeleteClassified, this, _1, _2)); + return; + } +} - //*HACK redo toggling of panels (should work on both "profiles") - if (self->mMeProfilePanel) - { - panel_pick_info->setPanelMeProfile(self->mMeProfilePanel); - //self->mMeProfilePanel->addChildInBack(panel_pick_info); - self->mMeProfilePanel->togglePanel(panel_pick_info); - } +bool LLPanelPicks::callbackDeletePick(const LLSD& notification, const LLSD& response) +{ + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); + LLSD pick_value = mPicksList->getSelectedValue(); + + if (0 == option) + { + LLAvatarPropertiesProcessor::instance().sendPickDelete(pick_value[PICK_ID]); + mPicksList->removeItemByValue(pick_value); + } + updateButtons(); + return false; +} + +bool LLPanelPicks::callbackDeleteClassified(const LLSD& notification, const LLSD& response) +{ + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); + LLSD value = mClassifiedsList->getSelectedValue(); + + if (0 == option) + { + LLAvatarPropertiesProcessor::instance().sendClassifiedDelete(value[CLASSIFIED_ID]); + mClassifiedsList->removeItemByValue(value); } + updateButtons(); + return false; +} + +bool LLPanelPicks::callbackTeleport( const LLSD& notification, const LLSD& response ) +{ + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); + + if (0 == option) + { + onClickTeleport(); + } + return false; } //static -void LLPanelPicks::onClickNew(void *data) +void LLPanelPicks::onClickTeleport() { - LLPanelPicks* self = (LLPanelPicks*) data; - if(self && self->mMeProfilePanel) + LLPickItem* pick_item = getSelectedPickItem(); + LLClassifiedItem* c_item = getSelectedClassifiedItem(); + + LLVector3d pos; + if(pick_item) + pos = pick_item->getPosGlobal(); + else if(c_item) { - if (self->mPickItemList.size() >= MAX_AVATAR_PICKS) - { - //*TODO show warning message - return; - } - - //in edit mode - LLPanelPick* panel_edit_pick = new LLPanelPick(TRUE); - panel_edit_pick->createNewPick(); + pos = c_item->getPosGlobal(); + LLPanelClassifiedInfo::sendClickMessage("teleport", false, + c_item->getClassifiedId(), LLUUID::null, pos, LLStringUtil::null); + } - //*HACK redo toggling of panels - panel_edit_pick->setPanelMeProfile(self->mMeProfilePanel); - self->mMeProfilePanel->togglePanel(panel_edit_pick); + if (!pos.isExactlyZero()) + { + gAgent.teleportViaLocation(pos); + LLFloaterWorldMap::getInstance()->trackLocation(pos); } } //static -void LLPanelPicks::onClickDelete(void *data) +void LLPanelPicks::onClickMap() +{ + LLPickItem* pick_item = getSelectedPickItem(); + LLClassifiedItem* c_item = getSelectedClassifiedItem(); + + LLVector3d pos; + if (pick_item) + pos = pick_item->getPosGlobal(); + else if(c_item) + { + LLPanelClassifiedInfo::sendClickMessage("map", false, + c_item->getClassifiedId(), LLUUID::null, pos, LLStringUtil::null); + pos = c_item->getPosGlobal(); + } + + LLFloaterWorldMap::getInstance()->trackLocation(pos); + LLFloaterReg::showInstance("world_map", "center"); +} + + +void LLPanelPicks::onRightMouseUpItem(LLUICtrl* item, S32 x, S32 y, MASK mask) { - LLPanelPicks* self = (LLPanelPicks*) data; - if(self && self->mMeProfilePanel) + updateButtons(); + + if (mPopupMenu) { - //*TODO redo, use the selected pick from List View, but not the first (last) one - LLView* scroll = self->getChild<LLView>("back_panel", TRUE, FALSE); - LLPickItem* first_pick = static_cast<LLPickItem*>(scroll->getFirstChild()); - if (!first_pick) return; + mPopupMenu->buildDrawLabels(); + mPopupMenu->updateParent(LLMenuGL::sMenuContainer); + ((LLContextMenu*)mPopupMenu)->show(x, y); + LLMenuGL::showPopup(item, mPopupMenu, x, y); + } +} +void LLPanelPicks::onDoubleClickPickItem(LLUICtrl* item) +{ + LLSD pick_value = mPicksList->getSelectedValue(); + if (pick_value.isUndefined()) return; + LLSD args; - args["PICK"] = first_pick->getPickName(); - LLNotifications::instance().add("DeleteAvatarPick", args, LLSD(), boost::bind(&LLPanelPicks::callbackDelete, self, _1, _2)); - } + args["PICK"] = pick_value[PICK_NAME]; + LLNotificationsUtil::add("TeleportToPick", args, LLSD(), boost::bind(&LLPanelPicks::callbackTeleport, this, _1, _2)); } -bool LLPanelPicks::callbackDelete(const LLSD& notification, const LLSD& response) +void LLPanelPicks::onDoubleClickClassifiedItem(LLUICtrl* item) { - S32 option = LLNotification::getSelectedOption(notification, response); + LLSD value = mClassifiedsList->getSelectedValue(); + if (value.isUndefined()) return; - //*TODO redo, use the selected pick from List View, but not the first (last) one - LLView* scroll = getChild<LLView>("back_panel",TRUE,FALSE); - LLPickItem* first_pick = static_cast<LLPickItem*>(scroll->getFirstChild()); - if (!first_pick) return false; + LLSD args; + args["CLASSIFIED"] = value[CLASSIFIED_NAME]; + LLNotificationsUtil::add("TeleportToClassified", args, LLSD(), boost::bind(&LLPanelPicks::callbackTeleport, this, _1, _2)); +} - if (0 == option) +void LLPanelPicks::updateButtons() +{ + bool has_selected = mPicksList->numSelected() > 0 || mClassifiedsList->numSelected() > 0; + + if (getAvatarId() == gAgentID) { - LLAvatarPropertiesProcessor::instance().sendPickDelete(first_pick->getPickId()); + getChildView(XML_BTN_DELETE)->setEnabled(has_selected); + } + + getChildView(XML_BTN_INFO)->setEnabled(has_selected); + getChildView(XML_BTN_TELEPORT)->setEnabled(has_selected); + getChildView(XML_BTN_SHOW_ON_MAP)->setEnabled(has_selected); - scroll->removeChild(first_pick); - mPickItemList.pop_back(); - first_pick = NULL; + LLClassifiedItem* c_item = dynamic_cast<LLClassifiedItem*>(mClassifiedsList->getSelectedItem()); + if(c_item) + { + getChildView(XML_BTN_INFO)->setEnabled(isClassifiedPublished(c_item)); } +} + +void LLPanelPicks::setProfilePanel(LLPanelProfile* profile_panel) +{ + mProfilePanel = profile_panel; +} + + +void LLPanelPicks::buildPickPanel() +{ +// if (mPickPanel == NULL) +// { +// mPickPanel = new LLPanelPick(); +// mPickPanel->setExitCallback(boost::bind(&LLPanelPicks::onPanelPickClose, this, NULL)); +// } +} + +void LLPanelPicks::onClickPlusBtn() +{ + LLRect rect(getChildView(XML_BTN_NEW)->getRect()); + + mPlusMenu->updateParent(LLMenuGL::sMenuContainer); + mPlusMenu->setButtonRect(rect, this); + LLMenuGL::showPopup(this, mPlusMenu, rect.mLeft, rect.mTop); +} + +void LLPanelPicks::createNewPick() +{ + createPickEditPanel(); + + getProfilePanel()->openPanel(mPanelPickEdit, LLSD()); +} + +void LLPanelPicks::createNewClassified() +{ + LLPanelClassifiedEdit* panel = NULL; + createClassifiedEditPanel(&panel); + + getProfilePanel()->openPanel(panel, LLSD()); +} + +void LLPanelPicks::onClickInfo() +{ + if(mPicksList->numSelected() > 0) + { + openPickInfo(); + } + else if(mClassifiedsList->numSelected() > 0) + { + openClassifiedInfo(); + } +} + +void LLPanelPicks::openPickInfo() +{ + LLSD selected_value = mPicksList->getSelectedValue(); + if (selected_value.isUndefined()) return; + + LLPickItem* pick = (LLPickItem*)mPicksList->getSelectedItem(); + + createPickInfoPanel(); + + LLSD params; + params["pick_id"] = pick->getPickId(); + params["avatar_id"] = pick->getCreatorId(); + params["snapshot_id"] = pick->getSnapshotId(); + params["pick_name"] = pick->getPickName(); + params["pick_desc"] = pick->getPickDesc(); + + getProfilePanel()->openPanel(mPanelPickInfo, params); +} + +void LLPanelPicks::openClassifiedInfo() +{ + LLSD selected_value = mClassifiedsList->getSelectedValue(); + if (selected_value.isUndefined()) return; + + LLClassifiedItem* c_item = getSelectedClassifiedItem(); + LLSD params; + params["classified_id"] = c_item->getClassifiedId(); + params["classified_creator_id"] = c_item->getAvatarId(); + params["classified_snapshot_id"] = c_item->getSnapshotId(); + params["classified_name"] = c_item->getClassifiedName(); + params["classified_desc"] = c_item->getDescription(); + params["from_search"] = false; + + openClassifiedInfo(params); +} + +void LLPanelPicks::openClassifiedInfo(const LLSD ¶ms) +{ + createClassifiedInfoPanel(); + getProfilePanel()->openPanel(mPanelClassifiedInfo, params); +} + +void LLPanelPicks::showAccordion(const std::string& name, bool show) +{ + LLAccordionCtrlTab* tab = getChild<LLAccordionCtrlTab>(name); + tab->setVisible(show); + LLAccordionCtrl* acc = getChild<LLAccordionCtrl>("accordion"); + acc->arrange(); +} + +void LLPanelPicks::onPanelPickClose(LLPanel* panel) +{ + panel->setVisible(FALSE); +} + +void LLPanelPicks::onPanelPickSave(LLPanel* panel) +{ + onPanelPickClose(panel); updateButtons(); - return false; } -void LLPanelPicks::setPanelMeProfile(LLPanelMeProfile* meProfilePanel) +void LLPanelPicks::onPanelClassifiedSave(LLPanelClassifiedEdit* panel) { - mMeProfilePanel = meProfilePanel; + if(!panel->canClose()) + { + return; + } + + if(panel->isNew()) + { + mEditClassifiedPanels[panel->getClassifiedId()] = panel; + + LLClassifiedItem* c_item = new LLClassifiedItem(getAvatarId(), panel->getClassifiedId()); + c_item->fillIn(panel); + + LLSD c_value; + c_value.insert(CLASSIFIED_ID, c_item->getClassifiedId()); + c_value.insert(CLASSIFIED_NAME, c_item->getClassifiedName()); + mClassifiedsList->addItem(c_item, c_value, ADD_TOP); + + c_item->setDoubleClickCallback(boost::bind(&LLPanelPicks::onDoubleClickClassifiedItem, this, _1)); + c_item->setRightMouseUpCallback(boost::bind(&LLPanelPicks::onRightMouseUpItem, this, _1, _2, _3, _4)); + c_item->setMouseUpCallback(boost::bind(&LLPanelPicks::updateButtons, this)); + c_item->childSetAction("info_chevron", boost::bind(&LLPanelPicks::onClickInfo, this)); + + // order does matter, showAccordion will invoke arrange for accordions. + mClassifiedsAccTab->changeOpenClose(false); + showAccordion("tab_classifieds", true); + } + else if(panel->isNewWithErrors()) + { + LLClassifiedItem* c_item = dynamic_cast<LLClassifiedItem*>(mClassifiedsList->getSelectedItem()); + llassert(c_item); + if (c_item) + { + c_item->fillIn(panel); + } + } + else + { + onPanelClassifiedClose(panel); + return; + } + + onPanelPickClose(panel); + updateButtons(); } -//static -void LLPanelPicks::teleport(const LLVector3d& position) +void LLPanelPicks::onPanelClassifiedClose(LLPanelClassifiedInfo* panel) { - if (!position.isExactlyZero()) + if(panel->getInfoLoaded() && !panel->isDirty()) { - gAgent.teleportViaLocation(position); - LLFloaterWorldMap::getInstance()->trackLocation(position); + std::vector<LLSD> values; + mClassifiedsList->getValues(values); + for(size_t n = 0; n < values.size(); ++n) + { + LLUUID c_id = values[n][CLASSIFIED_ID].asUUID(); + if(panel->getClassifiedId() == c_id) + { + LLClassifiedItem* c_item = dynamic_cast<LLClassifiedItem*>( + mClassifiedsList->getItemByValue(values[n])); + llassert(c_item); + if (c_item) + { + c_item->setClassifiedName(panel->getClassifiedName()); + c_item->setDescription(panel->getDescription()); + c_item->setSnapshotId(panel->getSnapshotId()); + } + } + } } + + onPanelPickClose(panel); + updateButtons(); } -//static -void LLPanelPicks::onClickTeleport(void* data) +void LLPanelPicks::createPickInfoPanel() { - LLPanelPicks* self = (LLPanelPicks*)data; + if(!mPanelPickInfo) + { + mPanelPickInfo = LLPanelPickInfo::create(); + mPanelPickInfo->setExitCallback(boost::bind(&LLPanelPicks::onPanelPickClose, this, mPanelPickInfo)); + mPanelPickInfo->setEditPickCallback(boost::bind(&LLPanelPicks::onPanelPickEdit, this)); + mPanelPickInfo->setVisible(FALSE); + } +} - if (!self->mPickItemList.size()) return; +void LLPanelPicks::createClassifiedInfoPanel() +{ + if(!mPanelClassifiedInfo) + { + mPanelClassifiedInfo = LLPanelClassifiedInfo::create(); + mPanelClassifiedInfo->setExitCallback(boost::bind(&LLPanelPicks::onPanelClassifiedClose, this, mPanelClassifiedInfo)); + mPanelClassifiedInfo->setEditClassifiedCallback(boost::bind(&LLPanelPicks::onPanelClassifiedEdit, this)); + mPanelClassifiedInfo->setVisible(FALSE); + } +} - //*TODO use the selected Pick instead of the last one in the list of Picks - LLPickItem* last_pick = self->mPickItemList.back(); - if (!last_pick) return; +void LLPanelPicks::createClassifiedEditPanel(LLPanelClassifiedEdit** panel) +{ + if(panel) + { + LLPanelClassifiedEdit* new_panel = LLPanelClassifiedEdit::create(); + new_panel->setExitCallback(boost::bind(&LLPanelPicks::onPanelClassifiedClose, this, new_panel)); + new_panel->setSaveCallback(boost::bind(&LLPanelPicks::onPanelClassifiedSave, this, new_panel)); + new_panel->setCancelCallback(boost::bind(&LLPanelPicks::onPanelClassifiedClose, this, new_panel)); + new_panel->setVisible(FALSE); + *panel = new_panel; + } +} - teleport(last_pick->getPosGlobal()); +void LLPanelPicks::createPickEditPanel() +{ + if(!mPanelPickEdit) + { + mPanelPickEdit = LLPanelPickEdit::create(); + mPanelPickEdit->setExitCallback(boost::bind(&LLPanelPicks::onPanelPickClose, this, mPanelPickEdit)); + mPanelPickEdit->setSaveCallback(boost::bind(&LLPanelPicks::onPanelPickSave, this, mPanelPickEdit)); + mPanelPickEdit->setCancelCallback(boost::bind(&LLPanelPicks::onPanelPickClose, this, mPanelPickEdit)); + mPanelPickEdit->setVisible(FALSE); + } } -//static -void LLPanelPicks::onClickMap(void* data) +// void LLPanelPicks::openPickEditPanel(LLPickItem* pick) +// { +// if(!pick) +// { +// return; +// } +// } + +// void LLPanelPicks::openPickInfoPanel(LLPickItem* pick) +// { +// if(!mPanelPickInfo) +// { +// mPanelPickInfo = LLPanelPickInfo::create(); +// mPanelPickInfo->setExitCallback(boost::bind(&LLPanelPicks::onPanelPickClose, this, mPanelPickInfo)); +// mPanelPickInfo->setEditPickCallback(boost::bind(&LLPanelPicks::onPanelPickEdit, this)); +// mPanelPickInfo->setVisible(FALSE); +// } +// +// LLSD params; +// params["pick_id"] = pick->getPickId(); +// params["avatar_id"] = pick->getCreatorId(); +// params["snapshot_id"] = pick->getSnapshotId(); +// params["pick_name"] = pick->getPickName(); +// params["pick_desc"] = pick->getPickDesc(); +// +// getProfilePanel()->openPanel(mPanelPickInfo, params); +// } + +void LLPanelPicks::onPanelPickEdit() { - LLPanelPicks* self = (LLPanelPicks*)data; - - if (!self->mPickItemList.size()) return; + LLSD selected_value = mPicksList->getSelectedValue(); + if (selected_value.isUndefined()) return; + + LLPickItem* pick = dynamic_cast<LLPickItem*>(mPicksList->getSelectedItem()); - //*TODO use the selected Pick instead of the last one in the list of Picks - LLPickItem* last_pick = self->mPickItemList.back(); - if (!last_pick) return; + createPickEditPanel(); - showOnMap(last_pick->getPosGlobal()); + LLSD params; + params["pick_id"] = pick->getPickId(); + params["avatar_id"] = pick->getCreatorId(); + params["snapshot_id"] = pick->getSnapshotId(); + params["pick_name"] = pick->getPickName(); + params["pick_desc"] = pick->getPickDesc(); + getProfilePanel()->openPanel(mPanelPickEdit, params); } -//static -void LLPanelPicks::showOnMap(const LLVector3d& position) +void LLPanelPicks::onPanelClassifiedEdit() { - LLFloaterWorldMap::getInstance()->trackLocation(position); - LLFloaterReg::showInstance("world_map", "center"); + LLSD selected_value = mClassifiedsList->getSelectedValue(); + if (selected_value.isUndefined()) + { + return; + } + + LLClassifiedItem* c_item = dynamic_cast<LLClassifiedItem*>(mClassifiedsList->getSelectedItem()); + llassert(c_item); + if (!c_item) + { + return; + } + + LLSD params; + params["classified_id"] = c_item->getClassifiedId(); + params["classified_creator_id"] = c_item->getAvatarId(); + params["snapshot_id"] = c_item->getSnapshotId(); + params["name"] = c_item->getClassifiedName(); + params["desc"] = c_item->getDescription(); + params["category"] = (S32)c_item->getCategory(); + params["content_type"] = (S32)c_item->getContentType(); + params["auto_renew"] = c_item->getAutoRenew(); + params["price_for_listing"] = c_item->getPriceForListing(); + params["location_text"] = c_item->getLocationText(); + + LLPanelClassifiedEdit* panel = mEditClassifiedPanels[c_item->getClassifiedId()]; + if(!panel) + { + createClassifiedEditPanel(&panel); + mEditClassifiedPanels[c_item->getClassifiedId()] = panel; + } + getProfilePanel()->openPanel(panel, params); + panel->setPosGlobal(c_item->getPosGlobal()); } -void LLPanelPicks::updateButtons() +void LLPanelPicks::onClickMenuEdit() { - int picks_num = mPickItemList.size(); - childSetEnabled(XML_BTN_INFO, picks_num > 0); + if(getSelectedPickItem()) + { + onPanelPickEdit(); + } + else if(getSelectedClassifiedItem()) + { + onPanelClassifiedEdit(); + } +} - if (mAvatarId == gAgentID) +bool LLPanelPicks::onEnableMenuItem(const LLSD& user_data) +{ + std::string param = user_data.asString(); + + LLClassifiedItem* c_item = dynamic_cast<LLClassifiedItem*>(mClassifiedsList->getSelectedItem()); + if(c_item && "info" == param) { - childSetEnabled(XML_BTN_NEW, picks_num < MAX_AVATAR_PICKS); - childSetEnabled(XML_BTN_DELETE, picks_num > 0); + // dont show Info panel if classified was not created + return isClassifiedPublished(c_item); } + + return true; } +inline LLPanelProfile* LLPanelPicks::getProfilePanel() +{ + llassert_always(NULL != mProfilePanel); + return mProfilePanel; +} //----------------------------------------------------------------------------- // LLPanelPicks //----------------------------------------------------------------------------- LLPickItem::LLPickItem() : LLPanel() -, mPicID(LLUUID::null) +, mPickID(LLUUID::null) , mCreatorID(LLUUID::null) , mParcelID(LLUUID::null) , mSnapshotID(LLUUID::null) , mNeedData(true) { - LLUICtrlFactory::getInstance()->buildPanel(this,"panel_pic_list_item.xml"); + buildFromFile("panel_pick_list_item.xml"); } LLPickItem::~LLPickItem() { - if (!mCreatorID.isNull()) + if (mCreatorID.notNull()) { LLAvatarPropertiesProcessor::instance().removeObserver(mCreatorID, this); } @@ -378,27 +1058,22 @@ LLPickItem* LLPickItem::create() void LLPickItem::init(LLPickData* pick_data) { - setPictureDescription(pick_data->desc); + setPickDesc(pick_data->desc); setSnapshotId(pick_data->snapshot_id); mPosGlobal = pick_data->pos_global; - mLocation = pick_data->location_text; + mSimName = pick_data->sim_name; + mPickDescription = pick_data->desc; + mUserName = pick_data->user_name; + mOriginalName = pick_data->original_name; - LLTextureCtrl* picture = getChild<LLTextureCtrl>("picture", TRUE, FALSE); - if (picture) - { - picture->setImageAssetID(pick_data->snapshot_id); - } + LLTextureCtrl* picture = getChild<LLTextureCtrl>("picture"); + picture->setImageAssetID(pick_data->snapshot_id); } -void LLPickItem::setPicture() -{ - -} - -void LLPickItem::setPictureName(const std::string& name) +void LLPickItem::setPickName(const std::string& name) { mPickName = name; - childSetValue("picture_name",name); + getChild<LLUICtrl>("picture_name")->setValue(name); } @@ -417,19 +1092,19 @@ const LLUUID& LLPickItem::getSnapshotId() return mSnapshotID; } -void LLPickItem::setPictureDescription(const std::string& descr) +void LLPickItem::setPickDesc(const std::string& descr) { - childSetValue("picture_descr",descr); + getChild<LLUICtrl>("picture_descr")->setValue(descr); } -void LLPickItem::setPictureId(const LLUUID& id) +void LLPickItem::setPickId(const LLUUID& id) { - mPicID = id; + mPickID = id; } const LLUUID& LLPickItem::getPickId() { - return mPicID; + return mPickID; } const LLVector3d& LLPickItem::getPosGlobal() @@ -437,33 +1112,145 @@ const LLVector3d& LLPickItem::getPosGlobal() return mPosGlobal; } -const std::string& LLPickItem::getLocation() -{ - return mLocation; -} - const std::string LLPickItem::getDescription() { - return childGetValue("picture_descr").asString(); + return getChild<LLUICtrl>("picture_descr")->getValue().asString(); } void LLPickItem::update() { - mNeedData = true; - LLAvatarPropertiesProcessor::instance().sendDataRequest(mCreatorID, APT_PICK_INFO, &mPicID); - mNeedData = false; + setNeedData(true); + LLAvatarPropertiesProcessor::instance().sendPickInfoRequest(mCreatorID, mPickID); } void LLPickItem::processProperties(void *data, EAvatarProcessorType type) { - if (APT_PICK_INFO != type) return; - if (!data) return; + if (APT_PICK_INFO != type) + { + return; + } LLPickData* pick_data = static_cast<LLPickData *>(data); - if (!pick_data) return; - if (mPicID != pick_data->pick_id) return; + if (!pick_data || mPickID != pick_data->pick_id) + { + return; + } init(pick_data); - LLAvatarPropertiesProcessor::instance().removeObserver(pick_data->agent_id, this); + setNeedData(false); + LLAvatarPropertiesProcessor::instance().removeObserver(mCreatorID, this); +} + +void set_child_visible(LLView* parent, const std::string& child_name, bool visible) +{ + parent->getChildView(child_name)->setVisible(visible); +} + +BOOL LLPickItem::postBuild() +{ + setMouseEnterCallback(boost::bind(&set_child_visible, this, "hovered_icon", true)); + setMouseLeaveCallback(boost::bind(&set_child_visible, this, "hovered_icon", false)); + return TRUE; +} + +void LLPickItem::setValue(const LLSD& value) +{ + if (!value.isMap()) return;; + if (!value.has("selected")) return; + getChildView("selected_icon")->setVisible( value["selected"]); +} + +////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////// + +LLClassifiedItem::LLClassifiedItem(const LLUUID& avatar_id, const LLUUID& classified_id) + : LLPanel() + , mAvatarId(avatar_id) + , mClassifiedId(classified_id) +{ + buildFromFile("panel_classifieds_list_item.xml"); + + LLAvatarPropertiesProcessor::getInstance()->addObserver(getAvatarId(), this); + LLAvatarPropertiesProcessor::getInstance()->sendClassifiedInfoRequest(getClassifiedId()); +} + +LLClassifiedItem::~LLClassifiedItem() +{ + LLAvatarPropertiesProcessor::getInstance()->removeObserver(getAvatarId(), this); +} + +void LLClassifiedItem::processProperties(void* data, EAvatarProcessorType type) +{ + if(APT_CLASSIFIED_INFO != type) + { + return; + } + + LLAvatarClassifiedInfo* c_info = static_cast<LLAvatarClassifiedInfo*>(data); + if( !c_info || c_info->classified_id != getClassifiedId() ) + { + return; + } + + setClassifiedName(c_info->name); + setDescription(c_info->description); + setSnapshotId(c_info->snapshot_id); + setPosGlobal(c_info->pos_global); + + LLAvatarPropertiesProcessor::getInstance()->removeObserver(getAvatarId(), this); +} + +BOOL LLClassifiedItem::postBuild() +{ + setMouseEnterCallback(boost::bind(&set_child_visible, this, "hovered_icon", true)); + setMouseLeaveCallback(boost::bind(&set_child_visible, this, "hovered_icon", false)); + return TRUE; +} + +void LLClassifiedItem::setValue(const LLSD& value) +{ + if (!value.isMap()) return;; + if (!value.has("selected")) return; + getChildView("selected_icon")->setVisible( value["selected"]); +} + +void LLClassifiedItem::fillIn(LLPanelClassifiedEdit* panel) +{ + if(!panel) + { + return; + } + + setClassifiedName(panel->getClassifiedName()); + setDescription(panel->getDescription()); + setSnapshotId(panel->getSnapshotId()); + setCategory(panel->getCategory()); + setContentType(panel->getContentType()); + setAutoRenew(panel->getAutoRenew()); + setPriceForListing(panel->getPriceForListing()); + setPosGlobal(panel->getPosGlobal()); + setLocationText(panel->getClassifiedLocation()); +} + +void LLClassifiedItem::setClassifiedName(const std::string& name) +{ + getChild<LLUICtrl>("name")->setValue(name); +} + +void LLClassifiedItem::setDescription(const std::string& desc) +{ + getChild<LLUICtrl>("description")->setValue(desc); +} + +void LLClassifiedItem::setSnapshotId(const LLUUID& snapshot_id) +{ + getChild<LLUICtrl>("picture")->setValue(snapshot_id); +} + +LLUUID LLClassifiedItem::getSnapshotId() +{ + return getChild<LLUICtrl>("picture")->getValue(); } +//EOF |