diff options
author | Yuri Chebotarev <ychebotarev@productengine.com> | 2010-04-26 19:07:55 +0300 |
---|---|---|
committer | Yuri Chebotarev <ychebotarev@productengine.com> | 2010-04-26 19:07:55 +0300 |
commit | 6a9d277e00d9c20a8f3359627864f731923baac3 (patch) | |
tree | e3a6ee9046bca45cc42e9cd82cb4713a99d8d3da /indra/newview/llinventoryitemslist.cpp | |
parent | 24894a5f71b76aab407976ff9bf36bfc0f7ae70a (diff) | |
parent | fbfc85176670f3f948e6e2f00c8d8e37c96d5299 (diff) |
merge
--HG--
branch : product-engine
Diffstat (limited to 'indra/newview/llinventoryitemslist.cpp')
-rw-r--r-- | indra/newview/llinventoryitemslist.cpp | 74 |
1 files changed, 50 insertions, 24 deletions
diff --git a/indra/newview/llinventoryitemslist.cpp b/indra/newview/llinventoryitemslist.cpp index 9f54b86607..dca130c672 100644 --- a/indra/newview/llinventoryitemslist.cpp +++ b/indra/newview/llinventoryitemslist.cpp @@ -2,6 +2,10 @@ * @file llinventoryitemslist.cpp * @brief A list of inventory items represented by LLFlatListView. * + * Class LLInventoryItemsList implements a flat list of inventory items. + * Class LLPanelInventoryListItem displays inventory item as an element + * of LLInventoryItemsList. + * * $LicenseInfo:firstyear=2010&license=viewergpl$ * * Copyright (c) 2010, Linden Research, Inc. @@ -39,33 +43,31 @@ #include "lliconctrl.h" #include "llinventoryfunctions.h" +#include "llinventorymodel.h" #include "lltextutil.h" //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// -LLPanelInventoryItem::LLPanelInventoryItem(LLAssetType::EType asset_type, - LLInventoryType::EType inventory_type, - U32 wearable_type, - const std::string &item_name, - const std::string &hl) -: LLPanel() - ,mItemName(item_name) - ,mHighlightedText(hl) - ,mIcon(NULL) - ,mTitle(NULL) +// static +LLPanelInventoryListItem* LLPanelInventoryListItem::createItemPanel(const LLViewerInventoryItem* item) { - mItemIcon = get_item_icon(asset_type, inventory_type, wearable_type, FALSE); - - LLUICtrlFactory::getInstance()->buildPanel(this, "panel_inventory_item.xml"); + if (item) + { + return new LLPanelInventoryListItem(item); + } + else + { + return NULL; + } } -LLPanelInventoryItem::~LLPanelInventoryItem() +LLPanelInventoryListItem::~LLPanelInventoryListItem() {} //virtual -BOOL LLPanelInventoryItem::postBuild() +BOOL LLPanelInventoryListItem::postBuild() { mIcon = getChild<LLIconCtrl>("item_icon"); mTitle = getChild<LLTextBox>("item_name"); @@ -76,14 +78,14 @@ BOOL LLPanelInventoryItem::postBuild() } //virtual -void LLPanelInventoryItem::setValue(const LLSD& value) +void LLPanelInventoryListItem::setValue(const LLSD& value) { if (!value.isMap()) return; if (!value.has("selected")) return; childSetVisible("selected_icon", value["selected"]); } -void LLPanelInventoryItem::updateItem() +void LLPanelInventoryListItem::updateItem() { if (mItemIcon.notNull()) mIcon->setImage(mItemIcon); @@ -95,28 +97,47 @@ void LLPanelInventoryItem::updateItem() mHighlightedText); } -void LLPanelInventoryItem::onMouseEnter(S32 x, S32 y, MASK mask) +void LLPanelInventoryListItem::onMouseEnter(S32 x, S32 y, MASK mask) { childSetVisible("hovered_icon", true); LLPanel::onMouseEnter(x, y, mask); } -void LLPanelInventoryItem::onMouseLeave(S32 x, S32 y, MASK mask) +void LLPanelInventoryListItem::onMouseLeave(S32 x, S32 y, MASK mask) { childSetVisible("hovered_icon", false); LLPanel::onMouseLeave(x, y, mask); } +LLPanelInventoryListItem::LLPanelInventoryListItem(const LLViewerInventoryItem* item) +: LLPanel() + ,mIcon(NULL) + ,mTitle(NULL) +{ + mItemName = item->getName(); + mItemIcon = get_item_icon(item->getType(), item->getInventoryType(), item->getFlags(), FALSE); + + LLUICtrlFactory::getInstance()->buildPanel(this, "panel_inventory_item.xml"); +} + //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// -LLInventoryItemsList::LLInventoryItemsList(const LLFlatListView::Params& p) +LLInventoryItemsList::Params::Params() +{} + +LLInventoryItemsList::LLInventoryItemsList(const LLInventoryItemsList::Params& p) : LLFlatListView(p) , mNeedsRefresh(false) -{} +{ + // TODO: mCommitOnSelectionChange is set to "false" in LLFlatListView + // but reset to true in all derived classes. This settings might need to + // be added to LLFlatListView::Params() and/or set to "true" by default. + setCommitOnSelectionChange(true); +} // virtual LLInventoryItemsList::~LLInventoryItemsList() @@ -196,10 +217,15 @@ void LLInventoryItemsList::computeDifference( void LLInventoryItemsList::addNewItem(LLViewerInventoryItem* item) { - llassert(item); + if (!item) + { + llwarns << "No inventory item. Couldn't create flat list item." << llendl; + llassert(!"No inventory item. Couldn't create flat list item."); + } - LLPanelInventoryItem *list_item = new LLPanelInventoryItem(item->getType(), - item->getInventoryType(), item->getFlags(), item->getName(), LLStringUtil::null); + LLPanelInventoryListItem *list_item = LLPanelInventoryListItem::createItemPanel(item); + if (!list_item) + return; if (!addItem(list_item, item->getUUID())) { |