summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
authorSergei Litovchuk <slitovchuk@productengine.com>2010-02-22 19:52:28 +0200
committerSergei Litovchuk <slitovchuk@productengine.com>2010-02-22 19:52:28 +0200
commitdcc39faab49bcb9b8784ce57447f92f9e8dbc777 (patch)
tree32ad079c196a2c1e91ad59da4bcbb4959ec921eb /indra/newview
parent16b284971ebb6ecb41ba65d5fd9da87bc08bcba3 (diff)
Fixed normal bug (EXT-5330) No way to collapse/expand accordions on My
Landmarks panel. - "Expand All" and "Collapse All" now affect all accordions in "My Landmarks". --HG-- branch : product-engine
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/llpanellandmarks.cpp248
-rw-r--r--indra/newview/skins/default/xui/en/menu_places_gear_folder.xml9
2 files changed, 189 insertions, 68 deletions
diff --git a/indra/newview/llpanellandmarks.cpp b/indra/newview/llpanellandmarks.cpp
index 40ea75ea7a..01fbf6f7fc 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 ?
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 (!rootFolderView)
{
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 (rootFolderView->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
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 9b3948b29b..3e38503e43 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
@@ -45,6 +45,9 @@
<on_click
function="Places.LandmarksGear.CopyPaste.Action"
parameter="copy" />
+ <on_enable
+ function="Places.LandmarksGear.Enable"
+ parameter="copy" />
</menu_item_call>
<menu_item_call
label="Paste"
@@ -88,6 +91,9 @@
<on_click
function="Places.LandmarksGear.Folding.Action"
parameter="expand" />
+ <on_enable
+ function="Places.LandmarksGear.Enable"
+ parameter="expand" />
</menu_item_call>
<menu_item_call
label="Collapse"
@@ -96,6 +102,9 @@
<on_click
function="Places.LandmarksGear.Folding.Action"
parameter="collapse" />
+ <on_enable
+ function="Places.LandmarksGear.Enable"
+ parameter="collapse" />
</menu_item_call>
<menu_item_call
label="Expand all folders"