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.cpp117
1 files changed, 68 insertions, 49 deletions
diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp
index 327a735f78..0c893dddd6 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,13 +151,13 @@ 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();
}
+ gIdleCallbacks.addFunction(onIdle, (void*)this);
+
if (mSortOrderSetting != INHERIT_SORT_ORDER)
{
setSortOrder(gSavedSettings.getU32(mSortOrderSetting));
@@ -252,15 +257,11 @@ void LLInventoryPanel::modelChanged(U32 mask)
bool handled = false;
- // inventory just initialized, do complete build
- if ((mask & LLInventoryObserver::ADD) && gInventory.getChangedIDs().empty() && !mHasInventoryConnection)
+ if (!mViewsInitialized)
{
- rebuildViews();
- mHasInventoryConnection = true;
- defaultOpenInventory();
return;
}
-
+
if (mask & LLInventoryObserver::LABEL)
{
handled = true;
@@ -327,22 +328,26 @@ void LLInventoryPanel::modelChanged(U32 mask)
// around in the panel's directory structure (i.e. reparented).
if (model_item && view_item)
{
- LLFolderViewFolder* new_parent = (LLFolderViewFolder*)mFolders->getItemByID(model_item->getParentUUID());
-
- // Item has been moved.
- if (view_item->getParentFolder() != new_parent)
+ // Don't process the item if it's hanging from the root, since its
+ // model_item's parent will be NULL.
+ if (view_item->getRoot() != view_item->getParent())
{
- if (new_parent != NULL)
+ LLFolderViewFolder* new_parent = (LLFolderViewFolder*)mFolders->getItemByID(model_item->getParentUUID());
+ // Item has been moved.
+ if (view_item->getParentFolder() != new_parent)
{
- // Item is to be moved and we found its new parent in the panel's directory, so move the item's UI.
- view_item->getParentFolder()->extractItem(view_item);
- view_item->addToFolder(new_parent, mFolders);
- }
- else
- {
- // Item is to be moved outside the panel's directory (e.g. moved to trash for a panel that
- // doesn't include trash). Just remove the item's UI.
- view_item->destroyView();
+ if (new_parent != NULL)
+ {
+ // Item is to be moved and we found its new parent in the panel's directory, so move the item's UI.
+ view_item->getParentFolder()->extractItem(view_item);
+ view_item->addToFolder(new_parent, mFolders);
+ }
+ else
+ {
+ // Item is to be moved outside the panel's directory (e.g. moved to trash for a panel that
+ // doesn't include trash). Just remove the item's UI.
+ view_item->destroyView();
+ }
}
}
}
@@ -366,11 +371,28 @@ void LLInventoryPanel::modelChanged(U32 mask)
}
}
+// static
+void LLInventoryPanel::onIdle(void *userdata)
+{
+ LLInventoryPanel *self = (LLInventoryPanel*)userdata;
+ // inventory just initialized, do complete build
+ if (!self->mViewsInitialized && gInventory.isInventoryUsable())
+ {
+ self->initializeViews();
+ }
+ if (self->mViewsInitialized)
+ {
+ gIdleCallbacks.deleteFunction(onIdle, (void*)self);
+ }
+}
-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 +403,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 +432,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 +545,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 +666,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).