Permalink
Browse files

Fixed folder collapse state not being properly restored after clearin…

…g search string.

Updated inventory filter classes.
LLInventoryView renamed to LLPanelMainInventory for easier diffing.
  • Loading branch information...
Shyotl committed May 26, 2016
1 parent f89a5aa commit 899ba7fdedd031beae7996eb122a16370583f4c5
@@ -416,12 +416,17 @@ U32 LLInventoryItem::getCRC32() const
return crc;
}
+// static
+void LLInventoryItem::correctInventoryDescription(std::string& desc)
+{
+ LLStringUtil::replaceNonstandardASCII(desc, ' ');
+ LLStringUtil::replaceChar(desc, '|', ' ');
+}
void LLInventoryItem::setDescription(const std::string& d)
{
std::string new_desc(d);
- LLStringUtil::replaceNonstandardASCII(new_desc, ' ');
- LLStringUtil::replaceChar(new_desc, '|', ' ');
+ LLInventoryItem::correctInventoryDescription(new_desc);
if( new_desc != mDescription )
{
mDescription = new_desc;
@@ -177,6 +177,7 @@ class LLInventoryItem : public LLInventoryObject
//--------------------------------------------------------------------
public:
void setAssetUUID(const LLUUID& asset_id);
+ static void correctInventoryDescription(std::string& name);
void setDescription(const std::string& new_desc);
void setSaleInfo(const LLSaleInfo& sale_info);
void setPermissions(const LLPermissions& perm);
@@ -53,6 +53,7 @@ struct InventoryEntry : public LLDictionaryEntry
LLAssetType::EType t = (LLAssetType::EType)va_arg(argp,int);
mAssetTypes.push_back(t);
}
+ va_end(argp);
}
const std::string mHumanName;
@@ -8,7 +8,7 @@
* (in header)
*
* class T {
- * class LLDoTest : public LLMemberListener<LLInventoryView>
+ * class LLDoTest : public LLMemberListener<LLPanelMainInventory>
* {
* bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata);
* };
@@ -4618,7 +4618,7 @@ void LLAppViewer::disconnectViewer()
saveNameCache();
// close inventory interface, close all windows
- LLInventoryView::cleanup();
+ LLPanelMainInventory::cleanup();
// [SL:KB] - Patch: Appearance-Misc | Checked: 2013-02-12 (Catznip-3.4)
// Destroying all objects below will trigger attachment detaching code and attempt to remove the COF links for them
LLAppearanceMgr::instance().setAttachmentInvLinkEnable(false);
@@ -572,7 +572,7 @@ void LLAvatarActions::share(const LLUUID& id)
LLFloaterSidePanelContainer::showPanel("inventory", key);
LLFloaterReg::showInstance("im_container");
*/
- LLInventoryView::getActiveInventory()->setVisible(true);
+ LLPanelMainInventory::getActiveInventory()->setVisible(true);
LLUUID session_id = gIMMgr->computeSessionID(IM_NOTHING_SPECIAL, id);
@@ -331,7 +331,7 @@ void LLFloaterGesture::onClickInventory(void* data)
if (!list) return;
const LLUUID& item_id = list->getCurrentID();
- LLInventoryView* inv = LLInventoryView::showAgentInventory();
+ LLPanelMainInventory* inv = LLPanelMainInventory::showAgentInventory();
if (!inv) return;
inv->getPanel()->setSelection(item_id, TRUE);
}
@@ -72,7 +72,6 @@ LLFloaterLandmark::LLFloaterLandmark(const LLSD& data)
mFilterEdit(NULL),
mContextConeOpacity(0.f),
mInventoryPanel(NULL),
- mSavedFolderState(NULL),
mNoCopyLandmarkSelected( FALSE )
{
LLUICtrlFactory::getInstance()->buildFloater(this,"floater_landmark_ctrl.xml");
@@ -115,7 +114,6 @@ BOOL LLFloaterLandmark::postBuild()
mInventoryPanel->setSelection(findItemID(mImageAssetID, FALSE), TAKE_FOCUS_NO);
}
- mSavedFolderState = new LLSaveFolderState();
mNoCopyLandmarkSelected = FALSE;
getChild<LLButton>("Close")->setClickedCallback(boost::bind(&LLFloaterLandmark::onBtnClose,this));
@@ -127,15 +125,11 @@ BOOL LLFloaterLandmark::postBuild()
setCanMinimize(FALSE);
- mSavedFolderState->setApply(FALSE);
-
return true;
}
LLFloaterLandmark::~LLFloaterLandmark()
{
- delete mSavedFolderState;
- mSavedFolderState = NULL;
}
void LLFloaterLandmark::setActive( BOOL active )
@@ -394,35 +388,13 @@ void LLFloaterLandmark::onShowFolders(LLUICtrl* ctrl)
void LLFloaterLandmark::onFilterEdit(const LLSD& value )
{
- std::string upper_case_search_string = value.asString();
- LLStringUtil::toUpper(upper_case_search_string);
-
- if (upper_case_search_string.empty())
+ if (!mInventoryPanel)
{
- if (mInventoryPanel->getFilterSubString().empty())
- {
- // current filter and new filter empty, do nothing
- return;
- }
-
- mSavedFolderState->setApply(TRUE);
- mInventoryPanel->getRootFolder()->applyFunctorRecursively(*mSavedFolderState);
- // add folder with current item to list of previously opened folders
- LLOpenFoldersWithSelection opener;
- mInventoryPanel->getRootFolder()->applyFunctorRecursively(opener);
- mInventoryPanel->getRootFolder()->scrollToShowSelection();
-
- }
- else if (mInventoryPanel->getFilterSubString().empty())
- {
- // first letter in search term, save existing folder open state
- if (!mInventoryPanel->getRootFolder()->isFilterModified())
- {
- mSavedFolderState->setApply(FALSE);
- mInventoryPanel->getRootFolder()->applyFunctorRecursively(*mSavedFolderState);
- }
+ return;
}
- mInventoryPanel->setFilterSubString(upper_case_search_string);
+ // set new filter string
+ // Internally handles saving/restoring folder states.
+ mInventoryPanel->setFilterSubString(value.asString());
}
@@ -113,7 +113,6 @@ class LLFloaterLandmark: public LLFloater, public LLFloaterSingleton<LLFloaterLa
PermissionMask mNonImmediateFilterPermMask;
BOOL mNoCopyLandmarkSelected;
F32 mContextConeOpacity;
- LLSaveFolderState* mSavedFolderState;
};
#endif // LL_FLOATERLANDMARK_H
@@ -447,7 +447,7 @@ S32 LLFolderView::arrange( S32* unused_width, S32* unused_height, S32 filter_gen
LLFastTimer t2(FTM_ARRANGE);
- filter_generation = mFilter->getMinRequiredGeneration();
+ filter_generation = mFilter->getFirstSuccessGeneration();
mMinWidth = 0;
mHasVisibleChildren = hasFilteredDescendants(filter_generation);
@@ -908,7 +908,7 @@ void LLFolderView::draw()
if (mDebugFilters)
{
std::string current_filter_string = llformat("Current Filter: %d, Least Filter: %d, Auto-accept Filter: %d",
- mFilter->getCurrentGeneration(), mFilter->getMinRequiredGeneration(), mFilter->getMustPassGeneration());
+ mFilter->getCurrentGeneration(), mFilter->getFirstSuccessGeneration(), mFilter->getFirstRequiredGeneration());
LLFontGL::getFontMonospace()->renderUTF8(current_filter_string, 0, 2,
getRect().getHeight() - LLFontGL::getFontMonospace()->getLineHeight(), LLColor4(0.5f, 0.5f, 0.8f, 1.f),
LLFontGL::LEFT, LLFontGL::BOTTOM, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, S32_MAX, S32_MAX, NULL, FALSE );
@@ -954,7 +954,7 @@ void LLFolderView::draw()
else if (mShowEmptyMessage)
{
static LLCachedControl<LLColor4> sSearchStatusColor(gColors, "InventorySearchStatusColor", LLColor4::white );
- if (LLInventoryModelBackgroundFetch::instance().folderFetchActive() || mCompletedFilterGeneration < mFilter->getMinRequiredGeneration())
+ if (LLInventoryModelBackgroundFetch::instance().folderFetchActive() || mCompletedFilterGeneration < mFilter->getFirstSuccessGeneration())
{
mStatusText = LLTrans::getString("Searching");
}
@@ -2385,6 +2385,22 @@ void LLFolderView::updateMenu()
}
}
+void LLFolderView::saveFolderState()
+{
+ mSavedFolderState = std::unique_ptr<LLSaveFolderState>(new LLSaveFolderState());
+ applyFunctorRecursively(*mSavedFolderState);
+}
+
+void LLFolderView::restoreFolderState()
+{
+ if (mSavedFolderState)
+ {
+ mSavedFolderState->setApply(true);
+ applyFunctorRecursively(*mSavedFolderState);
+ mSavedFolderState.reset();
+ }
+}
+
bool LLFolderView::selectFirstItem()
{
for (folders_t::iterator iter = mFolders.begin();
@@ -63,6 +63,7 @@ class LLMenuGL;
class LLScrollContainer;
class LLUICtrl;
class LLTextBox;
+class LLSaveFolderState;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Class LLFolderView
@@ -258,6 +259,8 @@ class LLFolderView : public LLFolderViewFolder, public LLEditMenuHandler
bool useLabelSuffix() { return mUseLabelSuffix; }
void updateMenu();
+ void saveFolderState();
+ void restoreFolderState();
// Note: We may eventually have to move that method up the hierarchy to LLFolderViewItem.
LLHandle<LLFolderView> getHandle() const { return getDerivedHandle<LLFolderView>(); }
@@ -279,6 +282,9 @@ class LLFolderView : public LLFolderViewFolder, public LLEditMenuHandler
bool selectLastItem();
BOOL addNoOptions(LLMenuGL* menu) const;
+
+private:
+ std::unique_ptr<LLSaveFolderState> mSavedFolderState;
protected:
LLHandle<LLView> mPopupMenuHandle;
@@ -210,12 +210,12 @@ BOOL LLFolderViewItem::potentiallyVisible()
{
// we haven't been checked against min required filter
// or we have and we passed
- return getLastFilterGeneration() < getRoot()->getFilter()->getMinRequiredGeneration() || getFiltered();
+ return getLastFilterGeneration() < getRoot()->getFilter()->getFirstSuccessGeneration() || getFiltered();
}
BOOL LLFolderViewItem::getFiltered()
{
- return mPassedFilter && mLastFilterGeneration >= getRoot()->getFilter()->getMinRequiredGeneration();
+ return mPassedFilter && mLastFilterGeneration >= getRoot()->getFilter()->getFirstSuccessGeneration();
}
BOOL LLFolderViewItem::getFiltered(S32 filter_generation)
@@ -1158,7 +1158,7 @@ void LLFolderViewFolder::setFilteredFolder(bool filtered, S32 filter_generation)
bool LLFolderViewFolder::getFilteredFolder(S32 filter_generation)
{
- return mPassedFolderFilter && mLastFilterGeneration >= getRoot()->getFilter()->getMinRequiredGeneration();
+ return mPassedFolderFilter && mLastFilterGeneration >= getRoot()->getFilter()->getFirstSuccessGeneration();
}
// addToFolder() returns TRUE if it succeeds. FALSE otherwise
@@ -1355,7 +1355,7 @@ void LLFolderViewFolder::filter( LLInventoryFilter& filter)
// if failed to pass filter newer than must_pass_generation
// you will automatically fail this time, so we only
// check against items that have passed the filter
- S32 must_pass_generation = filter.getMustPassGeneration();
+ S32 must_pass_generation = filter.getFirstRequiredGeneration();
bool autoopen_folders = (filter.hasFilterString());
@@ -1408,7 +1408,7 @@ void LLFolderViewFolder::filter( LLInventoryFilter& filter)
// when applying a filter, matching folders get their contents downloaded first
if (filter.isNotDefault()
- && getFiltered(filter.getMinRequiredGeneration())
+ && getFiltered(filter.getFirstSuccessGeneration())
&& (mListener
&& !gInventory.isCategoryComplete(mListener->getUUID())))
{
@@ -1433,7 +1433,7 @@ void LLFolderViewFolder::filter( LLInventoryFilter& filter)
if (folder->getCompletedFilterGeneration() >= filter_generation)
{
// track latest generation to pass any child items
- if (folder->getFiltered() || folder->hasFilteredDescendants(filter.getMinRequiredGeneration()))
+ if (folder->getFiltered() || folder->hasFilteredDescendants(filter.getFirstSuccessGeneration()))
{
mMostFilteredDescendantGeneration = filter_generation;
requestArrange();
@@ -1487,7 +1487,7 @@ void LLFolderViewFolder::filter( LLInventoryFilter& filter)
item->filter( filter );
- if (item->getFiltered(filter.getMinRequiredGeneration()))
+ if (item->getFiltered(filter.getFirstSuccessGeneration()))
{
mMostFilteredDescendantGeneration = filter_generation;
requestArrange();
@@ -1552,7 +1552,7 @@ void LLFolderViewFolder::dirtyFilter()
BOOL LLFolderViewFolder::getFiltered()
{
- return getFilteredFolder(getRoot()->getFilter()->getMinRequiredGeneration())
+ return getFilteredFolder(getRoot()->getFilter()->getFirstSuccessGeneration())
&& LLFolderViewItem::getFiltered();
}
@@ -2572,9 +2572,9 @@ BOOL LLFolderViewFolder::potentiallyVisible()
// folder should be visible by it's own filter status
return LLFolderViewItem::potentiallyVisible()
// or one or more of its descendants have passed the minimum filter requirement
- || hasFilteredDescendants(getRoot()->getFilter()->getMinRequiredGeneration())
+ || hasFilteredDescendants(getRoot()->getFilter()->getFirstSuccessGeneration())
// or not all of its descendants have been checked against minimum filter requirement
- || getCompletedFilterGeneration() < getRoot()->getFilter()->getMinRequiredGeneration();
+ || getCompletedFilterGeneration() < getRoot()->getFilter()->getFirstSuccessGeneration();
}
// this does prefix traversal, as folders are listed above their contents
@@ -66,7 +66,7 @@ namespace LLInventoryAction
}
typedef LLMemberListener<LLPanelObjectInventory> object_inventory_listener_t;
-typedef LLMemberListener<LLInventoryView> inventory_listener_t;
+typedef LLMemberListener<LLPanelMainInventory> inventory_listener_t;
typedef LLMemberListener<LLInventoryPanel> inventory_panel_listener_t;
bool LLInventoryAction::doToSelected(LLFolderView* folder, std::string action)
@@ -143,7 +143,7 @@ struct LLNewWindow : public inventory_listener_t
S32 left = 0 , top = 0;
gFloaterView->getNewFloaterPosition(&left, &top);
rect.setLeftTopAndSize(left, top, rect.getWidth(), rect.getHeight());
- LLInventoryView* iv = new LLInventoryView(std::string("Inventory"),
+ LLPanelMainInventory* iv = new LLPanelMainInventory(std::string("Inventory"),
rect,
mPtr->getActivePanel()->getModel());
iv->getActivePanel()->setFilterTypes(mPtr->getActivePanel()->getFilterObjectTypes());
@@ -467,15 +467,15 @@ void init_object_inventory_panel_actions(LLPanelObjectInventory *panel)
(new LLBindMemberListener(panel, "Inventory.DoToSelected", boost::bind(&LLInventoryAction::doToSelected, boost::bind(&LLPanelObjectInventory::getRootFolder, panel), _2)));
}
-void init_inventory_actions(LLInventoryView *floater)
+void init_inventory_actions(LLPanelMainInventory *floater)
{
- (new LLBindMemberListener(floater, "Inventory.DoToSelected", boost::bind(&LLInventoryAction::doToSelected, boost::bind(&LLInventoryView::getRootFolder, floater), _2)));
- (new LLBindMemberListener(floater, "Inventory.CloseAllFolders", boost::bind(&LLInventoryPanel::closeAllFolders, boost::bind(&LLInventoryView::getPanel, floater))));
+ (new LLBindMemberListener(floater, "Inventory.DoToSelected", boost::bind(&LLInventoryAction::doToSelected, boost::bind(&LLPanelMainInventory::getRootFolder, floater), _2)));
+ (new LLBindMemberListener(floater, "Inventory.CloseAllFolders", boost::bind(&LLInventoryPanel::closeAllFolders, boost::bind(&LLPanelMainInventory::getPanel, floater))));
(new LLBindMemberListener(floater, "Inventory.EmptyTrash", boost::bind(&LLInventoryModel::emptyFolderType, &gInventory, "", LLFolderType::FT_TRASH)));
- (new LLBindMemberListener(floater, "Inventory.DoCreate", boost::bind(&do_create, &gInventory, boost::bind(&LLInventoryView::getPanel, floater), _2, (LLFolderBridge*)0)));
+ (new LLBindMemberListener(floater, "Inventory.DoCreate", boost::bind(&do_create, &gInventory, boost::bind(&LLPanelMainInventory::getPanel, floater), _2, (LLFolderBridge*)0)));
(new LLNewWindow())->registerListener(floater, "Inventory.NewWindow");
- (new LLBindMemberListener(floater, "Inventory.ShowFilters", boost::bind(&LLInventoryView::toggleFindOptions, floater)));
- (new LLBindMemberListener(floater, "Inventory.ResetFilter", boost::bind(&LLInventoryView::resetFilters, floater)));
+ (new LLBindMemberListener(floater, "Inventory.ShowFilters", boost::bind(&LLPanelMainInventory::toggleFindOptions, floater)));
+ (new LLBindMemberListener(floater, "Inventory.ResetFilter", boost::bind(&LLPanelMainInventory::resetFilters, floater)));
(new LLSetSortBy())->registerListener(floater, "Inventory.SetSortBy");
(new LLSetSearchType())->registerListener(floater, "Inventory.SetSearchType");
}
@@ -1036,6 +1036,12 @@ LLInventoryModel* LLInvFVBridge::getInventoryModel() const
return panel ? panel->getModel() : NULL;
}
+LLInventoryFilter* LLInvFVBridge::getInventoryFilter() const
+{
+ LLInventoryPanel* panel = mInventoryPanel.get();
+ return panel ? panel->getFilter() : NULL;
+}
+
BOOL LLInvFVBridge::isItemInTrash() const
{
LLInventoryModel* model = getInventoryModel();
@@ -6305,7 +6311,7 @@ void LLLinkFolderBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
else
{
getClipboardEntries(false, items, disabled_items, flags);
- if (LLInventoryView::getActiveInventory() && !isOutboxFolder() && isAgentInventory())
+ if (LLPanelMainInventory::getActiveInventory() && !isOutboxFolder() && isAgentInventory())
build_context_menu_folder_options(getInventoryModel(), getFolderID(), items, disabled_items);
addDeleteContextMenuOptions(items, disabled_items);
}
@@ -6339,7 +6345,7 @@ void LLLinkFolderBridge::performAction(LLInventoryModel* model, std::string acti
copyToClipboard();
return;
}
- if (LLInventoryView* iv = LLInventoryView::getActiveInventory())
+ if (LLPanelMainInventory* iv = LLPanelMainInventory::getActiveInventory())
{
if (LLFolderViewItem* folder_item = iv->getActivePanel()->getRootFolder()->getItemByID(getFolderID()))
{
@@ -6508,7 +6514,7 @@ class LLCallingCardBridgeAction: public LLInvFVBridgeAction
virtual void doIt()
{
LLViewerInventoryItem* item = getItem();
- if (item)
+ if (item && item->getCreatorUUID().notNull())
{
LLAvatarActions::showProfile(item->getCreatorUUID());
}
Oops, something went wrong.

0 comments on commit 899ba7f

Please sign in to comment.