diff options
author | Merov Linden <merov@lindenlab.com> | 2012-09-17 17:53:17 -0700 |
---|---|---|
committer | Merov Linden <merov@lindenlab.com> | 2012-09-17 17:53:17 -0700 |
commit | d22c8510b19f12e81dc68562de45c2c364036440 (patch) | |
tree | 414bcd5946ac7a04b629d2526b4c0b119c631355 | |
parent | 9b0d627a06a817fc11edc4c6c718f1114aa7cfcf (diff) |
CHUI-340 : WIP : Sorting implemented. Type and name work. Date and distance still need the relevant values to be computed.
-rw-r--r-- | indra/newview/llconversationmodel.cpp | 70 | ||||
-rwxr-xr-x | indra/newview/llconversationmodel.h | 17 | ||||
-rwxr-xr-x | indra/newview/llimfloatercontainer.cpp | 1 | ||||
-rw-r--r-- | indra/newview/llparticipantlist.cpp | 21 |
4 files changed, 101 insertions, 8 deletions
diff --git a/indra/newview/llconversationmodel.cpp b/indra/newview/llconversationmodel.cpp index c36c3cbc65..612744c3e9 100644 --- a/indra/newview/llconversationmodel.cpp +++ b/indra/newview/llconversationmodel.cpp @@ -37,7 +37,8 @@ LLConversationItem::LLConversationItem(std::string display_name, const LLUUID& u LLFolderViewModelItemCommon(root_view_model), mName(display_name), mUUID(uuid), - mNeedsRefresh(true) + mNeedsRefresh(true), + mConvType(CONV_UNKNOWN) { } @@ -45,7 +46,8 @@ LLConversationItem::LLConversationItem(const LLUUID& uuid, LLFolderViewModelInte LLFolderViewModelItemCommon(root_view_model), mName(""), mUUID(uuid), - mNeedsRefresh(true) + mNeedsRefresh(true), + mConvType(CONV_UNKNOWN) { } @@ -53,7 +55,8 @@ LLConversationItem::LLConversationItem(LLFolderViewModelInterface& root_view_mod LLFolderViewModelItemCommon(root_view_model), mName(""), mUUID(), - mNeedsRefresh(true) + mNeedsRefresh(true), + mConvType(CONV_UNKNOWN) { } @@ -86,11 +89,13 @@ LLConversationItemSession::LLConversationItemSession(std::string display_name, c LLConversationItem(display_name,uuid,root_view_model), mIsLoaded(false) { + mConvType = CONV_SESSION_UNKNOWN; } LLConversationItemSession::LLConversationItemSession(const LLUUID& uuid, LLFolderViewModelInterface& root_view_model) : LLConversationItem(uuid,root_view_model) { + mConvType = CONV_SESSION_UNKNOWN; } bool LLConversationItemSession::hasChildren() const @@ -183,11 +188,13 @@ LLConversationItemParticipant::LLConversationItemParticipant(std::string display mIsMuted(false), mIsModerator(false) { + mConvType = CONV_PARTICIPANT; } LLConversationItemParticipant::LLConversationItemParticipant(const LLUUID& uuid, LLFolderViewModelInterface& root_view_model) : LLConversationItem(uuid,root_view_model) { + mConvType = CONV_PARTICIPANT; } void LLConversationItemParticipant::onAvatarNameCache(const LLAvatarName& av_name) @@ -212,11 +219,60 @@ void LLConversationItemParticipant::dumpDebugData() bool LLConversationSort::operator()(const LLConversationItem* const& a, const LLConversationItem* const& b) const { - // For the moment, we sort only by name - // *TODO : Implement the sorting by date as well (most recent first) - // *TODO : Check the type of item (session/participants) as order should be different for both (eventually) + LLConversationItem::EConversationType type_a = a->getType(); + LLConversationItem::EConversationType type_b = b->getType(); + + if ((type_a == LLConversationItem::CONV_PARTICIPANT) && (type_b == LLConversationItem::CONV_PARTICIPANT)) + { + // If both are participants + U32 sort_order = getSortOrderParticipants(); + if (sort_order == LLConversationFilter::SO_DATE) + { + F32 time_a = 0.0; + F32 time_b = 0.0; + if (a->getTime(time_a) && b->getTime(time_b)) + { + return (time_a > time_b); + } + } + else if (sort_order == LLConversationFilter::SO_DISTANCE) + { + F32 dist_a = 0.0; + F32 dist_b = 0.0; + if (a->getDistanceToAgent(dist_a) && b->getDistanceToAgent(dist_b)) + { + return (dist_a > dist_b); + } + } + } + else if ((type_a > LLConversationItem::CONV_PARTICIPANT) && (type_b > LLConversationItem::CONV_PARTICIPANT)) + { + // If both are sessions + U32 sort_order = getSortOrderSessions(); + if (sort_order == LLConversationFilter::SO_DATE) + { + F32 time_a = 0.0; + F32 time_b = 0.0; + if (a->getTime(time_a) && b->getTime(time_b)) + { + return (time_a > time_b); + } + } + else if (sort_order == LLConversationFilter::SO_SESSION_TYPE) + { + return (type_a < type_b); + } + } + else + { + // If one is a participant and the other a session, the session is always "less" than the participant + // so we simply compare the type + // Notes: as a consequence, CONV_UNKNOWN (which should never get created...) always come first + return (type_a < type_b); + } + // By default, in all other possible cases (including sort order of type LLConversationFilter::SO_NAME of course), sort by name S32 compare = LLStringUtil::compareDict(a->getDisplayName(), b->getDisplayName()); - return (compare < 0); + return (compare < 0); } // diff --git a/indra/newview/llconversationmodel.h b/indra/newview/llconversationmodel.h index ef1903ab19..954543f91a 100755 --- a/indra/newview/llconversationmodel.h +++ b/indra/newview/llconversationmodel.h @@ -46,6 +46,17 @@ typedef std::map<LLUUID, LLFolderViewItem*> conversations_widgets_map; class LLConversationItem : public LLFolderViewModelItemCommon { public: + enum EConversationType + { + CONV_UNKNOWN = 0, + CONV_PARTICIPANT = 1, + CONV_SESSION_NEARBY = 2, // The order counts here as it is used to sort sessions by type + CONV_SESSION_1_ON_1 = 3, + CONV_SESSION_AD_HOC = 4, + CONV_SESSION_GROUP = 5, + CONV_SESSION_UNKNOWN = 6 + }; + LLConversationItem(std::string display_name, const LLUUID& uuid, LLFolderViewModelInterface& root_view_model); LLConversationItem(const LLUUID& uuid, LLFolderViewModelInterface& root_view_model); LLConversationItem(LLFolderViewModelInterface& root_view_model); @@ -93,6 +104,11 @@ public: virtual void selectItem(void) { } virtual void showProperties(void); + // Methods used in sorting (see LLConversationSort::operator() + EConversationType const getType() const { return mConvType; } + virtual const bool getTime(F32& time) const { return false; } + virtual const bool getDistanceToAgent(F32& distance) const { return false; } + // This method will be called to determine if a drop can be // performed, and will set drop to TRUE if a drop is // requested. @@ -111,6 +127,7 @@ public: protected: std::string mName; // Name of the session or the participant LLUUID mUUID; // UUID of the session or the participant + EConversationType mConvType; // Type of conversation item bool mNeedsRefresh; // Flag signaling to the view that something changed for this item }; diff --git a/indra/newview/llimfloatercontainer.cpp b/indra/newview/llimfloatercontainer.cpp index ab4b64471b..76bd6b14b9 100755 --- a/indra/newview/llimfloatercontainer.cpp +++ b/indra/newview/llimfloatercontainer.cpp @@ -740,7 +740,6 @@ void LLIMFloaterContainer::addConversationListItem(const LLUUID& uuid) llwarns << "Couldn't create conversation session item : " << display_name << llendl; return; } - // *TODO: Should we flag LLConversationItemSession with a mIsNearbyChat? item->renameItem(display_name); mConversationsItems[uuid] = item; diff --git a/indra/newview/llparticipantlist.cpp b/indra/newview/llparticipantlist.cpp index 0d1a37c835..339cee3f95 100644 --- a/indra/newview/llparticipantlist.cpp +++ b/indra/newview/llparticipantlist.cpp @@ -280,6 +280,27 @@ LLParticipantList::LLParticipantList(LLSpeakerMgr* data_source, } // we need to exclude agent id for non group chat sort(); + + // Identify and store what kind of session we are + LLIMModel::LLIMSession* im_session = LLIMModel::getInstance()->findIMSession(data_source->getSessionID()); + if (im_session) + { + // By default, sessions that can't be identified as group or ad-hoc will be considered P2P (i.e. 1 on 1) + mConvType = CONV_SESSION_1_ON_1; + if (im_session->isAdHocSessionType()) + { + mConvType = CONV_SESSION_AD_HOC; + } + else if (im_session->isGroupSessionType()) + { + mConvType = CONV_SESSION_GROUP; + } + } + else + { + // That's the only session that doesn't get listed in the LLIMModel as a session... + mConvType = CONV_SESSION_NEARBY; + } } LLParticipantList::~LLParticipantList() |