diff options
Diffstat (limited to 'indra/newview/llinventorypanel.cpp')
-rw-r--r-- | indra/newview/llinventorypanel.cpp | 224 |
1 files changed, 116 insertions, 108 deletions
diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp index 83c2d62ee8..770bc02b40 100644 --- a/indra/newview/llinventorypanel.cpp +++ b/indra/newview/llinventorypanel.cpp @@ -38,6 +38,7 @@ #include "llagent.h" #include "llagentwearables.h" #include "llappearancemgr.h" +#include "llavataractions.h" #include "llfloaterinventory.h" #include "llfloaterreg.h" #include "llimfloater.h" @@ -48,6 +49,7 @@ #include "llsidepanelinventory.h" #include "llsidetray.h" #include "llscrollcontainer.h" +#include "llviewerattachmenu.h" #include "llviewerfoldertype.h" #include "llvoavatarself.h" @@ -80,11 +82,12 @@ protected: LLInventoryPanel::LLInventoryPanel(const LLInventoryPanel::Params& p) : LLPanel(p), mInventoryObserver(NULL), - mFolders(NULL), + mFolderRoot(NULL), mScroller(NULL), mSortOrderSetting(p.sort_order_setting), mInventory(p.inventory), mAllowMultiSelect(p.allow_multi_select), + mShowItemLinkOverlays(p.show_item_link_overlays), mViewsInitialized(false), mStartFolderString(p.start_folder), mBuildDefaultHierarchy(true), @@ -99,6 +102,7 @@ LLInventoryPanel::LLInventoryPanel(const LLInventoryPanel::Params& p) : mCommitCallbackRegistrar.add("Inventory.DoCreate", boost::bind(&LLInventoryPanel::doCreate, this, _2)); mCommitCallbackRegistrar.add("Inventory.AttachObject", boost::bind(&LLInventoryPanel::attachObject, this, _2)); mCommitCallbackRegistrar.add("Inventory.BeginIMSession", boost::bind(&LLInventoryPanel::beginIMSession, this)); + mCommitCallbackRegistrar.add("Inventory.Share", boost::bind(&LLAvatarActions::shareWithAvatars)); if (mStartFolderString != "") { @@ -106,7 +110,7 @@ LLInventoryPanel::LLInventoryPanel(const LLInventoryPanel::Params& p) : } } -BOOL LLInventoryPanel::postBuild() +void LLInventoryPanel::initFromParams(const LLInventoryPanel::Params& params) { LLMemType mt(LLMemType::MTYPE_INVENTORY_POST_BUILD); @@ -124,13 +128,14 @@ BOOL LLInventoryPanel::postBuild() p.rect = folder_rect; p.parent_panel = this; p.tool_tip = p.name; - mFolders = LLUICtrlFactory::create<LLFolderView>(p); - mFolders->setAllowMultiSelect(mAllowMultiSelect); + p.use_label_suffix = params.use_label_suffix; + mFolderRoot = LLUICtrlFactory::create<LLFolderView>(p); + mFolderRoot->setAllowMultiSelect(mAllowMultiSelect); } mCommitCallbackRegistrar.popScope(); - mFolders->setCallbackRegistrar(&mCommitCallbackRegistrar); + mFolderRoot->setCallbackRegistrar(&mCommitCallbackRegistrar); // Scroller { @@ -144,9 +149,9 @@ BOOL LLInventoryPanel::postBuild() p.tab_stop(true); mScroller = LLUICtrlFactory::create<LLScrollContainer>(p); addChild(mScroller); - mScroller->addChild(mFolders); - mFolders->setScrollContainer(mScroller); - mFolders->addChild(mFolders->mStatusTextBox); + mScroller->addChild(mFolderRoot); + mFolderRoot->setScrollContainer(mScroller); + mFolderRoot->addChild(mFolderRoot->mStatusTextBox); } // Set up the callbacks from the inventory we're viewing, and then build everything. @@ -169,22 +174,25 @@ BOOL LLInventoryPanel::postBuild() { setSortOrder(gSavedSettings.getU32(DEFAULT_SORT_ORDER)); } - mFolders->setSortOrder(getFilter()->getSortOrder()); + mFolderRoot->setSortOrder(getFilter()->getSortOrder()); - return TRUE; + // Initialize base class params. + LLPanel::initFromParams(params); } LLInventoryPanel::~LLInventoryPanel() { - if (mFolders) + if (mFolderRoot) { - U32 sort_order = mFolders->getSortOrder(); + U32 sort_order = mFolderRoot->getSortOrder(); if (mSortOrderSetting != INHERIT_SORT_ORDER) { gSavedSettings.setU32(mSortOrderSetting, sort_order); } } + gIdleCallbacks.deleteFunction(onIdle, this); + // LLView destructor will take care of the sub-views. mInventory->removeObserver(mInventoryObserver); delete mInventoryObserver; @@ -194,15 +202,15 @@ LLInventoryPanel::~LLInventoryPanel() void LLInventoryPanel::draw() { // Select the desired item (in case it wasn't loaded when the selection was requested) - mFolders->updateSelection(); + mFolderRoot->updateSelection(); LLPanel::draw(); } LLInventoryFilter* LLInventoryPanel::getFilter() { - if (mFolders) + if (mFolderRoot) { - return mFolders->getFilter(); + return mFolderRoot->getFilter(); } return NULL; } @@ -220,6 +228,11 @@ void LLInventoryPanel::setFilterPermMask(PermissionMask filter_perm_mask) getFilter()->setFilterPermissions(filter_perm_mask); } +void LLInventoryPanel::setFilterWearableTypes(U64 types) +{ + getFilter()->setFilterWearableTypes(types); +} + void LLInventoryPanel::setFilterSubString(const std::string& string) { getFilter()->setFilterSubString(string); @@ -230,9 +243,9 @@ void LLInventoryPanel::setSortOrder(U32 order) getFilter()->setSortOrder(order); if (getFilter()->isModified()) { - mFolders->setSortOrder(order); + mFolderRoot->setSortOrder(order); // try to keep selection onscreen, even if it wasn't to start with - mFolders->scrollToShowSelection(); + mFolderRoot->scrollToShowSelection(); } } @@ -246,6 +259,11 @@ void LLInventoryPanel::setHoursAgo(U32 hours) getFilter()->setHoursAgo(hours); } +void LLInventoryPanel::setFilterLinks(U64 filter_links) +{ + getFilter()->setFilterLinks(filter_links); +} + void LLInventoryPanel::setShowFolderState(LLInventoryFilter::EFolderShow show) { getFilter()->setShowFolderState(show); @@ -277,8 +295,8 @@ void LLInventoryPanel::modelChanged(U32 mask) { const LLUUID& item_id = (*items_iter); const LLInventoryObject* model_item = model->getObject(item_id); - LLFolderViewItem* view_item = mFolders->getItemByID(item_id); - LLFolderViewFolder* view_folder = mFolders->getFolderByID(item_id); + LLFolderViewItem* view_item = mFolderRoot->getItemByID(item_id); + LLFolderViewFolder* view_folder = mFolderRoot->getFolderByID(item_id); ////////////////////////////// // LABEL Operation @@ -353,7 +371,7 @@ void LLInventoryPanel::modelChanged(U32 mask) // Add the UI element for this item. buildNewViews(item_id); // Select any newly created object that has the auto rename at top of folder root set. - if(mFolders->getRoot()->needsAutoRename()) + if(mFolderRoot->getRoot()->needsAutoRename()) { setSelection(item_id, FALSE); } @@ -368,7 +386,7 @@ void LLInventoryPanel::modelChanged(U32 mask) // model_item's parent will be NULL. if (view_item->getRoot() != view_item->getParent()) { - LLFolderViewFolder* new_parent = (LLFolderViewFolder*)mFolders->getItemByID(model_item->getParentUUID()); + LLFolderViewFolder* new_parent = (LLFolderViewFolder*)mFolderRoot->getItemByID(model_item->getParentUUID()); // Item has been moved. if (view_item->getParentFolder() != new_parent) { @@ -376,7 +394,7 @@ void LLInventoryPanel::modelChanged(U32 mask) { // Item is to be moved and we found its new parent in the panel's directory, so move the item's UI. view_item->getParentFolder()->extractItem(view_item); - view_item->addToFolder(new_parent, mFolders); + view_item->addToFolder(new_parent, mFolderRoot); } else { @@ -444,14 +462,14 @@ void LLInventoryPanel::initializeViews() if (gAgent.isFirstLogin()) { // Auto open the user's library - LLFolderViewFolder* lib_folder = mFolders->getFolderByID(gInventory.getLibraryRootFolderID()); + LLFolderViewFolder* lib_folder = mFolderRoot->getFolderByID(gInventory.getLibraryRootFolderID()); if (lib_folder) { lib_folder->setOpen(TRUE); } // Auto close the user's my inventory folder - LLFolderViewFolder* my_inv_folder = mFolders->getFolderByID(gInventory.getRootFolderID()); + LLFolderViewFolder* my_inv_folder = mFolderRoot->getFolderByID(gInventory.getRootFolderID()); if (my_inv_folder) { my_inv_folder->setOpenArrangeRecursively(FALSE, LLFolderViewFolder::RECURSE_DOWN); @@ -462,7 +480,7 @@ void LLInventoryPanel::initializeViews() void LLInventoryPanel::rebuildViewsFor(const LLUUID& id) { // Destroy the old view for this ID so we can rebuild it. - LLFolderViewItem* old_view = mFolders->getItemByID(id); + LLFolderViewItem* old_view = mFolderRoot->getItemByID(id); if (old_view && id.notNull()) { old_view->destroyView(); @@ -479,10 +497,10 @@ void LLInventoryPanel::buildNewViews(const LLUUID& id) if (objectp) { const LLUUID &parent_id = objectp->getParentUUID(); - LLFolderViewFolder* parent_folder = (LLFolderViewFolder*)mFolders->getItemByID(parent_id); + LLFolderViewFolder* parent_folder = (LLFolderViewFolder*)mFolderRoot->getItemByID(parent_id); if (id == mStartFolderID) { - parent_folder = mFolders; + parent_folder = mFolderRoot; } else if ((mStartFolderID != LLUUID::null) && (!gInventory.isObjectDescendentOf(id, mStartFolderID))) { @@ -506,19 +524,23 @@ void LLInventoryPanel::buildNewViews(const LLUUID& id) objectp->getType(), LLInventoryType::IT_CATEGORY, this, + mFolderRoot, objectp->getUUID()); - if (new_listener) { LLFolderViewFolder::Params params; params.name = new_listener->getDisplayName(); params.icon = new_listener->getIcon(); params.icon_open = new_listener->getOpenIcon(); - params.root = mFolders; + if (mShowItemLinkOverlays) // if false, then links show up just like normal items + { + params.icon_overlay = LLUI::getUIImage("Inv_Link"); + } + params.root = mFolderRoot; params.listener = new_listener; params.tool_tip = params.name; LLFolderViewFolder* folderp = LLUICtrlFactory::create<LLFolderViewFolder>(params); - folderp->setItemSortOrder(mFolders->getSortOrder()); + folderp->setItemSortOrder(mFolderRoot->getSortOrder()); itemp = folderp; // Hide the root folder, so we can show the contents of a folder flat @@ -542,6 +564,7 @@ void LLInventoryPanel::buildNewViews(const LLUUID& id) item->getActualType(), item->getInventoryType(), this, + mFolderRoot, item->getUUID(), item->getFlags()); @@ -551,8 +574,12 @@ void LLInventoryPanel::buildNewViews(const LLUUID& id) params.name = new_listener->getDisplayName(); params.icon = new_listener->getIcon(); params.icon_open = new_listener->getOpenIcon(); + if (mShowItemLinkOverlays) // if false, then links show up just like normal items + { + params.icon_overlay = LLUI::getUIImage("Inv_Link"); + } params.creation_date = new_listener->getCreationDate(); - params.root = mFolders; + params.root = mFolderRoot; params.listener = new_listener; params.rect = LLRect (0, 0, 0, 0); params.tool_tip = params.name; @@ -562,7 +589,7 @@ void LLInventoryPanel::buildNewViews(const LLUUID& id) if (itemp) { - itemp->addToFolder(parent_folder, mFolders); + itemp->addToFolder(parent_folder, mFolderRoot); // Don't add children of hidden folders unless this is the panel's root folder. if (itemp->getHidden() && (id != mStartFolderID)) @@ -611,19 +638,19 @@ void LLInventoryPanel::openStartFolderOrMyInventory() { if (mStartFolderString != "") { - mFolders->openFolder(mStartFolderString); + mFolderRoot->openFolder(mStartFolderString); } else { // Find My Inventory folder and open it up by name - for (LLView *child = mFolders->getFirstChild(); child; child = mFolders->findNextSibling(child)) + for (LLView *child = mFolderRoot->getFirstChild(); child; child = mFolderRoot->findNextSibling(child)) { LLFolderViewFolder *fchild = dynamic_cast<LLFolderViewFolder*>(child); if (fchild && fchild->getListener() && (fchild->getListener()->getUUID() == gInventory.getRootFolderID())) { const std::string& child_name = child->getName(); - mFolders->openFolder(child_name); + mFolderRoot->openFolder(child_name); break; } } @@ -632,7 +659,7 @@ void LLInventoryPanel::openStartFolderOrMyInventory() void LLInventoryPanel::openSelected() { - LLFolderViewItem* folder_item = mFolders->getCurSelectedItem(); + LLFolderViewItem* folder_item = mFolderRoot->getCurSelectedItem(); if(!folder_item) return; LLInvFVBridge* bridge = (LLInvFVBridge*)folder_item->getListener(); if(!bridge) return; @@ -668,38 +695,24 @@ BOOL LLInventoryPanel::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, // If folder view is empty the (x, y) point won't be in its rect // so the handler must be called explicitly. - if (!mFolders->hasVisibleChildren()) + // but only if was not handled before. See EXT-6746. + if (!handled && !mFolderRoot->hasVisibleChildren()) { - handled = mFolders->handleDragAndDrop(x, y, mask, drop, cargo_type, cargo_data, accept, tooltip_msg); + handled = mFolderRoot->handleDragAndDrop(x, y, mask, drop, cargo_type, cargo_data, accept, tooltip_msg); } if (handled) { - mFolders->setDragAndDropThisFrame(); + mFolderRoot->setDragAndDropThisFrame(); } return handled; } -// virtual -void LLInventoryPanel::onMouseEnter(S32 x, S32 y, MASK mask) -{ - LLPanel::onMouseEnter(x, y, mask); - // don't auto-scroll a list when cursor is over Inventory. See EXT-3981. - mFolders->setEnableScroll(false); -} - -// virtual -void LLInventoryPanel::onMouseLeave(S32 x, S32 y, MASK mask) -{ - LLPanel::onMouseLeave(x, y, mask); - mFolders->setEnableScroll(true); -} - void LLInventoryPanel::onFocusLost() { // inventory no longer handles cut/copy/paste/delete - if (LLEditMenuHandler::gEditMenuHandler == mFolders) + if (LLEditMenuHandler::gEditMenuHandler == mFolderRoot) { LLEditMenuHandler::gEditMenuHandler = NULL; } @@ -710,15 +723,15 @@ void LLInventoryPanel::onFocusLost() void LLInventoryPanel::onFocusReceived() { // inventory now handles cut/copy/paste/delete - LLEditMenuHandler::gEditMenuHandler = mFolders; + LLEditMenuHandler::gEditMenuHandler = mFolderRoot; LLPanel::onFocusReceived(); } void LLInventoryPanel::openAllFolders() { - mFolders->setOpenArrangeRecursively(TRUE, LLFolderViewFolder::RECURSE_DOWN); - mFolders->arrangeAll(); + mFolderRoot->setOpenArrangeRecursively(TRUE, LLFolderViewFolder::RECURSE_DOWN); + mFolderRoot->arrangeAll(); } void LLInventoryPanel::setSelection(const LLUUID& obj_id, BOOL take_keyboard_focus) @@ -729,20 +742,20 @@ void LLInventoryPanel::setSelection(const LLUUID& obj_id, BOOL take_keyboard_foc { return; } - mFolders->setSelectionByID(obj_id, take_keyboard_focus); + mFolderRoot->setSelectionByID(obj_id, take_keyboard_focus); } void LLInventoryPanel::setSelectCallback(const LLFolderView::signal_t::slot_type& cb) { - if (mFolders) + if (mFolderRoot) { - mFolders->setSelectCallback(cb); + mFolderRoot->setSelectCallback(cb); } } void LLInventoryPanel::clearSelection() { - mFolders->clearSelection(); + mFolderRoot->clearSelection(); } void LLInventoryPanel::onSelectionChange(const std::deque<LLFolderViewItem*>& items, BOOL user_action) @@ -756,23 +769,21 @@ void LLInventoryPanel::onSelectionChange(const std::deque<LLFolderViewItem*>& it fv->startRenamingSelectedItem(); } } - // Seraph - Put determineFolderType in here for ensemble typing? } void LLInventoryPanel::doToSelected(const LLSD& userdata) { - mFolders->doToSelected(&gInventory, userdata); + mFolderRoot->doToSelected(&gInventory, userdata); } void LLInventoryPanel::doCreate(const LLSD& userdata) { - menu_create_inventory_item(mFolders, LLFolderBridge::sSelf, userdata); + menu_create_inventory_item(mFolderRoot, LLFolderBridge::sSelf.get(), userdata); } bool LLInventoryPanel::beginIMSession() { - std::set<LLUUID> selected_items; - mFolders->getSelectionList(selected_items); + std::set<LLUUID> selected_items = mFolderRoot->getSelectionList(); std::string name; static int session_num = 1; @@ -785,7 +796,7 @@ bool LLInventoryPanel::beginIMSession() { LLUUID item = *iter; - LLFolderViewItem* folder_item = mFolders->getItemByID(item); + LLFolderViewItem* folder_item = mFolderRoot->getItemByID(item); if(folder_item) { @@ -827,7 +838,7 @@ bool LLInventoryPanel::beginIMSession() } else { - LLFolderViewItem* folder_item = mFolders->getItemByID(item); + LLFolderViewItem* folder_item = mFolderRoot->getItemByID(item); if(!folder_item) return true; LLInvFVBridge* listenerp = (LLInvFVBridge*)folder_item->getListener(); @@ -869,49 +880,19 @@ bool LLInventoryPanel::beginIMSession() bool LLInventoryPanel::attachObject(const LLSD& userdata) { - std::set<LLUUID> selected_items; - mFolders->getSelectionList(selected_items); - - std::string joint_name = userdata.asString(); - LLViewerJointAttachment* attachmentp = NULL; - for (LLVOAvatar::attachment_map_t::iterator iter = gAgentAvatarp->mAttachmentPoints.begin(); - iter != gAgentAvatarp->mAttachmentPoints.end(); ) - { - LLVOAvatar::attachment_map_t::iterator curiter = iter++; - LLViewerJointAttachment* attachment = curiter->second; - if (attachment->getName() == joint_name) - { - attachmentp = attachment; - break; - } - } - if (attachmentp == NULL) - { - return true; - } - + // Copy selected item UUIDs to a vector. + std::set<LLUUID> selected_items = mFolderRoot->getSelectionList(); + uuid_vec_t items; for (std::set<LLUUID>::const_iterator set_iter = selected_items.begin(); set_iter != selected_items.end(); ++set_iter) { - const LLUUID &id = *set_iter; - LLViewerInventoryItem* item = (LLViewerInventoryItem*)gInventory.getItem(id); - if(item && gInventory.isObjectDescendentOf(id, gInventory.getRootFolderID())) - { - rez_attachment(item, attachmentp); - } - else if(item && item->isComplete()) - { - // must be in library. copy it to our inventory and put it on. - LLPointer<LLInventoryCallback> cb = new RezAttachmentCallback(attachmentp); - copy_inventory_item(gAgent.getID(), - item->getPermissions().getOwner(), - item->getUUID(), - LLUUID::null, - std::string(), - cb); - } + items.push_back(*set_iter); } + + // Attach selected items. + LLViewerAttachMenu::attachObjects(items, userdata.asString()); + gFocusMgr.setKeyboardFocus(NULL); return true; @@ -927,7 +908,7 @@ BOOL LLInventoryPanel::getSinceLogoff() void LLInventoryPanel::dumpSelectionInformation(void* user_data) { LLInventoryPanel* iv = (LLInventoryPanel*)user_data; - iv->mFolders->dumpSelectionInformation(); + iv->mFolderRoot->dumpSelectionInformation(); } BOOL is_inventorysp_active() @@ -997,3 +978,30 @@ BOOL LLInventoryPanel::getIsHiddenFolderType(LLFolderType::EType folder_type) co { return (std::find(mHiddenFolderTypes.begin(), mHiddenFolderTypes.end(), folder_type) != mHiddenFolderTypes.end()); } + + +/************************************************************************/ +/* Recent Inventory Panel related class */ +/************************************************************************/ +class LLInventoryRecentItemsPanel; +static LLDefaultChildRegistry::Register<LLInventoryRecentItemsPanel> t_recent_inventory_panel("recent_inventory_panel"); + +static const LLRecentInventoryBridgeBuilder RECENT_ITEMS_BUILDER; +class LLInventoryRecentItemsPanel : public LLInventoryPanel +{ +public: + struct Params : public LLInitParam::Block<Params, LLInventoryPanel::Params> + {}; + +protected: + LLInventoryRecentItemsPanel (const Params&); + friend class LLUICtrlFactory; +}; + +LLInventoryRecentItemsPanel::LLInventoryRecentItemsPanel( const Params& params) +: LLInventoryPanel(params) +{ + // replace bridge builder to have necessary View bridges. + mInvFVBridgeBuilder = &RECENT_ITEMS_BUILDER; +} + |