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.cpp186
1 files changed, 131 insertions, 55 deletions
diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp
index 9141d50829..15c872a7c4 100644
--- a/indra/newview/llinventorypanel.cpp
+++ b/indra/newview/llinventorypanel.cpp
@@ -38,11 +38,14 @@
#include "llagent.h"
#include "llagentwearables.h"
#include "llappearancemgr.h"
+#include "llavataractions.h"
#include "llfloaterinventory.h"
#include "llfloaterreg.h"
#include "llimfloater.h"
#include "llimview.h"
#include "llinventorybridge.h"
+#include "llinventoryfunctions.h"
+#include "llinventorymodelbackgroundfetch.h"
#include "llsidepanelinventory.h"
#include "llsidetray.h"
#include "llscrollcontainer.h"
@@ -78,7 +81,7 @@ protected:
LLInventoryPanel::LLInventoryPanel(const LLInventoryPanel::Params& p) :
LLPanel(p),
mInventoryObserver(NULL),
- mFolders(NULL),
+ mFolderRoot(NULL),
mScroller(NULL),
mSortOrderSetting(p.sort_order_setting),
mInventory(p.inventory),
@@ -97,6 +100,7 @@ LLInventoryPanel::LLInventoryPanel(const LLInventoryPanel::Params& p) :
mCommitCallbackRegistrar.add("Inventory.DoCreate", boost::bind(&LLInventoryPanel::doCreate, this, _2));
mCommitCallbackRegistrar.add("Inventory.AttachObject", boost::bind(&LLInventoryPanel::attachObject, this, _2));
mCommitCallbackRegistrar.add("Inventory.BeginIMSession", boost::bind(&LLInventoryPanel::beginIMSession, this));
+ mCommitCallbackRegistrar.add("Inventory.Share", boost::bind(&LLAvatarActions::shareWithAvatars));
if (mStartFolderString != "")
{
@@ -118,16 +122,17 @@ BOOL LLInventoryPanel::postBuild()
0);
LLFolderView::Params p;
p.name = getName();
+ p.title = getLabel();
p.rect = folder_rect;
p.parent_panel = this;
p.tool_tip = p.name;
- mFolders = LLUICtrlFactory::create<LLFolderView>(p);
- mFolders->setAllowMultiSelect(mAllowMultiSelect);
+ mFolderRoot = LLUICtrlFactory::create<LLFolderView>(p);
+ mFolderRoot->setAllowMultiSelect(mAllowMultiSelect);
}
mCommitCallbackRegistrar.popScope();
- mFolders->setCallbackRegistrar(&mCommitCallbackRegistrar);
+ mFolderRoot->setCallbackRegistrar(&mCommitCallbackRegistrar);
// Scroller
{
@@ -141,8 +146,9 @@ BOOL LLInventoryPanel::postBuild()
p.tab_stop(true);
mScroller = LLUICtrlFactory::create<LLScrollContainer>(p);
addChild(mScroller);
- mScroller->addChild(mFolders);
- mFolders->setScrollContainer(mScroller);
+ mScroller->addChild(mFolderRoot);
+ mFolderRoot->setScrollContainer(mScroller);
+ mFolderRoot->addChild(mFolderRoot->mStatusTextBox);
}
// Set up the callbacks from the inventory we're viewing, and then build everything.
@@ -165,16 +171,16 @@ BOOL LLInventoryPanel::postBuild()
{
setSortOrder(gSavedSettings.getU32(DEFAULT_SORT_ORDER));
}
- mFolders->setSortOrder(getFilter()->getSortOrder());
+ mFolderRoot->setSortOrder(getFilter()->getSortOrder());
return TRUE;
}
LLInventoryPanel::~LLInventoryPanel()
{
- if (mFolders)
+ if (mFolderRoot)
{
- U32 sort_order = mFolders->getSortOrder();
+ U32 sort_order = mFolderRoot->getSortOrder();
if (mSortOrderSetting != INHERIT_SORT_ORDER)
{
gSavedSettings.setU32(mSortOrderSetting, sort_order);
@@ -190,15 +196,15 @@ LLInventoryPanel::~LLInventoryPanel()
void LLInventoryPanel::draw()
{
// Select the desired item (in case it wasn't loaded when the selection was requested)
- mFolders->updateSelection();
+ mFolderRoot->updateSelection();
LLPanel::draw();
}
LLInventoryFilter* LLInventoryPanel::getFilter()
{
- if (mFolders)
+ if (mFolderRoot)
{
- return mFolders->getFilter();
+ return mFolderRoot->getFilter();
}
return NULL;
}
@@ -226,9 +232,9 @@ void LLInventoryPanel::setSortOrder(U32 order)
getFilter()->setSortOrder(order);
if (getFilter()->isModified())
{
- mFolders->setSortOrder(order);
+ mFolderRoot->setSortOrder(order);
// try to keep selection onscreen, even if it wasn't to start with
- mFolders->scrollToShowSelection();
+ mFolderRoot->scrollToShowSelection();
}
}
@@ -273,8 +279,8 @@ void LLInventoryPanel::modelChanged(U32 mask)
{
const LLUUID& item_id = (*items_iter);
const LLInventoryObject* model_item = model->getObject(item_id);
- LLFolderViewItem* view_item = mFolders->getItemByID(item_id);
- LLFolderViewFolder* view_folder = mFolders->getFolderByID(item_id);
+ LLFolderViewItem* view_item = mFolderRoot->getItemByID(item_id);
+ LLFolderViewFolder* view_folder = mFolderRoot->getFolderByID(item_id);
//////////////////////////////
// LABEL Operation
@@ -289,8 +295,9 @@ void LLInventoryPanel::modelChanged(U32 mask)
if(bridge)
{ // Clear the display name first, so it gets properly re-built during refresh()
bridge->clearDisplayName();
+
+ view_item->refresh();
}
- view_item->refresh();
}
}
@@ -348,7 +355,7 @@ void LLInventoryPanel::modelChanged(U32 mask)
// Add the UI element for this item.
buildNewViews(item_id);
// Select any newly created object that has the auto rename at top of folder root set.
- if(mFolders->getRoot()->needsAutoRename())
+ if(mFolderRoot->getRoot()->needsAutoRename())
{
setSelection(item_id, FALSE);
}
@@ -363,7 +370,7 @@ void LLInventoryPanel::modelChanged(U32 mask)
// model_item's parent will be NULL.
if (view_item->getRoot() != view_item->getParent())
{
- LLFolderViewFolder* new_parent = (LLFolderViewFolder*)mFolders->getItemByID(model_item->getParentUUID());
+ LLFolderViewFolder* new_parent = (LLFolderViewFolder*)mFolderRoot->getItemByID(model_item->getParentUUID());
// Item has been moved.
if (view_item->getParentFolder() != new_parent)
{
@@ -371,7 +378,7 @@ void LLInventoryPanel::modelChanged(U32 mask)
{
// 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);
+ view_item->addToFolder(new_parent, mFolderRoot);
}
else
{
@@ -432,13 +439,32 @@ void LLInventoryPanel::initializeViews()
rebuildViewsFor(mStartFolderID);
mViewsInitialized = true;
+
openStartFolderOrMyInventory();
+
+ // Special case for new user login
+ if (gAgent.isFirstLogin())
+ {
+ // Auto open the user's library
+ LLFolderViewFolder* lib_folder = mFolderRoot->getFolderByID(gInventory.getLibraryRootFolderID());
+ if (lib_folder)
+ {
+ lib_folder->setOpen(TRUE);
+ }
+
+ // Auto close the user's my inventory folder
+ LLFolderViewFolder* my_inv_folder = mFolderRoot->getFolderByID(gInventory.getRootFolderID());
+ if (my_inv_folder)
+ {
+ my_inv_folder->setOpenArrangeRecursively(FALSE, LLFolderViewFolder::RECURSE_DOWN);
+ }
+ }
}
void LLInventoryPanel::rebuildViewsFor(const LLUUID& id)
{
// Destroy the old view for this ID so we can rebuild it.
- LLFolderViewItem* old_view = mFolders->getItemByID(id);
+ LLFolderViewItem* old_view = mFolderRoot->getItemByID(id);
if (old_view && id.notNull())
{
old_view->destroyView();
@@ -455,10 +481,10 @@ void LLInventoryPanel::buildNewViews(const LLUUID& id)
if (objectp)
{
const LLUUID &parent_id = objectp->getParentUUID();
- LLFolderViewFolder* parent_folder = (LLFolderViewFolder*)mFolders->getItemByID(parent_id);
+ LLFolderViewFolder* parent_folder = (LLFolderViewFolder*)mFolderRoot->getItemByID(parent_id);
if (id == mStartFolderID)
{
- parent_folder = mFolders;
+ parent_folder = mFolderRoot;
}
else if ((mStartFolderID != LLUUID::null) && (!gInventory.isObjectDescendentOf(id, mStartFolderID)))
{
@@ -482,19 +508,19 @@ void LLInventoryPanel::buildNewViews(const LLUUID& id)
objectp->getType(),
LLInventoryType::IT_CATEGORY,
this,
+ mFolderRoot,
objectp->getUUID());
-
if (new_listener)
{
LLFolderViewFolder::Params params;
params.name = new_listener->getDisplayName();
params.icon = new_listener->getIcon();
params.icon_open = new_listener->getOpenIcon();
- params.root = mFolders;
+ params.root = mFolderRoot;
params.listener = new_listener;
params.tool_tip = params.name;
LLFolderViewFolder* folderp = LLUICtrlFactory::create<LLFolderViewFolder>(params);
- folderp->setItemSortOrder(mFolders->getSortOrder());
+ folderp->setItemSortOrder(mFolderRoot->getSortOrder());
itemp = folderp;
// Hide the root folder, so we can show the contents of a folder flat
@@ -503,6 +529,11 @@ void LLInventoryPanel::buildNewViews(const LLUUID& id)
{
folderp->setHidden(TRUE);
}
+ const LLViewerInventoryCategory *cat = dynamic_cast<LLViewerInventoryCategory *>(objectp);
+ if (cat && getIsHiddenFolderType(cat->getPreferredType()))
+ {
+ folderp->setHidden(TRUE);
+ }
}
}
else
@@ -513,6 +544,7 @@ void LLInventoryPanel::buildNewViews(const LLUUID& id)
item->getActualType(),
item->getInventoryType(),
this,
+ mFolderRoot,
item->getUUID(),
item->getFlags());
@@ -523,7 +555,7 @@ void LLInventoryPanel::buildNewViews(const LLUUID& id)
params.icon = new_listener->getIcon();
params.icon_open = new_listener->getOpenIcon();
params.creation_date = new_listener->getCreationDate();
- params.root = mFolders;
+ params.root = mFolderRoot;
params.listener = new_listener;
params.rect = LLRect (0, 0, 0, 0);
params.tool_tip = params.name;
@@ -533,7 +565,13 @@ void LLInventoryPanel::buildNewViews(const LLUUID& id)
if (itemp)
{
- itemp->addToFolder(parent_folder, mFolders);
+ itemp->addToFolder(parent_folder, mFolderRoot);
+
+ // Don't add children of hidden folders unless this is the panel's root folder.
+ if (itemp->getHidden() && (id != mStartFolderID))
+ {
+ return;
+ }
}
}
@@ -576,19 +614,19 @@ void LLInventoryPanel::openStartFolderOrMyInventory()
{
if (mStartFolderString != "")
{
- mFolders->openFolder(mStartFolderString);
+ mFolderRoot->openFolder(mStartFolderString);
}
else
{
// Find My Inventory folder and open it up by name
- for (LLView *child = mFolders->getFirstChild(); child; child = mFolders->findNextSibling(child))
+ for (LLView *child = mFolderRoot->getFirstChild(); child; child = mFolderRoot->findNextSibling(child))
{
LLFolderViewFolder *fchild = dynamic_cast<LLFolderViewFolder*>(child);
if (fchild && fchild->getListener() &&
(fchild->getListener()->getUUID() == gInventory.getRootFolderID()))
{
const std::string& child_name = child->getName();
- mFolders->openFolder(child_name);
+ mFolderRoot->openFolder(child_name);
break;
}
}
@@ -597,7 +635,7 @@ void LLInventoryPanel::openStartFolderOrMyInventory()
void LLInventoryPanel::openSelected()
{
- LLFolderViewItem* folder_item = mFolders->getCurSelectedItem();
+ LLFolderViewItem* folder_item = mFolderRoot->getCurSelectedItem();
if(!folder_item) return;
LLInvFVBridge* bridge = (LLInvFVBridge*)folder_item->getListener();
if(!bridge) return;
@@ -610,7 +648,7 @@ BOOL LLInventoryPanel::handleHover(S32 x, S32 y, MASK mask)
if(handled)
{
ECursorType cursor = getWindow()->getCursor();
- if (LLInventoryModel::backgroundFetchActive() && cursor == UI_CURSOR_ARROW)
+ if (LLInventoryModelBackgroundFetch::instance().backgroundFetchActive() && cursor == UI_CURSOR_ARROW)
{
// replace arrow cursor with arrow and hourglass cursor
getWindow()->setCursor(UI_CURSOR_WORKING);
@@ -633,23 +671,39 @@ BOOL LLInventoryPanel::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
// If folder view is empty the (x, y) point won't be in its rect
// so the handler must be called explicitly.
- if (!mFolders->hasVisibleChildren())
+ // but only if was not handled before. See EXT-6746.
+ if (!handled && !mFolderRoot->hasVisibleChildren())
{
- handled = mFolders->handleDragAndDrop(x, y, mask, drop, cargo_type, cargo_data, accept, tooltip_msg);
+ handled = mFolderRoot->handleDragAndDrop(x, y, mask, drop, cargo_type, cargo_data, accept, tooltip_msg);
}
if (handled)
{
- mFolders->setDragAndDropThisFrame();
+ mFolderRoot->setDragAndDropThisFrame();
}
return handled;
}
+// virtual
+void LLInventoryPanel::onMouseEnter(S32 x, S32 y, MASK mask)
+{
+ LLPanel::onMouseEnter(x, y, mask);
+ // don't auto-scroll a list when cursor is over Inventory. See EXT-3981.
+ mFolderRoot->setEnableScroll(false);
+}
+
+// virtual
+void LLInventoryPanel::onMouseLeave(S32 x, S32 y, MASK mask)
+{
+ LLPanel::onMouseLeave(x, y, mask);
+ mFolderRoot->setEnableScroll(true);
+}
+
void LLInventoryPanel::onFocusLost()
{
// inventory no longer handles cut/copy/paste/delete
- if (LLEditMenuHandler::gEditMenuHandler == mFolders)
+ if (LLEditMenuHandler::gEditMenuHandler == mFolderRoot)
{
LLEditMenuHandler::gEditMenuHandler = NULL;
}
@@ -660,31 +714,39 @@ void LLInventoryPanel::onFocusLost()
void LLInventoryPanel::onFocusReceived()
{
// inventory now handles cut/copy/paste/delete
- LLEditMenuHandler::gEditMenuHandler = mFolders;
+ LLEditMenuHandler::gEditMenuHandler = mFolderRoot;
LLPanel::onFocusReceived();
}
void LLInventoryPanel::openAllFolders()
{
- mFolders->setOpenArrangeRecursively(TRUE, LLFolderViewFolder::RECURSE_DOWN);
- mFolders->arrangeAll();
+ mFolderRoot->setOpenArrangeRecursively(TRUE, LLFolderViewFolder::RECURSE_DOWN);
+ mFolderRoot->arrangeAll();
}
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).
const LLInventoryObject *obj = gInventory.getObject(obj_id);
- if (obj && obj->getParentUUID() == LLAppearanceManager::instance().getCOF())
+ if (obj && obj->getParentUUID() == LLAppearanceMgr::instance().getCOF())
{
return;
}
- mFolders->setSelectionByID(obj_id, take_keyboard_focus);
+ mFolderRoot->setSelectionByID(obj_id, take_keyboard_focus);
+}
+
+void LLInventoryPanel::setSelectCallback(const LLFolderView::signal_t::slot_type& cb)
+{
+ if (mFolderRoot)
+ {
+ mFolderRoot->setSelectCallback(cb);
+ }
}
void LLInventoryPanel::clearSelection()
{
- mFolders->clearSelection();
+ mFolderRoot->clearSelection();
}
void LLInventoryPanel::onSelectionChange(const std::deque<LLFolderViewItem*>& items, BOOL user_action)
@@ -703,18 +765,18 @@ void LLInventoryPanel::onSelectionChange(const std::deque<LLFolderViewItem*>& it
void LLInventoryPanel::doToSelected(const LLSD& userdata)
{
- mFolders->doToSelected(&gInventory, userdata);
+ mFolderRoot->doToSelected(&gInventory, userdata);
}
void LLInventoryPanel::doCreate(const LLSD& userdata)
{
- menu_create_inventory_item(mFolders, LLFolderBridge::sSelf, userdata);
+ menu_create_inventory_item(mFolderRoot, LLFolderBridge::sSelf, userdata);
}
bool LLInventoryPanel::beginIMSession()
{
std::set<LLUUID> selected_items;
- mFolders->getSelectionList(selected_items);
+ mFolderRoot->getSelectionList(selected_items);
std::string name;
static int session_num = 1;
@@ -727,7 +789,7 @@ bool LLInventoryPanel::beginIMSession()
{
LLUUID item = *iter;
- LLFolderViewItem* folder_item = mFolders->getItemByID(item);
+ LLFolderViewItem* folder_item = mFolderRoot->getItemByID(item);
if(folder_item)
{
@@ -751,7 +813,9 @@ bool LLInventoryPanel::beginIMSession()
S32 count = item_array.count();
if(count > 0)
{
- LLFloaterReg::showInstance("communicate");
+ //*TODO by what to replace that?
+ //LLFloaterReg::showInstance("communicate");
+
// create the session
LLAvatarTracker& at = LLAvatarTracker::instance();
LLUUID id;
@@ -767,7 +831,7 @@ bool LLInventoryPanel::beginIMSession()
}
else
{
- LLFolderViewItem* folder_item = mFolders->getItemByID(item);
+ LLFolderViewItem* folder_item = mFolderRoot->getItemByID(item);
if(!folder_item) return true;
LLInvFVBridge* listenerp = (LLInvFVBridge*)folder_item->getListener();
@@ -810,13 +874,12 @@ bool LLInventoryPanel::beginIMSession()
bool LLInventoryPanel::attachObject(const LLSD& userdata)
{
std::set<LLUUID> selected_items;
- mFolders->getSelectionList(selected_items);
+ mFolderRoot->getSelectionList(selected_items);
std::string joint_name = userdata.asString();
- LLVOAvatar *avatarp = static_cast<LLVOAvatar*>(gAgent.getAvatarObject());
LLViewerJointAttachment* attachmentp = NULL;
- for (LLVOAvatar::attachment_map_t::iterator iter = avatarp->mAttachmentPoints.begin();
- iter != avatarp->mAttachmentPoints.end(); )
+ for (LLVOAvatar::attachment_map_t::iterator iter = gAgentAvatarp->mAttachmentPoints.begin();
+ iter != gAgentAvatarp->mAttachmentPoints.end(); )
{
LLVOAvatar::attachment_map_t::iterator curiter = iter++;
LLViewerJointAttachment* attachment = curiter->second;
@@ -841,7 +904,7 @@ bool LLInventoryPanel::attachObject(const LLSD& userdata)
{
rez_attachment(item, attachmentp);
}
- else if(item && item->isComplete())
+ else if(item && item->isFinished())
{
// must be in library. copy it to our inventory and put it on.
LLPointer<LLInventoryCallback> cb = new RezAttachmentCallback(attachmentp);
@@ -868,7 +931,7 @@ BOOL LLInventoryPanel::getSinceLogoff()
void LLInventoryPanel::dumpSelectionInformation(void* user_data)
{
LLInventoryPanel* iv = (LLInventoryPanel*)user_data;
- iv->mFolders->dumpSelectionInformation();
+ iv->mFolderRoot->dumpSelectionInformation();
}
BOOL is_inventorysp_active()
@@ -925,3 +988,16 @@ LLInventoryPanel* LLInventoryPanel::getActiveInventoryPanel(BOOL auto_open)
return NULL;
}
+
+void LLInventoryPanel::addHideFolderType(LLFolderType::EType folder_type)
+{
+ if (!getIsHiddenFolderType(folder_type))
+ {
+ mHiddenFolderTypes.push_back(folder_type);
+ }
+}
+
+BOOL LLInventoryPanel::getIsHiddenFolderType(LLFolderType::EType folder_type) const
+{
+ return (std::find(mHiddenFolderTypes.begin(), mHiddenFolderTypes.end(), folder_type) != mHiddenFolderTypes.end());
+}