summaryrefslogtreecommitdiff
path: root/indra/newview/llinventorypanel.cpp
diff options
context:
space:
mode:
authorMerov Linden <merov@lindenlab.com>2013-02-08 22:38:54 -0800
committerMerov Linden <merov@lindenlab.com>2013-02-08 22:38:54 -0800
commit5ecac2e900054526c5e9e2fe5610f470ad06df32 (patch)
treee65cda79851337c39df8d7b693d6b753a743dc1b /indra/newview/llinventorypanel.cpp
parent22bc40ad60d166cd9e8ff90671a6171a1954cd9b (diff)
CHUI-735 : Fixed! Refactor the code to move isSelectionRemovable() to the LLInventoryPanel level. Use it when using the delete key.
Diffstat (limited to 'indra/newview/llinventorypanel.cpp')
-rw-r--r--indra/newview/llinventorypanel.cpp32
1 files changed, 31 insertions, 1 deletions
diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp
index 578b83fd28..1357b613bb 100644
--- a/indra/newview/llinventorypanel.cpp
+++ b/indra/newview/llinventorypanel.cpp
@@ -1370,7 +1370,7 @@ BOOL LLInventoryPanel::handleKeyHere( KEY key, MASK mask )
case KEY_BACKSPACE:
// Delete selected items if delete or backspace key hit on the inventory panel
// Note: on Mac laptop keyboards, backspace and delete are one and the same
- if (mask == MASK_NONE)
+ if (isSelectionRemovable() && (mask == MASK_NONE))
{
LLInventoryAction::doToSelected(mInventory, mFolderRoot, "delete");
handled = TRUE;
@@ -1380,6 +1380,36 @@ BOOL LLInventoryPanel::handleKeyHere( KEY key, MASK mask )
return handled;
}
+bool LLInventoryPanel::isSelectionRemovable()
+{
+ bool can_delete = false;
+ if (mFolderRoot)
+ {
+ std::set<LLFolderViewItem*> selection_set = mFolderRoot->getSelectionList();
+ if (!selection_set.empty())
+ {
+ can_delete = true;
+ for (std::set<LLFolderViewItem*>::iterator iter = selection_set.begin();
+ iter != selection_set.end();
+ ++iter)
+ {
+ LLFolderViewItem *item = *iter;
+ const LLFolderViewModelItemInventory *listener = static_cast<const LLFolderViewModelItemInventory*>(item->getViewModelItem());
+ if (!listener)
+ {
+ can_delete = false;
+ }
+ else
+ {
+ can_delete &= listener->isItemRemovable();
+ can_delete &= !listener->isItemInTrash();
+ }
+ }
+ }
+ }
+ return can_delete;
+}
+
/************************************************************************/
/* Recent Inventory Panel related class */
/************************************************************************/