Skip to content

Commit ce99ab7

Browse files
committed
#3757 Smarter subfolders dragndrop
1 parent 50108bf commit ce99ab7

File tree

4 files changed

+75
-14
lines changed

4 files changed

+75
-14
lines changed

indra/newview/llinventorybridge.cpp

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2664,6 +2664,7 @@ bool LLFolderBridge::dragCategoryIntoFolder(LLInventoryCategory* inv_cat,
26642664
//
26652665

26662666
bool is_movable = true;
2667+
bool create_outfit = false;
26672668

26682669
if (is_movable && (marketplacelistings_id == cat_id))
26692670
{
@@ -2708,7 +2709,12 @@ bool LLFolderBridge::dragCategoryIntoFolder(LLInventoryCategory* inv_cat,
27082709
tooltip_msg = LLTrans::getString("TooltipOutfitNotInInventory");
27092710
is_movable = false;
27102711
}
2711-
else if (can_move_to_my_outfits(model, inv_cat, max_items_to_wear))
2712+
else if (can_move_to_my_outfits_as_outfit(model, inv_cat, max_items_to_wear))
2713+
{
2714+
is_movable = true;
2715+
create_outfit = true;
2716+
}
2717+
else if (can_move_to_my_outfits_as_subfolder(model, inv_cat))
27122718
{
27132719
is_movable = true;
27142720
}
@@ -2742,7 +2748,12 @@ bool LLFolderBridge::dragCategoryIntoFolder(LLInventoryCategory* inv_cat,
27422748
is_movable = false;
27432749
tooltip_msg = LLTrans::getString("TooltipCantCreateOutfit");
27442750
}
2745-
else if (can_move_to_my_outfits(model, inv_cat, max_items_to_wear))
2751+
else if (can_move_to_my_outfits_as_outfit(model, inv_cat, max_items_to_wear))
2752+
{
2753+
is_movable = true;
2754+
create_outfit = true;
2755+
}
2756+
else if (can_move_to_my_outfits_as_subfolder(model, inv_cat))
27462757
{
27472758
is_movable = true;
27482759
}
@@ -2943,7 +2954,7 @@ bool LLFolderBridge::dragCategoryIntoFolder(LLInventoryCategory* inv_cat,
29432954
if (mUUID == my_outifts_id)
29442955
{
29452956
EMyOutfitsSubfolderType inv_res = myoutfit_object_subfolder_type(model, cat_id, my_outifts_id);
2946-
if (inv_res == MY_OUTFITS_SUBFOLDER || inv_res == MY_OUTFITS_OUTFIT)
2957+
if (inv_res == MY_OUTFITS_SUBFOLDER || inv_res == MY_OUTFITS_OUTFIT || !create_outfit)
29472958
{
29482959
LLInvFVBridge::changeCategoryParent(
29492960
model,
@@ -2967,7 +2978,7 @@ bool LLFolderBridge::dragCategoryIntoFolder(LLInventoryCategory* inv_cat,
29672978
{
29682979
case MY_OUTFITS_NO:
29692980
// Moning from outside outfits into outfits
2970-
if (dest_res == MY_OUTFITS_SUBFOLDER)
2981+
if (dest_res == MY_OUTFITS_SUBFOLDER && create_outfit)
29712982
{
29722983
// turn it into outfit
29732984
dropToMyOutfitsSubfolder(inv_cat, mUUID, LLFolderType::FT_OUTFIT, cb);
@@ -4094,7 +4105,6 @@ void LLFolderBridge::perform_pasteFromClipboard()
40944105
LLInventoryObject *obj = model->getObject(item_id);
40954106
if (obj)
40964107
{
4097-
40984108
if (move_is_into_lost_and_found)
40994109
{
41004110
if (LLAssetType::AT_CATEGORY == obj->getType())
@@ -4111,9 +4121,9 @@ void LLFolderBridge::perform_pasteFromClipboard()
41114121
}
41124122
else if (move_is_into_my_outfits && LLAssetType::AT_CATEGORY == obj->getType())
41134123
{
4114-
LLInventoryCategory* cat = model->getCategory(item_id);
4124+
LLViewerInventoryCategory* cat = model->getCategory(item_id);
41154125
U32 max_items_to_wear = gSavedSettings.getU32("WearFolderLimit");
4116-
if (cat && can_move_to_my_outfits(model, cat, max_items_to_wear))
4126+
if (cat && can_move_to_my_outfits_as_outfit(model, cat, max_items_to_wear))
41174127
{
41184128
if (mUUID == my_outifts_id)
41194129
{
@@ -4133,6 +4143,18 @@ void LLFolderBridge::perform_pasteFromClipboard()
41334143
}
41344144
}
41354145
}
4146+
else if (cat && can_move_to_my_outfits_as_subfolder(model, cat))
4147+
{
4148+
if (LLClipboard::instance().isCutMode())
4149+
{
4150+
changeCategoryParent(model, cat, parent_id, false);
4151+
if (cb) cb->fire(item_id);
4152+
}
4153+
else
4154+
{
4155+
copy_inventory_category(model, cat, parent_id);
4156+
}
4157+
}
41364158
else
41374159
{
41384160
LLNotificationsUtil::add("MyOutfitsPasteFailed");
@@ -4181,7 +4203,7 @@ void LLFolderBridge::perform_pasteFromClipboard()
41814203
// move_inventory_item() is not enough, as we have to update inventory locally too
41824204
if (LLAssetType::AT_CATEGORY == obj->getType())
41834205
{
4184-
LLViewerInventoryCategory* vicat = (LLViewerInventoryCategory *) model->getCategory(item_id);
4206+
LLViewerInventoryCategory* vicat = model->getCategory(item_id);
41854207
llassert(vicat);
41864208
if (vicat)
41874209
{

indra/newview/llinventoryfunctions.cpp

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2314,7 +2314,7 @@ bool can_move_to_landmarks(LLInventoryItem* inv_item)
23142314
}
23152315

23162316
// Returns true if folder's content can be moved to Current Outfit or any outfit folder.
2317-
bool can_move_to_my_outfits(LLInventoryModel* model, LLInventoryCategory* inv_cat, U32 wear_limit)
2317+
bool can_move_to_my_outfits_as_outfit(LLInventoryModel* model, LLInventoryCategory* inv_cat, U32 wear_limit)
23182318
{
23192319
LLInventoryModel::cat_array_t *cats;
23202320
LLInventoryModel::item_array_t *items;
@@ -2353,6 +2353,33 @@ bool can_move_to_my_outfits(LLInventoryModel* model, LLInventoryCategory* inv_ca
23532353
return true;
23542354
}
23552355

2356+
bool can_move_to_my_outfits_as_subfolder(LLInventoryModel* model, LLInventoryCategory* inv_cat)
2357+
{
2358+
LLInventoryModel::cat_array_t* cats;
2359+
LLInventoryModel::item_array_t* items;
2360+
model->getDirectDescendentsOf(inv_cat->getUUID(), cats, items);
2361+
2362+
if (items->size() > 0)
2363+
{
2364+
// subfolders don't allow items
2365+
return false;
2366+
}
2367+
2368+
for (LLPointer<LLViewerInventoryCategory>& cat : *cats)
2369+
{
2370+
// outfits are valid to move, check non-outfit folders
2371+
if (cat->getPreferredType() != LLFolderType::FT_OUTFIT)
2372+
{
2373+
if (!can_move_to_my_outfits_as_subfolder(model, cat))
2374+
{
2375+
return false;
2376+
}
2377+
}
2378+
}
2379+
2380+
return true;
2381+
}
2382+
23562383
std::string get_localized_folder_name(LLUUID cat_uuid)
23572384
{
23582385
std::string localized_root_name;

indra/newview/llinventoryfunctions.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ std::string get_category_path(LLUUID cat_id);
112112

113113
bool can_move_to_outfit(LLInventoryItem* inv_item, bool move_is_into_current_outfit);
114114
bool can_move_to_landmarks(LLInventoryItem* inv_item);
115-
bool can_move_to_my_outfits(LLInventoryModel* model, LLInventoryCategory* inv_cat, U32 wear_limit);
115+
bool can_move_to_my_outfits_as_outfit(LLInventoryModel* model, LLInventoryCategory* inv_cat, U32 wear_limit);
116+
bool can_move_to_my_outfits_as_subfolder(LLInventoryModel* model, LLInventoryCategory* inv_cat);
116117
std::string get_localized_folder_name(LLUUID cat_uuid);
117118
void new_folder_window(const LLUUID& folder_id);
118119
void ungroup_folder_items(const LLUUID& folder_id);

indra/newview/llinventorygallery.cpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3714,6 +3714,7 @@ bool dragCategoryIntoFolder(LLUUID dest_id, LLInventoryCategory* inv_cat,
37143714
//
37153715

37163716
bool is_movable = true;
3717+
bool create_outfit = false;
37173718

37183719
if (is_movable && (marketplacelistings_id == cat_id))
37193720
{
@@ -3759,7 +3760,12 @@ bool dragCategoryIntoFolder(LLUUID dest_id, LLInventoryCategory* inv_cat,
37593760
tooltip_msg = LLTrans::getString("TooltipOutfitNotInInventory");
37603761
is_movable = false;
37613762
}
3762-
else if (can_move_to_my_outfits(model, inv_cat, max_items_to_wear))
3763+
else if (can_move_to_my_outfits_as_outfit(model, inv_cat, max_items_to_wear))
3764+
{
3765+
is_movable = true;
3766+
create_outfit = true;
3767+
}
3768+
else if (can_move_to_my_outfits_as_subfolder(model, inv_cat))
37633769
{
37643770
is_movable = true;
37653771
}
@@ -3793,7 +3799,12 @@ bool dragCategoryIntoFolder(LLUUID dest_id, LLInventoryCategory* inv_cat,
37933799
is_movable = false;
37943800
tooltip_msg = LLTrans::getString("TooltipCantCreateOutfit");
37953801
}
3796-
else if (can_move_to_my_outfits(model, inv_cat, max_items_to_wear))
3802+
else if (can_move_to_my_outfits_as_outfit(model, inv_cat, max_items_to_wear))
3803+
{
3804+
is_movable = true;
3805+
create_outfit = true;
3806+
}
3807+
else if (can_move_to_my_outfits_as_subfolder(model, inv_cat))
37973808
{
37983809
is_movable = true;
37993810
}
@@ -3928,7 +3939,7 @@ bool dragCategoryIntoFolder(LLUUID dest_id, LLInventoryCategory* inv_cat,
39283939
if (dest_id == my_outifts_id)
39293940
{
39303941
EMyOutfitsSubfolderType inv_res = myoutfit_object_subfolder_type(model, cat_id, my_outifts_id);
3931-
if (inv_res == MY_OUTFITS_SUBFOLDER || inv_res == MY_OUTFITS_OUTFIT)
3942+
if (inv_res == MY_OUTFITS_SUBFOLDER || inv_res == MY_OUTFITS_OUTFIT || !create_outfit)
39323943
{
39333944
gInventory.changeCategoryParent(
39343945
(LLViewerInventoryCategory*)inv_cat,
@@ -3950,7 +3961,7 @@ bool dragCategoryIntoFolder(LLUUID dest_id, LLInventoryCategory* inv_cat,
39503961
{
39513962
case MY_OUTFITS_NO:
39523963
// Moning from outside outfits into outfits
3953-
if (dest_res == MY_OUTFITS_SUBFOLDER)
3964+
if (dest_res == MY_OUTFITS_SUBFOLDER && create_outfit)
39543965
{
39553966
// turn it into outfit
39563967
dropToMyOutfitsSubfolder(inv_cat, dest_id, LLFolderType::FT_OUTFIT);

0 commit comments

Comments
 (0)