diff options
Diffstat (limited to 'indra')
-rw-r--r-- | indra/newview/app_settings/settings.xml | 11 | ||||
-rwxr-xr-x | indra/newview/llconversationmodel.h | 23 | ||||
-rwxr-xr-x | indra/newview/llimfloatercontainer.cpp | 89 | ||||
-rw-r--r-- | indra/newview/llimfloatercontainer.h | 4 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/menu_participant_view.xml | 70 |
5 files changed, 190 insertions, 7 deletions
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 593381cb29..9ada5e5918 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -1683,6 +1683,17 @@ <key>Value</key> <integer>100</integer> </map> + <key>ConversationSortOrder</key> + <map> + <key>Comment</key> + <string>Specifies sort key for conversations</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>U32</string> + <key>Value</key> + <integer>131073</integer> + </map> <key>NearbyChatIsNotTornOff</key> <map> <key>Comment</key> diff --git a/indra/newview/llconversationmodel.h b/indra/newview/llconversationmodel.h index c340194dd3..ef1903ab19 100755 --- a/indra/newview/llconversationmodel.h +++ b/indra/newview/llconversationmodel.h @@ -170,10 +170,14 @@ public: enum ESortOrderType { - SO_NAME = 0, // Sort inventory by name - SO_DATE = 0x1, // Sort inventory by date + SO_NAME = 0, // Sort by name + SO_DATE = 0x1, // Sort by date (most recent) + SO_SESSION_TYPE = 0x2, // Sort by type (valid only for sessions) + SO_DISTANCE = 0x3, // Sort by distance (valid only for participants in nearby chat) }; - + // Default sort order is by type for sessions and by date for participants + static const U32 SO_DEFAULT = (SO_SESSION_TYPE << 16) | (SO_DATE); + LLConversationFilter() { mEmpty = ""; } ~LLConversationFilter() {} @@ -211,13 +215,18 @@ private: class LLConversationSort { public: - LLConversationSort(U32 order = 0) : mSortOrder(order) { } - - bool isByDate() const { return (mSortOrder & LLConversationFilter::SO_DATE); } - U32 getSortOrder() const { return mSortOrder; } + LLConversationSort(U32 order = LLConversationFilter::SO_DEFAULT) : mSortOrder(order) { } + // 16 LSB bits used for participants, 16 MSB bits for sessions + U32 getSortOrderSessions() const { return ((mSortOrder >> 16) & 0xFFFF); } + U32 getSortOrderParticipants() const { return (mSortOrder & 0xFFFF); } + void setSortOrderSessions(LLConversationFilter::ESortOrderType session) { mSortOrder = ((session & 0xFFFF) << 16) | (mSortOrder & 0xFFFF); } + void setSortOrderParticipants(LLConversationFilter::ESortOrderType participant) { mSortOrder = (mSortOrder & 0xFFFF0000) | (participant & 0xFFFF); } + bool operator()(const LLConversationItem* const& a, const LLConversationItem* const& b) const; + operator U32() const { return mSortOrder; } private: + // Note: we're treating this value as a sort order bitmask as done in other places in the code (e.g. inventory) U32 mSortOrder; }; diff --git a/indra/newview/llimfloatercontainer.cpp b/indra/newview/llimfloatercontainer.cpp index 81dddfaa70..ab4b64471b 100755 --- a/indra/newview/llimfloatercontainer.cpp +++ b/indra/newview/llimfloatercontainer.cpp @@ -58,6 +58,7 @@ LLIMFloaterContainer::LLIMFloaterContainer(const LLSD& seed) mInitialized(false) { mCommitCallbackRegistrar.add("IMFloaterContainer.Action", boost::bind(&LLIMFloaterContainer::onCustomAction, this, _2)); + mEnableCallbackRegistrar.add("IMFloaterContainer.Check", boost::bind(&LLIMFloaterContainer::isActionChecked, this, _2)); // Firstly add our self to IMSession observers, so we catch session events LLIMMgr::getInstance()->addSessionObserver(this); @@ -169,6 +170,9 @@ BOOL LLIMFloaterContainer::postBuild() mConversationsPane->handleReshape(list_size, TRUE); } + // Init the sort order now that the root had been created + setSortOrder(LLConversationSort(gSavedSettings.getU32("ConversationSortOrder"))); + mInitialized = true; // Add callback: we'll take care of view updates on idle @@ -546,6 +550,30 @@ void LLIMFloaterContainer::onCustomAction(const LLSD& userdata) { std::string command = userdata.asString(); + if ("sort_sessions_by_type" == command) + { + setSortOrderSessions(LLConversationFilter::SO_SESSION_TYPE); + } + if ("sort_sessions_by_name" == command) + { + setSortOrderSessions(LLConversationFilter::SO_NAME); + } + if ("sort_sessions_by_recent" == command) + { + setSortOrderSessions(LLConversationFilter::SO_DATE); + } + if ("sort_participants_by_name" == command) + { + setSortOrderParticipants(LLConversationFilter::SO_NAME); + } + if ("sort_participants_by_recent" == command) + { + setSortOrderParticipants(LLConversationFilter::SO_DATE); + } + if ("sort_participants_by_distance" == command) + { + setSortOrderParticipants(LLConversationFilter::SO_DISTANCE); + } if ("chat_preferences" == command) { LLFloaterPreference* floater_prefs = LLFloaterReg::showTypedInstance<LLFloaterPreference>("preferences"); @@ -561,6 +589,67 @@ void LLIMFloaterContainer::onCustomAction(const LLSD& userdata) } } +BOOL LLIMFloaterContainer::isActionChecked(const LLSD& userdata) +{ + LLConversationSort order = mConversationViewModel.getSorter(); + std::string command = userdata.asString(); + if ("sort_sessions_by_type" == command) + { + return (order.getSortOrderSessions() == LLConversationFilter::SO_SESSION_TYPE); + } + if ("sort_sessions_by_name" == command) + { + return (order.getSortOrderSessions() == LLConversationFilter::SO_NAME); + } + if ("sort_sessions_by_recent" == command) + { + return (order.getSortOrderSessions() == LLConversationFilter::SO_DATE); + } + if ("sort_participants_by_name" == command) + { + return (order.getSortOrderParticipants() == LLConversationFilter::SO_NAME); + } + if ("sort_participants_by_recent" == command) + { + return (order.getSortOrderParticipants() == LLConversationFilter::SO_DATE); + } + if ("sort_participants_by_distance" == command) + { + return (order.getSortOrderParticipants() == LLConversationFilter::SO_DISTANCE); + } + + return FALSE; +} + +void LLIMFloaterContainer::setSortOrderSessions(const LLConversationFilter::ESortOrderType order) +{ + LLConversationSort old_order = mConversationViewModel.getSorter(); + if (order != old_order.getSortOrderSessions()) + { + old_order.setSortOrderSessions(order); + setSortOrder(old_order); + } +} + +void LLIMFloaterContainer::setSortOrderParticipants(const LLConversationFilter::ESortOrderType order) +{ + LLConversationSort old_order = mConversationViewModel.getSorter(); + if (order != old_order.getSortOrderParticipants()) + { + old_order.setSortOrderParticipants(order); + setSortOrder(old_order); + } +} + +void LLIMFloaterContainer::setSortOrder(const LLConversationSort& order) +{ + mConversationViewModel.setSorter(order); + mConversationsRoot->arrangeAll(); + // try to keep selection onscreen, even if it wasn't to start with + mConversationsRoot->scrollToShowSelection(); + gSavedSettings.setU32("ConversationSortOrder", (U32)order); +} + void LLIMFloaterContainer::repositioningWidgets() { if (!mInitialized) diff --git a/indra/newview/llimfloatercontainer.h b/indra/newview/llimfloatercontainer.h index f6048bed37..1f526091bb 100644 --- a/indra/newview/llimfloatercontainer.h +++ b/indra/newview/llimfloatercontainer.h @@ -105,7 +105,11 @@ private: void onAddButtonClicked(); void onAvatarPicked(const uuid_vec_t& ids); + BOOL isActionChecked(const LLSD& userdata); void onCustomAction (const LLSD& userdata); + void setSortOrderSessions(const LLConversationFilter::ESortOrderType order); + void setSortOrderParticipants(const LLConversationFilter::ESortOrderType order); + void setSortOrder(const LLConversationSort& order); LLButton* mExpandCollapseBtn; LLLayoutPanel* mMessagesPane; diff --git a/indra/newview/skins/default/xui/en/menu_participant_view.xml b/indra/newview/skins/default/xui/en/menu_participant_view.xml index df2700c94c..0043c14479 100644 --- a/indra/newview/skins/default/xui/en/menu_participant_view.xml +++ b/indra/newview/skins/default/xui/en/menu_participant_view.xml @@ -2,6 +2,76 @@ <toggleable_menu layout="topleft" name="participant_manu_view"> + <menu_item_check + label="Sort conversations by type" + layout="topleft" + name="sort_sessions_by_type"> + <on_click + function="IMFloaterContainer.Action" + parameter="sort_sessions_by_type" /> + <on_check + function="IMFloaterContainer.Check" + parameter="sort_sessions_by_type" /> + </menu_item_check> + <menu_item_check + label="Sort conversations by name" + layout="topleft" + name="sort_sessions_by_name"> + <on_click + function="IMFloaterContainer.Action" + parameter="sort_sessions_by_name" /> + <on_check + function="IMFloaterContainer.Check" + parameter="sort_sessions_by_name" /> + </menu_item_check> + <menu_item_check + label="Sort conversations by recent activity" + layout="topleft" + name="sort_sessions_by_recent"> + <on_click + function="IMFloaterContainer.Action" + parameter="sort_sessions_by_recent" /> + <on_check + function="IMFloaterContainer.Check" + parameter="sort_sessions_by_recent" /> + </menu_item_check> + <menu_item_separator + layout="topleft" /> + <menu_item_check + label="Sort participants by name" + layout="topleft" + name="sort_participants_by_name"> + <on_click + function="IMFloaterContainer.Action" + parameter="sort_participants_by_name" /> + <on_check + function="IMFloaterContainer.Check" + parameter="sort_participants_by_name" /> + </menu_item_check> + <menu_item_check + label="Sort participants by recent activity" + layout="topleft" + name="sort_participants_by_recent"> + <on_click + function="IMFloaterContainer.Action" + parameter="sort_participants_by_recent" /> + <on_check + function="IMFloaterContainer.Check" + parameter="sort_participants_by_recent" /> + </menu_item_check> + <menu_item_check + label="Sort participants by distance from you" + layout="topleft" + name="sort_participants_by_distance"> + <on_click + function="IMFloaterContainer.Action" + parameter="sort_participants_by_distance" /> + <on_check + function="IMFloaterContainer.Check" + parameter="sort_participants_by_distance" /> + </menu_item_check> + <menu_item_separator + layout="topleft" /> <menu_item_call label="Chat preferences..." name="chat_preferences"> |