diff options
author | Loren Shih <seraph@lindenlab.com> | 2009-12-11 15:57:41 -0500 |
---|---|---|
committer | Loren Shih <seraph@lindenlab.com> | 2009-12-11 15:57:41 -0500 |
commit | d2b72fe0184fb92f4a79eebd242825fbcc5f32e9 (patch) | |
tree | 1d8bb75f6db751ae2e347737b2df3fb3f26f37e8 | |
parent | 3cb997a50475f4de54090f3e3a4490aac9e6d218 (diff) |
EXT-3373 : Favorites folder disappears after canceling filter
Doing a more robust check to see if folders need to be refreshed.
--HG--
branch : avatar-pipeline
-rw-r--r-- | indra/newview/llfolderview.cpp | 11 | ||||
-rw-r--r-- | indra/newview/llfolderviewitem.cpp | 27 | ||||
-rw-r--r-- | indra/newview/llfolderviewitem.h | 13 | ||||
-rw-r--r-- | indra/newview/llinventoryfilter.cpp | 32 | ||||
-rw-r--r-- | indra/newview/llpanellandmarks.cpp | 19 |
5 files changed, 61 insertions, 41 deletions
diff --git a/indra/newview/llfolderview.cpp b/indra/newview/llfolderview.cpp index 1c5d7ae9b9..321982ceb6 100644 --- a/indra/newview/llfolderview.cpp +++ b/indra/newview/llfolderview.cpp @@ -411,7 +411,12 @@ S32 LLFolderView::arrange( S32* unused_width, S32* unused_height, S32 filter_gen folderp->setVisible(show_folder_state == LLInventoryFilter::SHOW_ALL_FOLDERS || // always show folders? (folderp->getFiltered(filter_generation) || folderp->hasFilteredDescendants(filter_generation))); // passed filter or has descendants that passed filter } - if (folderp->getVisible()) + + // Need to call arrange regardless of visibility, since children's visibility + // might need to be changed too (e.g. even though a folder is invisible, its + // children also need to be set invisible for state-tracking purposes, e.g. + // llfolderviewitem::filter). + // if (folderp->getVisible()) { S32 child_height = 0; S32 child_width = 0; @@ -479,13 +484,13 @@ void LLFolderView::filter( LLInventoryFilter& filter ) if (getCompletedFilterGeneration() < filter.getCurrentGeneration()) { - mFiltered = FALSE; + mPassedFilter = FALSE; mMinWidth = 0; LLFolderViewFolder::filter(filter); } else { - mFiltered = TRUE; + mPassedFilter = TRUE; } } diff --git a/indra/newview/llfolderviewitem.cpp b/indra/newview/llfolderviewitem.cpp index 5bef306485..220fd75191 100644 --- a/indra/newview/llfolderviewitem.cpp +++ b/indra/newview/llfolderviewitem.cpp @@ -121,7 +121,7 @@ LLFolderViewItem::LLFolderViewItem(LLFolderViewItem::Params p) mHasVisibleChildren(FALSE), mIndentation(0), mNumDescendantsSelected(0), - mFiltered(FALSE), + mPassedFilter(FALSE), mLastFilterGeneration(-1), mStringMatchOffset(std::string::npos), mControlLabelRotation(0.f), @@ -223,17 +223,17 @@ BOOL LLFolderViewItem::potentiallyVisible() BOOL LLFolderViewItem::getFiltered() { - return mFiltered && mLastFilterGeneration >= getRoot()->getFilter()->getMinRequiredGeneration(); + return mPassedFilter && mLastFilterGeneration >= getRoot()->getFilter()->getMinRequiredGeneration(); } BOOL LLFolderViewItem::getFiltered(S32 filter_generation) { - return mFiltered && mLastFilterGeneration >= filter_generation; + return mPassedFilter && mLastFilterGeneration >= filter_generation; } void LLFolderViewItem::setFiltered(BOOL filtered, S32 filter_generation) { - mFiltered = filtered; + mPassedFilter = filtered; mLastFilterGeneration = filter_generation; } @@ -423,19 +423,20 @@ S32 LLFolderViewItem::getItemHeight() void LLFolderViewItem::filter( LLInventoryFilter& filter) { - BOOL filtered = mListener && filter.check(this); + const BOOL previous_passed_filter = mPassedFilter; + const BOOL passed_filter = mListener && filter.check(this); - // if our visibility will change as a result of this filter, then + // If our visibility will change as a result of this filter, then // we need to be rearranged in our parent folder - if (getVisible() != filtered) + if (mParentFolder) { - if (mParentFolder) - { + if (getVisible() != passed_filter) + mParentFolder->requestArrange(); + if (passed_filter != previous_passed_filter) mParentFolder->requestArrange(); - } } - setFiltered(filtered, filter.getCurrentGeneration()); + setFiltered(passed_filter, filter.getCurrentGeneration()); mStringMatchOffset = filter.getStringMatchOffset(); filter.decrementFilterCount(); @@ -1237,7 +1238,7 @@ void LLFolderViewFolder::filter( LLInventoryFilter& filter) if (getLastFilterGeneration() < filter_generation) { if (getLastFilterGeneration() >= must_pass_generation && // folder has been compared to a valid precursor filter - !mFiltered) // and did not pass the filter + !mPassedFilter) // and did not pass the filter { // go ahead and flag this folder as done mLastFilterGeneration = filter_generation; @@ -1375,7 +1376,7 @@ void LLFolderViewFolder::setFiltered(BOOL filtered, S32 filter_generation) { // if this folder is now filtered, but wasn't before // (it just passed) - if (filtered && !mFiltered) + if (filtered && !mPassedFilter) { // reset current height, because last time we drew it // it might have had more visible items than now diff --git a/indra/newview/llfolderviewitem.h b/indra/newview/llfolderviewitem.h index 0ea031108b..24c401ec49 100644 --- a/indra/newview/llfolderviewitem.h +++ b/indra/newview/llfolderviewitem.h @@ -120,6 +120,9 @@ public: static const F32 FOLDER_CLOSE_TIME_CONSTANT; static const F32 FOLDER_OPEN_TIME_CONSTANT; + // Mostly for debugging printout purposes. + const std::string& getSearchableLabel() { return mSearchableLabel; } + protected: friend class LLUICtrlFactory; friend class LLFolderViewEventListener; @@ -148,7 +151,7 @@ protected: BOOL mHasVisibleChildren; S32 mIndentation; S32 mNumDescendantsSelected; - BOOL mFiltered; + BOOL mPassedFilter; S32 mLastFilterGeneration; std::string::size_type mStringMatchOffset; F32 mControlLabelRotation; @@ -156,8 +159,8 @@ protected: BOOL mDragAndDropTarget; LLUIImagePtr mArrowImage; LLUIImagePtr mBoxImage; - BOOL mIsLoading; - LLTimer mTimeSinceRequestStart; + BOOL mIsLoading; + LLTimer mTimeSinceRequestStart; bool mDontShowInHierarchy; // helper function to change the selection from the root. @@ -202,7 +205,7 @@ public: virtual S32 arrange( S32* width, S32* height, S32 filter_generation ); virtual S32 getItemHeight(); void setDontShowInHierarchy(bool dont_show) { mDontShowInHierarchy = dont_show; } - bool getDontShowInHierarchy() { return mDontShowInHierarchy; } + bool getDontShowInHierarchy() const { return mDontShowInHierarchy; } // applies filters to control visibility of inventory items virtual void filter( LLInventoryFilter& filter); @@ -328,7 +331,7 @@ public: EAcceptance* accept, std::string& tooltip_msg); - private: +private: static std::map<U8, LLFontGL*> sFonts; // map of styles to fonts }; diff --git a/indra/newview/llinventoryfilter.cpp b/indra/newview/llinventoryfilter.cpp index 81b10f5a62..522edd0cb5 100644 --- a/indra/newview/llinventoryfilter.cpp +++ b/indra/newview/llinventoryfilter.cpp @@ -40,6 +40,7 @@ #include "llinventorymodel.h" // gInventory.backgroundFetchActive() #include "llviewercontrol.h" #include "llviewerinventory.h" +#include "llfolderview.h" // linden library includes #include "lltrans.h" @@ -329,7 +330,6 @@ void LLInventoryFilter::setFilterSubString(const std::string& string) mFilterSubString = string; LLStringUtil::toUpper(mFilterSubString); LLStringUtil::trimHead(mFilterSubString); - if (less_restrictive) { setModified(FILTER_LESS_RESTRICTIVE); @@ -512,21 +512,21 @@ void LLInventoryFilter::setModified(EFilterBehavior behavior) // if not keeping current filter results, update last valid as well switch(mFilterBehavior) { - case FILTER_RESTART: - mMustPassGeneration = mFilterGeneration; - mMinRequiredGeneration = mFilterGeneration; - break; - case FILTER_LESS_RESTRICTIVE: - mMustPassGeneration = mFilterGeneration; - break; - case FILTER_MORE_RESTRICTIVE: - mMinRequiredGeneration = mFilterGeneration; - // must have passed either current filter generation (meaningless, as it hasn't been run yet) - // or some older generation, so keep the value - mMustPassGeneration = llmin(mMustPassGeneration, mFilterGeneration); - break; - default: - llerrs << "Bad filter behavior specified" << llendl; + case FILTER_RESTART: + mMustPassGeneration = mFilterGeneration; + mMinRequiredGeneration = mFilterGeneration; + break; + case FILTER_LESS_RESTRICTIVE: + mMustPassGeneration = mFilterGeneration; + break; + case FILTER_MORE_RESTRICTIVE: + mMinRequiredGeneration = mFilterGeneration; + // must have passed either current filter generation (meaningless, as it hasn't been run yet) + // or some older generation, so keep the value + mMustPassGeneration = llmin(mMustPassGeneration, mFilterGeneration); + break; + default: + llerrs << "Bad filter behavior specified" << llendl; } } else diff --git a/indra/newview/llpanellandmarks.cpp b/indra/newview/llpanellandmarks.cpp index c85fab2092..4b5ff1732d 100644 --- a/indra/newview/llpanellandmarks.cpp +++ b/indra/newview/llpanellandmarks.cpp @@ -328,6 +328,7 @@ void LLLandmarksPanel::initFavoritesInventoryPanel() initLandmarksPanel(mFavoritesInventoryPanel); mFavoritesInventoryPanel->getFilter()->setEmptyLookupMessage("FavoritesNoMatchingItems"); + initAccordion("tab_favorites", mFavoritesInventoryPanel); } @@ -389,6 +390,7 @@ void LLLandmarksPanel::initLandmarksPanel(LLInventorySubTreePanel* inventory_lis } root_folder->setParentLandmarksPanel(this); + inventory_list->saveFolderState(); } void LLLandmarksPanel::initAccordion(const std::string& accordion_tab_name, LLInventorySubTreePanel* inventory_list) @@ -991,21 +993,30 @@ void LLLandmarksPanel::doCreatePick(LLLandmark* landmark) ////////////////////////////////////////////////////////////////////////// static void filter_list(LLInventorySubTreePanel* inventory_list, const std::string& string) { - // 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(); - + // When search is cleared, restore the old folder state. if (string == "") { inventory_list->setFilterSubString(LLStringUtil::null); + // Re-open folders that were open before + inventory_list->restoreFolderState(); } + // 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()) { // current filter and new filter empty, do nothing return; } + // save current folder open state if no filter currently applied + if (inventory_list->getRootFolder()->getFilterSubString().empty()) + { + inventory_list->saveFolderState(); + } + // Set new filter string inventory_list->setFilterSubString(string); |