From 3d0ec3da5baea6bb2b9b72707a884ac7b516c4fd Mon Sep 17 00:00:00 2001
From: Merov Linden <merov@lindenlab.com>
Date: Mon, 7 Jan 2013 15:32:47 -0800
Subject: [PATCH] CHUI-659 : WIP : Verified (tested) and cleaned up some
 CHUI-101 refactoring code.

---
 indra/llui/llfolderviewmodel.h           |  4 ++--
 indra/newview/llinventoryfilter.cpp      |  9 +++------
 indra/newview/llpanelobjectinventory.cpp | 10 +++++-----
 indra/newview/lltexturectrl.cpp          | 15 ---------------
 4 files changed, 10 insertions(+), 28 deletions(-)

diff --git a/indra/llui/llfolderviewmodel.h b/indra/llui/llfolderviewmodel.h
index 7019857c0f8..5837052565a 100644
--- a/indra/llui/llfolderviewmodel.h
+++ b/indra/llui/llfolderviewmodel.h
@@ -401,8 +401,8 @@ class LLFolderViewModel : public LLFolderViewModelCommon
 	virtual const FilterType& getFilter() const		 { return mFilter; }
 	virtual void setFilter(const FilterType& filter) { mFilter = filter; }
 
-	// TODO RN: remove this and put all filtering logic in view model
-	// add getStatusText and isFiltering()
+	// By default, we assume the content is available. If a network fetch mechanism is implemented for the model,
+	// this method needs to be overloaded and return the relevant fetch status.
 	virtual bool contentsReady()					{ return true; }
 
 
diff --git a/indra/newview/llinventoryfilter.cpp b/indra/newview/llinventoryfilter.cpp
index c913269aada..92f2d33073e 100644
--- a/indra/newview/llinventoryfilter.cpp
+++ b/indra/newview/llinventoryfilter.cpp
@@ -42,8 +42,6 @@
 #include "llclipboard.h"
 #include "lltrans.h"
 
-//TODO RN: fix use of static cast as much as possible
-
 LLFastTimer::DeclareTimer FT_FILTER_CLIPBOARD("Filter Clipboard");
 
 LLInventoryFilter::FilterOps::FilterOps(const Params& p)
@@ -83,7 +81,7 @@ LLInventoryFilter::LLInventoryFilter(const Params& p)
 
 bool LLInventoryFilter::check(const LLFolderViewModelItem* item) 
 {
-	const LLFolderViewModelItemInventory* listener = static_cast<const LLFolderViewModelItemInventory*>(item);
+	const LLFolderViewModelItemInventory* listener = dynamic_cast<const LLFolderViewModelItemInventory*>(item);
 	// Clipboard cut items are *always* filtered so we need this value upfront
 	const BOOL passed_clipboard = (listener ? checkAgainstClipboard(listener->getUUID()) : TRUE);
 
@@ -122,7 +120,7 @@ bool LLInventoryFilter::check(const LLInventoryItem* item)
 
 bool LLInventoryFilter::checkFolder(const LLFolderViewModelItem* item) const
 {
-	const LLFolderViewModelItemInventory* listener = static_cast<const LLFolderViewModelItemInventory*>(item);
+	const LLFolderViewModelItemInventory* listener = dynamic_cast<const LLFolderViewModelItemInventory*>(item);
 	if (!listener)
 	{
 		llerrs << "Folder view event listener not found." << llendl;
@@ -384,8 +382,7 @@ const std::string& LLInventoryFilter::getFilterSubString(BOOL trim) const
 
 std::string::size_type LLInventoryFilter::getStringMatchOffset(LLFolderViewModelItem* item) const
 {
-	const LLFolderViewModelItemInventory* listener = static_cast<const LLFolderViewModelItemInventory*>(item);
-	return mFilterSubString.size() ? listener->getSearchableName().find(mFilterSubString) : std::string::npos;
+	return mFilterSubString.size() ? item->getSearchableName().find(mFilterSubString) : std::string::npos;
 }
 
 bool LLInventoryFilter::isDefault() const
diff --git a/indra/newview/llpanelobjectinventory.cpp b/indra/newview/llpanelobjectinventory.cpp
index a2aabb50b56..527aefe8216 100644
--- a/indra/newview/llpanelobjectinventory.cpp
+++ b/indra/newview/llpanelobjectinventory.cpp
@@ -1555,6 +1555,10 @@ void LLPanelObjectInventory::reset()
 
 	mCommitCallbackRegistrar.pushScope(); // push local callbacks
 	
+	// Reset the inventory model to show all folders by default
+	mInventoryViewModel.getFilter().setShowFolderState(LLInventoryFilter::SHOW_ALL_FOLDERS);
+	
+	// Create a new folder view root
 	LLRect dummy_rect(0, 1, 1, 0);
 	LLFolderView::Params p;
 	p.name = "task inventory";
@@ -1566,11 +1570,7 @@ void LLPanelObjectInventory::reset()
 	p.view_model = &mInventoryViewModel;
 	p.root = NULL;
 	mFolders = LLUICtrlFactory::create<LLFolderView>(p);
-	// this ensures that we never say "searching..." or "no items found"
-	//TODO RN: make this happen by manipulating filter object directly
-  	LLInventoryFilter& inventoryFilter = dynamic_cast<LLInventoryFilter&>(mFolders->getFolderViewModel()->getFilter());
-   	inventoryFilter.setShowFolderState(LLInventoryFilter::SHOW_ALL_FOLDERS);
-  
+
 	mFolders->setCallbackRegistrar(&mCommitCallbackRegistrar);
 
 	if (hasFocus())
diff --git a/indra/newview/lltexturectrl.cpp b/indra/newview/lltexturectrl.cpp
index 65f02900605..007eb8e33f8 100644
--- a/indra/newview/lltexturectrl.cpp
+++ b/indra/newview/lltexturectrl.cpp
@@ -652,26 +652,11 @@ void LLFloaterTexturePicker::draw()
 		{
 			folder_view->setPinningSelectedItem(mSelectedItemPinned);
 			folder_view->getViewModelItem()->dirtyFilter();
-			//TODO RN: test..still works without this?
-			//folder_view->arrangeFromRoot();
-
 			mSelectedItemPinned = TRUE;
 		}
 	}
 }
 
-// static
-/*
-void LLFloaterTexturePicker::onSaveAnotherCopyDialog( S32 option, void* userdata )
-{
-	LLFloaterTexturePicker* self = (LLFloaterTexturePicker*) userdata;
-	if( 0 == option )
-	{
-		self->copyToInventoryFinal();
-	}
-}
-*/
-
 const LLUUID& LLFloaterTexturePicker::findItemID(const LLUUID& asset_id, BOOL copyable_only)
 {
 	LLViewerInventoryCategory::cat_array_t cats;
-- 
GitLab