EXT-7609 FIXED Item name (worn) suffix made searchable.

- Wearable list items filter now searches sub-string in whole item title including (worn) suffix.
- Removed (worn) indication from items which don't need it in Edit Outfit. Only worn items can be edited there.
- Added null pointer checks for inventory item member of LLPanelInventoryListItemBase class and its descendants.

Reviewed by Vadim Savchuk https://codereview.productengine.com/secondlife/r/551/.

--HG--
branch : product-engine
master
Sergei Litovchuk 2010-06-10 22:49:25 +03:00
parent 33d91c0a39
commit ab399e0cd5
4 changed files with 79 additions and 32 deletions

View File

@ -70,23 +70,19 @@ void LLPanelInventoryListItemBase::draw()
{
if (getNeedsRefresh())
{
updateItem();
if (mItem)
{
updateItem(mItem->getName());
}
setNeedsRefresh(false);
}
LLPanel::draw();
}
void LLPanelInventoryListItemBase::updateItem()
// virtual
void LLPanelInventoryListItemBase::updateItem(const std::string& name)
{
setIconImage(mIconImage);
std::string name = mItem->getName();
if (get_is_item_worn(mItem->getUUID()))
{
name += LLTrans::getString("worn");
}
setTitle(name, mHighlightedText);
}
@ -140,7 +136,11 @@ BOOL LLPanelInventoryListItemBase::postBuild()
setIconCtrl(getChild<LLIconCtrl>("item_icon"));
setTitleCtrl(getChild<LLTextBox>("item_name"));
mIconImage = LLInventoryIcon::getIcon(mItem->getType(), mItem->getInventoryType(), mItem->getFlags(), FALSE);
if (mItem)
{
mIconImage = LLInventoryIcon::getIcon(mItem->getType(), mItem->getInventoryType(), mItem->getFlags(), FALSE);
updateItem(mItem->getName());
}
setNeedsRefresh(true);
@ -169,6 +169,42 @@ void LLPanelInventoryListItemBase::onMouseLeave(S32 x, S32 y, MASK mask)
LLPanel::onMouseLeave(x, y, mask);
}
const std::string& LLPanelInventoryListItemBase::getItemName() const
{
if (!mItem)
{
return LLStringUtil::null;
}
return mItem->getName();
}
LLAssetType::EType LLPanelInventoryListItemBase::getType() const
{
if (!mItem)
{
return LLAssetType::AT_NONE;
}
return mItem->getType();
}
LLWearableType::EType LLPanelInventoryListItemBase::getWearableType() const
{
if (!mItem)
{
return LLWearableType::WT_NONE;
}
return mItem->getWearableType();
}
const std::string& LLPanelInventoryListItemBase::getDescription() const
{
if (!mItem)
{
return LLStringUtil::null;
}
return mItem->getDescription();
}
S32 LLPanelInventoryListItemBase::notify(const LLSD& info)
{
S32 rv = 0;
@ -176,7 +212,7 @@ S32 LLPanelInventoryListItemBase::notify(const LLSD& info)
{
mHighlightedText = info["match_filter"].asString();
std::string test(mItem->getName());
std::string test(mTitleCtrl->getText());
LLStringUtil::toUpper(test);
if(mHighlightedText.empty() || std::string::npos != test.find(mHighlightedText))

View File

@ -122,16 +122,16 @@ public:
/*virtual*/ void onMouseLeave(S32 x, S32 y, MASK mask);
/** Get the name of a corresponding inventory item */
const std::string& getItemName() const { return mItem->getName(); }
const std::string& getItemName() const;
/** Get the asset type of a corresponding inventory item */
LLAssetType::EType getType() const { return mItem->getType(); }
LLAssetType::EType getType() const;
/** Get the wearable type of a corresponding inventory item */
LLWearableType::EType getWearableType() const { return mItem->getWearableType(); }
LLWearableType::EType getWearableType() const;
/** Get the description of a corresponding inventory item */
const std::string& getDescription() const { return mItem->getDescription(); }
const std::string& getDescription() const;
/** Get the associated inventory item */
LLViewerInventoryItem* getItem() const { return mItem; }
@ -152,7 +152,7 @@ protected:
/**
* Called after inventory item was updated, update panel widgets to reflect inventory changes.
*/
virtual void updateItem();
virtual void updateItem(const std::string& name);
/** setter for mIconCtrl */
void setIconCtrl(LLIconCtrl* icon) { mIconCtrl = icon; }

View File

@ -126,6 +126,19 @@ BOOL LLPanelWearableOutfitItem::handleDoubleClick(S32 x, S32 y, MASK mask)
return LLUICtrl::handleDoubleClick(x, y, mask);
}
// virtual
void LLPanelWearableOutfitItem::updateItem(const std::string& name)
{
std::string search_label = name;
if (mItem && get_is_item_worn(mItem->getUUID()))
{
search_label += LLTrans::getString("worn");
}
LLPanelInventoryListItemBase::updateItem(search_label);
}
LLPanelWearableOutfitItem::LLPanelWearableOutfitItem(LLViewerInventoryItem* item)
: LLPanelInventoryListItemBase(item)
{
@ -292,12 +305,6 @@ LLPanelDummyClothingListItem* LLPanelDummyClothingListItem::create(LLWearableTyp
return list_item;
}
void LLPanelDummyClothingListItem::updateItem()
{
std::string title = wearableTypeToString(mWearableType);
setTitle(title, LLStringUtil::null);
}
BOOL LLPanelDummyClothingListItem::postBuild()
{
LLIconCtrl* icon = getChild<LLIconCtrl>("item_icon");
@ -307,7 +314,7 @@ BOOL LLPanelDummyClothingListItem::postBuild()
addWidgetToRightSide("btn_add_panel");
setIconImage(LLInventoryIcon::getIcon(LLAssetType::AT_CLOTHING, LLInventoryType::IT_NONE, mWearableType, FALSE));
updateItem();
updateItem(wearableTypeToString(mWearableType));
// Make it look loke clothing item - reserve space for 'delete' button
setLeftWidgetsWidth(icon->getRect().mLeft);

View File

@ -56,13 +56,13 @@ class LLPanelWearableListItem : public LLPanelInventoryListItemBase
public:
/**
* Shows buttons when mouse is over
*/
* Shows buttons when mouse is over
*/
/*virtual*/ void onMouseEnter(S32 x, S32 y, MASK mask);
/**
* Hides buttons when mouse is out
*/
* Hides buttons when mouse is out
*/
/*virtual*/ void onMouseLeave(S32 x, S32 y, MASK mask);
protected:
@ -84,11 +84,16 @@ public:
static LLPanelWearableOutfitItem* create(LLViewerInventoryItem* item);
/**
* Puts item on if it is not worn by agent
* otherwise takes it off on double click.
*/
* Puts item on if it is not worn by agent
* otherwise takes it off on double click.
*/
/*virtual*/ BOOL handleDoubleClick(S32 x, S32 y, MASK mask);
/**
* Updates item name and (worn) suffix.
*/
/*virtual*/ void updateItem(const std::string& name);
protected:
LLPanelWearableOutfitItem(LLViewerInventoryItem* item);
@ -198,7 +203,6 @@ class LLPanelDummyClothingListItem : public LLPanelWearableListItem
public:
static LLPanelDummyClothingListItem* create(LLWearableType::EType w_type);
/*virtual*/ void updateItem();
/*virtual*/ BOOL postBuild();
LLWearableType::EType getWearableType() const;