PageRenderTime 1290ms CodeModel.GetById 647ms app.highlight 224ms RepoModel.GetById 260ms app.codeStats 0ms

/indra/newview/lloutfitslist.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 215 lines | 77 code | 49 blank | 89 comment | 0 complexity | 42a0a76d8b23d081da22914c7b6c162c MD5 | raw file
  1/**
  2 * @file lloutfitslist.h
  3 * @brief List of agent's outfits for My Appearance side panel.
  4 *
  5 * $LicenseInfo:firstyear=2010&license=viewerlgpl$
  6 * Second Life Viewer Source Code
  7 * Copyright (C) 2010, Linden Research, Inc.
  8 * 
  9 * This library is free software; you can redistribute it and/or
 10 * modify it under the terms of the GNU Lesser General Public
 11 * License as published by the Free Software Foundation;
 12 * version 2.1 of the License only.
 13 * 
 14 * This library is distributed in the hope that it will be useful,
 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 17 * Lesser General Public License for more details.
 18 * 
 19 * You should have received a copy of the GNU Lesser General Public
 20 * License along with this library; if not, write to the Free Software
 21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 22 * 
 23 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
 24 * $/LicenseInfo$
 25 */
 26
 27#ifndef LL_LLOUTFITSLIST_H
 28#define LL_LLOUTFITSLIST_H
 29
 30#include "llaccordionctrl.h"
 31#include "llpanel.h"
 32
 33// newview
 34#include "llinventorymodel.h"
 35#include "llpanelappearancetab.h"
 36
 37class LLAccordionCtrlTab;
 38class LLInventoryCategoriesObserver;
 39class LLOutfitListGearMenu;
 40class LLWearableItemsList;
 41class LLListContextMenu;
 42
 43
 44/**
 45 * @class LLOutfitTabNameComparator
 46 *
 47 * Comparator of outfit tabs.
 48 */
 49class LLOutfitTabNameComparator : public LLAccordionCtrl::LLTabComparator
 50{
 51	LOG_CLASS(LLOutfitTabNameComparator);
 52
 53public:
 54	LLOutfitTabNameComparator() {};
 55	virtual ~LLOutfitTabNameComparator() {};
 56
 57	/*virtual*/ bool compare(const LLAccordionCtrlTab* tab1, const LLAccordionCtrlTab* tab2) const;
 58};
 59
 60/**
 61 * @class LLOutfitsList
 62 *
 63 * A list of agents's outfits from "My Outfits" inventory category
 64 * which displays each outfit in an accordion tab with a flat list
 65 * of items inside it.
 66 *
 67 * Starts fetching necessary inventory content on first opening.
 68 */
 69class LLOutfitsList : public LLPanelAppearanceTab
 70{
 71public:
 72	typedef boost::function<void (const LLUUID&)> selection_change_callback_t;
 73	typedef boost::signals2::signal<void (const LLUUID&)> selection_change_signal_t;
 74
 75	LLOutfitsList();
 76	virtual ~LLOutfitsList();
 77
 78	/*virtual*/ BOOL postBuild();
 79
 80	/*virtual*/ void onOpen(const LLSD& info);
 81
 82	void refreshList(const LLUUID& category_id);
 83
 84	// highlits currently worn outfit tab text and unhighlights previously worn
 85	void highlightBaseOutfit();
 86
 87	void performAction(std::string action);
 88
 89	void removeSelected();
 90
 91	void setSelectedOutfitByUUID(const LLUUID& outfit_uuid);
 92
 93	/*virtual*/ void setFilterSubString(const std::string& string);
 94
 95	/*virtual*/ bool isActionEnabled(const LLSD& userdata);
 96
 97	const LLUUID& getSelectedOutfitUUID() const { return mSelectedOutfitUUID; }
 98
 99	/*virtual*/ void getSelectedItemsUUIDs(uuid_vec_t& selected_uuids) const;
100
101	boost::signals2::connection setSelectionChangeCallback(selection_change_callback_t cb);
102
103	// Collects selected items from all selected lists and wears them(if possible- adds, else replaces)
104	void wearSelectedItems();
105
106	/**
107	 * Returns true if there is a selection inside currently selected outfit
108	 */
109	bool hasItemSelected();
110
111private:
112
113	void onOutfitsRemovalConfirmation(const LLSD& notification, const LLSD& response);
114
115	/**
116	 * Wrapper for LLCommonUtils::computeDifference. @see LLCommonUtils::computeDifference
117	 */
118	void computeDifference(const LLInventoryModel::cat_array_t& vcats, uuid_vec_t& vadded, uuid_vec_t& vremoved);
119
120	/**
121	 * Updates tab displaying outfit identified by category_id.
122	 */
123	void updateOutfitTab(const LLUUID& category_id);
124
125	/**
126	 * Resets previous selection and stores newly selected list and outfit id.
127	 */
128	void changeOutfitSelection(LLWearableItemsList* list, const LLUUID& category_id);
129
130	/**
131	 *Resets items selection inside outfit
132	 */
133	void resetItemSelection(LLWearableItemsList* list, const LLUUID& category_id);
134
135	/**
136	 * Saves newly selected outfit ID.
137	 */
138	void setSelectedOutfitUUID(const LLUUID& category_id);
139
140	/**
141	 * Removes the outfit from selection.
142	 */
143	void deselectOutfit(const LLUUID& category_id);
144
145	/**
146	 * Try restoring selection for a temporary hidden tab.
147	 *
148	 * A tab may be hidden if it doesn't match current filter.
149	 */
150	void restoreOutfitSelection(LLAccordionCtrlTab* tab, const LLUUID& category_id);
151
152	/**
153	 * Called upon list refresh event to update tab visibility depending on
154	 * the results of applying filter to the title and list items of the tab.
155	 */
156	void onFilteredWearableItemsListRefresh(LLUICtrl* ctrl);
157
158	/**
159	 * Highlights filtered items and hides tabs which haven't passed filter.
160	 */
161	void applyFilter(const std::string& new_filter_substring);
162
163	/**
164	 * Applies filter to the given tab
165	 *
166	 * @see applyFilter()
167	 */
168	void applyFilterToTab(const LLUUID& category_id, LLAccordionCtrlTab* tab, const std::string& filter_substring);
169
170	/**
171	 * Returns true if all selected items can be worn.
172	 */
173	bool canWearSelected();
174
175	void onAccordionTabRightClick(LLUICtrl* ctrl, S32 x, S32 y, const LLUUID& cat_id);
176	void onWearableItemsListRightClick(LLUICtrl* ctrl, S32 x, S32 y);
177	void onCOFChanged();
178
179	void onSelectionChange(LLUICtrl* ctrl);
180
181	static void onOutfitRename(const LLSD& notification, const LLSD& response);
182
183	LLInventoryCategoriesObserver* 	mCategoriesObserver;
184
185	LLAccordionCtrl*				mAccordion;
186	LLPanel*						mListCommands;
187
188	typedef	std::map<LLUUID, LLWearableItemsList*>		wearables_lists_map_t;
189	typedef wearables_lists_map_t::value_type			wearables_lists_map_value_t;
190	wearables_lists_map_t			mSelectedListsMap;
191
192	LLUUID							mSelectedOutfitUUID;
193	// id of currently highlited outfit
194	LLUUID							mHighlightedOutfitUUID;
195	selection_change_signal_t		mSelectionChangeSignal;
196
197	typedef	std::map<LLUUID, LLAccordionCtrlTab*>		outfits_map_t;
198	typedef outfits_map_t::value_type					outfits_map_value_t;
199	outfits_map_t					mOutfitsMap;
200
201	// IDs of original items which are worn and linked in COF.
202	// Used to monitor COF changes for updating items worn state. See EXT-8636.
203	uuid_vec_t						mCOFLinkedItems;
204
205	LLOutfitListGearMenu*			mGearMenu;
206	LLListContextMenu*				mOutfitMenu;
207
208	bool							mIsInitialized;
209	/**
210	 * True if there is a selection inside currently selected outfit
211	 */
212	bool							mItemSelected;
213};
214
215#endif //LL_LLOUTFITSLIST_H