summaryrefslogtreecommitdiff
path: root/indra/newview/llinventorypanel.cpp
diff options
context:
space:
mode:
authorOz Linden <oz@lindenlab.com>2014-04-22 13:05:26 -0400
committerOz Linden <oz@lindenlab.com>2014-04-22 13:05:26 -0400
commitb4ca93cadce90466d41704b68933c21fe909bcb8 (patch)
tree34b19278571d885a42c5ae31baeb5af532e7ea39 /indra/newview/llinventorypanel.cpp
parentcd382d08c84e2d984a4a20888280084daa290c3f (diff)
parentb1a7137ba6e56e1b692205f129d86acc942209e9 (diff)
merge up to 3.7.6-release
Diffstat (limited to 'indra/newview/llinventorypanel.cpp')
-rwxr-xr-xindra/newview/llinventorypanel.cpp194
1 files changed, 109 insertions, 85 deletions
diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp
index e5b9e11d48..81ee7ac07e 100755
--- a/indra/newview/llinventorypanel.cpp
+++ b/indra/newview/llinventorypanel.cpp
@@ -137,7 +137,6 @@ LLInventoryPanel::LLInventoryPanel(const LLInventoryPanel::Params& p) :
LLPanel(p),
mInventoryObserver(NULL),
mCompletionObserver(NULL),
- mFolderRoot(NULL),
mScroller(NULL),
mSortOrderSetting(p.sort_order_setting),
mInventory(p.inventory),
@@ -196,6 +195,32 @@ LLFolderView * LLInventoryPanel::createFolderRoot(LLUUID root_id )
return LLUICtrlFactory::create<LLFolderView>(p);
}
+void LLInventoryPanel::clearFolderRoot()
+{
+ gIdleCallbacks.deleteFunction(idle, this);
+ gIdleCallbacks.deleteFunction(onIdle, this);
+
+ if (mInventoryObserver)
+ {
+ mInventory->removeObserver(mInventoryObserver);
+ delete mInventoryObserver;
+ mInventoryObserver = NULL;
+ }
+ if (mCompletionObserver)
+ {
+ mInventory->removeObserver(mCompletionObserver);
+ delete mCompletionObserver;
+ mCompletionObserver = NULL;
+ }
+
+ if (mScroller)
+ {
+ removeChild(mScroller);
+ delete mScroller;
+ mScroller = NULL;
+ }
+}
+
void LLInventoryPanel::initFromParams(const LLInventoryPanel::Params& params)
{
// save off copy of params
@@ -203,23 +228,23 @@ void LLInventoryPanel::initFromParams(const LLInventoryPanel::Params& params)
// Clear up the root view
// Note: This needs to be done *before* we build the new folder view
LLUUID root_id = getRootFolderID();
- if (mFolderRoot)
+ if (mFolderRoot.get())
{
removeItemID(root_id);
- mFolderRoot->destroyView();
- mFolderRoot = NULL;
+ mFolderRoot.get()->destroyView();
}
mCommitCallbackRegistrar.pushScope(); // registered as a widget; need to push callback scope ourselves
{
// Determine the root folder in case specified, and
// build the views starting with that folder.
- mFolderRoot = createFolderRoot(root_id);
+ LLFolderView* folder_view = createFolderRoot(root_id);
+ mFolderRoot = folder_view->getHandle();
- addItemID(root_id, mFolderRoot);
+ addItemID(root_id, mFolderRoot.get());
}
mCommitCallbackRegistrar.popScope();
- mFolderRoot->setCallbackRegistrar(&mCommitCallbackRegistrar);
+ mFolderRoot.get()->setCallbackRegistrar(&mCommitCallbackRegistrar);
// Scroller
LLRect scroller_view_rect = getRect();
@@ -228,10 +253,10 @@ void LLInventoryPanel::initFromParams(const LLInventoryPanel::Params& params)
scroller_params.rect(scroller_view_rect);
mScroller = LLUICtrlFactory::create<LLFolderViewScrollContainer>(scroller_params);
addChild(mScroller);
- mScroller->addChild(mFolderRoot);
- mFolderRoot->setScrollContainer(mScroller);
- mFolderRoot->setFollowsAll();
- mFolderRoot->addChild(mFolderRoot->mStatusTextBox);
+ mScroller->addChild(mFolderRoot.get());
+ mFolderRoot.get()->setScrollContainer(mScroller);
+ mFolderRoot.get()->setFollowsAll();
+ mFolderRoot.get()->addChild(mFolderRoot.get()->mStatusTextBox);
// Set up the callbacks from the inventory we're viewing, and then build everything.
mInventoryObserver = new LLInventoryPanelObserver(this);
@@ -259,8 +284,11 @@ void LLInventoryPanel::initFromParams(const LLInventoryPanel::Params& params)
}
// hide inbox
- getFilter().setFilterCategoryTypes(getFilter().getFilterCategoryTypes() & ~(1ULL << LLFolderType::FT_INBOX));
- getFilter().setFilterCategoryTypes(getFilter().getFilterCategoryTypes() & ~(1ULL << LLFolderType::FT_OUTBOX));
+ if (!gSavedSettings.getBOOL("InventoryOutboxMakeVisible"))
+ {
+ getFilter().setFilterCategoryTypes(getFilter().getFilterCategoryTypes() & ~(1ULL << LLFolderType::FT_INBOX));
+ getFilter().setFilterCategoryTypes(getFilter().getFilterCategoryTypes() & ~(1ULL << LLFolderType::FT_OUTBOX));
+ }
// set the filter for the empty folder if the debug setting is on
if (gSavedSettings.getBOOL("DebugHideEmptySystemFolders"))
@@ -277,23 +305,13 @@ void LLInventoryPanel::initFromParams(const LLInventoryPanel::Params& params)
LLInventoryPanel::~LLInventoryPanel()
{
- gIdleCallbacks.deleteFunction(idle, this);
-
U32 sort_order = getFolderViewModel()->getSorter().getSortOrder();
- if (mSortOrderSetting != INHERIT_SORT_ORDER)
- {
- gSavedSettings.setU32(mSortOrderSetting, sort_order);
- }
-
- gIdleCallbacks.deleteFunction(onIdle, this);
-
- // LLView destructor will take care of the sub-views.
- mInventory->removeObserver(mInventoryObserver);
- mInventory->removeObserver(mCompletionObserver);
- delete mInventoryObserver;
- delete mCompletionObserver;
-
- mScroller = NULL;
+ if (mSortOrderSetting != INHERIT_SORT_ORDER)
+ {
+ gSavedSettings.setU32(mSortOrderSetting, sort_order);
+ }
+
+ clearFolderRoot();
}
void LLInventoryPanel::draw()
@@ -360,9 +378,9 @@ void LLInventoryPanel::setSortOrder(U32 order)
if (order != getFolderViewModel()->getSorter().getSortOrder())
{
getFolderViewModel()->setSorter(sorter);
- mFolderRoot->arrangeAll();
+ mFolderRoot.get()->arrangeAll();
// try to keep selection onscreen, even if it wasn't to start with
- mFolderRoot->scrollToShowSelection();
+ mFolderRoot.get()->scrollToShowSelection();
}
}
@@ -505,7 +523,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(mFolderRoot->getRoot()->needsAutoRename())
+ if(mFolderRoot.get()->getRoot()->needsAutoRename())
{
setSelection(item_id, FALSE);
}
@@ -556,17 +574,11 @@ void LLInventoryPanel::modelChanged(U32 mask)
}
}
-LLFolderView* LLInventoryPanel::getRootFolder()
-{
- return mFolderRoot;
-}
-
LLUUID LLInventoryPanel::getRootFolderID()
{
- if (mFolderRoot && mFolderRoot->getViewModelItem())
+ if (mFolderRoot.get() && mFolderRoot.get()->getViewModelItem())
{
- return static_cast<LLFolderViewModelItemInventory*>(mFolderRoot->getViewModelItem())->getUUID();
-
+ return static_cast<LLFolderViewModelItemInventory*>(mFolderRoot.get()->getViewModelItem())->getUUID();
}
else
{
@@ -587,6 +599,9 @@ LLUUID LLInventoryPanel::getRootFolderID()
}
else if (preferred_type != LLFolderType::FT_NONE)
{
+ LLStringExplicit label(mParams.start_folder.name());
+ setLabel(label);
+
root_id = gInventory.findCategoryUUIDForType(preferred_type, false);
if (root_id.isNull())
{
@@ -646,24 +661,33 @@ void LLInventoryPanel::idle(void* user_data)
}
- panel->mFolderRoot->update();
- // while dragging, update selection rendering to reflect single/multi drag status
- if (LLToolDragAndDrop::getInstance()->hasMouseCapture())
- {
- EAcceptance last_accept = LLToolDragAndDrop::getInstance()->getLastAccept();
- if (last_accept == ACCEPT_YES_SINGLE || last_accept == ACCEPT_YES_COPY_SINGLE)
- {
- panel->mFolderRoot->setShowSingleSelection(TRUE);
- }
- else
- {
- panel->mFolderRoot->setShowSingleSelection(FALSE);
- }
-}
- else
- {
- panel->mFolderRoot->setShowSingleSelection(FALSE);
- }
+ // Take into account the fact that the root folder might be invalidated
+ if (panel->mFolderRoot.get())
+ {
+ panel->mFolderRoot.get()->update();
+ // while dragging, update selection rendering to reflect single/multi drag status
+ if (LLToolDragAndDrop::getInstance()->hasMouseCapture())
+ {
+ EAcceptance last_accept = LLToolDragAndDrop::getInstance()->getLastAccept();
+ if (last_accept == ACCEPT_YES_SINGLE || last_accept == ACCEPT_YES_COPY_SINGLE)
+ {
+ panel->mFolderRoot.get()->setShowSingleSelection(TRUE);
+ }
+ else
+ {
+ panel->mFolderRoot.get()->setShowSingleSelection(FALSE);
+ }
+ }
+ else
+ {
+ panel->mFolderRoot.get()->setShowSingleSelection(FALSE);
+ }
+ }
+ else
+ {
+ llwarns << "Inventory : Deleted folder root detected on panel" << llendl;
+ panel->clearFolderRoot();
+ }
}
@@ -714,7 +738,7 @@ LLFolderViewFolder * LLInventoryPanel::createFolderViewFolder(LLInvFVBridge * br
LLFolderViewFolder::Params params(mParams.folder);
params.name = bridge->getDisplayName();
- params.root = mFolderRoot;
+ params.root = mFolderRoot.get();
params.listener = bridge;
params.tool_tip = params.name;
@@ -730,7 +754,7 @@ LLFolderViewItem * LLInventoryPanel::createFolderViewItem(LLInvFVBridge * bridge
params.name = bridge->getDisplayName();
params.creation_date = bridge->getCreationDate();
- params.root = mFolderRoot;
+ params.root = mFolderRoot.get();
params.listener = bridge;
params.rect = LLRect (0, 0, 0, 0);
params.tool_tip = params.name;
@@ -771,7 +795,7 @@ LLFolderViewItem* LLInventoryPanel::buildNewViews(const LLUUID& id)
LLInventoryType::IT_CATEGORY,
this,
&mInventoryViewModel,
- mFolderRoot,
+ mFolderRoot.get(),
objectp->getUUID());
if (new_listener)
{
@@ -787,7 +811,7 @@ LLFolderViewItem* LLInventoryPanel::buildNewViews(const LLUUID& id)
item->getInventoryType(),
this,
&mInventoryViewModel,
- mFolderRoot,
+ mFolderRoot.get(),
item->getUUID(),
item->getFlags());
@@ -844,7 +868,7 @@ LLFolderViewItem* LLInventoryPanel::buildNewViews(const LLUUID& id)
void LLInventoryPanel::openStartFolderOrMyInventory()
{
// Find My Inventory folder and open it up by name
- for (LLView *child = mFolderRoot->getFirstChild(); child; child = mFolderRoot->findNextSibling(child))
+ for (LLView *child = mFolderRoot.get()->getFirstChild(); child; child = mFolderRoot.get()->findNextSibling(child))
{
LLFolderViewFolder *fchild = dynamic_cast<LLFolderViewFolder*>(child);
if (fchild
@@ -859,12 +883,12 @@ void LLInventoryPanel::openStartFolderOrMyInventory()
void LLInventoryPanel::onItemsCompletion()
{
- if (mFolderRoot) mFolderRoot->updateMenu();
+ if (mFolderRoot.get()) mFolderRoot.get()->updateMenu();
}
void LLInventoryPanel::openSelected()
{
- LLFolderViewItem* folder_item = mFolderRoot->getCurSelectedItem();
+ LLFolderViewItem* folder_item = mFolderRoot.get()->getCurSelectedItem();
if(!folder_item) return;
LLInvFVBridge* bridge = (LLInvFVBridge*)folder_item->getViewModelItem();
if(!bridge) return;
@@ -873,7 +897,7 @@ void LLInventoryPanel::openSelected()
void LLInventoryPanel::unSelectAll()
{
- mFolderRoot->setSelection(NULL, FALSE, FALSE);
+ mFolderRoot.get()->setSelection(NULL, FALSE, FALSE);
}
@@ -911,14 +935,14 @@ 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.
// but only if was not handled before. See EXT-6746.
- if (!handled && !mFolderRoot->hasVisibleChildren())
+ if (!handled && !mFolderRoot.get()->hasVisibleChildren())
{
- handled = mFolderRoot->handleDragAndDrop(x, y, mask, drop, cargo_type, cargo_data, accept, tooltip_msg);
+ handled = mFolderRoot.get()->handleDragAndDrop(x, y, mask, drop, cargo_type, cargo_data, accept, tooltip_msg);
}
if (handled)
{
- mFolderRoot->setDragAndDropThisFrame();
+ mFolderRoot.get()->setDragAndDropThisFrame();
}
}
@@ -928,7 +952,7 @@ BOOL LLInventoryPanel::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
void LLInventoryPanel::onFocusLost()
{
// inventory no longer handles cut/copy/paste/delete
- if (LLEditMenuHandler::gEditMenuHandler == mFolderRoot)
+ if (LLEditMenuHandler::gEditMenuHandler == mFolderRoot.get())
{
LLEditMenuHandler::gEditMenuHandler = NULL;
}
@@ -939,7 +963,7 @@ void LLInventoryPanel::onFocusLost()
void LLInventoryPanel::onFocusReceived()
{
// inventory now handles cut/copy/paste/delete
- LLEditMenuHandler::gEditMenuHandler = mFolderRoot;
+ LLEditMenuHandler::gEditMenuHandler = mFolderRoot.get();
LLPanel::onFocusReceived();
}
@@ -950,7 +974,7 @@ bool LLInventoryPanel::addBadge(LLBadge * badge)
if (acceptsBadge())
{
- badge_added = badge->addToView(mFolderRoot);
+ badge_added = badge->addToView(mFolderRoot.get());
}
return badge_added;
@@ -958,8 +982,8 @@ bool LLInventoryPanel::addBadge(LLBadge * badge)
void LLInventoryPanel::openAllFolders()
{
- mFolderRoot->setOpenArrangeRecursively(TRUE, LLFolderViewFolder::RECURSE_DOWN);
- mFolderRoot->arrangeAll();
+ mFolderRoot.get()->setOpenArrangeRecursively(TRUE, LLFolderViewFolder::RECURSE_DOWN);
+ mFolderRoot.get()->arrangeAll();
}
void LLInventoryPanel::setSelection(const LLUUID& obj_id, BOOL take_keyboard_focus)
@@ -975,9 +999,9 @@ void LLInventoryPanel::setSelection(const LLUUID& obj_id, BOOL take_keyboard_foc
void LLInventoryPanel::setSelectCallback(const boost::function<void (const std::deque<LLFolderViewItem*>& items, BOOL user_action)>& cb)
{
- if (mFolderRoot)
+ if (mFolderRoot.get())
{
- mFolderRoot->setSelectCallback(cb);
+ mFolderRoot.get()->setSelectCallback(cb);
}
}
@@ -1001,7 +1025,7 @@ void LLInventoryPanel::onSelectionChange(const std::deque<LLFolderViewItem*>& it
}
}
- LLFolderView* fv = getRootFolder();
+ LLFolderView* fv = mFolderRoot.get();
if (fv->needsAutoRename()) // auto-selecting a new user-created asset and preparing to rename
{
fv->setNeedsAutoRename(FALSE);
@@ -1020,7 +1044,7 @@ void LLInventoryPanel::doCreate(const LLSD& userdata)
bool LLInventoryPanel::beginIMSession()
{
- std::set<LLFolderViewItem*> selected_items = mFolderRoot->getSelectionList();
+ std::set<LLFolderViewItem*> selected_items = mFolderRoot.get()->getSelectionList();
std::string name;
@@ -1114,7 +1138,7 @@ bool LLInventoryPanel::beginIMSession()
bool LLInventoryPanel::attachObject(const LLSD& userdata)
{
// Copy selected item UUIDs to a vector.
- std::set<LLFolderViewItem*> selected_items = mFolderRoot->getSelectionList();
+ std::set<LLFolderViewItem*> selected_items = mFolderRoot.get()->getSelectionList();
uuid_vec_t items;
for (std::set<LLFolderViewItem*>::const_iterator set_iter = selected_items.begin();
set_iter != selected_items.end();
@@ -1141,7 +1165,7 @@ BOOL LLInventoryPanel::getSinceLogoff()
void LLInventoryPanel::dumpSelectionInformation(void* user_data)
{
LLInventoryPanel* iv = (LLInventoryPanel*)user_data;
- iv->mFolderRoot->dumpSelectionInformation();
+ iv->mFolderRoot.get()->dumpSelectionInformation();
}
BOOL is_inventorysp_active()
@@ -1343,7 +1367,7 @@ void LLInventoryPanel::updateSelection()
void LLInventoryPanel::doToSelected(const LLSD& userdata)
{
- LLInventoryAction::doToSelected(mInventory, mFolderRoot, userdata.asString());
+ LLInventoryAction::doToSelected(mInventory, mFolderRoot.get(), userdata.asString());
return;
}
@@ -1357,7 +1381,7 @@ BOOL LLInventoryPanel::handleKeyHere( KEY key, MASK mask )
// Open selected items if enter key hit on the inventory panel
if (mask == MASK_NONE)
{
- LLInventoryAction::doToSelected(mInventory, mFolderRoot, "open");
+ LLInventoryAction::doToSelected(mInventory, mFolderRoot.get(), "open");
handled = TRUE;
}
break;
@@ -1367,7 +1391,7 @@ BOOL LLInventoryPanel::handleKeyHere( KEY key, MASK mask )
// Note: on Mac laptop keyboards, backspace and delete are one and the same
if (isSelectionRemovable() && (mask == MASK_NONE))
{
- LLInventoryAction::doToSelected(mInventory, mFolderRoot, "delete");
+ LLInventoryAction::doToSelected(mInventory, mFolderRoot.get(), "delete");
handled = TRUE;
}
break;
@@ -1378,9 +1402,9 @@ BOOL LLInventoryPanel::handleKeyHere( KEY key, MASK mask )
bool LLInventoryPanel::isSelectionRemovable()
{
bool can_delete = false;
- if (mFolderRoot)
+ if (mFolderRoot.get())
{
- std::set<LLFolderViewItem*> selection_set = mFolderRoot->getSelectionList();
+ std::set<LLFolderViewItem*> selection_set = mFolderRoot.get()->getSelectionList();
if (!selection_set.empty())
{
can_delete = true;