diff options
Diffstat (limited to 'indra/newview/llpanellandmarks.cpp')
-rw-r--r-- | indra/newview/llpanellandmarks.cpp | 82 |
1 files changed, 67 insertions, 15 deletions
diff --git a/indra/newview/llpanellandmarks.cpp b/indra/newview/llpanellandmarks.cpp index 998f508a8c..35cd3edc81 100644 --- a/indra/newview/llpanellandmarks.cpp +++ b/indra/newview/llpanellandmarks.cpp @@ -67,6 +67,30 @@ static const std::string TRASH_BUTTON_NAME = "trash_btn"; // helper functions static void filter_list(LLInventorySubTreePanel* inventory_list, const std::string& string); +static void save_folder_state_if_no_filter(LLInventorySubTreePanel* inventory_list); + +/** + * Bridge to support knowing when the inventory has changed to update folder (open/close) state + * for landmarks panels. + * + * Due to Inventory data are loaded in background we need to save folder state each time + * next level is loaded. See EXT-3094. + */ +class LLLandmarksPanelObserver : public LLInventoryObserver +{ +public: + LLLandmarksPanelObserver(LLLandmarksPanel* lp) : mLP(lp) {} + virtual ~LLLandmarksPanelObserver() {} + /*virtual*/ void changed(U32 mask); + +private: + LLLandmarksPanel* mLP; +}; + +void LLLandmarksPanelObserver::changed(U32 mask) +{ + mLP->saveFolderStateIfNoFilter(); +} LLLandmarksPanel::LLLandmarksPanel() : LLPanelPlacesTab() @@ -79,11 +103,18 @@ LLLandmarksPanel::LLLandmarksPanel() , mGearFolderMenu(NULL) , mGearLandmarkMenu(NULL) { + mInventoryObserver = new LLLandmarksPanelObserver(this); + gInventory.addObserver(mInventoryObserver); + LLUICtrlFactory::getInstance()->buildPanel(this, "panel_landmarks.xml"); } LLLandmarksPanel::~LLLandmarksPanel() { + if (gInventory.containsObserver(mInventoryObserver)) + { + gInventory.removeObserver(mInventoryObserver); + } } BOOL LLLandmarksPanel::postBuild() @@ -126,7 +157,10 @@ void LLLandmarksPanel::onSearchEdit(const std::string& string) tab->setVisible(TRUE); // expand accordion to see matched items in each one. See EXT-2014. - tab->changeOpenClose(false); + if (string != "") + { + tab->changeOpenClose(false); + } LLInventorySubTreePanel* inventory_list = dynamic_cast<LLInventorySubTreePanel*>(tab->getAccordionView()); if (NULL == inventory_list) continue; @@ -224,6 +258,14 @@ void LLLandmarksPanel::onSelectorButtonClicked() } } +void LLLandmarksPanel::saveFolderStateIfNoFilter() +{ + save_folder_state_if_no_filter(mFavoritesInventoryPanel); + save_folder_state_if_no_filter(mLandmarksInventoryPanel); + save_folder_state_if_no_filter(mMyInventoryPanel); + save_folder_state_if_no_filter(mLibraryInventoryPanel); +} + ////////////////////////////////////////////////////////////////////////// // PROTECTED METHODS ////////////////////////////////////////////////////////////////////////// @@ -325,6 +367,7 @@ void LLLandmarksPanel::initFavoritesInventoryPanel() mFavoritesInventoryPanel = getChild<LLInventorySubTreePanel>("favorites_list"); initLandmarksPanel(mFavoritesInventoryPanel); + mFavoritesInventoryPanel->getFilter()->setEmptyLookupMessage("FavoritesNoMatchingItems"); initAccordion("tab_favorites", mFavoritesInventoryPanel); } @@ -387,9 +430,6 @@ void LLLandmarksPanel::initLandmarksPanel(LLInventorySubTreePanel* inventory_lis } root_folder->setParentLandmarksPanel(this); - - // save initial folder state to avoid incorrect work while switching between Landmarks & Teleport History tabs - // See EXT-1609. inventory_list->saveFolderState(); } @@ -745,7 +785,7 @@ void LLLandmarksPanel::updateFilteredAccordions() { LLInventoryPanel* inventory_list = NULL; LLAccordionCtrlTab* accordion_tab = NULL; -// bool needs_arrange = false; + bool needs_arrange = false; for (accordion_tabs_t::const_iterator iter = mAccordionTabs.begin(); iter != mAccordionTabs.end(); ++iter) { @@ -757,7 +797,7 @@ void LLLandmarksPanel::updateFilteredAccordions() if (NULL == inventory_list) continue; // This doesn't seem to work correctly. Disabling for now. -Seraph - /* + // Enabled to show/hide accordions with/without landmarks. See EXT-2346. (Seth PE) LLFolderView* fv = inventory_list->getRootFolder(); // arrange folder view contents to draw its descendants if it has any @@ -768,17 +808,17 @@ void LLLandmarksPanel::updateFilteredAccordions() needs_arrange = true; accordion_tab->setVisible(has_descendants); - */ - accordion_tab->setVisible(TRUE); + + //accordion_tab->setVisible(TRUE); } // we have to arrange accordion tabs for cases when filter string is less restrictive but // all items are still filtered. -// if (needs_arrange) -// { + if (needs_arrange) + { static LLAccordionCtrl* accordion = getChild<LLAccordionCtrl>("landmarks_accordion"); accordion->arrange(); -// } + } } /* @@ -993,15 +1033,17 @@ void LLLandmarksPanel::doCreatePick(LLLandmark* landmark) ////////////////////////////////////////////////////////////////////////// static void filter_list(LLInventorySubTreePanel* inventory_list, const std::string& string) { + // When search is cleared, restore the old folder state. if (string == "") { inventory_list->setFilterSubString(LLStringUtil::null); - - // re-open folders that were initially open + // Re-open folders that were open before inventory_list->restoreFolderState(); } - gInventory.startBackgroundFetch(); + // Open the immediate children of the root folder, since those + // are invisible in the UI and thus must always be open. + inventory_list->getRootFolder()->openTopLevelFolders(); if (inventory_list->getFilterSubString().empty() && string.empty()) { @@ -1015,7 +1057,17 @@ static void filter_list(LLInventorySubTreePanel* inventory_list, const std::stri inventory_list->saveFolderState(); } - // set new filter string + // Set new filter string inventory_list->setFilterSubString(string); + +} + +static void save_folder_state_if_no_filter(LLInventorySubTreePanel* inventory_list) +{ + // save current folder open state if no filter currently applied + if (inventory_list->getRootFolder() && inventory_list->getRootFolder()->getFilterSubString().empty()) + { + // inventory_list->saveFolderState(); // *TODO: commented out to fix build + } } // EOF |