diff options
Diffstat (limited to 'indra/newview/llpanellandmarks.cpp')
-rw-r--r-- | indra/newview/llpanellandmarks.cpp | 250 |
1 files changed, 181 insertions, 69 deletions
diff --git a/indra/newview/llpanellandmarks.cpp b/indra/newview/llpanellandmarks.cpp index 40ea75ea7a..45a8dc4cbe 100644 --- a/indra/newview/llpanellandmarks.cpp +++ b/indra/newview/llpanellandmarks.cpp @@ -69,6 +69,10 @@ static const std::string TRASH_BUTTON_NAME = "trash_btn"; // helper functions static void filter_list(LLPlacesInventoryPanel* inventory_list, const std::string& string); static bool category_has_descendents(LLPlacesInventoryPanel* inventory_list); +static void collapse_all_folders(LLFolderView* root_folder); +static void expand_all_folders(LLFolderView* root_folder); +static bool has_expanded_folders(LLFolderView* root_folder); +static bool has_collapsed_folders(LLFolderView* root_folder); /** * Functor counting expanded and collapsed folders in folder view tree to know @@ -683,31 +687,29 @@ void LLLandmarksPanel::updateListCommands() // keep Options & Add Landmark buttons always enabled mListCommands->childSetEnabled(ADD_FOLDER_BUTTON_NAME, add_folder_enabled); mListCommands->childSetEnabled(TRASH_BUTTON_NAME, trash_enabled); - mListCommands->childSetEnabled(OPTIONS_BUTTON_NAME,getCurSelectedItem() != NULL); } void LLLandmarksPanel::onActionsButtonClick() { + LLMenuGL* menu = mGearFolderMenu; + LLFolderViewItem* cur_item = NULL; if(mCurrentSelectedList) - cur_item = mCurrentSelectedList->getRootFolder()->getCurSelectedItem(); - - if(!cur_item) - return; - - LLFolderViewEventListener* listenerp = cur_item->getListener(); - - LLMenuGL* menu =NULL; - if (listenerp->getInventoryType() == LLInventoryType::IT_LANDMARK) - { - menu = mGearLandmarkMenu; - } - else if (listenerp->getInventoryType() == LLInventoryType::IT_CATEGORY) { - mGearFolderMenu->getChild<LLMenuItemCallGL>("expand")->setVisible(!cur_item->isOpen()); - mGearFolderMenu->getChild<LLMenuItemCallGL>("collapse")->setVisible(cur_item->isOpen()); - menu = mGearFolderMenu; + cur_item = mCurrentSelectedList->getRootFolder()->getCurSelectedItem(); + if(!cur_item) + return; + + LLFolderViewEventListener* listenerp = cur_item->getListener(); + if(!listenerp) + return; + + if (listenerp->getInventoryType() == LLInventoryType::IT_LANDMARK) + { + menu = mGearLandmarkMenu; + } } + showActionMenu(menu,OPTIONS_BUTTON_NAME); } @@ -805,26 +807,33 @@ void LLLandmarksPanel::onClipboardAction(const LLSD& userdata) const void LLLandmarksPanel::onFoldingAction(const LLSD& userdata) { - if(!mCurrentSelectedList) return; - - LLFolderView* root_folder = mCurrentSelectedList->getRootFolder(); std::string command_name = userdata.asString(); if ("expand_all" == command_name) { - root_folder->setOpenArrangeRecursively(TRUE, LLFolderViewFolder::RECURSE_DOWN); - root_folder->arrangeAll(); + expand_all_folders(mFavoritesInventoryPanel->getRootFolder()); + expand_all_folders(mLandmarksInventoryPanel->getRootFolder()); + expand_all_folders(mMyInventoryPanel->getRootFolder()); + expand_all_folders(mLibraryInventoryPanel->getRootFolder()); + + for (accordion_tabs_t::const_iterator iter = mAccordionTabs.begin(); iter != mAccordionTabs.end(); ++iter) + { + (*iter)->changeOpenClose(false); + } } else if ("collapse_all" == command_name) { - root_folder->setOpenArrangeRecursively(FALSE, LLFolderViewFolder::RECURSE_DOWN); + collapse_all_folders(mFavoritesInventoryPanel->getRootFolder()); + collapse_all_folders(mLandmarksInventoryPanel->getRootFolder()); + collapse_all_folders(mMyInventoryPanel->getRootFolder()); + collapse_all_folders(mLibraryInventoryPanel->getRootFolder()); - // The top level folder is invisible, it must be open to - // display its sub-folders. - root_folder->openTopLevelFolders(); - root_folder->arrangeAll(); + for (accordion_tabs_t::const_iterator iter = mAccordionTabs.begin(); iter != mAccordionTabs.end(); ++iter) + { + (*iter)->changeOpenClose(true); + } } - else if ( "sort_by_date" == command_name) + else if ("sort_by_date" == command_name) { mSortByDate = !mSortByDate; updateSortOrder(mLandmarksInventoryPanel, mSortByDate); @@ -833,7 +842,10 @@ void LLLandmarksPanel::onFoldingAction(const LLSD& userdata) } else { - root_folder->doToSelected(&gInventory, userdata); + if(mCurrentSelectedList) + { + mCurrentSelectedList->getRootFolder()->doToSelected(&gInventory, userdata); + } } } @@ -853,53 +865,87 @@ bool LLLandmarksPanel::isActionEnabled(const LLSD& userdata) const { std::string command_name = userdata.asString(); - - LLPlacesFolderView* rootFolderView = mCurrentSelectedList ? + LLPlacesFolderView* root_folder_view = mCurrentSelectedList ? static_cast<LLPlacesFolderView*>(mCurrentSelectedList->getRootFolder()) : NULL; - if (NULL == rootFolderView) return false; - - // disable some commands for multi-selection. EXT-1757 - if (rootFolderView->getSelectedCount() > 1) + if ("collapse_all" == command_name) { - if ( "teleport" == command_name - || "more_info" == command_name - || "rename" == command_name - || "show_on_map" == command_name - || "copy_slurl" == command_name - ) + bool disable_collapse_all = !has_expanded_folders(mFavoritesInventoryPanel->getRootFolder()) + && !has_expanded_folders(mLandmarksInventoryPanel->getRootFolder()) + && !has_expanded_folders(mMyInventoryPanel->getRootFolder()) + && !has_expanded_folders(mLibraryInventoryPanel->getRootFolder()); + if (disable_collapse_all) { - return false; + for (accordion_tabs_t::const_iterator iter = mAccordionTabs.begin(); iter != mAccordionTabs.end(); ++iter) + { + if ((*iter)->isExpanded()) + { + disable_collapse_all = false; + break; + } + } } + return !disable_collapse_all; } + else if ("expand_all" == command_name) + { + bool disable_expand_all = !has_collapsed_folders(mFavoritesInventoryPanel->getRootFolder()) + && !has_collapsed_folders(mLandmarksInventoryPanel->getRootFolder()) + && !has_collapsed_folders(mMyInventoryPanel->getRootFolder()) + && !has_collapsed_folders(mLibraryInventoryPanel->getRootFolder()); + if (disable_expand_all) + { + for (accordion_tabs_t::const_iterator iter = mAccordionTabs.begin(); iter != mAccordionTabs.end(); ++iter) + { + if (!(*iter)->isExpanded()) + { + disable_expand_all = false; + break; + } + } + } - // disable some commands for Favorites accordion. EXT-1758 - if (mCurrentSelectedList == mFavoritesInventoryPanel) + return !disable_expand_all; + } + else if ("sort_by_date" == command_name) { - if ( "expand_all" == command_name - || "collapse_all" == command_name - || "sort_by_date" == command_name - ) + // disable "sort_by_date" for Favorites accordion because + // it has its own items order. EXT-1758 + if (mCurrentSelectedList == mFavoritesInventoryPanel) + { return false; + } } - - LLCheckFolderState checker; - rootFolderView->applyFunctorRecursively(checker); - - // We assume that the root folder is always expanded so we enable "collapse_all" - // command when we have at least one more expanded folder. - if (checker.getExpandedFolders() < 2 && "collapse_all" == command_name) + else if (!root_folder_view) { return false; } - - if (checker.getCollapsedFolders() < 1 && "expand_all" == command_name) + else if ( "paste" == command_name + || "rename" == command_name + || "cut" == command_name + || "copy" == command_name + || "delete" == command_name + || "collapse" == command_name + || "expand" == command_name + ) { - return false; + return canSelectedBeModified(command_name); } - - if("category" == command_name) + else if ( "teleport" == command_name + || "more_info" == command_name + || "rename" == command_name + || "show_on_map" == command_name + || "copy_slurl" == command_name + ) + { + // disable some commands for multi-selection. EXT-1757 + if (root_folder_view->getSelectedCount() > 1) + { + return false; + } + } + else if("category" == command_name) { // we can add folder only in Landmarks Accordion if (mCurrentSelectedList == mLandmarksInventoryPanel) @@ -909,10 +955,6 @@ bool LLLandmarksPanel::isActionEnabled(const LLSD& userdata) const } else return false; } - else if("paste" == command_name || "rename" == command_name || "cut" == command_name || "delete" == command_name) - { - return canSelectedBeModified(command_name); - } else if("create_pick" == command_name) { std::set<LLUUID> selection; @@ -970,6 +1012,9 @@ bool LLLandmarksPanel::canSelectedBeModified(const std::string& command_name) co { // validate own rules first + LLFolderViewItem* selected = getCurSelectedItem(); + if (!selected) return false; + // nothing can be modified in Library if (mLibraryInventoryPanel == mCurrentSelectedList) return false; @@ -996,24 +1041,41 @@ bool LLLandmarksPanel::canSelectedBeModified(const std::string& command_name) co } // then ask LLFolderView permissions + + LLFolderView* root_folder = mCurrentSelectedList->getRootFolder(); + + if ("copy" == command_name) + { + return root_folder->canCopy(); + } + else if ("collapse" == command_name) + { + return selected->isOpen(); + } + else if ("expand" == command_name) + { + return !selected->isOpen(); + } + if (can_be_modified) { - LLFolderViewItem* selected = getCurSelectedItem(); + LLFolderViewEventListener* listenerp = selected->getListener(); + if ("cut" == command_name) { - can_be_modified = mCurrentSelectedList->getRootFolder()->canCut(); + can_be_modified = root_folder->canCut(); } else if ("rename" == command_name) { - can_be_modified = selected ? selected->getListener()->isItemRenameable() : false; + can_be_modified = listenerp ? listenerp->isItemRenameable() : false; } else if ("delete" == command_name) { - can_be_modified = selected ? selected->getListener()->isItemRemovable(): false; + can_be_modified = listenerp ? listenerp->isItemRemovable() : false; } else if("paste" == command_name) { - return mCurrentSelectedList->getRootFolder()->canPaste(); + can_be_modified = root_folder->canPaste(); } else { @@ -1197,4 +1259,54 @@ static bool category_has_descendents(LLPlacesInventoryPanel* inventory_list) return false; } + +static void collapse_all_folders(LLFolderView* root_folder) +{ + if (!root_folder) + return; + + root_folder->setOpenArrangeRecursively(FALSE, LLFolderViewFolder::RECURSE_DOWN); + + // The top level folder is invisible, it must be open to + // display its sub-folders. + root_folder->openTopLevelFolders(); + root_folder->arrangeAll(); +} + +static void expand_all_folders(LLFolderView* root_folder) +{ + if (!root_folder) + return; + + root_folder->setOpenArrangeRecursively(TRUE, LLFolderViewFolder::RECURSE_DOWN); + root_folder->arrangeAll(); +} + +static bool has_expanded_folders(LLFolderView* root_folder) +{ + LLCheckFolderState checker; + root_folder->applyFunctorRecursively(checker); + + // We assume that the root folder is always expanded so we enable "collapse_all" + // command when we have at least one more expanded folder. + if (checker.getExpandedFolders() < 2) + { + return false; + } + + return true; +} + +static bool has_collapsed_folders(LLFolderView* root_folder) +{ + LLCheckFolderState checker; + root_folder->applyFunctorRecursively(checker); + + if (checker.getCollapsedFolders() < 1) + { + return false; + } + + return true; +} // EOF |