diff options
-rw-r--r-- | indra/newview/llfolderview.cpp | 25 | ||||
-rw-r--r-- | indra/newview/llfolderview.h | 1 | ||||
-rw-r--r-- | indra/newview/llinventoryfunctions.cpp | 25 | ||||
-rw-r--r-- | indra/newview/llinventoryfunctions.h | 2 |
4 files changed, 52 insertions, 1 deletions
diff --git a/indra/newview/llfolderview.cpp b/indra/newview/llfolderview.cpp index 1d318ca221..51a5839b75 100644 --- a/indra/newview/llfolderview.cpp +++ b/indra/newview/llfolderview.cpp @@ -1014,6 +1014,24 @@ bool isDescendantOfASelectedItem(LLFolderViewItem* item, const std::vector<LLFol return false; } +void LLFolderView::removeCutItems() +{ + // There's no item in "cut" mode on the clipboard -> exit + if (!LLClipboard::getInstance()->isCutMode()) + return; + + // Get the list of clipboard item uuids and iterate through them + LLDynamicArray<LLUUID> objects; + LLClipboard::getInstance()->pasteFromClipboard(objects); + for (LLDynamicArray<LLUUID>::const_iterator iter = objects.begin(); + iter != objects.end(); + ++iter) + { + const LLUUID& item_id = (*iter); + remove_item(&gInventory, item_id); + } +} + void LLFolderView::onItemsRemovalConfirmation(const LLSD& notification, const LLSD& response) { S32 option = LLNotificationsUtil::getSelectedOption(notification, response); @@ -2109,7 +2127,12 @@ bool LLFolderView::doToSelected(LLInventoryModel* model, const LLSD& userdata) return true; } if (("copy" == action) || ("cut" == action)) - { + { + // If there are things on the clipboard that have not been pasted but + // already disappeared from view, we need to move them to the trash + removeCutItems(); + + // Clear the clipboard before we start adding things on it LLClipboard::getInstance()->reset(); } diff --git a/indra/newview/llfolderview.h b/indra/newview/llfolderview.h index 1d018b5e6a..2f148d4e25 100644 --- a/indra/newview/llfolderview.h +++ b/indra/newview/llfolderview.h @@ -159,6 +159,7 @@ public: // deletion functionality void removeSelectedItems(); + void removeCutItems(); // open the selected item. void openSelectedItems( void ); diff --git a/indra/newview/llinventoryfunctions.cpp b/indra/newview/llinventoryfunctions.cpp index ea00474b2a..8313b23f44 100644 --- a/indra/newview/llinventoryfunctions.cpp +++ b/indra/newview/llinventoryfunctions.cpp @@ -160,6 +160,31 @@ void change_category_parent(LLInventoryModel* model, model->notifyObservers(); } +// Move the item to the trash. Works for folders and objects. +// Caution: This method assumes that the item is removable! +void remove_item(LLInventoryModel* model, const LLUUID& id) +{ + LLViewerInventoryItem* item = model->getItem(id); + if (!item) + return; + + if (item->getType() == LLAssetType::AT_CATEGORY) + { + // Call the general helper function to delete a folder + remove_category(model, id); + } + else + { + // Get the trash UUID + LLUUID trash_id = model->findCategoryUUIDForType(LLFolderType::FT_TRASH, false); + if (trash_id.notNull()) + { + // Finally, move the item to the trash + change_item_parent(model, item, trash_id, true); + } + } +} + void remove_category(LLInventoryModel* model, const LLUUID& cat_id) { if (!model || !get_is_category_removable(model, cat_id)) diff --git a/indra/newview/llinventoryfunctions.h b/indra/newview/llinventoryfunctions.h index ce2b89b22e..f8ecca22b6 100644 --- a/indra/newview/llinventoryfunctions.h +++ b/indra/newview/llinventoryfunctions.h @@ -62,6 +62,8 @@ void change_item_parent(LLInventoryModel* model, const LLUUID& new_parent_id, BOOL restamp); +void remove_item(LLInventoryModel* model, const LLUUID& id); + void change_category_parent(LLInventoryModel* model, LLViewerInventoryCategory* cat, const LLUUID& new_parent_id, |