EXT-7577 FIXED added filtering add wearables panel (list and folder views) according to the current user's selection

- added filtering add wearables panel (list and folder views) according to the current user's selection (rules for showing a particular view and setting a particular filtering are specified in the table at https://jira.secondlife.com/browse/EXT-7577)
- minor refactoring

Reviewed by Neal Orman at https://codereview.productengine.com/secondlife/r/534/

--HG--
branch : product-engine
meow-7.2.2
Igor Borovkov 2010-06-09 15:48:48 +03:00
parent a3a037ea7d
commit 206aab29dc
3 changed files with 126 additions and 45 deletions

View File

@ -189,7 +189,8 @@ LLPanelOutfitEdit::LLPanelOutfitEdit()
mInitialized(false),
mAddWearablesPanel(NULL),
mWearableListMaskCollector(NULL),
mWearableListTypeCollector(NULL)
mWearableListTypeCollector(NULL),
mFilterComboBox(NULL)
{
mSavedFolderState = new LLSaveFolderState();
mSavedFolderState->setApply(FALSE);
@ -235,12 +236,12 @@ BOOL LLPanelOutfitEdit::postBuild()
mListViewBtn = getChild<LLButton>("list_view_btn");
childSetCommitCallback("filter_button", boost::bind(&LLPanelOutfitEdit::showWearablesFilter, this), NULL);
childSetCommitCallback("folder_view_btn", boost::bind(&LLPanelOutfitEdit::showFilteredFolderWearablesPanel, this), NULL);
childSetCommitCallback("list_view_btn", boost::bind(&LLPanelOutfitEdit::showFilteredWearablesPanel, this), NULL);
childSetCommitCallback("folder_view_btn", boost::bind(&LLPanelOutfitEdit::showWearablesFolderView, this), NULL);
childSetCommitCallback("list_view_btn", boost::bind(&LLPanelOutfitEdit::showWearablesListView, this), NULL);
childSetCommitCallback("wearables_gear_menu_btn", boost::bind(&LLPanelOutfitEdit::onGearButtonClick, this, _1), NULL);
mCOFWearables = getChild<LLCOFWearables>("cof_wearables_list");
mCOFWearables->setCommitCallback(boost::bind(&LLPanelOutfitEdit::onOutfitItemSelectionChange, this));
mCOFWearables->setCommitCallback(boost::bind(&LLPanelOutfitEdit::filterWearablesBySelectedItem, this));
mCOFWearables->getCOFCallbacks().mAddWearable = boost::bind(&LLPanelOutfitEdit::onAddWearableClicked, this);
mCOFWearables->getCOFCallbacks().mEditWearable = boost::bind(&LLPanelOutfitEdit::onEditWearableClicked, this);
@ -258,19 +259,20 @@ BOOL LLPanelOutfitEdit::postBuild()
mCOFDragAndDropObserver = new LLCOFDragAndDropObserver(mInventoryItemsPanel->getModel());
LLComboBox* type_filter = getChild<LLComboBox>("filter_wearables_combobox");
type_filter->setCommitCallback(boost::bind(&LLPanelOutfitEdit::onTypeFilterChanged, this, _1));
type_filter->removeall();
mFilterComboBox = getChild<LLComboBox>("filter_wearables_combobox");
mFilterComboBox->setCommitCallback(boost::bind(&LLPanelOutfitEdit::onTypeFilterChanged, this, _1));
mFilterComboBox->removeall();
for (U32 i = 0; i < mLookItemTypes.size(); ++i)
{
type_filter->add(mLookItemTypes[i].displayName);
mFilterComboBox->add(mLookItemTypes[i].displayName);
}
type_filter->setCurrentByIndex(LIT_ALL);
mFilterComboBox->setCurrentByIndex(LIT_ALL);
mSearchFilter = getChild<LLFilterEditor>("look_item_filter");
mSearchFilter->setCommitCallback(boost::bind(&LLPanelOutfitEdit::onSearchEdit, this, _2));
childSetAction("show_add_wearables_btn", boost::bind(&LLPanelOutfitEdit::toggleAddWearablesPanel, this));
childSetAction("show_add_wearables_btn", boost::bind(&LLPanelOutfitEdit::onAddMoreButtonClicked, this));
childSetAction("add_to_outfit_btn", boost::bind(&LLPanelOutfitEdit::onAddToOutfitClicked, this));
mEditWearableBtn = getChild<LLButton>("edit_wearable_btn");
@ -353,7 +355,7 @@ void LLPanelOutfitEdit::showWearablesFilter()
}
}
void LLPanelOutfitEdit::showFilteredWearablesPanel()
void LLPanelOutfitEdit::showWearablesListView()
{
if(switchPanels(mInventoryItemsPanel, mWearableItemsPanel))
{
@ -364,7 +366,7 @@ void LLPanelOutfitEdit::showFilteredWearablesPanel()
mListViewBtn->setToggleState(TRUE);
}
void LLPanelOutfitEdit::showFilteredFolderWearablesPanel()
void LLPanelOutfitEdit::showWearablesFolderView()
{
if(switchPanels(mWearableItemsPanel, mInventoryItemsPanel))
{
@ -377,17 +379,12 @@ void LLPanelOutfitEdit::showFilteredFolderWearablesPanel()
void LLPanelOutfitEdit::onTypeFilterChanged(LLUICtrl* ctrl)
{
LLComboBox* type_filter = dynamic_cast<LLComboBox*>(ctrl);
llassert(type_filter);
if (type_filter)
{
U32 curr_filter_type = type_filter->getCurrentIndex();
mInventoryItemsPanel->setFilterTypes(mLookItemTypes[curr_filter_type].inventoryMask);
U32 curr_filter_type = mFilterComboBox->getCurrentIndex();
mInventoryItemsPanel->setFilterTypes(mLookItemTypes[curr_filter_type].inventoryMask);
mWearableListMaskCollector->setFilterMask(mLookItemTypes[curr_filter_type].inventoryMask);
mWearableListManager->setFilterCollector(mWearableListMaskCollector);
mWearableListMaskCollector->setFilterMask(mLookItemTypes[curr_filter_type].inventoryMask);
mWearableListManager->setFilterCollector(mWearableListMaskCollector);
}
mSavedFolderState->setApply(TRUE);
mInventoryItemsPanel->getRootFolder()->applyFunctorRecursively(*mSavedFolderState);
@ -471,7 +468,7 @@ void LLPanelOutfitEdit::onAddWearableClicked(void)
if(item)
{
showFilteredWearableItemsList(item->getWearableType());
showFilteredWearablesListView(item->getWearableType());
}
}
@ -481,7 +478,7 @@ void LLPanelOutfitEdit::onReplaceBodyPartMenuItemClicked(LLUUID selected_item_id
if (item && item->getType() == LLAssetType::AT_BODYPART)
{
showFilteredWearableItemsList(item->getWearableType());
showFilteredWearablesListView(item->getWearableType());
}
}
@ -538,24 +535,81 @@ void LLPanelOutfitEdit::onInventorySelectionChange(const std::deque<LLFolderView
current_item->addChild(mAddToLookBtn); */
}
void LLPanelOutfitEdit::onOutfitItemSelectionChange(void)
{
LLUUID item_id = mCOFWearables->getSelectedUUID();
//*TODO show Edit Wearable Button
LLViewerInventoryItem* item_to_remove = gInventory.getItem(item_id);
if (!item_to_remove) return;
switch (item_to_remove->getType())
{
case LLAssetType::AT_CLOTHING:
case LLAssetType::AT_OBJECT:
default:
break;
}
void LLPanelOutfitEdit::applyFilter(e_look_item_type type)
{
mFilterComboBox->setCurrentByIndex(type);
mFilterComboBox->onCommit();
}
void LLPanelOutfitEdit::filterWearablesBySelectedItem(void)
{
if (!mAddWearablesPanel->getVisible()) return;
uuid_vec_t ids;
mCOFWearables->getSelectedUUIDs(ids);
bool nothing_selected = ids.empty();
bool one_selected = ids.size() == 1;
bool more_than_one_selected = ids.size() > 1;
bool is_dummy_item = (ids.size() && dynamic_cast<LLPanelDummyClothingListItem*>(mCOFWearables->getSelectedItem()));
//resetting selection if no item is selected or than one item is selected
if (nothing_selected || more_than_one_selected)
{
if (nothing_selected)
{
showWearablesFolderView();
}
if (more_than_one_selected)
{
showWearablesListView();
}
applyFilter(LIT_ALL);
return;
}
//filter wearables by a type represented by a dummy item
if (one_selected && is_dummy_item)
{
onAddWearableClicked();
return;
}
LLViewerInventoryItem* item = gInventory.getItem(ids[0]);
if (!item && ids[0].notNull())
{
//Inventory misses an item with non-zero id
showWearablesListView();
applyFilter(LIT_ALL);
return;
}
if (one_selected && !is_dummy_item)
{
if (item->isWearableType())
{
//single clothing or bodypart item is selected
showFilteredWearablesListView(item->getWearableType());
mFilterComboBox->setLabel(getString("Filter.Custom"));
return;
}
else
{
//attachment is selected
showWearablesListView();
applyFilter(LIT_ATTACHMENT);
return;
}
}
}
void LLPanelOutfitEdit::update()
{
mCOFWearables->refresh();
@ -676,12 +730,21 @@ void LLPanelOutfitEdit::onGearButtonClick(LLUICtrl* clicked_button)
LLMenuGL::showPopup(clicked_button, mGearMenu, 0, menu_y);
}
void LLPanelOutfitEdit::showFilteredWearableItemsList(LLWearableType::EType type)
void LLPanelOutfitEdit::onAddMoreButtonClicked()
{
toggleAddWearablesPanel();
filterWearablesBySelectedItem();
}
void LLPanelOutfitEdit::showFilteredWearablesListView(LLWearableType::EType type)
{
mFilterComboBox->setLabel(getString("Filter.Custom"));
mWearableListTypeCollector->setType(type);
mWearableListManager->setFilterCollector(mWearableListTypeCollector);
showAddWearablesPanel(true);
showFilteredWearablesPanel();
showWearablesListView();
}
// EOF

View File

@ -47,6 +47,7 @@
class LLButton;
class LLCOFWearables;
class LLComboBox;
class LLTextBox;
class LLInventoryCategory;
class LLOutfitObserver;
@ -94,15 +95,27 @@ public:
void toggleAddWearablesPanel();
void showAddWearablesPanel(bool show__add_wearables);
//following methods operate with "add wearables" panel
void showWearablesFilter();
void showFilteredWearablesPanel();
void showFilteredFolderWearablesPanel();
void showWearablesListView();
void showWearablesFolderView();
void onTypeFilterChanged(LLUICtrl* ctrl);
void onSearchEdit(const std::string& string);
void onInventorySelectionChange(const std::deque<LLFolderViewItem*> &items, BOOL user_action);
void onAddToOutfitClicked(void);
void onOutfitItemSelectionChange(void);
void applyFilter(e_look_item_type type);
/**
* Filter items in views of Add Wearables Panel and show appropriate view depending on currently selected COF item(s)
* No COF items selected - shows the folder view, reset filter
* 1 COF item selected - shows the list view and filters wearables there by a wearable type of the selected item
* More than 1 COF item selected - shows the list view and filters it by a type of the selected item (attachment or clothing)
*/
void filterWearablesBySelectedItem(void);
void onRemoveFromOutfitClicked(void);
void onEditWearableClicked(void);
void onAddWearableClicked(void);
@ -132,7 +145,8 @@ public:
private:
void onGearButtonClick(LLUICtrl* clicked_button);
void showFilteredWearableItemsList(LLWearableType::EType type);
void onAddMoreButtonClicked();
void showFilteredWearablesListView(LLWearableType::EType type);
LLTextBox* mCurrentOutfitName;
@ -145,6 +159,7 @@ private:
LLButton* mFolderViewBtn;
LLButton* mListViewBtn;
LLPanel* mAddWearablesPanel;
LLComboBox* mFilterComboBox;
LLFindNonLinksByMask* mWearableListMaskCollector;
LLFindWearablesOfType* mWearableListTypeCollector;
@ -162,6 +177,8 @@ private:
bool mInitialized;
std::auto_ptr<LLSaveOutfitComboBtn> mSaveComboBtn;
};
#endif // LL_LLPANELOUTFITEDIT_H

View File

@ -51,6 +51,7 @@
<string name="Filter.All" value="All"/>
<string name="Filter.Clothes/Body" value="Clothes/Body"/>
<string name="Filter.Objects" value="Objects"/>
<string name="Filter.Custom" value="Custom filter"/>
<button