diff options
Diffstat (limited to 'indra/newview/llpanellandmarks.cpp')
-rw-r--r-- | indra/newview/llpanellandmarks.cpp | 328 |
1 files changed, 249 insertions, 79 deletions
diff --git a/indra/newview/llpanellandmarks.cpp b/indra/newview/llpanellandmarks.cpp index 47feef496a..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 @@ -111,25 +115,76 @@ void LLCheckFolderState::doFolder(LLFolderViewFolder* folder) } } +// Functor searching and opening a folder specified by UUID +// in a folder view tree. +class LLOpenFolderByID : public LLFolderViewFunctor +{ +public: + LLOpenFolderByID(const LLUUID& folder_id) + : mFolderID(folder_id) + , mIsFolderOpen(false) + {} + virtual ~LLOpenFolderByID() {} + /*virtual*/ void doFolder(LLFolderViewFolder* folder); + /*virtual*/ void doItem(LLFolderViewItem* item) {} + + bool isFolderOpen() { return mIsFolderOpen; } + +private: + bool mIsFolderOpen; + LLUUID mFolderID; +}; + +// virtual +void LLOpenFolderByID::doFolder(LLFolderViewFolder* folder) +{ + if (folder->getListener() && folder->getListener()->getUUID() == mFolderID) + { + if (!folder->isOpen()) + { + folder->setOpen(TRUE); + mIsFolderOpen = true; + } + } +} + /** * 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 * empty folder message when Landmarks inventory category has no children. + * Ensures that "Landmarks" folder in the Library is open on strart up. */ class LLLandmarksPanelObserver : public LLInventoryObserver { public: - LLLandmarksPanelObserver(LLLandmarksPanel* lp) : mLP(lp) {} + LLLandmarksPanelObserver(LLLandmarksPanel* lp) + : mLP(lp), + mIsLibraryLandmarksOpen(false) + {} virtual ~LLLandmarksPanelObserver() {} /*virtual*/ void changed(U32 mask); private: LLLandmarksPanel* mLP; + bool mIsLibraryLandmarksOpen; }; void LLLandmarksPanelObserver::changed(U32 mask) { mLP->updateShowFolderState(); + + LLPlacesInventoryPanel* library = mLP->getLibraryInventoryPanel(); + if (!mIsLibraryLandmarksOpen && library) + { + // Search for "Landmarks" folder in the Library and open it once on start up. See EXT-4827. + const LLUUID &landmarks_cat = gInventory.findCategoryUUIDForType(LLFolderType::FT_LANDMARK, false, true); + if (landmarks_cat.notNull()) + { + LLOpenFolderByID opener(landmarks_cat); + library->getRootFolder()->applyFunctorRecursively(opener); + mIsLibraryLandmarksOpen = opener.isFolderOpen(); + } + } } LLLandmarksPanel::LLLandmarksPanel() @@ -171,8 +226,6 @@ BOOL LLLandmarksPanel::postBuild() initLandmarksInventoryPanel(); initMyInventoryPanel(); initLibraryInventoryPanel(); - getChild<LLAccordionCtrlTab>("tab_favorites")->setDisplayChildren(true); - getChild<LLAccordionCtrlTab>("tab_landmarks")->setDisplayChildren(true); return TRUE; } @@ -462,7 +515,7 @@ void LLLandmarksPanel::initFavoritesInventoryPanel() initLandmarksPanel(mFavoritesInventoryPanel); mFavoritesInventoryPanel->getFilter()->setEmptyLookupMessage("FavoritesNoMatchingItems"); - initAccordion("tab_favorites", mFavoritesInventoryPanel); + initAccordion("tab_favorites", mFavoritesInventoryPanel, true); } void LLLandmarksPanel::initLandmarksInventoryPanel() @@ -481,7 +534,7 @@ void LLLandmarksPanel::initLandmarksInventoryPanel() // subscribe to have auto-rename functionality while creating New Folder mLandmarksInventoryPanel->setSelectCallback(boost::bind(&LLInventoryPanel::onSelectionChange, mLandmarksInventoryPanel, _1, _2)); - initAccordion("tab_landmarks", mLandmarksInventoryPanel); + initAccordion("tab_landmarks", mLandmarksInventoryPanel, true); } void LLLandmarksPanel::initMyInventoryPanel() @@ -490,7 +543,7 @@ void LLLandmarksPanel::initMyInventoryPanel() initLandmarksPanel(mMyInventoryPanel); - initAccordion("tab_inventory", mMyInventoryPanel); + initAccordion("tab_inventory", mMyInventoryPanel, false); } void LLLandmarksPanel::initLibraryInventoryPanel() @@ -499,7 +552,15 @@ void LLLandmarksPanel::initLibraryInventoryPanel() initLandmarksPanel(mLibraryInventoryPanel); - initAccordion("tab_library", mLibraryInventoryPanel); + // We want to fetch only "Landmarks" category from the library. + const LLUUID &landmarks_cat = gInventory.findCategoryUUIDForType(LLFolderType::FT_LANDMARK, false, true); + if (landmarks_cat.notNull()) + { + gInventory.startBackgroundFetch(landmarks_cat); + } + + // Expanding "Library" tab for new users who have no landmarks in "My Inventory". + initAccordion("tab_library", mLibraryInventoryPanel, true); } void LLLandmarksPanel::initLandmarksPanel(LLPlacesInventoryPanel* inventory_list) @@ -520,20 +581,21 @@ void LLLandmarksPanel::initLandmarksPanel(LLPlacesInventoryPanel* inventory_list { root_folder->setupMenuHandle(LLInventoryType::IT_CATEGORY, mGearFolderMenu->getHandle()); root_folder->setupMenuHandle(LLInventoryType::IT_LANDMARK, mGearLandmarkMenu->getHandle()); + + root_folder->setParentLandmarksPanel(this); } - root_folder->setParentLandmarksPanel(this); inventory_list->saveFolderState(); } -void LLLandmarksPanel::initAccordion(const std::string& accordion_tab_name, LLPlacesInventoryPanel* inventory_list) +void LLLandmarksPanel::initAccordion(const std::string& accordion_tab_name, LLPlacesInventoryPanel* inventory_list, bool expand_tab) { LLAccordionCtrlTab* accordion_tab = getChild<LLAccordionCtrlTab>(accordion_tab_name); mAccordionTabs.push_back(accordion_tab); accordion_tab->setDropDownStateChangedCallback( boost::bind(&LLLandmarksPanel::onAccordionExpandedCollapsed, this, _2, inventory_list)); - accordion_tab->setDisplayChildren(false); + accordion_tab->setDisplayChildren(expand_tab); } void LLLandmarksPanel::onAccordionExpandedCollapsed(const LLSD& param, LLPlacesInventoryPanel* inventory_list) @@ -625,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); } @@ -747,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); @@ -775,7 +842,10 @@ void LLLandmarksPanel::onFoldingAction(const LLSD& userdata) } else { - root_folder->doToSelected(&gInventory, userdata); + if(mCurrentSelectedList) + { + mCurrentSelectedList->getRootFolder()->doToSelected(&gInventory, userdata); + } } } @@ -795,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) @@ -851,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; @@ -912,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; @@ -938,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 { @@ -1139,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 |