summaryrefslogtreecommitdiff
path: root/indra/newview/llfloatermyenvironment.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llfloatermyenvironment.cpp')
-rw-r--r--indra/newview/llfloatermyenvironment.cpp129
1 files changed, 91 insertions, 38 deletions
diff --git a/indra/newview/llfloatermyenvironment.cpp b/indra/newview/llfloatermyenvironment.cpp
index f93af9c312..48138a258a 100644
--- a/indra/newview/llfloatermyenvironment.cpp
+++ b/indra/newview/llfloatermyenvironment.cpp
@@ -1,25 +1,25 @@
-/**
+/**
* @file llfloatergesture.cpp
* @brief LLFloaterMyEnvironment class implementation
*
* $LicenseInfo:firstyear=2002&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2019, Linden Research, Inc.
- *
+ *
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
+ *
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
@@ -38,7 +38,9 @@
#include "llcheckboxctrl.h"
#include "llviewerinventory.h"
#include "llenvironment.h"
+#include "llnotificationsutil.h"
#include "llparcel.h"
+#include "lltrans.h"
#include "llviewerparcelmgr.h"
//=========================================================================
@@ -223,6 +225,35 @@ void LLFloaterMyEnvironment::onFilterEdit(const std::string& search_string)
mInventoryList->setFilterSubString(search_string);
}
+void LLFloaterMyEnvironment::onItemsRemovalConfirmation(const LLSD& notification, const LLSD& response, uuid_vec_t item_ids)
+{
+ S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
+ if (option == 0)
+ {
+ const LLUUID trash_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_TRASH);
+ for (const LLUUID& itemid : item_ids)
+ {
+ LLInventoryItem* inv_item = gInventory.getItem(itemid);
+
+ if (inv_item && inv_item->getInventoryType() == LLInventoryType::IT_SETTINGS)
+ {
+ LLInventoryModel::update_list_t update;
+ LLInventoryModel::LLCategoryUpdate old_folder(inv_item->getParentUUID(), -1);
+ update.push_back(old_folder);
+ LLInventoryModel::LLCategoryUpdate new_folder(trash_id, 1);
+ update.push_back(new_folder);
+ gInventory.accountForUpdate(update);
+
+ LLPointer<LLViewerInventoryItem> new_item = new LLViewerInventoryItem(inv_item);
+ new_item->setParent(trash_id);
+ new_item->updateParentOnServer(FALSE);
+ gInventory.updateItem(new_item);
+ }
+ }
+ gInventory.notifyObservers();
+ }
+}
+
void LLFloaterMyEnvironment::onDeleteSelected()
{
uuid_vec_t selected;
@@ -231,27 +262,16 @@ void LLFloaterMyEnvironment::onDeleteSelected()
if (selected.empty())
return;
- const LLUUID trash_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_TRASH);
- for (const LLUUID& itemid: selected)
- {
- LLInventoryItem* inv_item = gInventory.getItem(itemid);
-
- if (inv_item && inv_item->getInventoryType() == LLInventoryType::IT_SETTINGS)
+ LLSD args;
+ args["QUESTION"] = LLTrans::getString(selected.size() > 1 ? "DeleteItems" : "DeleteItem");
+ LLNotificationsUtil::add(
+ "DeleteItems",
+ args,
+ LLSD(),
+ [this, selected](const LLSD& notification, const LLSD& response)
{
- LLInventoryModel::update_list_t update;
- LLInventoryModel::LLCategoryUpdate old_folder(inv_item->getParentUUID(), -1);
- update.push_back(old_folder);
- LLInventoryModel::LLCategoryUpdate new_folder(trash_id, 1);
- update.push_back(new_folder);
- gInventory.accountForUpdate(update);
-
- LLPointer<LLViewerInventoryItem> new_item = new LLViewerInventoryItem(inv_item);
- new_item->setParent(trash_id);
- new_item->updateParentOnServer(FALSE);
- gInventory.updateItem(new_item);
- }
- }
- gInventory.notifyObservers();
+ onItemsRemovalConfirmation(notification, response, selected);
+ });
}
@@ -278,7 +298,7 @@ void LLFloaterMyEnvironment::onDoApply(const std::string &context)
std::string name = itemp->getName();
U32 flags(0);
-
+
if (!itemp->getPermissions().allowOperationBy(PERM_MODIFY, gAgent.getID()))
flags |= LLSettingsBase::FLAG_NOMOD;
if (!itemp->getPermissions().allowOperationBy(PERM_TRANSFER, gAgent.getID()))
@@ -317,14 +337,14 @@ bool LLFloaterMyEnvironment::canAction(const std::string &context)
return false;
if (context == PARAMETER_EDIT)
- {
- return (selected.size() == 1) && isSettingSelected(selected.front());
+ {
+ return (selected.size() == 1) && isSettingId(selected.front());
}
else if (context == PARAMETER_COPY)
{
for (std::vector<LLUUID>::iterator it = selected.begin(); it != selected.end(); it++)
{
- if(!isSettingSelected(*it))
+ if(!isSettingId(*it))
{
return false;
}
@@ -340,7 +360,7 @@ bool LLFloaterMyEnvironment::canAction(const std::string &context)
LLClipboard::instance().pasteFromClipboard(ids);
for (std::vector<LLUUID>::iterator it = ids.begin(); it != ids.end(); it++)
{
- if (!isSettingSelected(*it))
+ if (!isSettingId(*it))
{
return false;
}
@@ -349,7 +369,7 @@ bool LLFloaterMyEnvironment::canAction(const std::string &context)
}
else if (context == PARAMETER_COPYUUID)
{
- return (selected.size() == 1) && isSettingSelected(selected.front());
+ return (selected.size() == 1) && isSettingId(selected.front());
}
return false;
@@ -364,17 +384,43 @@ bool LLFloaterMyEnvironment::canApply(const std::string &context)
return false;
if (context == PARAMETER_REGION)
- {
- return LLEnvironment::instance().canAgentUpdateRegionEnvironment();
+ {
+ return isSettingId(selected.front()) && LLEnvironment::instance().canAgentUpdateRegionEnvironment();
}
else if (context == PARAMETER_PARCEL)
+ {
+ return isSettingId(selected.front()) && LLEnvironment::instance().canAgentUpdateParcelEnvironment();
+ }
+ else if (context == PARAMETER_LOCAL)
{
- return LLEnvironment::instance().canAgentUpdateParcelEnvironment();
+ return isSettingId(selected.front());
}
- else
+
+ return false;
+}
+
+bool can_delete(const LLUUID& id)
+{
+ const LLUUID trash_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_TRASH);
+ if (id == trash_id || gInventory.isObjectDescendentOf(id, trash_id))
+ {
+ return false;
+ }
+
+ LLViewerInventoryCategory* cat = gInventory.getCategory(id);
+ if (cat)
{
- return (context == PARAMETER_LOCAL);
+ if (!get_is_category_removable(&gInventory, id))
+ {
+ return false;
+ }
+ }
+ else if (!get_is_item_removable(&gInventory, id, false))
+ {
+ return false;
}
+
+ return true;
}
//-------------------------------------------------------------------------
@@ -387,7 +433,14 @@ void LLFloaterMyEnvironment::refreshButtonStates()
getChild<LLUICtrl>(BUTTON_GEAR)->setEnabled(settings_ok);
getChild<LLUICtrl>(BUTTON_NEWSETTINGS)->setEnabled(true);
- getChild<LLUICtrl>(BUTTON_DELETE)->setEnabled(settings_ok && !selected.empty());
+
+ bool enable_delete = false;
+ if(settings_ok && !selected.empty())
+ {
+ enable_delete = can_delete(selected.front());
+ }
+
+ getChild<LLUICtrl>(BUTTON_DELETE)->setEnabled(enable_delete);
}
//-------------------------------------------------------------------------
@@ -436,7 +489,7 @@ LLUUID LLFloaterMyEnvironment::findItemByAssetId(LLUUID asset_id, bool copyable_
return LLUUID::null;
}
-bool LLFloaterMyEnvironment::isSettingSelected(LLUUID item_id)
+bool LLFloaterMyEnvironment::isSettingId(const LLUUID& item_id)
{
LLInventoryItem* itemp = gInventory.getItem(item_id);