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); }
/* Processes such actions: cut/rename/delete/paste actions Rules: 1. We can't perform any action in Library 2. For Landmarks we can: - cut/rename/delete in any other accordions - paste - only in Favorites, Landmarks accordions 3. For Folders we can: perform any action in Landmarks accordion, except Received folder 4. We can not paste folders from Clipboard (processed by LLFolderView::canPaste()) 5. Check LLFolderView/Inventory Bridges rules */ bool LLLandmarksPanel::canItemBeModified(const std::string& command_name, LLFolderViewItem* item) const { // validate own rules first if (!item) return false; // nothing can be modified in Library if (mLibraryInventoryPanel == mCurrentSelectedList) return false; bool can_be_modified = false; // landmarks can be modified in any other accordion... if (item->getListener()->getInventoryType() == LLInventoryType::IT_LANDMARK) { can_be_modified = true; // we can modify landmarks anywhere except paste to My Inventory if ("paste" == command_name) { can_be_modified = (mCurrentSelectedList != mMyInventoryPanel); } } else { // ...folders only in the Landmarks accordion... can_be_modified = mLandmarksInventoryPanel == mCurrentSelectedList; // ...except "Received" folder can_be_modified &= !isReceivedFolderSelected(); } // then ask LLFolderView permissions LLFolderView* root_folder = mCurrentSelectedList->getRootFolder(); if ("copy" == command_name) { return root_folder->canCopy(); } else if ("collapse" == command_name) { return item->isOpen(); } else if ("expand" == command_name) { return !item->isOpen(); } if (can_be_modified) { LLFolderViewEventListener* listenerp = item->getListener(); if ("cut" == command_name) { // "Cut" disabled for folders. See EXT-8697. can_be_modified = root_folder->canCut() && listenerp->getInventoryType() != LLInventoryType::IT_CATEGORY; } else if ("rename" == command_name) { can_be_modified = listenerp ? listenerp->isItemRenameable() : false; } else if ("delete" == command_name) { can_be_modified = listenerp ? listenerp->isItemRemovable() && !listenerp->isItemInTrash() : false; } else if("paste" == command_name) { can_be_modified = root_folder->canPaste(); } else { llwarns << "Unprocessed command has come: " << command_name << llendl; } } return can_be_modified; }