summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
authorLoren Shih <seraph@lindenlab.com>2009-12-01 20:21:54 -0500
committerLoren Shih <seraph@lindenlab.com>2009-12-01 20:21:54 -0500
commitf62ea011ea5e99de16bd3bb761ea9203815ce0e6 (patch)
tree40a8d676981f16c12dd5651da614cb16364a1fce /indra/newview
parent4916305ce1ea60c969c12d8dc8e573f3ee933c3f (diff)
EXT-3028 : "Find Original" does nothing if floater inventory isn't open
Preliminary checkin, includes cleanup for llinventorypanel. Also removed several unused private classes and such from llinventorypanel. --HG-- branch : avatar-pipeline
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/llinventorypanel.cpp201
-rw-r--r--indra/newview/llinventorypanel.h12
2 files changed, 82 insertions, 131 deletions
diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp
index 0c893dddd6..f633225dbf 100644
--- a/indra/newview/llinventorypanel.cpp
+++ b/indra/newview/llinventorypanel.cpp
@@ -39,6 +39,7 @@
#include "llagent.h"
#include "llagentwearables.h"
#include "llappearancemgr.h"
+#include "llfloaterinventory.h"
#include "llfloaterreg.h"
#include "llimview.h"
#include "llinventorybridge.h"
@@ -65,7 +66,10 @@ class LLInventoryPanelObserver : public LLInventoryObserver
public:
LLInventoryPanelObserver(LLInventoryPanel* ip) : mIP(ip) {}
virtual ~LLInventoryPanelObserver() {}
- virtual void changed(U32 mask);
+ virtual void changed(U32 mask)
+ {
+ mIP->modelChanged(mask);
+ }
protected:
LLInventoryPanel* mIP;
};
@@ -109,7 +113,7 @@ BOOL LLInventoryPanel::postBuild()
mCommitCallbackRegistrar.pushScope(); // registered as a widget; need to push callback scope ourselves
- // create root folder
+ // Create root folder
{
LLRect folder_rect(0,
0,
@@ -128,7 +132,7 @@ BOOL LLInventoryPanel::postBuild()
mFolders->setCallbackRegistrar(&mCommitCallbackRegistrar);
- // scroller
+ // Scroller
{
LLRect scroller_view_rect = getRect();
scroller_view_rect.translate(-scroller_view_rect.mLeft, -scroller_view_rect.mBottom);
@@ -139,23 +143,21 @@ BOOL LLInventoryPanel::postBuild()
p.reserve_scroll_corner(true);
p.tab_stop(true);
mScroller = LLUICtrlFactory::create<LLScrollContainer>(p);
+ addChild(mScroller);
+ mScroller->addChild(mFolders);
+ mFolders->setScrollContainer(mScroller);
}
- addChild(mScroller);
- mScroller->addChild(mFolders);
-
- mFolders->setScrollContainer(mScroller);
- // set up the callbacks from the inventory we're viewing, and then
- // build everything.
+ // Set up the callbacks from the inventory we're viewing, and then build everything.
mInventoryObserver = new LLInventoryPanelObserver(this);
mInventory->addObserver(mInventoryObserver);
- // build view of inventory if we need default full hierarchy and inventory ready, otherwise wait for modelChanged() callback
+ // Build view of inventory if we need default full hierarchy and inventory ready,
+ // otherwise wait for idle callback.
if (mBuildDefaultHierarchy && mInventory->isInventoryUsable() && !mViewsInitialized)
{
initializeViews();
}
-
gIdleCallbacks.addFunction(onIdle, (void*)this);
if (mSortOrderSetting != INHERIT_SORT_ORDER)
@@ -173,7 +175,6 @@ BOOL LLInventoryPanel::postBuild()
LLInventoryPanel::~LLInventoryPanel()
{
- // should this be a global setting?
if (mFolders)
{
U32 sort_order = mFolders->getSortOrder();
@@ -189,17 +190,19 @@ LLInventoryPanel::~LLInventoryPanel()
mScroller = NULL;
}
-LLMemType mt(LLMemType::MTYPE_INVENTORY_FROM_XML); // ! BUG ! Should this be removed?
void LLInventoryPanel::draw()
{
- // select the desired item (in case it wasn't loaded when the selection was requested)
+ // Select the desired item (in case it wasn't loaded when the selection was requested)
mFolders->updateSelection();
LLPanel::draw();
}
LLInventoryFilter* LLInventoryPanel::getFilter()
{
- if (mFolders) return mFolders->getFilter();
+ if (mFolders)
+ {
+ return mFolders->getFilter();
+ }
return NULL;
}
@@ -249,10 +252,9 @@ LLInventoryFilter::EFolderShow LLInventoryPanel::getShowFolderState()
return mFolders->getFilter()->getShowFolderState();
}
-static LLFastTimer::DeclareTimer FTM_REFRESH("Inventory Refresh");
-
void LLInventoryPanel::modelChanged(U32 mask)
{
+ static LLFastTimer::DeclareTimer FTM_REFRESH("Inventory Refresh");
LLFastTimer t2(FTM_REFRESH);
bool handled = false;
@@ -265,8 +267,7 @@ void LLInventoryPanel::modelChanged(U32 mask)
if (mask & LLInventoryObserver::LABEL)
{
handled = true;
- // label change - empty out the display name for each object
- // in this change set.
+ // Label change - empty out the display name for each object in this change set.
const std::set<LLUUID>& changed_items = gInventory.getChangedIDs();
std::set<LLUUID>::const_iterator id_it = changed_items.begin();
std::set<LLUUID>::const_iterator id_end = changed_items.end();
@@ -277,7 +278,7 @@ void LLInventoryPanel::modelChanged(U32 mask)
view = mFolders->getItemByID(*id_it);
if(view)
{
- // request refresh on this item (also flags for filtering)
+ // Request refresh on this item (also flags for filtering)
bridge = (LLInvFVBridge*)view->getListener();
if(bridge)
{ // Clear the display name first, so it gets properly re-built during refresh()
@@ -298,7 +299,6 @@ void LLInventoryPanel::modelChanged(U32 mask)
LLInventoryObserver::REMOVE))
{
handled = true;
- // Record which folders are open by uuid.
LLInventoryModel* model = getModel();
if (model)
{
@@ -308,10 +308,11 @@ void LLInventoryPanel::modelChanged(U32 mask)
std::set<LLUUID>::const_iterator id_end = changed_items.end();
for (;id_it != id_end; ++id_it)
{
- // sync view with model
LLInventoryObject* model_item = model->getObject(*id_it);
LLFolderViewItem* view_item = mFolders->getItemByID(*id_it);
-
+
+ //////////////////////////////
+ // ADD Operation
// Item exists in memory but a UI element hasn't been created for it.
if (model_item && !view_item)
{
@@ -324,8 +325,9 @@ void LLInventoryPanel::modelChanged(U32 mask)
}
}
- // This item already exists in both memory and UI. It was probably moved
- // around in the panel's directory structure (i.e. reparented).
+ //////////////////////////////
+ // STRUCTURE Operation
+ // This item already exists in both memory and UI. It was probably reparented.
if (model_item && view_item)
{
// Don't process the item if it's hanging from the root, since its
@@ -352,6 +354,8 @@ void LLInventoryPanel::modelChanged(U32 mask)
}
}
+ //////////////////////////////
+ // REMOVE Operation
// This item has been removed from memory, but its associated UI element still exists.
if (!model_item && view_item)
{
@@ -364,7 +368,7 @@ void LLInventoryPanel::modelChanged(U32 mask)
if (!handled)
{
- // it's a small change that only requires a refresh.
+ // It's a small change that only requires a refresh.
// *TODO: figure out a more efficient way to do the refresh
// since it is expensive on large inventories
mFolders->refresh();
@@ -375,7 +379,7 @@ void LLInventoryPanel::modelChanged(U32 mask)
void LLInventoryPanel::onIdle(void *userdata)
{
LLInventoryPanel *self = (LLInventoryPanel*)userdata;
- // inventory just initialized, do complete build
+ // Inventory just initialized, do complete build
if (!self->mViewsInitialized && gInventory.isInventoryUsable())
{
self->initializeViews();
@@ -388,8 +392,7 @@ void LLInventoryPanel::onIdle(void *userdata)
void LLInventoryPanel::initializeViews()
{
- if (!gInventory.isInventoryUsable())
- return;
+ if (!gInventory.isInventoryUsable()) return;
// Determine the root folder in case specified, and
// build the views starting with that folder.
@@ -412,7 +415,7 @@ void LLInventoryPanel::initializeViews()
void LLInventoryPanel::rebuildViewsFor(const LLUUID& id)
{
- // Destroy the old view for this ID so we can rebuild it
+ // Destroy the old view for this ID so we can rebuild it.
LLFolderViewItem* old_view = mFolders->getItemByID(id);
if (old_view && id.notNull())
{
@@ -437,21 +440,21 @@ void LLInventoryPanel::buildNewViews(const LLUUID& id)
}
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;
}
if (objectp->getType() <= LLAssetType::AT_NONE ||
objectp->getType() >= LLAssetType::AT_COUNT)
{
- llwarns << "LLInventoryPanel::buildNewViews called with invalid objectp->mType : " <<
- ((S32) objectp->getType()) << " name " << objectp->getName() << " UUID " << objectp->getUUID() << llendl;
+ llwarns << "LLInventoryPanel::buildNewViews called with invalid objectp->mType : "
+ << ((S32) objectp->getType()) << " name " << objectp->getName() << " UUID " << objectp->getUUID()
+ << llendl;
return;
}
- if (objectp->getType() == LLAssetType::AT_CATEGORY &&
- objectp->getActualType() != LLAssetType::AT_LINK_FOLDER)
+ if ((objectp->getType() == LLAssetType::AT_CATEGORY) &&
+ (objectp->getActualType() != LLAssetType::AT_LINK_FOLDER))
{
LLInvFVBridge* new_listener = mInvFVBridgeBuilder->createBridge(objectp->getType(),
objectp->getType(),
@@ -471,9 +474,8 @@ void LLInventoryPanel::buildNewViews(const LLUUID& id)
folderp->setItemSortOrder(mFolders->getSortOrder());
itemp = folderp;
- // Hide the root folder, so we can show the contents of a folder
- // flat but still have the parent folder present for listener-related
- // operations.
+ // Hide the root folder, so we can show the contents of a folder flat
+ // but still have the parent folder present for listener-related operations.
if (id == mStartFolderID)
{
folderp->setDontShowInHierarchy(TRUE);
@@ -482,7 +484,7 @@ void LLInventoryPanel::buildNewViews(const LLUUID& id)
}
else
{
- // Build new view for item
+ // Build new view for item.
LLInventoryItem* item = (LLInventoryItem*)objectp;
LLInvFVBridge* new_listener = mInvFVBridgeBuilder->createBridge(item->getType(),
item->getActualType(),
@@ -518,23 +520,26 @@ void LLInventoryPanel::buildNewViews(const LLUUID& id)
{
LLViewerInventoryCategory::cat_array_t* categories;
LLViewerInventoryItem::item_array_t* items;
-
mInventory->lockDirectDescendentArrays(id, categories, items);
+
if(categories)
{
- S32 count = categories->count();
- for(S32 i = 0; i < count; ++i)
+ for (LLViewerInventoryCategory::cat_array_t::const_iterator cat_iter = categories->begin();
+ cat_iter != categories->end();
+ ++cat_iter)
{
- LLInventoryCategory* cat = categories->get(i);
+ const LLInventoryCategory* cat = (*cat_iter);
buildNewViews(cat->getUUID());
}
}
+
if(items)
{
- S32 count = items->count();
- for(S32 i = 0; i < count; ++i)
+ for (LLViewerInventoryItem::item_array_t::const_iterator item_iter = items->begin();
+ item_iter != items->end();
+ ++item_iter)
{
- LLInventoryItem* item = items->get(i);
+ const LLInventoryItem* item = (*item_iter);
buildNewViews(item->getUUID());
}
}
@@ -562,39 +567,6 @@ void LLInventoryPanel::defaultOpenInventory()
}
}
-struct LLConfirmPurgeData
-{
- LLUUID mID;
- LLInventoryModel* mModel;
-};
-
-class LLIsNotWorn : public LLInventoryCollectFunctor
-{
-public:
- LLIsNotWorn() {}
- virtual ~LLIsNotWorn() {}
- virtual bool operator()(LLInventoryCategory* cat,
- LLInventoryItem* item)
- {
- return !gAgentWearables.isWearingItem(item->getUUID());
- }
-};
-
-class LLOpenFolderByID : public LLFolderViewFunctor
-{
-public:
- LLOpenFolderByID(const LLUUID& id) : mID(id) {}
- virtual ~LLOpenFolderByID() {}
- virtual void doFolder(LLFolderViewFolder* folder)
- {
- if (folder->getListener() && folder->getListener()->getUUID() == mID) folder->setOpenArrangeRecursively(TRUE, LLFolderViewFolder::RECURSE_UP);
- }
- virtual void doItem(LLFolderViewItem* item) {}
-protected:
- const LLUUID& mID;
-};
-
-
void LLInventoryPanel::openSelected()
{
LLFolderViewItem* folder_item = mFolders->getCurSelectedItem();
@@ -659,7 +631,6 @@ void LLInventoryPanel::onFocusReceived()
LLPanel::onFocusReceived();
}
-
void LLInventoryPanel::openAllFolders()
{
mFolders->setOpenArrangeRecursively(TRUE, LLFolderViewFolder::RECURSE_DOWN);
@@ -696,8 +667,6 @@ void LLInventoryPanel::onSelectionChange(const std::deque<LLFolderViewItem*>& it
// Seraph - Put determineFolderType in here for ensemble typing?
}
-//----------------------------------------------------------------------------
-
void LLInventoryPanel::doToSelected(const LLSD& userdata)
{
mFolders->doToSelected(&gInventory, userdata);
@@ -855,55 +824,37 @@ bool LLInventoryPanel::attachObject(const LLSD& userdata)
return true;
}
-
-//----------------------------------------------------------------------------
-
-// static DEBUG ONLY:
-void LLInventoryPanel::dumpSelectionInformation(void* user_data)
-{
- LLInventoryPanel* iv = (LLInventoryPanel*)user_data;
- iv->mFolders->dumpSelectionInformation();
-}
-
BOOL LLInventoryPanel::getSinceLogoff()
{
return mFolders->getFilter()->isSinceLogoff();
}
-void example_param_block_usage()
+// DEBUG ONLY
+// static
+void LLInventoryPanel::dumpSelectionInformation(void* user_data)
{
- LLInventoryPanel::Params param_block;
- param_block.name(std::string("inventory"));
-
- param_block.sort_order_setting(LLInventoryPanel::RECENTITEMS_SORT_ORDER);
- param_block.allow_multi_select(true);
- param_block.filter(LLInventoryPanel::Filter()
- .sort_order(1)
- .types(0xffff0000));
- param_block.inventory(&gInventory);
- param_block.has_border(true);
-
- LLUICtrlFactory::create<LLInventoryPanel>(param_block);
-
- param_block = LLInventoryPanel::Params();
- param_block.name(std::string("inventory"));
-
- //LLSD param_block_sd;
- //param_block_sd["sort_order_setting"] = LLInventoryPanel::RECENTITEMS_SORT_ORDER;
- //param_block_sd["allow_multi_select"] = true;
- //param_block_sd["filter"]["sort_order"] = 1;
- //param_block_sd["filter"]["types"] = (S32)0xffff0000;
- //param_block_sd["has_border"] = true;
-
- //LLInitParam::LLSDParser(param_block_sd).parse(param_block);
-
- LLUICtrlFactory::create<LLInventoryPanel>(param_block);
+ LLInventoryPanel* iv = (LLInventoryPanel*)user_data;
+ iv->mFolders->dumpSelectionInformation();
}
-// +=================================================+
-// | LLInventoryPanelObserver |
-// +=================================================+
-void LLInventoryPanelObserver::changed(U32 mask)
+// static
+LLInventoryPanel* LLInventoryPanel::getActiveInventoryPanel()
{
- mIP->modelChanged(mask);
+ LLInventoryPanel* res = NULL;
+ LLFloaterReg::const_instance_list_t& inst_list = LLFloaterReg::getFloaterList("inventory");
+ S32 z_min = S32_MAX;
+ for (LLFloaterReg::const_instance_list_t::const_iterator iter = inst_list.begin(); iter != inst_list.end(); ++iter)
+ {
+ LLFloaterInventory* iv = dynamic_cast<LLFloaterInventory*>(*iter);
+ if (iv)
+ {
+ S32 z_order = gFloaterView->getZOrder(iv);
+ if (z_order < z_min)
+ {
+ res = iv->getPanel();
+ z_min = z_order;
+ }
+ }
+ }
+ return res;
}
diff --git a/indra/newview/llinventorypanel.h b/indra/newview/llinventorypanel.h
index fd83729630..d65fe53812 100644
--- a/indra/newview/llinventorypanel.h
+++ b/indra/newview/llinventorypanel.h
@@ -162,11 +162,9 @@ public:
static void onIdle(void* user_data);
-private:
+ // Find whichever inventory panel is active / on top.
+ static LLInventoryPanel *getActiveInventoryPanel();
- // Given the id and the parent, build all of the folder views.
- void rebuildViewsFor(const LLUUID& id);
- virtual void buildNewViews(const LLUUID& id); // made virtual to support derived classes. EXT-719
protected:
void defaultOpenInventory(); // open the first level of inventory
@@ -193,12 +191,14 @@ protected:
public:
BOOL getIsViewsInitialized() const { return mViewsInitialized; }
const LLUUID& getStartFolderID() const { return mStartFolderID; }
-private:
+protected:
// Builds the UI. Call this once the inventory is usable.
void initializeViews();
+ void rebuildViewsFor(const LLUUID& id); // Given the id and the parent, build all of the folder views.
+ virtual void buildNewViews(const LLUUID& id);
+private:
BOOL mBuildDefaultHierarchy; // default inventory hierarchy should be created in postBuild()
BOOL mViewsInitialized; // Views have been generated
-
// UUID of category from which hierarchy should be built. Set with the
// "start_folder" xml property. Default is LLUUID::null that means total Inventory hierarchy.
std::string mStartFolderString;