STORM-2149: Add a warning notification when deleting a folder of filtered content

meow-7.2.2
Kitty Barnett 2017-06-02 16:44:00 +02:00
parent 71f580e72a
commit d7edeb2df8
8 changed files with 78 additions and 9 deletions

View File

@ -822,6 +822,7 @@ Kitty Barnett
MAINT-6153
MAINT-6154
MAINT-6568
STORM-2149
Kolor Fall
Komiko Okamoto
Korvel Noh

View File

@ -102,6 +102,18 @@ void LLCloseAllFoldersFunctor::doFolder(LLFolderViewFolder* folder)
void LLCloseAllFoldersFunctor::doItem(LLFolderViewItem* item)
{ }
//---------------------------------------------------------------------------
void LLAllDescendentsPassedFilter::doFolder(LLFolderViewFolder* folder)
{
mAllDescendentsPassedFilter &= (folder) && (folder->passedFilter()) && (folder->descendantsPassedFilter());
}
void LLAllDescendentsPassedFilter::doItem(LLFolderViewItem* item)
{
mAllDescendentsPassedFilter &= (item) && (item->passedFilter());
}
///----------------------------------------------------------------------------
/// Class LLFolderViewScrollContainer
///----------------------------------------------------------------------------

View File

@ -400,6 +400,18 @@ public:
virtual void doItem(LLFolderViewItem* item);
};
class LLAllDescendentsPassedFilter : public LLFolderViewFunctor
{
public:
LLAllDescendentsPassedFilter() : mAllDescendentsPassedFilter(true) {}
/*virtual*/ ~LLAllDescendentsPassedFilter() {}
/*virtual*/ void doFolder(LLFolderViewFolder* folder);
/*virtual*/ void doItem(LLFolderViewItem* item);
bool allDescendentsPassedFilter() const { return mAllDescendentsPassedFilter; }
protected:
bool mAllDescendentsPassedFilter;
};
// Flags for buildContextMenu()
const U32 SUPPRESS_OPEN_ITEM = 0x1;
const U32 FIRST_SELECTED_ITEM = 0x2;

View File

@ -1176,6 +1176,11 @@ BOOL LLFolderViewFolder::needsArrange()
return mLastArrangeGeneration < getRoot()->getArrangeGeneration();
}
bool LLFolderViewFolder::descendantsPassedFilter(S32 filter_generation)
{
return getViewModelItem()->descendantsPassedFilter(filter_generation);
}
// Passes selection information on to children and record selection
// information if necessary.
BOOL LLFolderViewFolder::setSelection(LLFolderViewItem* selection, BOOL openitem,

View File

@ -1798,6 +1798,12 @@ bool LLNotifications::getIgnoreAllNotifications()
{
return mIgnoreAllNotifications;
}
bool LLNotifications::getIgnored(const std::string& name)
{
LLNotificationTemplatePtr templatep = getTemplate(name);
return (mIgnoreAllNotifications) || ( (templatep->mForm->getIgnoreType() != LLNotificationForm::IGNORE_NO) && (templatep->mForm->getIgnored()) );
}
bool LLNotifications::isVisibleByRules(LLNotificationPtr n)
{

View File

@ -964,6 +964,8 @@ public:
void setIgnoreAllNotifications(bool ignore);
bool getIgnoreAllNotifications();
bool getIgnored(const std::string& name);
bool isVisibleByRules(LLNotificationPtr pNotification);
private:

View File

@ -2297,15 +2297,12 @@ void LLInventoryAction::doToSelected(LLInventoryModel* model, LLFolderView* root
if ("delete" == action)
{
LLSD args;
args["QUESTION"] = LLTrans::getString(root->getSelectedCount() > 1 ? "DeleteItems" : "DeleteItem");
static bool sDisplayedAtSession = false;
std::set<LLFolderViewItem*>::iterator set_iter = selected_items.begin();
LLFolderViewModelItemInventory * viewModel = NULL;
bool has_folder_items = false;
for (; set_iter != selected_items.end(); ++set_iter)
for (std::set<LLFolderViewItem*>::iterator set_iter = selected_items.begin(); set_iter != selected_items.end(); ++set_iter)
{
viewModel = dynamic_cast<LLFolderViewModelItemInventory *>((*set_iter)->getViewModelItem());
LLFolderViewModelItemInventory * viewModel = dynamic_cast<LLFolderViewModelItemInventory *>((*set_iter)->getViewModelItem());
if (viewModel && viewModel->hasChildren())
{
has_folder_items = true;
@ -2317,16 +2314,34 @@ void LLInventoryAction::doToSelected(LLInventoryModel* model, LLFolderView* root
bool ignore = !(LLUI::sSettingGroups["ignores"]->getBOOL("DeleteItems"));
if (ignore)
{
if (!sDisplayedAtSession)
{
LLUI::sSettingGroups["ignores"]->setBOOL("DeleteItems", TRUE);
sDisplayedAtSession = true;
}
}
}
LLNotificationsUtil::add("DeleteItems", args, LLSD(), boost::bind(&LLInventoryAction::onItemsRemovalConfirmation, _1, _2, root->getHandle()));
LLAllDescendentsPassedFilter f;
for (std::set<LLFolderViewItem*>::iterator it = selected_items.begin(); (it != selected_items.end()) && (f.allDescendentsPassedFilter()); ++it)
{
if (LLFolderViewFolder* folder = dynamic_cast<LLFolderViewFolder*>(*it))
{
folder->applyFunctorRecursively(f);
}
}
// Fall through to the generic confirmation if the user choose to ignore the specialized one
if ( (!f.allDescendentsPassedFilter()) && (!LLNotifications::instance().getIgnored("DeleteFilteredItems")) )
{
LLNotificationsUtil::add("DeleteFilteredItems", LLSD(), LLSD(), boost::bind(&LLInventoryAction::onItemsRemovalConfirmation, _1, _2, root->getHandle()));
}
else
{
LLSD args;
args["QUESTION"] = LLTrans::getString(root->getSelectedCount() > 1 ? "DeleteItems" : "DeleteItem");
LLNotificationsUtil::add("DeleteItems", args, LLSD(), boost::bind(&LLInventoryAction::onItemsRemovalConfirmation, _1, _2, root->getHandle()));
}
// Note: marketplace listings will be updated in the callback if delete confirmed
return;
}

View File

@ -6010,6 +6010,22 @@ You cannot undo this action.
notext="Cancel"
yestext="OK"/>
</notification>
<notification
icon="alertmodal.tga"
name="DeleteFilteredItems"
type="alertmodal">
<unique/>
Your inventory is currently filtered and not all of the items you're about to delete are currently visible.
Are you sure you want to delete them?
<tag>confirm</tag>
<usetemplate
ignoretext="Confirm before deleting filtered items"
name="okcancelignore"
notext="Cancel"
yestext="OK"/>
</notification>
<notification
icon="alertmodal.tga"