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