PageRenderTime 345ms CodeModel.GetById 141ms app.highlight 14ms RepoModel.GetById 127ms app.codeStats 0ms

/indra/newview/llavatarlist.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 208 lines | 115 code | 42 blank | 51 comment | 0 complexity | 7aa05c284a1b1eb521b1c617564c0fbc MD5 | raw file
  1/** 
  2 * @file llavatarlist.h
  3 * @brief Generic avatar list
  4 *
  5 * $LicenseInfo:firstyear=2009&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_LLAVATARLIST_H
 28#define LL_LLAVATARLIST_H
 29
 30#include "llflatlistview.h"
 31#include "llavatarlistitem.h"
 32
 33class LLTimer;
 34class LLListContextMenu;
 35
 36/**
 37 * Generic list of avatars.
 38 * 
 39 * Updates itself when it's dirty, using optional name filter.
 40 * To initiate update, modify the UUID list and call setDirty().
 41 * 
 42 * @see getIDs()
 43 * @see setDirty()
 44 * @see setNameFilter()
 45 */
 46class LLAvatarList : public LLFlatListViewEx
 47{
 48	LOG_CLASS(LLAvatarList);
 49public:
 50	struct Params : public LLInitParam::Block<Params, LLFlatListViewEx::Params>
 51	{
 52		Optional<bool>	ignore_online_status, // show all items as online
 53						show_last_interaction_time, // show most recent interaction time. *HACK: move this to a derived class
 54						show_info_btn,
 55						show_profile_btn,
 56						show_speaking_indicator,
 57						show_permissions_granted;
 58		Params();
 59	};
 60
 61	LLAvatarList(const Params&);
 62	virtual	~LLAvatarList();
 63
 64	virtual void draw(); // from LLView
 65
 66	virtual void clear();
 67
 68	virtual void setVisible(BOOL visible);
 69
 70	void setNameFilter(const std::string& filter);
 71	void setDirty(bool val = true, bool force_refresh = false);
 72	uuid_vec_t& getIDs() 							{ return mIDs; }
 73	bool contains(const LLUUID& id);
 74
 75	void setContextMenu(LLListContextMenu* menu) { mContextMenu = menu; }
 76	void setSessionID(const LLUUID& session_id) { mSessionID = session_id; }
 77	const LLUUID& getSessionID() { return mSessionID; }
 78
 79	void toggleIcons();
 80	void setSpeakingIndicatorsVisible(bool visible);
 81	void showPermissions(bool visible);
 82	void sortByName();
 83	void setShowIcons(std::string param_name);
 84	bool getIconsVisible() const { return mShowIcons; }
 85	const std::string getIconParamName() const{return mIconParamName;}
 86	virtual BOOL handleRightMouseDown(S32 x, S32 y, MASK mask);
 87
 88	// Return true if filter has at least one match.
 89	bool filterHasMatches();
 90
 91	boost::signals2::connection setRefreshCompleteCallback(const commit_signal_t::slot_type& cb);
 92
 93	boost::signals2::connection setItemDoubleClickCallback(const mouse_signal_t::slot_type& cb);
 94
 95	virtual S32 notifyParent(const LLSD& info);
 96
 97	void addAvalineItem(const LLUUID& item_id, const LLUUID& session_id, const std::string& item_name);
 98	void handleDisplayNamesOptionChanged();
 99
100protected:
101	void refresh();
102
103	void addNewItem(const LLUUID& id, const std::string& name, BOOL is_online, EAddPosition pos = ADD_BOTTOM);
104	void computeDifference(
105		const uuid_vec_t& vnew,
106		uuid_vec_t& vadded,
107		uuid_vec_t& vremoved);
108	void updateLastInteractionTimes();	
109	void rebuildNames();
110	void onItemDoubleClicked(LLUICtrl* ctrl, S32 x, S32 y, MASK mask);
111	void updateAvatarNames();
112
113private:
114
115	bool isAvalineItemSelected();
116
117	bool mIgnoreOnlineStatus;
118	bool mShowLastInteractionTime;
119	bool mDirty;
120	bool mNeedUpdateNames;
121	bool mShowIcons;
122	bool mShowInfoBtn;
123	bool mShowProfileBtn;
124	bool mShowSpeakingIndicator;
125	bool mShowPermissions;
126
127	LLTimer*				mLITUpdateTimer; // last interaction time update timer
128	std::string				mIconParamName;
129	std::string				mNameFilter;
130	uuid_vec_t				mIDs;
131	LLUUID					mSessionID;
132
133	LLListContextMenu*	mContextMenu;
134
135	commit_signal_t mRefreshCompleteSignal;
136	mouse_signal_t mItemDoubleClickSignal;
137};
138
139/** Abstract comparator for avatar items */
140class LLAvatarItemComparator : public LLFlatListView::ItemComparator
141{
142	LOG_CLASS(LLAvatarItemComparator);
143
144public:
145	LLAvatarItemComparator() {};
146	virtual ~LLAvatarItemComparator() {};
147
148	virtual bool compare(const LLPanel* item1, const LLPanel* item2) const;
149
150protected:
151
152	/** 
153	 * Returns true if avatar_item1 < avatar_item2, false otherwise 
154	 * Implement this method in your particular comparator.
155	 * In Linux a compiler failed to build it using the name "compare", so it was renamed to doCompare
156	 */
157	virtual bool doCompare(const LLAvatarListItem* avatar_item1, const LLAvatarListItem* avatar_item2) const = 0;
158};
159
160
161class LLAvatarItemNameComparator : public LLAvatarItemComparator
162{
163	LOG_CLASS(LLAvatarItemNameComparator);
164
165public:
166	LLAvatarItemNameComparator() {};
167	virtual ~LLAvatarItemNameComparator() {};
168
169protected:
170	virtual bool doCompare(const LLAvatarListItem* avatar_item1, const LLAvatarListItem* avatar_item2) const;
171};
172
173class LLAvatarItemAgentOnTopComparator : public LLAvatarItemNameComparator
174{
175	LOG_CLASS(LLAvatarItemAgentOnTopComparator);
176
177public:
178	LLAvatarItemAgentOnTopComparator() {};
179	virtual ~LLAvatarItemAgentOnTopComparator() {};
180
181protected:
182	virtual bool doCompare(const LLAvatarListItem* avatar_item1, const LLAvatarListItem* avatar_item2) const;
183};
184
185/**
186 * Represents Avaline caller in Avatar list in Voice Control Panel and group chats.
187 */
188class LLAvalineListItem : public LLAvatarListItem
189{
190public:
191
192	/**
193	 * Constructor
194	 *
195	 * @param hide_number - flag indicating if number should be hidden.
196	 *		In this case It will be shown as "Avaline Caller 1", "Avaline Caller 1", etc.
197	 */
198	LLAvalineListItem(bool hide_number = true);
199
200	/*virtual*/ BOOL postBuild();
201
202	/*virtual*/ void setName(const std::string& name);
203
204private:
205	bool mIsHideNumber;
206};
207
208#endif // LL_LLAVATARLIST_H