Added convenient way to retrieve LLScrollListCells by name if names are already provided

Ansariel 2011-12-29 18:41:48 +01:00
parent 2efd716087
commit 262f36cfae
4 changed files with 27 additions and 1 deletions

View File

@ -66,7 +66,8 @@ LLScrollListCell* LLScrollListCell::create(const LLScrollListCell::Params& cell_
LLScrollListCell::LLScrollListCell(const LLScrollListCell::Params& p)
: mWidth(p.width),
mToolTip(p.tool_tip)
mToolTip(p.tool_tip),
mColumn(p.column) // Ansariel: Also store the column name the cell belongs to if that info is already provided
{}
// virtual

View File

@ -110,9 +110,15 @@ public:
virtual BOOL handleClick() { return FALSE; }
virtual void setEnabled(BOOL enable) { }
// Ansariel: Return column name the cell belongs to
virtual std::string getName() const { return mColumn; }
private:
S32 mWidth;
std::string mToolTip;
// Ansariel: Column name the cell belongs to
std::string mColumn;
};
class LLScrollListSpacer : public LLScrollListCell

View File

@ -101,6 +101,22 @@ LLScrollListCell* LLScrollListItem::getColumn(const S32 i) const
return NULL;
}
// Ansariel: Return LLScrollListCell by name
LLScrollListCell* LLScrollListItem::getColumn(const std::string& name) const
{
std::vector<LLScrollListCell *>::const_iterator it = mColumns.begin();
for (; it < mColumns.end(); it++)
{
if ((*it)->getName() == name)
{
return (*it);
}
}
return NULL;
}
std::string LLScrollListItem::getContentsCSV() const
{
std::string ret;

View File

@ -105,6 +105,9 @@ public:
LLScrollListCell *getColumn(const S32 i) const;
// Ansariel: Return LLScrollListCell by name
LLScrollListCell *getColumn(const std::string& name) const;
std::string getContentsCSV() const;
virtual void draw(const LLRect& rect, const LLColor4& fg_color, const LLColor4& bg_color, const LLColor4& highlight_color, S32 column_padding);