Futher contact sets refactoring:

* Get rid of duplicated group name constants that actually mean the same
* Move presentation-related group list building to the floater; this also fixes the remaining localization issues of FIRE-5434
* Fixed missing save operation after deleting a set
meow-7.2.2
Ansariel 2013-04-27 13:34:36 +02:00
parent 9c4f7ef2a2
commit 5caeb8aa0c
5 changed files with 81 additions and 50 deletions

View File

@ -432,7 +432,6 @@ void LGGContactSets::setDefaultColor(const LLColor4& dColor)
std::vector<std::string> LGGContactSets::getInnerGroups(const std::string& groupName)
{
std::vector<std::string> toReturn;
toReturn.clear();
static LLCachedControl<bool> useFolders(gSavedSettings, "FSContactSetsShowFolders");
static LLCachedControl<bool> showOnline(gSavedSettings, "FSContactSetsShowOnline");
static LLCachedControl<bool> showOffline(gSavedSettings, "FSContactSetsShowOffline");
@ -444,11 +443,6 @@ std::vector<std::string> LGGContactSets::getInnerGroups(const std::string& group
std::set<std::string> newGroups;
if (groupName != CS_GROUP_ALL_SETS && getAllGroups(FALSE).size() > 0)
{
newGroups.insert(CS_GROUP_ALL_SETS);
}
std::vector<LLUUID> freindsInGroup = getFriendsInGroup(groupName);
for (U32 fn = 0; fn < (U32)freindsInGroup.size(); fn++)
{
@ -508,12 +502,12 @@ std::vector<LLUUID> LGGContactSets::getFriendsInGroup(const std::string& groupNa
return toReturn;
}
if (groupName == CS_GROUP_PSEUDONYM || groupName == CS_GROUP_RENAMED)
if (groupName == CS_GROUP_PSEUDONYM)
{
return getListOfPseudonymAvs();
}
if (groupName == CS_GROUP_NON_FRIENDS)
if (groupName == CS_GROUP_EXTRA_AVS)
{
return getListOfNonFriends();
}
@ -527,29 +521,10 @@ std::vector<LLUUID> LGGContactSets::getFriendsInGroup(const std::string& groupNa
return toReturn;
}
std::vector<std::string> LGGContactSets::getAllGroups(BOOL extraGroups)
std::vector<std::string> LGGContactSets::getAllGroups()
{
std::vector<std::string> toReturn;
if (extraGroups)
{
if (getAllGroups(FALSE).size() > 0)
{
toReturn.push_back(CS_GROUP_ALL_SETS);
toReturn.push_back(CS_GROUP_NO_SETS);
}
if (getListOfPseudonymAvs().size() > 0)
{
toReturn.push_back(CS_GROUP_RENAMED);
}
if (getListOfNonFriends().size() > 0)
{
toReturn.push_back(CS_GROUP_NON_FRIENDS);
}
}
for (group_map_t::iterator it = mGroups.begin(); it != mGroups.end(); ++it)
{
toReturn.push_back(it->second->mName);
@ -600,12 +575,12 @@ BOOL LGGContactSets::isFriendInGroup(const LLUUID& friend_id, const std::string&
return !isFriendInAnyGroup(friend_id);
}
if (groupName == CS_GROUP_RENAMED)
if (groupName == CS_GROUP_PSEUDONYM)
{
return hasPseudonym(friend_id);
}
if (groupName == CS_GROUP_NON_FRIENDS)
if (groupName == CS_GROUP_EXTRA_AVS)
{
return isNonFriend(friend_id);
}
@ -763,12 +738,12 @@ void LGGContactSets::removeDisplayName(const LLUUID& friend_id)
void LGGContactSets::removeFriendFromGroup(const LLUUID& friend_id, const std::string& groupName)
{
if (groupName == CS_GROUP_EXTRA_AVS || groupName == CS_GROUP_NON_FRIENDS)
if (groupName == CS_GROUP_EXTRA_AVS)
{
return removeNonFriendFromList(friend_id);
}
if (groupName == CS_GROUP_RENAMED || groupName == CS_GROUP_PSEUDONYM)
if (groupName == CS_GROUP_PSEUDONYM)
{
return clearPseudonym(friend_id);
}
@ -806,6 +781,7 @@ void LGGContactSets::deleteGroup(const std::string& groupName)
{
delete found->second;
mGroups.erase(found);
saveToDisk();
}
}
@ -848,10 +824,7 @@ bool LGGContactSets::isInternalGroupName(const std::string& groupName)
groupName == CS_GROUP_PSEUDONYM ||
groupName == CS_GLOBAL_SETTINGS ||
groupName == CS_GROUP_NO_SETS ||
groupName == CS_GROUP_ALL_SETS ||
groupName == CS_GROUP_ALL_GROUPS ||
groupName == CS_GROUP_RENAMED ||
groupName == CS_GROUP_NON_FRIENDS
groupName == CS_GROUP_ALL_SETS
);
}

View File

@ -33,11 +33,8 @@ typedef enum e_lgg_cs
LGG_CS_MINIMAP
} ELGGCSType;
const std::string CS_GROUP_ALL_GROUPS = "All Groups";
const std::string CS_GROUP_ALL_SETS = "All Sets";
const std::string CS_GROUP_NO_SETS = "No Sets";
const std::string CS_GROUP_RENAMED = "ReNamed";
const std::string CS_GROUP_NON_FRIENDS = "Non Friends";
const std::string CS_GROUP_EXTRA_AVS = "extraAvs";
const std::string CS_GROUP_PSEUDONYM = "pseudonym";
const std::string CS_GLOBAL_SETTINGS = "globalSettings";
@ -67,7 +64,7 @@ public:
std::vector<std::string> getInnerGroups(const std::string& groupName);
std::vector<std::string> getFriendGroups(const LLUUID& friend_id);
std::vector<std::string> getAllGroups(BOOL extraGroups = TRUE);
std::vector<std::string> getAllGroups();
void addFriendToGroup(const LLUUID& friend_id, const std::string& groupName);
void removeFriendFromGroup(const LLUUID& friend_id, const std::string& groupName);
@ -83,6 +80,7 @@ public:
void removeNonFriendFromList(const LLUUID& non_friend_id);
BOOL isNonFriend(const LLUUID& non_friend_id);
std::vector<LLUUID> getListOfNonFriends();
std::vector<LLUUID> getListOfPseudonymAvs();
BOOL notifyForFriend(const LLUUID& friend_id);
void setNotifyForGroup(const std::string& groupName, BOOL notify);
@ -91,6 +89,7 @@ public:
bool callbackAliasReset(const LLSD& notification, const LLSD& response);
bool isInternalGroupName(const std::string& groupName);
bool hasGroups() { return !mGroups.empty(); }
private:
typedef boost::unordered_set<LLUUID, FSUUIDHash> uuid_set_t;
@ -119,7 +118,6 @@ private:
std::vector<LLUUID> getFriendsInAnyGroup();
void setPseudonym(const LLUUID& friend_id, const std::string& pseudonym);
std::vector<LLUUID> getListOfPseudonymAvs();
BOOL hasVisuallyDifferentPseudonym(const LLUUID& friend_id);
void loadFromDisk();

View File

@ -238,25 +238,65 @@ void lggContactSetsFloater::onPickAvatar(const std::vector<LLUUID>& ids,
void lggContactSetsFloater::updateGroupsList()
{
static LLCachedControl<std::string> currentGroup(gSavedSettings, "FSContactSetsSelectedGroup");
static LLCachedControl<std::string> current_group(gSavedSettings, "FSContactSetsSelectedGroup");
LLComboBox* cb = groupsList;
cb->clear();
cb->removeall();
bool current_group_in_list = false;
std::vector<std::string> groups = LGGContactSets::getInstance()->getAllGroups();
for (int i = 0; i < (int)groups.size(); i++)
if (!groups.empty())
{
cb->add(groups[i], groups[i], ADD_BOTTOM, TRUE);
cb->add(getString("AllSets"), CS_GROUP_ALL_SETS);
if (!current_group_in_list && current_group() == CS_GROUP_ALL_SETS)
{
current_group_in_list = true;
}
cb->add(getString("NoSets"), CS_GROUP_NO_SETS);
if (!current_group_in_list && current_group() == CS_GROUP_NO_SETS)
{
current_group_in_list = true;
}
}
if (LGGContactSets::getInstance()->isAGroup(currentGroup))
if (!LGGContactSets::getInstance()->getListOfPseudonymAvs().empty())
{
cb->setSimple(LLStringExplicit(currentGroup));
cb->add(getString("Renamed"), CS_GROUP_PSEUDONYM);
if (!current_group_in_list && current_group() == CS_GROUP_PSEUDONYM)
{
current_group_in_list = true;
}
}
if (!LGGContactSets::getInstance()->getListOfNonFriends().empty())
{
cb->add(getString("NoFriend"), CS_GROUP_EXTRA_AVS);
if (!current_group_in_list && current_group() == CS_GROUP_EXTRA_AVS)
{
current_group_in_list = true;
}
}
for (std::vector<std::string>::iterator it = groups.begin(); it != groups.end(); ++it)
{
std::string group_name = *it;
cb->add(group_name, group_name, ADD_BOTTOM, TRUE);
if (!current_group_in_list && group_name == current_group())
{
current_group_in_list = true;
}
}
if (current_group_in_list)
{
cb->selectByValue(current_group());
}
else if (groups.size() > 0)
{
gSavedSettings.setString("FSContactSetsSelectedGroup", groups[0]);
cb->setSimple(groups[0]);
gSavedSettings.setString("FSContactSetsSelectedGroup", groups.front());
cb->selectFirstItem();
updateGroupGUIs();
generateCurrentList();
}
@ -297,7 +337,7 @@ void lggContactSetsFloater::updateGroupGUIs()
void lggContactSetsFloater::onSelectGroup()
{
gSavedSettings.setString("FSContactSetsSelectedGroup", sInstance->groupsList->getSimple());
gSavedSettings.setString("FSContactSetsSelectedGroup", sInstance->groupsList->getSelectedValue());
sInstance->updateGroupGUIs();
sInstance->selected.clear();
sInstance->generateCurrentList();
@ -368,7 +408,7 @@ void lggContactSetsFloater::drawRightClick()
extras += 2;
}
std::vector<std::string> groups = LGGContactSets::getInstance()->getAllGroups(FALSE);
std::vector<std::string> groups = LGGContactSets::getInstance()->getAllGroups();
if (selected.size() == 0)
{
groups.clear();
@ -1132,6 +1172,12 @@ void lggContactSetsFloater::draw()
// see if we are guna draw some folders
allFolders = LGGContactSets::getInstance()->getInnerGroups(currentGroup);
if (currentGroup() != CS_GROUP_ALL_SETS && LGGContactSets::getInstance()->hasGroups())
{
allFolders.insert(allFolders.begin(), CS_GROUP_ALL_SETS);
}
numberOfPanels += allFolders.size();
LLRect topScroll = getChild<LLPanel>("top_region")->getRect();
@ -1370,6 +1416,12 @@ void lggContactSetsFloater::draw()
groupTextColor = LGGContactSets::toneDownColor(color, 1.0f);
}
if (folder == CS_GROUP_ALL_SETS)
{
static const std::string ALL_SETS = getString("AllSets");
folder = ALL_SETS;
}
useFont->render(
utf8str_to_wstring(folder),
0,

View File

@ -24,6 +24,10 @@
<floater.string name="TooltipIM" value="Instant Message"/>
<floater.string name="TooltipProfile" value="Profil anzeigen"/>
<floater.string name="TooltipNameChanged" value="Name wurde geändert"/>
<floater.string name="AllSets" value="&lt;Alle Sets&gt;"/>
<floater.string name="NoSets" value="&lt;Keine Sets&gt;"/>
<floater.string name="Renamed" value="&lt;Umbenannt&gt;"/>
<floater.string name="NoFriend" value="&lt;Nicht-Freunde&gt;"/>
<text name="lgg_fg_text1">
Set:

View File

@ -39,6 +39,10 @@
<floater.string name="TooltipIM" value="Instant message"/>
<floater.string name="TooltipProfile" value="Show profile"/>
<floater.string name="TooltipNameChanged" value="Name has been changed"/>
<floater.string name="AllSets" value="&lt;All Sets&gt;"/>
<floater.string name="NoSets" value="&lt;No Sets&gt;"/>
<floater.string name="Renamed" value="&lt;Renamed&gt;"/>
<floater.string name="NoFriend" value="&lt;Non Friends&gt;"/>
<check_box
bottom_delta="-5000"