From 1107803a5c6da07cd5171f06afc0490f3eca7bf7 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Thu, 20 Sep 2012 17:50:58 -0700 Subject: CHUI-340 : WIP : Implement time update and comparison for sessions and participants --- indra/newview/llconversationmodel.cpp | 44 +++++++++++++++++++++++++++++------ indra/newview/llconversationmodel.h | 10 ++++++-- indra/newview/llparticipantlist.cpp | 9 +++++-- 3 files changed, 52 insertions(+), 11 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llconversationmodel.cpp b/indra/newview/llconversationmodel.cpp index 612744c3e9..b39b997a55 100644 --- a/indra/newview/llconversationmodel.cpp +++ b/indra/newview/llconversationmodel.cpp @@ -167,6 +167,31 @@ void LLConversationItemSession::setParticipantIsModerator(const LLUUID& particip } } +// The time of activity of a session is the time of the most recent participation +const bool LLConversationItemSession::getTime(F64& time) const +{ + bool has_time = false; + F64 most_recent_time = 0.0; + LLConversationItemParticipant* participant = NULL; + child_list_t::const_iterator iter; + for (iter = mChildren.begin(); iter != mChildren.end(); iter++) + { + participant = dynamic_cast(*iter); + F64 participant_time; + if (participant->getTime(participant_time)) + { + has_time = true; + most_recent_time = llmax(most_recent_time,participant_time); + } + } + if (has_time) + { + time = most_recent_time; + } + llinfos << "Merov debug : get time session, uuid = " << mUUID << ", has_time = " << has_time << ", time = " << time << llendl; + return has_time; +} + void LLConversationItemSession::dumpDebugData() { llinfos << "Merov debug : session, uuid = " << mUUID << ", name = " << mName << ", is loaded = " << mIsLoaded << llendl; @@ -186,7 +211,8 @@ void LLConversationItemSession::dumpDebugData() LLConversationItemParticipant::LLConversationItemParticipant(std::string display_name, const LLUUID& uuid, LLFolderViewModelInterface& root_view_model) : LLConversationItem(display_name,uuid,root_view_model), mIsMuted(false), - mIsModerator(false) + mIsModerator(false), + mLastActiveTime(0.0) { mConvType = CONV_PARTICIPANT; } @@ -228,8 +254,8 @@ bool LLConversationSort::operator()(const LLConversationItem* const& a, const LL U32 sort_order = getSortOrderParticipants(); if (sort_order == LLConversationFilter::SO_DATE) { - F32 time_a = 0.0; - F32 time_b = 0.0; + F64 time_a = 0.0; + F64 time_b = 0.0; if (a->getTime(time_a) && b->getTime(time_b)) { return (time_a > time_b); @@ -251,8 +277,8 @@ bool LLConversationSort::operator()(const LLConversationItem* const& a, const LL U32 sort_order = getSortOrderSessions(); if (sort_order == LLConversationFilter::SO_DATE) { - F32 time_a = 0.0; - F32 time_b = 0.0; + F64 time_a = 0.0; + F64 time_b = 0.0; if (a->getTime(time_a) && b->getTime(time_b)) { return (time_a > time_b); @@ -260,7 +286,10 @@ bool LLConversationSort::operator()(const LLConversationItem* const& a, const LL } else if (sort_order == LLConversationFilter::SO_SESSION_TYPE) { - return (type_a < type_b); + if (type_a != type_b) + { + return (type_a < type_b); + } } } else @@ -270,7 +299,8 @@ bool LLConversationSort::operator()(const LLConversationItem* const& a, const LL // 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 + // By default, in all other possible cases (including sort order of type LLConversationFilter::SO_NAME of course), + // we sort by name S32 compare = LLStringUtil::compareDict(a->getDisplayName(), b->getDisplayName()); return (compare < 0); } diff --git a/indra/newview/llconversationmodel.h b/indra/newview/llconversationmodel.h index dbc04223af..f3f99b5575 100755 --- a/indra/newview/llconversationmodel.h +++ b/indra/newview/llconversationmodel.h @@ -104,9 +104,9 @@ public: virtual void selectItem(void) { } virtual void showProperties(void); - // Methods used in sorting (see LLConversationSort::operator() + // 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 getTime(F64& 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 @@ -152,6 +152,8 @@ public: bool isLoaded() { return mIsLoaded; } + virtual const bool getTime(F64& time) const; + void dumpDebugData(); private: @@ -169,14 +171,18 @@ public: bool isModerator() {return mIsModerator; } void setIsMuted(bool is_muted) { mIsMuted = is_muted; mNeedsRefresh = true; } void setIsModerator(bool is_moderator) { mIsModerator = is_moderator; mNeedsRefresh = true; } + void setTimeNow() { mLastActiveTime = LLFrameTimer::getElapsedSeconds(); } void onAvatarNameCache(const LLAvatarName& av_name); + virtual const bool getTime(F64& time) const { time = mLastActiveTime; return (time > 0.1 ? true : false); } + void dumpDebugData(); private: bool mIsMuted; // default is false bool mIsModerator; // default is false + F64 mLastActiveTime; }; // We don't want to ever filter conversations but we need to declare that class to create a conversation view model. diff --git a/indra/newview/llparticipantlist.cpp b/indra/newview/llparticipantlist.cpp index 8bc6bb60cf..9f470a735e 100644 --- a/indra/newview/llparticipantlist.cpp +++ b/indra/newview/llparticipantlist.cpp @@ -591,8 +591,13 @@ bool LLParticipantList::onSpeakerUpdateEvent(LLPointer eve const LLSD& evt_data = event->getValue(); if ( evt_data.has("id") ) { - LLUUID id = evt_data["id"]; - llinfos << "Merov debug : onSpeakerUpdateEvent, session = " << mUUID << ", uuid = " << id << ", date = " << LLFrameTimer::getElapsedSeconds() << llendl; + LLUUID participant_id = evt_data["id"]; + LLConversationItemParticipant* participant = findParticipant(participant_id); + if (participant) + { + participant->setTimeNow(); + } + llinfos << "Merov debug : onSpeakerUpdateEvent, session = " << mUUID << ", uuid = " << participant_id << ", date = " << LLFrameTimer::getElapsedSeconds() << llendl; } return true; } -- cgit v1.2.3