Pull relevant part of MAINT-8061 to show item count for folders in inventory with improvements and fixes

Wed, 13 Dec 2017 12:58:25 +0100

author
Ansariel
date
Wed, 13 Dec 2017 12:58:25 +0100
changeset 53569
ae38377652ec
parent 53568
6f5484ad72f7
child 53570
7ff990646a76

Pull relevant part of MAINT-8061 to show item count for folders in inventory with improvements and fixes

indra/newview/llinventorybridge.cpp file | annotate | diff | revisions
indra/newview/llinventorybridge.h file | annotate | diff | revisions
indra/newview/llinventorypanel.cpp file | annotate | diff | revisions
indra/newview/llinventorypanel.h file | annotate | diff | revisions
indra/newview/skins/default/xui/de/strings.xml file | annotate | diff | revisions
indra/newview/skins/default/xui/en/strings.xml file | annotate | diff | revisions
     1.1 --- a/indra/newview/llinventorybridge.cpp	Tue Dec 12 20:07:12 2017 +0100
     1.2 +++ b/indra/newview/llinventorybridge.cpp	Wed Dec 13 12:58:25 2017 +0100
     1.3 @@ -100,6 +100,7 @@
     1.4  // </FS:Zi>
     1.5  #include "fsfloaterplacedetails.h"
     1.6  #include "llviewerattachmenu.h"
     1.7 +#include "llresmgr.h"
     1.8  
     1.9  #include <boost/shared_ptr.hpp>
    1.10  
    1.11 @@ -2428,8 +2429,35 @@
    1.12      {
    1.13          return llformat(" ( %s ) ", LLTrans::getString("LoadingData").c_str());
    1.14      }
    1.15 -    
    1.16 -    return LLInvFVBridge::getLabelSuffix();
    1.17 +    std::string suffix = "";
    1.18 +    if(mShowDescendantsCount)
    1.19 +    {
    1.20 +        LLInventoryModel::cat_array_t cat_array;
    1.21 +        LLInventoryModel::item_array_t item_array;
    1.22 +        gInventory.collectDescendents(getUUID(), cat_array, item_array, TRUE);
    1.23 +        // <FS:Ansariel> Fix item count formatting
    1.24 +        //S32 count = item_array.size();
    1.25 +        //if(count > 0)
    1.26 +        //{
    1.27 +        //    std::ostringstream oss;
    1.28 +        //    oss << count;
    1.29 +        //    suffix = " ( " + oss.str() + " Items )";
    1.30 +        //}
    1.31 +        if (cat_array.size() > 0 || item_array.size() > 0)
    1.32 +        {
    1.33 +            LLLocale locale("");
    1.34 +            LLStringUtil::format_map_t args;
    1.35 +            std::string count_str;
    1.36 +            LLResMgr::getInstance()->getIntegerString(count_str, item_array.size());
    1.37 +            args["ITEMS"] = count_str;
    1.38 +            LLResMgr::getInstance()->getIntegerString(count_str, cat_array.size());
    1.39 +            args["FOLDERS"] = count_str;
    1.40 +            suffix = " " + LLTrans::getString("FolderItemCount", args);
    1.41 +        }
    1.42 +        // </FS:Ansariel>
    1.43 +    }
    1.44 +
    1.45 +    return LLInvFVBridge::getLabelSuffix() + suffix;
    1.46  }
    1.47  
    1.48  LLFontGL::StyleFlags LLFolderBridge::getLabelStyle() const
     2.1 --- a/indra/newview/llinventorybridge.h	Tue Dec 12 20:07:12 2017 +0100
     2.2 +++ b/indra/newview/llinventorybridge.h	Wed Dec 13 12:58:25 2017 +0100
     2.3 @@ -286,7 +286,8 @@
     2.4  	:	LLInvFVBridge(inventory, root, uuid),
     2.5  		mCallingCards(FALSE),
     2.6  		mWearables(FALSE),
     2.7 -		mIsLoading(false)
     2.8 +		mIsLoading(false),
     2.9 +		mShowDescendantsCount(false)
    2.10  	{}
    2.11  		
    2.12  	BOOL dragItemIntoFolder(LLInventoryItem* inv_item, BOOL drop, std::string& tooltip_msg, BOOL user_confirm = TRUE);
    2.13 @@ -311,6 +312,8 @@
    2.14  	virtual std::string getLabelSuffix() const;
    2.15  	virtual LLFontGL::StyleFlags getLabelStyle() const;
    2.16  
    2.17 +	void setShowDescendantsCount(bool show_count) {mShowDescendantsCount = show_count;}
    2.18 +
    2.19  	virtual BOOL renameItem(const std::string& new_name);
    2.20  
    2.21  	virtual BOOL removeItem();
    2.22 @@ -397,6 +400,7 @@
    2.23  	bool							mCallingCards;
    2.24  	bool							mWearables;
    2.25  	bool							mIsLoading;
    2.26 +	bool							mShowDescendantsCount;
    2.27  	LLTimer							mTimeSinceRequestStart;
    2.28      std::string                     mMessage;
    2.29  	LLRootHandle<LLFolderBridge> mHandle;
     3.1 --- a/indra/newview/llinventorypanel.cpp	Tue Dec 12 20:07:12 2017 +0100
     3.2 +++ b/indra/newview/llinventorypanel.cpp	Wed Dec 13 12:58:25 2017 +0100
     3.3 @@ -1182,6 +1182,56 @@
     3.4  			fv->startRenamingSelectedItem();
     3.5  		}
     3.6  	}
     3.7 +
     3.8 +	std::set<LLFolderViewItem*> selected_items = mFolderRoot.get()->getSelectionList();
     3.9 +	LLFolderViewItem* prev_folder_item = getItemByID(mPreviousSelectedFolder);
    3.10 +
    3.11 +	if (selected_items.size() == 1)
    3.12 +	{
    3.13 +		std::set<LLFolderViewItem*>::const_iterator iter = selected_items.begin();
    3.14 +		LLFolderViewItem* folder_item = (*iter);
    3.15 +		if(folder_item && (folder_item != prev_folder_item))
    3.16 +		{
    3.17 +			LLFolderViewModelItemInventory* fve_listener = static_cast<LLFolderViewModelItemInventory*>(folder_item->getViewModelItem());
    3.18 +			if (fve_listener && (fve_listener->getInventoryType() == LLInventoryType::IT_CATEGORY))
    3.19 +			{
    3.20 +				if(prev_folder_item)
    3.21 +				{
    3.22 +					LLFolderBridge* prev_bridge = (LLFolderBridge*)prev_folder_item->getViewModelItem();
    3.23 +					if(prev_bridge)
    3.24 +					{
    3.25 +						prev_bridge->clearDisplayName();
    3.26 +						prev_bridge->setShowDescendantsCount(false);
    3.27 +						prev_folder_item->refresh();
    3.28 +					}
    3.29 +				}
    3.30 +
    3.31 +				LLFolderBridge* bridge = (LLFolderBridge*)folder_item->getViewModelItem();
    3.32 +				if(bridge)
    3.33 +				{
    3.34 +					bridge->clearDisplayName();
    3.35 +					bridge->setShowDescendantsCount(true);
    3.36 +					folder_item->refresh();
    3.37 +					mPreviousSelectedFolder = bridge->getUUID();
    3.38 +				}
    3.39 +			}
    3.40 +		}
    3.41 +	}
    3.42 +	else
    3.43 +	{
    3.44 +		if(prev_folder_item)
    3.45 +		{
    3.46 +			LLFolderBridge* prev_bridge = (LLFolderBridge*)prev_folder_item->getViewModelItem();
    3.47 +			if(prev_bridge)
    3.48 +			{
    3.49 +				prev_bridge->clearDisplayName();
    3.50 +				prev_bridge->setShowDescendantsCount(false);
    3.51 +				prev_folder_item->refresh();
    3.52 +			}
    3.53 +		}
    3.54 +		mPreviousSelectedFolder = LLUUID();
    3.55 +	}
    3.56 +
    3.57  }
    3.58  
    3.59  void LLInventoryPanel::doCreate(const LLSD& userdata)
     4.1 --- a/indra/newview/llinventorypanel.h	Tue Dec 12 20:07:12 2017 +0100
     4.2 +++ b/indra/newview/llinventorypanel.h	Wed Dec 13 12:58:25 2017 +0100
     4.3 @@ -263,6 +263,8 @@
     4.4  	LLHandle<LLFolderView>      mFolderRoot;
     4.5  	LLScrollContainer*			mScroller;
     4.6  
     4.7 +	LLUUID						mPreviousSelectedFolder;
     4.8 +
     4.9  	LLFolderViewModelInventory	mInventoryViewModel;
    4.10      LLPointer<LLFolderViewGroupedItemBridge> mGroupedItemBridge;
    4.11  	Params						mParams;	// stored copy of parameter block
     5.1 --- a/indra/newview/skins/default/xui/de/strings.xml	Tue Dec 12 20:07:12 2017 +0100
     5.2 +++ b/indra/newview/skins/default/xui/de/strings.xml	Wed Dec 13 12:58:25 2017 +0100
     5.3 @@ -6849,4 +6849,7 @@
     5.4  
     5.5  [ASSET_NAME]
     5.6  	</string>
     5.7 +	<string name="FolderItemCount">
     5.8 +		([ITEMS]/[FOLDERS] Elemente)
     5.9 +	</string>
    5.10  </strings>
     6.1 --- a/indra/newview/skins/default/xui/en/strings.xml	Tue Dec 12 20:07:12 2017 +0100
     6.2 +++ b/indra/newview/skins/default/xui/en/strings.xml	Wed Dec 13 12:58:25 2017 +0100
     6.3 @@ -3080,4 +3080,5 @@
     6.4  
     6.5  [ASSET_NAME]
     6.6    </string>
     6.7 +  <string name="FolderItemCount">([ITEMS]/[FOLDERS] Elements)</string>
     6.8  </strings>

mercurial