EXP-1873 : Move cut items to trash in cut/copy over cut situations.

meow-7.2.2
Merov Linden 2012-02-08 17:22:04 -08:00
parent 91f77318db
commit 10dadc6b0d
4 changed files with 52 additions and 1 deletions

View File

@ -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();
}

View File

@ -159,6 +159,7 @@ public:
// deletion functionality
void removeSelectedItems();
void removeCutItems();
// open the selected item.
void openSelectedItems( void );

View File

@ -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))

View File

@ -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,