From f416e4a7662d8c49a816ac764e29d8d2c2fbd062 Mon Sep 17 00:00:00 2001 From: Sergei Litovchuk Date: Sat, 26 Dec 2009 18:33:45 +0200 Subject: Fixed low bug EXT-3345 ""Expand all folders" ability is enabled while all folders are expanded in "My Landmarks" tab". - Added check for folder view's folders being in expanded or collapsed state on "My Landmarks" tab. - Added enabling/disabling of "Expand all folders" and "Collapse all folders" commands for landmark and folder "gear" menu. --HG-- branch : product-engine --- indra/newview/llpanellandmarks.cpp | 55 ++++++++++++++++++++++ .../default/xui/en/menu_places_gear_folder.xml | 6 +++ 2 files changed, 61 insertions(+) diff --git a/indra/newview/llpanellandmarks.cpp b/indra/newview/llpanellandmarks.cpp index d75744ead9..87abb16395 100644 --- a/indra/newview/llpanellandmarks.cpp +++ b/indra/newview/llpanellandmarks.cpp @@ -69,6 +69,47 @@ static const std::string TRASH_BUTTON_NAME = "trash_btn"; static void filter_list(LLPlacesInventoryPanel* inventory_list, const std::string& string); static bool category_has_descendents(LLPlacesInventoryPanel* inventory_list); +/** + * Functor counting expanded and collapsed folders in folder view tree to know + * when to enable or disable "Expand all folders" and "Collapse all folders" commands. + */ +class LLCheckFolderState : public LLFolderViewFunctor +{ +public: + LLCheckFolderState() + : mCollapsedFolders(0), + mExpandedFolders(0) + {} + virtual ~LLCheckFolderState() {} + virtual void doFolder(LLFolderViewFolder* folder); + virtual void doItem(LLFolderViewItem* item) {} + S32 getCollapsedFolders() { return mCollapsedFolders; } + S32 getExpandedFolders() { return mExpandedFolders; } + +private: + S32 mCollapsedFolders; + S32 mExpandedFolders; +}; + +// virtual +void LLCheckFolderState::doFolder(LLFolderViewFolder* folder) +{ + // Counting only folders that pass the filter. + // The listener check allow us to avoid counting the folder view + // object itself because it has no listener assigned. + if (folder->hasFilteredDescendants() && folder->getListener()) + { + if (folder->isOpen()) + { + ++mExpandedFolders; + } + else + { + ++mCollapsedFolders; + } + } +} + /** * Bridge to support knowing when the inventory has changed to update Landmarks tab * ShowFolderState filter setting to show all folders when the filter string is empty and @@ -728,6 +769,20 @@ bool LLLandmarksPanel::isActionEnabled(const LLSD& userdata) const 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) + { + return false; + } + + if (checker.getCollapsedFolders() < 1 && "expand_all" == command_name) + { + return false; + } if("category" == command_name) { diff --git a/indra/newview/skins/default/xui/en/menu_places_gear_folder.xml b/indra/newview/skins/default/xui/en/menu_places_gear_folder.xml index c849188699..9b3948b29b 100644 --- a/indra/newview/skins/default/xui/en/menu_places_gear_folder.xml +++ b/indra/newview/skins/default/xui/en/menu_places_gear_folder.xml @@ -104,6 +104,9 @@ + +