summaryrefslogtreecommitdiff
path: root/indra/newview/llinventorypanel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llinventorypanel.cpp')
-rw-r--r--indra/newview/llinventorypanel.cpp67
1 files changed, 34 insertions, 33 deletions
diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp
index 327a735f78..47201b2ccc 100644
--- a/indra/newview/llinventorypanel.cpp
+++ b/indra/newview/llinventorypanel.cpp
@@ -78,7 +78,7 @@ LLInventoryPanel::LLInventoryPanel(const LLInventoryPanel::Params& p) :
mSortOrderSetting(p.sort_order_setting),
mInventory(p.inventory),
mAllowMultiSelect(p.allow_multi_select),
- mHasInventoryConnection(false),
+ mViewsInitialized(false),
mStartFolderString(p.start_folder),
mBuildDefaultHierarchy(true),
mInvFVBridgeBuilder(NULL)
@@ -96,6 +96,11 @@ LLInventoryPanel::LLInventoryPanel(const LLInventoryPanel::Params& p) :
setBackgroundColor(LLUIColorTable::instance().getColor("InventoryBackgroundColor"));
setBackgroundVisible(TRUE);
setBackgroundOpaque(TRUE);
+
+ if (mStartFolderString != "")
+ {
+ mBuildDefaultHierarchy = false;
+ }
}
BOOL LLInventoryPanel::postBuild()
@@ -146,11 +151,9 @@ BOOL LLInventoryPanel::postBuild()
mInventory->addObserver(mInventoryObserver);
// build view of inventory if we need default full hierarchy and inventory ready, otherwise wait for modelChanged() callback
- if (mBuildDefaultHierarchy && mInventory->isInventoryUsable() && !mHasInventoryConnection)
+ if (mBuildDefaultHierarchy && mInventory->isInventoryUsable() && !mViewsInitialized)
{
- rebuildViews();
- mHasInventoryConnection = true;
- defaultOpenInventory();
+ initializeViews();
}
if (mSortOrderSetting != INHERIT_SORT_ORDER)
@@ -253,11 +256,9 @@ void LLInventoryPanel::modelChanged(U32 mask)
bool handled = false;
// inventory just initialized, do complete build
- if ((mask & LLInventoryObserver::ADD) && gInventory.getChangedIDs().empty() && !mHasInventoryConnection)
+ if ((mask & LLInventoryObserver::ADD) && mInventory->isInventoryUsable() && gInventory.getChangedIDs().empty() && !mViewsInitialized)
{
- rebuildViews();
- mHasInventoryConnection = true;
- defaultOpenInventory();
+ initializeViews();
return;
}
@@ -367,10 +368,13 @@ void LLInventoryPanel::modelChanged(U32 mask)
}
-void LLInventoryPanel::rebuildViews()
+void LLInventoryPanel::initializeViews()
{
- // Determine the root folder and rebuild the views starting
- // at that folder.
+ if (!gInventory.isInventoryUsable())
+ return;
+
+ // Determine the root folder in case specified, and
+ // build the views starting with that folder.
const LLFolderType::EType preferred_type = LLViewerFolderType::lookupTypeFromNewCategoryName(mStartFolderString);
if ("LIBRARY" == mStartFolderString)
@@ -381,16 +385,17 @@ void LLInventoryPanel::rebuildViews()
{
mStartFolderID = (preferred_type != LLFolderType::FT_NONE ? gInventory.findCategoryUUIDForType(preferred_type) : LLUUID::null);
}
-
+ llinfos << this << " Generating views for start folder " << mStartFolderString << llendl;
rebuildViewsFor(mStartFolderID);
+
+ mViewsInitialized = true;
+ defaultOpenInventory();
}
void LLInventoryPanel::rebuildViewsFor(const LLUUID& id)
{
- LLFolderViewItem* old_view = NULL;
-
- // get old LLFolderViewItem
- old_view = mFolders->getItemByID(id);
+ // Destroy the old view for this ID so we can rebuild it
+ LLFolderViewItem* old_view = mFolders->getItemByID(id);
if (old_view && id.notNull())
{
old_view->destroyView();
@@ -409,11 +414,13 @@ void LLInventoryPanel::buildNewViews(const LLUUID& id)
const LLUUID &parent_id = objectp->getParentUUID();
LLFolderViewFolder* parent_folder = (LLFolderViewFolder*)mFolders->getItemByID(parent_id);
if (id == mStartFolderID)
+ {
parent_folder = mFolders;
-
- if (!parent_folder)
+ }
+ else if ((mStartFolderID != LLUUID::null) && (!gInventory.isObjectDescendentOf(id, mStartFolderID)))
{
- // This item exists outside the inventory's hierarchy, so don't add it.
+ // This item exists outside the inventory's hierarchy,
+ // so don't add it.
return;
}
@@ -520,19 +527,20 @@ void LLInventoryPanel::buildNewViews(const LLUUID& id)
// bit of a hack to make sure the inventory is open.
void LLInventoryPanel::defaultOpenInventory()
{
- const LLFolderType::EType preferred_type = LLViewerFolderType::lookupTypeFromNewCategoryName(mStartFolderString);
- if (preferred_type != LLFolderType::FT_NONE)
+ if (mStartFolderString != "")
{
- const std::string& top_level_folder_name = LLViewerFolderType::lookupNewCategoryName(preferred_type);
- mFolders->openFolder(top_level_folder_name);
+ mFolders->openFolder(mStartFolderString);
}
else
{
// Get the first child (it should be "My Inventory") and
// open it up by name (just to make sure the first child is actually a folder).
LLView* first_child = mFolders->getFirstChild();
- const std::string& first_child_name = first_child->getName();
- mFolders->openFolder(first_child_name);
+ if (first_child)
+ {
+ const std::string& first_child_name = first_child->getName();
+ mFolders->openFolder(first_child_name);
+ }
}
}
@@ -640,13 +648,6 @@ void LLInventoryPanel::openAllFolders()
mFolders->arrangeAll();
}
-void LLInventoryPanel::openDefaultFolderForType(LLFolderType::EType type)
-{
- LLUUID category_id = mInventory->findCategoryUUIDForType(type);
- LLOpenFolderByID opener(category_id);
- mFolders->applyFunctorRecursively(opener);
-}
-
void LLInventoryPanel::setSelection(const LLUUID& obj_id, BOOL take_keyboard_focus)
{
// Don't select objects in COF (e.g. to prevent refocus when items are worn).