void LLInventoryPanel::setSelection(const LLUUID& obj_id, BOOL take_keyboard_focus) { LLFolderViewItem* itemp = mFolders->getItemByID(obj_id); if(itemp && itemp->getListener()) { itemp->getListener()->arrangeAndSet(itemp, TRUE, take_keyboard_focus); } }
void LLInventoryPanel::setSelection(const LLUUID& obj_id, BOOL take_keyboard_focus) { LLFolderViewItem* itemp = mFolders->getItemByID(obj_id); if(itemp && itemp->getListener()) { itemp->getListener()->arrangeAndSet(itemp, TRUE, take_keyboard_focus); mSelectThisID.setNull(); return; } else { // save the desired item to be selected later (if/when ready) mSelectThisID = obj_id; } }
void LLLandmarksPanel::onAddAction(const LLSD& userdata) const { std::string command_name = userdata.asString(); if("add_landmark" == command_name) { LLViewerInventoryItem* landmark = LLLandmarkActions::findLandmarkForAgentPos(); if(landmark) { LLNotificationsUtil::add("LandmarkAlreadyExists"); } else { LLSideTray::getInstance()->showPanel("panel_places", LLSD().with("type", "create_landmark")); } } else if ("category" == command_name) { LLFolderViewItem* item = getCurSelectedItem(); if (item && mCurrentSelectedList == mLandmarksInventoryPanel) { LLFolderViewEventListener* folder_bridge = NULL; if (item-> getListener()->getInventoryType() == LLInventoryType::IT_LANDMARK) { // for a landmark get parent folder bridge folder_bridge = item->getParentFolder()->getListener(); } else if (item-> getListener()->getInventoryType() == LLInventoryType::IT_CATEGORY) { // for a folder get its own bridge folder_bridge = item->getListener(); } menu_create_inventory_item(mCurrentSelectedList->getRootFolder(), dynamic_cast<LLFolderBridge*> (folder_bridge), LLSD( "category"), gInventory.findCategoryUUIDForType( LLFolderType::FT_LANDMARK)); } else { //in case My Landmarks tab is completely empty (thus cannot be determined as being selected) menu_create_inventory_item(mLandmarksInventoryPanel->getRootFolder(), NULL, LLSD("category"), gInventory.findCategoryUUIDForType(LLFolderType::FT_LANDMARK)); if (mMyLandmarksAccordionTab) { mMyLandmarksAccordionTab->changeOpenClose(false); } } } }
void LLLandmarksPanel::onMenuVisibilityChange(LLUICtrl* ctrl, const LLSD& param) { bool new_visibility = param["visibility"].asBoolean(); // We don't have to update items visibility if the menu is hiding. if (!new_visibility) return; BOOL are_any_items_in_trash = FALSE; BOOL are_all_items_in_trash = TRUE; LLFolderView* root_folder_view = mCurrentSelectedList ? mCurrentSelectedList->getRootFolder() : NULL; if(root_folder_view) { const LLUUID trash_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_TRASH); std::set<LLUUID> selected_uuids = root_folder_view->getSelectionList(); // Iterate through selected items to find out if any of these items are in Trash // or all the items are in Trash category. for (std::set<LLUUID>::const_iterator iter = selected_uuids.begin(); iter != selected_uuids.end(); ++iter) { LLFolderViewItem* item = root_folder_view->getItemByID(*iter); // If no item is found it might be a folder id. if (!item) { item = root_folder_view->getFolderByID(*iter); } if (!item) continue; LLFolderViewEventListener* listenerp = item->getListener(); if(!listenerp) continue; // Trash category itself should not be included because it can't be // actually restored from trash. are_all_items_in_trash &= listenerp->isItemInTrash() && *iter != trash_id; // If there are any selected items in Trash including the Trash category itself // we show "Restore Item" in context menu and hide other irrelevant items. are_any_items_in_trash |= listenerp->isItemInTrash(); } } // Display "Restore Item" menu entry if at least one of the selected items // is in Trash or the Trash category itself is among selected items. // Hide other menu entries in this case. // Enable this menu entry only if all selected items are in the Trash category. toggle_restore_menu((LLMenuGL*)ctrl, are_any_items_in_trash, are_all_items_in_trash); }
void LLInventoryPanel::modelChanged(U32 mask) { LLFastTimer t2(LLFastTimer::FTM_REFRESH); bool handled = false; if(mask & LLInventoryObserver::LABEL) { handled = true; // label change - empty out the display name for each object // in this change set. const std::set<LLUUID>& changed_items = gInventory.getChangedIDs(); std::set<LLUUID>::const_iterator id_it = changed_items.begin(); std::set<LLUUID>::const_iterator id_end = changed_items.end(); LLFolderViewItem* view = NULL; LLInvFVBridge* bridge = NULL; for (;id_it != id_end; ++id_it) { view = mFolders->getItemByID(*id_it); if(view) { // request refresh on this item (also flags for filtering) bridge = (LLInvFVBridge*)view->getListener(); if(bridge) { // Clear the display name first, so it gets properly re-built during refresh() bridge->clearDisplayName(); } view->refresh(); } } } if((mask & (LLInventoryObserver::STRUCTURE | LLInventoryObserver::ADD | LLInventoryObserver::REMOVE)) != 0) { handled = true; // Record which folders are open by uuid. LLInventoryModel* model = getModel(); if (model) { const std::set<LLUUID>& changed_items = gInventory.getChangedIDs(); std::set<LLUUID>::const_iterator id_it = changed_items.begin(); std::set<LLUUID>::const_iterator id_end = changed_items.end(); for (;id_it != id_end; ++id_it) { // sync view with model LLInventoryObject* model_item = model->getObject(*id_it); LLFolderViewItem* view_item = mFolders->getItemByID(*id_it); if (model_item) { if (!view_item) { // this object was just created, need to build a view for it if ((mask & LLInventoryObserver::ADD) != LLInventoryObserver::ADD) { llwarns << *id_it << " is in model but not in view, but ADD flag not set" << llendl; } buildNewViews(*id_it); // select any newly created object // that has the auto rename at top of folder // root set if(mFolders->getRoot()->needsAutoRename()) { setSelection(*id_it, FALSE); } } else { // this object was probably moved, check its parent if ((mask & LLInventoryObserver::STRUCTURE) != LLInventoryObserver::STRUCTURE) { llwarns << *id_it << " is in model and in view, but STRUCTURE flag not set" << llendl; } LLFolderViewFolder* new_parent = (LLFolderViewFolder*)mFolders->getItemByID(model_item->getParentUUID()); if (view_item->getParentFolder() != new_parent) { view_item->getParentFolder()->extractItem(view_item); view_item->addToFolder(new_parent, mFolders); } } } else { if (view_item) { if ((mask & LLInventoryObserver::REMOVE) != LLInventoryObserver::REMOVE) { llwarns << *id_it << " is not in model but in view, but REMOVE flag not set" << llendl; } // item in view but not model, need to delete view view_item->destroyView(); } else { llwarns << *id_it << "Item does not exist in either view or model, but notification triggered" << llendl; } } } } } if (!handled) { // it's a small change that only requires a refresh. // *TODO: figure out a more efficient way to do the refresh // since it is expensive on large inventories mFolders->refresh(); } }
BOOL LLPanelMainInventory::isActionEnabled(const LLSD& userdata) { const std::string command_name = userdata.asString(); if (command_name == "delete") { BOOL can_delete = FALSE; LLFolderView* root = getActivePanel()->getRootFolder(); if (root) { can_delete = TRUE; std::set<LLUUID> selection_set = root->getSelectionList(); if (selection_set.empty()) return FALSE; for (std::set<LLUUID>::iterator iter = selection_set.begin(); iter != selection_set.end(); ++iter) { const LLUUID &item_id = (*iter); LLFolderViewItem *item = root->getItemByID(item_id); const LLFolderViewEventListener *listener = item->getListener(); llassert(listener); if (!listener) return FALSE; can_delete &= listener->isItemRemovable(); can_delete &= !listener->isItemInTrash(); } return can_delete; } return FALSE; } if (command_name == "save_texture") { return isSaveTextureEnabled(userdata); } if (command_name == "find_original") { LLFolderViewItem* current_item = getActivePanel()->getRootFolder()->getCurSelectedItem(); if (!current_item) return FALSE; const LLUUID& item_id = current_item->getListener()->getUUID(); const LLViewerInventoryItem *item = gInventory.getItem(item_id); if (item && item->getIsLinkType() && !item->getIsBrokenLink()) { return TRUE; } return FALSE; } if (command_name == "find_links") { LLFolderView* root = getActivePanel()->getRootFolder(); std::set<LLUUID> selection_set = root->getSelectionList(); if (selection_set.size() != 1) return FALSE; LLFolderViewItem* current_item = root->getCurSelectedItem(); if (!current_item) return FALSE; const LLUUID& item_id = current_item->getListener()->getUUID(); const LLInventoryObject *obj = gInventory.getObject(item_id); if (obj && !obj->getIsLinkType() && LLAssetType::lookupCanLink(obj->getType())) { return TRUE; } return FALSE; } // This doesn't currently work, since the viewer can't change an assetID an item. if (command_name == "regenerate_link") { LLFolderViewItem* current_item = getActivePanel()->getRootFolder()->getCurSelectedItem(); if (!current_item) return FALSE; const LLUUID& item_id = current_item->getListener()->getUUID(); const LLViewerInventoryItem *item = gInventory.getItem(item_id); if (item && item->getIsBrokenLink()) { return TRUE; } return FALSE; } if (command_name == "share") { LLSidepanelInventory* parent = dynamic_cast<LLSidepanelInventory*>(LLSideTray::getInstance()->getPanel("sidepanel_inventory")); return parent ? parent->canShare() : FALSE; } return TRUE; }
BOOL LLPanelOutfitsInventory::isActionEnabled(const LLSD& userdata) { const std::string command_name = userdata.asString(); if (command_name == "delete" || command_name == "remove") { BOOL can_delete = FALSE; LLFolderView *folder = getActivePanel()->getRootFolder(); if (folder) { std::set<LLUUID> selection_set; folder->getSelectionList(selection_set); can_delete = (selection_set.size() > 0); for (std::set<LLUUID>::iterator iter = selection_set.begin(); iter != selection_set.end(); ++iter) { const LLUUID &item_id = (*iter); LLFolderViewItem *item = folder->getItemByID(item_id); can_delete &= item->getListener()->isItemRemovable(); } return can_delete; } return FALSE; } if (command_name == "remove_link") { BOOL can_delete = FALSE; LLFolderView *folder = getActivePanel()->getRootFolder(); if (folder) { std::set<LLUUID> selection_set; folder->getSelectionList(selection_set); can_delete = (selection_set.size() > 0); for (std::set<LLUUID>::iterator iter = selection_set.begin(); iter != selection_set.end(); ++iter) { const LLUUID &item_id = (*iter); LLViewerInventoryItem *item = gInventory.getItem(item_id); if (!item || !item->getIsLinkType()) return FALSE; } return can_delete; } return FALSE; } if (command_name == "rename" || command_name == "delete_outfit") { return (getCorrectListenerForAction() != NULL) && hasItemsSelected(); } if (command_name == "wear") { if (isCOFPanelActive()) { return FALSE; } } if (command_name == "make_outfit") { return TRUE; } if (command_name == "edit" || command_name == "add" ) { return (getCorrectListenerForAction() != NULL); } return TRUE; }