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
meow-7.2.2
Sergei Litovchuk 2009-12-26 18:33:45 +02:00
parent bb0fc4cdf7
commit f416e4a766
2 changed files with 61 additions and 0 deletions

View File

@ -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)
{

View File

@ -104,6 +104,9 @@
<on_click
function="Places.LandmarksGear.Folding.Action"
parameter="expand_all" />
<on_enable
function="Places.LandmarksGear.Enable"
parameter="expand_all" />
</menu_item_call>
<menu_item_call
label="Collapse all folders"
@ -112,6 +115,9 @@
<on_click
function="Places.LandmarksGear.Folding.Action"
parameter="collapse_all" />
<on_enable
function="Places.LandmarksGear.Enable"
parameter="collapse_all" />
</menu_item_call>
<menu_item_check
label="Sort by Date"