Rework Name List Items to store the name type fully

It's more proper this way, but this will create some merge fighting
This commit is contained in:
Liru Færs
2019-08-25 15:51:29 -04:00
parent 29236442de
commit a399bd7b62
4 changed files with 48 additions and 48 deletions

View File

@@ -1639,7 +1639,7 @@ void LLPanelLandObjects::processParcelObjectOwnersReply(LLMessageSystem *msg, vo
LLNameListCtrl::NameItem item_params; LLNameListCtrl::NameItem item_params;
item_params.value = owner_id; item_params.value = owner_id;
item_params.target = is_group_owned ? LLNameListCtrl::GROUP : LLNameListCtrl::INDIVIDUAL; item_params.target = is_group_owned ? LLNameListItem::GROUP : LLNameListItem::INDIVIDUAL;
if (is_group_owned) if (is_group_owned)
{ {

View File

@@ -267,20 +267,20 @@ void LLFloaterMute::refreshMuteList()
{ {
case LLMute::GROUP: case LLMute::GROUP:
icon_column.value = mGroupIcon->getName(); icon_column.value = mGroupIcon->getName();
element.target = LLNameListCtrl::GROUP; element.target = LLNameListItem::GROUP;
break; break;
case LLMute::AGENT: case LLMute::AGENT:
icon_column.value = mAvatarIcon->getName(); icon_column.value = mAvatarIcon->getName();
element.target = LLNameListCtrl::INDIVIDUAL; element.target = LLNameListItem::INDIVIDUAL;
break; break;
case LLMute::OBJECT: case LLMute::OBJECT:
icon_column.value = mObjectIcon->getName(); icon_column.value = mObjectIcon->getName();
element.target = LLNameListCtrl::SPECIAL; element.target = LLNameListItem::SPECIAL;
break; break;
case LLMute::BY_NAME: case LLMute::BY_NAME:
default: default:
icon_column.value = mNameIcon->getName(); icon_column.value = mNameIcon->getName();
element.target = LLNameListCtrl::SPECIAL; element.target = LLNameListItem::SPECIAL;
break; break;
} }

View File

@@ -42,11 +42,11 @@
static LLRegisterWidget<LLNameListCtrl> r("name_list"); static LLRegisterWidget<LLNameListCtrl> r("name_list");
void LLNameListCtrl::NameTypeNames::declareValues() void LLNameListItem::NameTypeNames::declareValues()
{ {
declare("INDIVIDUAL", LLNameListCtrl::INDIVIDUAL); declare("INDIVIDUAL", INDIVIDUAL);
declare("GROUP", LLNameListCtrl::GROUP); declare("GROUP", GROUP);
declare("SPECIAL", LLNameListCtrl::SPECIAL); declare("SPECIAL", SPECIAL);
} }
LLNameListCtrl::LLNameListCtrl(const std::string& name, const LLRect& rect, BOOL allow_multiple_selection, BOOL draw_border, bool draw_heading, S32 name_column_index, const std::string& name_system, const std::string& tooltip) LLNameListCtrl::LLNameListCtrl(const std::string& name, const LLRect& rect, BOOL allow_multiple_selection, BOOL draw_border, bool draw_heading, S32 name_column_index, const std::string& name_system, const std::string& tooltip)
@@ -68,7 +68,7 @@ LLScrollListItem* LLNameListCtrl::addNameItem(const LLUUID& agent_id, EAddPositi
NameItem item; NameItem item;
item.value = agent_id; item.value = agent_id;
item.enabled = enabled; item.enabled = enabled;
item.target = INDIVIDUAL; item.target = LLNameListItem::INDIVIDUAL;
return addNameItemRow(item, pos, suffix, prefix); return addNameItemRow(item, pos, suffix, prefix);
} }
@@ -129,7 +129,7 @@ void LLNameListCtrl::addGroupNameItem(const LLUUID& group_id, EAddPosition pos,
NameItem item; NameItem item;
item.value = group_id; item.value = group_id;
item.enabled = enabled; item.enabled = enabled;
item.target = GROUP; item.target = LLNameListItem::GROUP;
addNameItemRow(item, pos); addNameItemRow(item, pos);
} }
@@ -137,13 +137,13 @@ void LLNameListCtrl::addGroupNameItem(const LLUUID& group_id, EAddPosition pos,
// public // public
void LLNameListCtrl::addGroupNameItem(LLNameListCtrl::NameItem& item, EAddPosition pos) void LLNameListCtrl::addGroupNameItem(LLNameListCtrl::NameItem& item, EAddPosition pos)
{ {
item.target = GROUP; item.target = LLNameListItem::GROUP;
addNameItemRow(item, pos); addNameItemRow(item, pos);
} }
LLScrollListItem* LLNameListCtrl::addNameItem(LLNameListCtrl::NameItem& item, EAddPosition pos) LLScrollListItem* LLNameListCtrl::addNameItem(LLNameListCtrl::NameItem& item, EAddPosition pos)
{ {
item.target = INDIVIDUAL; item.target = LLNameListItem::INDIVIDUAL;
return addNameItemRow(item, pos); return addNameItemRow(item, pos);
} }
@@ -164,7 +164,7 @@ LLScrollListItem* LLNameListCtrl::addNameItemRow(
const std::string& prefix) const std::string& prefix)
{ {
LLUUID id = name_item.value().asUUID(); LLUUID id = name_item.value().asUUID();
LLNameListItem* item = new LLNameListItem(name_item,name_item.target() == GROUP); LLNameListItem* item = new LLNameListItem(name_item);
if (!item) return NULL; if (!item) return NULL;
@@ -174,7 +174,7 @@ LLScrollListItem* LLNameListCtrl::addNameItemRow(
std::string fullname = name_item.name; std::string fullname = name_item.name;
switch(name_item.target) switch(name_item.target)
{ {
case GROUP: case LLNameListItem::GROUP:
if (!gCacheName->getGroupName(id, fullname)) if (!gCacheName->getGroupName(id, fullname))
{ {
avatar_name_cache_connection_map_t::iterator it = mAvatarNameCacheConnections.find(id); avatar_name_cache_connection_map_t::iterator it = mAvatarNameCacheConnections.find(id);
@@ -189,10 +189,10 @@ LLScrollListItem* LLNameListCtrl::addNameItemRow(
mAvatarNameCacheConnections[id] = gCacheName->getGroup(id, boost::bind(&LLNameListCtrl::onGroupNameCache, this, _1, _2, item->getHandle())); mAvatarNameCacheConnections[id] = gCacheName->getGroup(id, boost::bind(&LLNameListCtrl::onGroupNameCache, this, _1, _2, item->getHandle()));
} }
break; break;
case SPECIAL: case LLNameListItem::SPECIAL:
// just use supplied name // just use supplied name
break; break;
case INDIVIDUAL: case LLNameListItem::INDIVIDUAL:
{ {
LLAvatarName av_name; LLAvatarName av_name;
if (id.isNull()) if (id.isNull())

View File

@@ -42,24 +42,47 @@ class LLAvatarName;
class LLNameListItem : public LLScrollListItem, public LLHandleProvider<LLNameListItem> class LLNameListItem : public LLScrollListItem, public LLHandleProvider<LLNameListItem>
{ {
public: public:
bool isGroup() const { return mIsGroup; } enum ENameType
void setIsGroup(bool is_group) { mIsGroup = is_group; } {
INDIVIDUAL,
GROUP,
SPECIAL
};
// provide names for enums
struct NameTypeNames : public LLInitParam::TypeValuesHelper<ENameType, NameTypeNames>
{
static void declareValues();
};
struct Params : public LLInitParam::Block<Params, LLScrollListItem::Params>
{
Optional<std::string> name;
Optional<ENameType, NameTypeNames> target;
Params()
: name("name"),
target("target", INDIVIDUAL)
{}
};
ENameType getNameType() const { return mNameType; }
void setNameType(ENameType name_type) { mNameType = name_type; }
protected: protected:
friend class LLNameListCtrl; friend class LLNameListCtrl;
LLNameListItem( const LLScrollListItem::Params& p ) LLNameListItem( const Params& p )
: LLScrollListItem(p), mIsGroup(false) : LLScrollListItem(p), mNameType(p.target)
{ {
} }
LLNameListItem( const LLScrollListItem::Params& p, bool is_group ) LLNameListItem( const LLScrollListItem::Params& p, ENameType name_type)
: LLScrollListItem(p), mIsGroup(is_group) : LLScrollListItem(p), mNameType(name_type)
{ {
} }
private: private:
bool mIsGroup; ENameType mNameType;
}; };
@@ -68,30 +91,7 @@ class LLNameListCtrl
{ {
public: public:
typedef boost::signals2::signal<void(bool)> namelist_complete_signal_t; typedef boost::signals2::signal<void(bool)> namelist_complete_signal_t;
typedef LLNameListItem::Params NameItem;
typedef enum e_name_type
{
INDIVIDUAL,
GROUP,
SPECIAL
} ENameType;
// provide names for enums
struct NameTypeNames : public LLInitParam::TypeValuesHelper<LLNameListCtrl::ENameType, NameTypeNames>
{
static void declareValues();
};
struct NameItem : public LLInitParam::Block<NameItem, LLScrollListItem::Params>
{
Optional<std::string> name;
Optional<ENameType, NameTypeNames> target;
NameItem()
: name("name"),
target("target", INDIVIDUAL)
{}
};
struct NameColumn : public LLInitParam::ChoiceBlock<NameColumn> struct NameColumn : public LLInitParam::ChoiceBlock<NameColumn>
{ {