summaryrefslogtreecommitdiff
path: root/indra/newview/llconversationmodel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llconversationmodel.cpp')
-rw-r--r--indra/newview/llconversationmodel.cpp90
1 files changed, 78 insertions, 12 deletions
diff --git a/indra/newview/llconversationmodel.cpp b/indra/newview/llconversationmodel.cpp
index 612744c3e9..e090d1647f 100644
--- a/indra/newview/llconversationmodel.cpp
+++ b/indra/newview/llconversationmodel.cpp
@@ -38,7 +38,8 @@ LLConversationItem::LLConversationItem(std::string display_name, const LLUUID& u
mName(display_name),
mUUID(uuid),
mNeedsRefresh(true),
- mConvType(CONV_UNKNOWN)
+ mConvType(CONV_UNKNOWN),
+ mLastActiveTime(0.0)
{
}
@@ -47,7 +48,8 @@ LLConversationItem::LLConversationItem(const LLUUID& uuid, LLFolderViewModelInte
mName(""),
mUUID(uuid),
mNeedsRefresh(true),
- mConvType(CONV_UNKNOWN)
+ mConvType(CONV_UNKNOWN),
+ mLastActiveTime(0.0)
{
}
@@ -56,7 +58,8 @@ LLConversationItem::LLConversationItem(LLFolderViewModelInterface& root_view_mod
mName(""),
mUUID(),
mNeedsRefresh(true),
- mConvType(CONV_UNKNOWN)
+ mConvType(CONV_UNKNOWN),
+ mLastActiveTime(0.0)
{
}
@@ -167,6 +170,41 @@ void LLConversationItemSession::setParticipantIsModerator(const LLUUID& particip
}
}
+void LLConversationItemSession::setTimeNow(const LLUUID& participant_id)
+{
+ mLastActiveTime = LLFrameTimer::getElapsedSeconds();
+ mNeedsRefresh = true;
+ LLConversationItemParticipant* participant = findParticipant(participant_id);
+ if (participant)
+ {
+ participant->setTimeNow();
+ }
+}
+
+// The time of activity of a session is the time of the most recent activity, session and participants included
+const bool LLConversationItemSession::getTime(F64& time) const
+{
+ F64 most_recent_time = mLastActiveTime;
+ bool has_time = (most_recent_time > 0.1);
+ LLConversationItemParticipant* participant = NULL;
+ child_list_t::const_iterator iter;
+ for (iter = mChildren.begin(); iter != mChildren.end(); iter++)
+ {
+ participant = dynamic_cast<LLConversationItemParticipant*>(*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;
+ }
+ return has_time;
+}
+
void LLConversationItemSession::dumpDebugData()
{
llinfos << "Merov debug : session, uuid = " << mUUID << ", name = " << mName << ", is loaded = " << mIsLoaded << llendl;
@@ -228,21 +266,36 @@ 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;
- if (a->getTime(time_a) && b->getTime(time_b))
+ F64 time_a = 0.0;
+ F64 time_b = 0.0;
+ bool has_time_a = a->getTime(time_a);
+ bool has_time_b = b->getTime(time_b);
+ if (has_time_a && has_time_b)
{
return (time_a > time_b);
}
+ else if (has_time_a || has_time_b)
+ {
+ // If we have only one time updated, we consider the element with time as the "highest".
+ // That boils down to "has_time_a" if you think about it.
+ return has_time_a;
+ }
+ // If not time available, we'll default to sort by name at the end of this method
}
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))
+ bool has_dist_a = a->getDistanceToAgent(dist_a);
+ bool has_dist_b = b->getDistanceToAgent(dist_b);
+ if (has_dist_a && has_dist_b)
{
return (dist_a > dist_b);
}
+ else if (has_dist_a || has_dist_b)
+ {
+ return has_dist_a;
+ }
}
}
else if ((type_a > LLConversationItem::CONV_PARTICIPANT) && (type_b > LLConversationItem::CONV_PARTICIPANT))
@@ -251,16 +304,28 @@ 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;
- if (a->getTime(time_a) && b->getTime(time_b))
+ F64 time_a = 0.0;
+ F64 time_b = 0.0;
+ bool has_time_a = a->getTime(time_a);
+ bool has_time_b = b->getTime(time_b);
+ if (has_time_a && has_time_b)
{
return (time_a > time_b);
}
+ else if (has_time_a || has_time_b)
+ {
+ // If we have only one time updated, we consider the element with time as the "highest".
+ // That boils down to "has_time_a" if you think about it.
+ return has_time_a;
+ }
+ // If not time available, we'll default to sort by name at the end of this method
}
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 +335,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);
}