Fix for friends list not resorting upon avatar online status change. Also did some minor cleanup

This commit is contained in:
Shyotl
2012-12-09 17:05:54 -06:00
parent 8a7cc9259c
commit a4591a5eaa
2 changed files with 62 additions and 30 deletions

View File

@@ -642,6 +642,18 @@ public:
// manually call this whenever editing list items in place to flag need for resorting
void setNeedsSort(bool val = true) { mSorted = !val; }
void setNeedsSortColumn(S32 col)
{
if(!isSorted())return;
for(std::vector<std::pair<S32, BOOL> >::iterator it=mSortColumns.begin();it!=mSortColumns.end();++it)
{
if((*it).first == col)
{
setNeedsSort();
break;
}
}
}
void dirtyColumns(); // some operation has potentially affected column layout or ordering
boost::signals2::connection setSortCallback(sort_signal_t::slot_type cb )

View File

@@ -78,7 +78,7 @@
#include "llfloaterchat.h"
// <dogmode> stuff for Contact groups
#include "ascentfloatercontactgroups.h"
//#include "ascentfloatercontactgroups.h"
#define DEFAULT_PERIOD 5.0
#define RIGHTS_CHANGE_TIMEOUT 5.0
@@ -87,18 +87,40 @@
#define ONLINE_SIP_ICON_NAME "slim_icon_16_viewer.tga"
// simple class to observe the calling cards.
class LLLocalFriendsObserver : public LLFriendObserver, public LLEventTimer
class LLAvatarListUpdater : public LLEventTimer
{
public:
LLLocalFriendsObserver(LLPanelFriends* floater) : mFloater(floater), LLEventTimer(OBSERVER_TIMEOUT)
public:
LLAvatarListUpdater(F32 period)
: LLEventTimer(period)
{
mEventTimer.stop();
}
virtual ~LLLocalFriendsObserver()
virtual BOOL tick() // from LLEventTimer
{
mFloater = NULL;
return FALSE;
}
virtual void changed(U32 mask)
};
class LLLocalFriendsObserver : public LLAvatarListUpdater, public LLFriendObserver
{
LOG_CLASS(LLLocalFriendsObserver);
public:
LLLocalFriendsObserver(LLPanelFriends* floater)
: mFloater(floater), LLAvatarListUpdater(OBSERVER_TIMEOUT)
{
LLAvatarTracker::instance().addObserver(this);
// For notification when SIP online status changes.
LLVoiceClient::getInstance()->addObserver(this);
}
/*virtual*/ ~LLLocalFriendsObserver()
{
LLVoiceClient::getInstance()->removeObserver(this);
LLAvatarTracker::instance().removeObserver(this);
}
/*virtual*/ void changed(U32 mask)
{
// events can arrive quickly in bulk - we need not process EVERY one of them -
// so we wait a short while to let others pile-in, and process them in aggregate.
@@ -107,9 +129,9 @@ public:
// save-up all the mask-bits which have come-in
mMask |= mask;
}
virtual BOOL tick()
/*virtual*/ BOOL tick()
{
mFloater->populateContactGroupSelect();
//mFloater->populateContactGroupSelect();
mFloater->updateFriends(mMask);
mEventTimer.stop();
@@ -134,16 +156,10 @@ LLPanelFriends::LLPanelFriends() :
{
mEventTimer.stop();
mObserver = new LLLocalFriendsObserver(this);
LLAvatarTracker::instance().addObserver(mObserver);
// For notification when SIP online status changes.
LLVoiceClient::getInstance()->addObserver(mObserver);
}
LLPanelFriends::~LLPanelFriends()
{
// For notification when SIP online status changes.
LLVoiceClient::getInstance()->removeObserver(mObserver);
LLAvatarTracker::instance().removeObserver(mObserver);
delete mObserver;
}
@@ -218,7 +234,7 @@ std::string LLPanelFriends::cleanFileName(std::string filename)
return filename;
}
void LLPanelFriends::populateContactGroupSelect()
/*void LLPanelFriends::populateContactGroupSelect()
{
LLComboBox* combo = getChild<LLComboBox>("buddy_group_combobox");
@@ -241,18 +257,18 @@ void LLPanelFriends::populateContactGroupSelect()
LLChat msg("Null combo");
LLFloaterChat::addChat(msg);
}
}
}*/
void LLPanelFriends::setContactGroup(std::string contact_grp)
/*void LLPanelFriends::setContactGroup(std::string contact_grp)
{
LLChat msg("Group set to " + contact_grp);
LLFloaterChat::addChat(msg);
refreshNames(LLFriendObserver::ADD);
refreshUI();
categorizeContacts();
}
}*/
void LLPanelFriends::categorizeContacts()
/*void LLPanelFriends::categorizeContacts()
{
LLSD contact_groups = gSavedPerAccountSettings.getLLSD("AscentContactGroups");
std::string group_name = "All";
@@ -306,7 +322,7 @@ void LLPanelFriends::categorizeContacts()
LLChat msg("Null combo.");
LLFloaterChat::addChat(msg);
}
}
}*/
void LLPanelFriends::filterContacts(const std::string& search_name)
{
@@ -350,7 +366,7 @@ void LLPanelFriends::onContactSearchEdit(const std::string& search_string, void*
}
}
void LLPanelFriends::onChangeContactGroup(LLUICtrl* ctrl, void* user_data)
/*void LLPanelFriends::onChangeContactGroup(LLUICtrl* ctrl, void* user_data)
{
LLPanelFriends* panelp = (LLPanelFriends*)user_data;
@@ -359,7 +375,7 @@ void LLPanelFriends::onChangeContactGroup(LLUICtrl* ctrl, void* user_data)
LLComboBox* combo = panelp->getChild<LLComboBox>("buddy_group_combobox");
panelp->setContactGroup(combo->getValue().asString());
}
}
}*/
// --
// virtual
@@ -368,7 +384,7 @@ BOOL LLPanelFriends::postBuild()
mFriendsList = getChild<LLScrollListCtrl>("friend_list");
mFriendsList->setCommitOnSelectionChange(TRUE);
mFriendsList->setCommitCallback(onSelectName, this);
childSetCommitCallback("buddy_group_combobox", onChangeContactGroup, this);
//childSetCommitCallback("buddy_group_combobox", onChangeContactGroup, this);
mFriendsList->setDoubleClickCallback(onClickIM, this);
// <dogmode>
@@ -387,7 +403,7 @@ BOOL LLPanelFriends::postBuild()
refreshNames(changed_mask);
childSetAction("im_btn", onClickIM, this);
childSetAction("assign_btn", onClickAssign, this);
//childSetAction("assign_btn", onClickAssign, this);
childSetAction("expand_collapse_btn", onClickExpand, this);
childSetAction("profile_btn", onClickProfile, this);
childSetAction("offer_teleport_btn", onClickOfferTeleport, this);
@@ -580,6 +596,8 @@ BOOL LLPanelFriends::updateFriendItem(const LLUUID& agent_id, const LLRelationsh
// enable this item, in case it was disabled after user input
itemp->setEnabled(TRUE);
mFriendsList->setNeedsSort();
// Do not resort, this function can be called frequently.
return have_name;
}
@@ -635,7 +653,7 @@ void LLPanelFriends::refreshRightsChangeList()
if (num_selected == 0) // nothing selected
{
childSetEnabled("im_btn", FALSE);
childSetEnabled("assign_btn", FALSE);
//childSetEnabled("assign_btn", FALSE);
childSetEnabled("offer_teleport_btn", FALSE);
}
else // we have at least one friend selected...
@@ -644,7 +662,7 @@ void LLPanelFriends::refreshRightsChangeList()
// to be consistent with context menus in inventory and because otherwise
// offline friends would be silently dropped from the session
childSetEnabled("im_btn", selected_friends_online || num_selected == 1);
childSetEnabled("assign_btn", num_selected == 1);
//childSetEnabled("assign_btn", num_selected == 1);
childSetEnabled("offer_teleport_btn", can_offer_teleport);
}
}
@@ -776,7 +794,7 @@ void LLPanelFriends::refreshUI()
//Options that can only be performed with one friend selected
childSetEnabled("profile_btn", single_selected && !multiple_selected);
childSetEnabled("pay_btn", single_selected && !multiple_selected);
childSetEnabled("assign_btn", single_selected && !multiple_selected);
//childSetEnabled("assign_btn", single_selected && !multiple_selected);
//Options that can be performed with up to MAX_FRIEND_SELECT friends selected
//(single_selected will always be true in this situations)
@@ -817,7 +835,7 @@ void LLPanelFriends::onClickProfile(void* user_data)
}
// static
void LLPanelFriends::onClickAssign(void* user_data)
/*void LLPanelFriends::onClickAssign(void* user_data)
{
LLPanelFriends* panelp = (LLPanelFriends*)user_data;
if (panelp)
@@ -825,7 +843,7 @@ void LLPanelFriends::onClickAssign(void* user_data)
const uuid_vec_t ids = panelp->mFriendsList->getSelectedIDs();
ASFloaterContactGroups::show(ids);
}
}
}*/
// static
void LLPanelFriends::onClickExpand(void* user_data)
@@ -1394,6 +1412,7 @@ void LLPanelFriends::applyRightsToFriends()
rights &= ~LLRelationship::GRANT_MAP_LOCATION;
// propagate rights constraint to UI
(*itr)->getColumn(LIST_VISIBLE_MAP)->setValue(FALSE);
mFriendsList->setNeedsSortColumn(LIST_VISIBLE_MAP);
}
}
if(buddy_relationship->isRightGrantedTo(LLRelationship::GRANT_MAP_LOCATION) != show_map_location)
@@ -1405,6 +1424,7 @@ void LLPanelFriends::applyRightsToFriends()
rights |= LLRelationship::GRANT_MAP_LOCATION;
rights |= LLRelationship::GRANT_ONLINE_STATUS;
(*itr)->getColumn(LIST_VISIBLE_ONLINE)->setValue(TRUE);
mFriendsList->setNeedsSortColumn(LIST_VISIBLE_ONLINE);
}
else
{