PageRenderTime 24ms CodeModel.GetById 18ms app.highlight 3ms RepoModel.GetById 2ms app.codeStats 0ms

/indra/newview/llinventoryitemslist.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 116 lines | 37 code | 25 blank | 54 comment | 0 complexity | cc1cc7528e155882cce7bf8973e9b0a3 MD5 | raw file
  1/**
  2 * @file llinventoryitemslist.h
  3 * @brief A list of inventory items represented by LLFlatListView.
  4 *
  5 * Class LLInventoryItemsList implements a flat list of inventory items.
  6 *
  7 * $LicenseInfo:firstyear=2010&license=viewerlgpl$
  8 * Second Life Viewer Source Code
  9 * Copyright (C) 2010, Linden Research, Inc.
 10 * 
 11 * This library is free software; you can redistribute it and/or
 12 * modify it under the terms of the GNU Lesser General Public
 13 * License as published by the Free Software Foundation;
 14 * version 2.1 of the License only.
 15 * 
 16 * This library is distributed in the hope that it will be useful,
 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 19 * Lesser General Public License for more details.
 20 * 
 21 * You should have received a copy of the GNU Lesser General Public
 22 * License along with this library; if not, write to the Free Software
 23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 24 * 
 25 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
 26 * $/LicenseInfo$
 27 */
 28
 29#ifndef LL_LLINVENTORYITEMSLIST_H
 30#define LL_LLINVENTORYITEMSLIST_H
 31
 32#include "lldarray.h"
 33
 34// newview
 35#include "llflatlistview.h"
 36
 37class LLViewerInventoryItem;
 38
 39class LLInventoryItemsList : public LLFlatListViewEx
 40{
 41public:
 42	struct Params : public LLInitParam::Block<Params, LLFlatListViewEx::Params>
 43	{
 44		Params();
 45	};
 46
 47	virtual ~LLInventoryItemsList();
 48
 49	void refreshList(const LLDynamicArray<LLPointer<LLViewerInventoryItem> > item_array);
 50
 51	boost::signals2::connection setRefreshCompleteCallback(const commit_signal_t::slot_type& cb);
 52
 53	/**
 54	 * Let list know items need to be refreshed in next doIdle()
 55	 */
 56	void setNeedsRefresh(bool needs_refresh){ mNeedsRefresh = needs_refresh; }
 57
 58	bool getNeedsRefresh(){ return mNeedsRefresh; }
 59
 60	/**
 61	 * Sets the flag indicating that the list needs to be refreshed even if it is
 62	 * not currently visible.
 63	 */
 64	void setForceRefresh(bool force_refresh){ mForceRefresh = force_refresh; }
 65
 66	virtual bool selectItemByValue(const LLSD& value, bool select = true);
 67
 68	void updateSelection();
 69
 70	/**
 71	 * Idle routine used to refresh the list regardless of the current list
 72	 * visibility, unlike draw() which is called only for the visible list.
 73	 * This is needed for example to filter items of the list hidden by closed
 74	 * accordion tab.
 75	 */
 76	void	doIdle();						// Real idle routine
 77	static void idle(void* user_data);		// static glue to doIdle()
 78
 79protected:
 80	friend class LLUICtrlFactory;
 81	LLInventoryItemsList(const LLInventoryItemsList::Params& p);
 82
 83	uuid_vec_t& getIDs() { return mIDs; }
 84
 85	/**
 86	 * Refreshes list items, adds new items and removes deleted items. 
 87	 * Called from doIdle() until all new items are added,
 88	 * maximum 50 items can be added during single call.
 89	 */
 90	void refresh();
 91
 92	/**
 93	 * Compute difference between new items and current items, fills 'vadded' with added items,
 94	 * 'vremoved' with removed items. See LLCommonUtils::computeDifference
 95	 */
 96	void computeDifference(const uuid_vec_t& vnew, uuid_vec_t& vadded, uuid_vec_t& vremoved);
 97
 98	/**
 99	 * Add an item to the list
100	 */
101	virtual void addNewItem(LLViewerInventoryItem* item, bool rearrange = true);
102
103private:
104	uuid_vec_t mIDs; // IDs of items that were added in refreshList().
105					 // Will be used in refresh() to determine added and removed ids
106
107	uuid_vec_t mSelectTheseIDs; // IDs that will be selected if list is not loaded till now
108
109	bool mNeedsRefresh;
110
111	bool mForceRefresh;
112
113	commit_signal_t mRefreshCompleteSignal;
114};
115
116#endif //LL_LLINVENTORYITEMSLIST_H