diff options
-rwxr-xr-x | indra/llui/llfolderview.cpp | 16 | ||||
-rwxr-xr-x | indra/llui/llfolderview.h | 8 | ||||
-rwxr-xr-x[-rw-r--r--] | indra/llui/llfolderviewitem.h | 7 | ||||
-rwxr-xr-x | indra/newview/llinventorybridge.cpp | 86 | ||||
-rwxr-xr-x | indra/newview/llinventorybridge.h | 8 | ||||
-rwxr-xr-x | indra/newview/llinventorypanel.cpp | 4 | ||||
-rwxr-xr-x | indra/newview/llinventorypanel.h | 2 | ||||
-rwxr-xr-x | indra/newview/llwearableitemslist.h | 3 |
8 files changed, 129 insertions, 5 deletions
diff --git a/indra/llui/llfolderview.cpp b/indra/llui/llfolderview.cpp index 26cb90505d..7f0d486981 100755 --- a/indra/llui/llfolderview.cpp +++ b/indra/llui/llfolderview.cpp @@ -171,7 +171,8 @@ LLFolderView::LLFolderView(const Params& p) mDraggingOverItem(NULL), mStatusTextBox(NULL), mShowItemLinkOverlays(p.show_item_link_overlays), - mViewModel(p.view_model) + mViewModel(p.view_model), + mGroupedItemModel(p.grouped_item_model) { claimMem(mViewModel); LLPanel* panel = p.parent_panel; @@ -1828,6 +1829,19 @@ void LLFolderView::updateMenuOptions(LLMenuGL* menu) flags = multi_select_flag; } + if (getFolderViewGroupedItemModel()) + { + getFolderViewGroupedItemModel()->groupFilterContextMenu(mSelectedItems,*menu); + } +#if 0 + selected_items_t::iterator item_itor = mSelectedItems.begin(); + if (item_itor != mSelectedItems.end()) + { + LLFolderViewItem* selected_item = (*item_itor); + selected_item->getViewModelItem()->groupFilterContextMenu(mSelectedItems,*menu); + } +#endif + addNoOptions(menu); } diff --git a/indra/llui/llfolderview.h b/indra/llui/llfolderview.h index 08e0a6220a..114dd7bd2f 100755 --- a/indra/llui/llfolderview.h +++ b/indra/llui/llfolderview.h @@ -45,6 +45,7 @@ #include "llscrollcontainer.h" class LLFolderViewModelInterface; +class LLFolderViewGroupedItemModel; class LLFolderViewFolder; class LLFolderViewItem; class LLFolderViewFilter; @@ -93,6 +94,7 @@ public: use_ellipses, show_item_link_overlays; Mandatory<LLFolderViewModelInterface*> view_model; + Optional<LLFolderViewGroupedItemModel*> grouped_item_model; Mandatory<std::string> options_menu; @@ -100,7 +102,7 @@ public: }; friend class LLFolderViewScrollContainer; - typedef std::deque<LLFolderViewItem*> selected_items_t; + typedef folder_view_item_deque selected_items_t; LLFolderView(const Params&); virtual ~LLFolderView( void ); @@ -113,6 +115,9 @@ public: LLFolderViewModelInterface* getFolderViewModel() { return mViewModel; } const LLFolderViewModelInterface* getFolderViewModel() const { return mViewModel; } + LLFolderViewGroupedItemModel* getFolderViewGroupedItemModel() { return mGroupedItemModel; } + const LLFolderViewGroupedItemModel* getFolderViewGroupedItemModel() const { return mGroupedItemModel; } + typedef boost::signals2::signal<void (const std::deque<LLFolderViewItem*>& items, BOOL user_action)> signal_t; void setSelectCallback(const signal_t::slot_type& cb) { mSelectSignal.connect(cb); } void setReshapeCallback(const signal_t::slot_type& cb) { mReshapeSignal.connect(cb); } @@ -300,6 +305,7 @@ protected: LLHandle<LLPanel> mParentPanel; LLFolderViewModelInterface* mViewModel; + LLFolderViewGroupedItemModel* mGroupedItemModel; /** * Is used to determine if we need to cut text In LLFolderViewItem to avoid horizontal scroll. diff --git a/indra/llui/llfolderviewitem.h b/indra/llui/llfolderviewitem.h index 0cd20a0f2d..5ad5731cad 100644..100755 --- a/indra/llui/llfolderviewitem.h +++ b/indra/llui/llfolderviewitem.h @@ -454,5 +454,12 @@ public: template<typename SORT_FUNC> void sortItems(const SORT_FUNC& func) { mItems.sort(func); } }; +typedef std::deque<LLFolderViewItem*> folder_view_item_deque; + +class LLFolderViewGroupedItemModel: public LLRefCount +{ +public: + virtual void groupFilterContextMenu(folder_view_item_deque& selected_items, LLMenuGL& menu) = 0; +}; #endif // LLFOLDERVIEWITEM_H diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index 958bc7d558..3ec8bb0ab9 100755 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -74,6 +74,7 @@ #include "llviewerwindow.h" #include "llvoavatarself.h" #include "llwearablelist.h" +#include "llwearableitemslist.h" #include "lllandmarkactions.h" #include "llpanellandmarks.h" @@ -557,6 +558,46 @@ BOOL LLInvFVBridge::isClipboardPasteableAsLink() const return TRUE; } +void disable_context_entries_if_present(LLMenuGL& menu, + const menuentry_vec_t &disabled_entries) +{ + const LLView::child_list_t *list = menu.getChildList(); + for (LLView::child_list_t::const_iterator itor = list->begin(); + itor != list->end(); + ++itor) + { + LLView *menu_item = (*itor); + std::string name = menu_item->getName(); + + // descend into split menus: + LLMenuItemBranchGL* branchp = dynamic_cast<LLMenuItemBranchGL*>(menu_item); + if ((name == "More") && branchp) + { + disable_context_entries_if_present(*branchp->getBranch(), disabled_entries); + } + + bool found = false; + menuentry_vec_t::const_iterator itor2; + for (itor2 = disabled_entries.begin(); itor2 != disabled_entries.end(); ++itor2) + { + if (*itor2 == name) + { + found = true; + break; + } + } + + if (found) + { + menu_item->setVisible(TRUE); + // A bit of a hack so we can remember that some UI element explicitly set this to be visible + // so that some other UI element from multi-select doesn't later set this invisible. + menu_item->pushVisible(TRUE); + + menu_item->setEnabled(FALSE); + } + } +} void hide_context_entries(LLMenuGL& menu, const menuentry_vec_t &entries_to_show, const menuentry_vec_t &disabled_entries) @@ -765,6 +806,31 @@ void LLInvFVBridge::buildContextMenu(LLMenuGL& menu, U32 flags) hide_context_entries(menu, items, disabled_items); } +bool get_selection_item_uuids(LLFolderView::selected_items_t& selected_items, uuid_vec_t& ids) +{ + uuid_vec_t results; + S32 non_item = 0; + for(LLFolderView::selected_items_t::iterator it = selected_items.begin(); it != selected_items.end(); ++it) + { + LLItemBridge *view_model = dynamic_cast<LLItemBridge *>((*it)->getViewModelItem()); + + if(view_model && view_model->getUUID().notNull()) + { + results.push_back(view_model->getUUID()); + } + else + { + non_item++; + } + } + if (non_item == 0) + { + ids = results; + return true; + } + return false; +} + void LLInvFVBridge::addTrashContextMenuOptions(menuentry_vec_t &items, menuentry_vec_t &disabled_items) { @@ -3585,7 +3651,7 @@ void LLFolderBridge::buildContextMenu(LLMenuGL& menu, U32 flags) if(!model) return; buildContextMenuOptions(flags, items, disabled_items); - hide_context_entries(menu, items, disabled_items); + hide_context_entries(menu, items, disabled_items); // Reposition the menu, in case we're adding items to an existing menu. menu.needsArrange(); @@ -6439,4 +6505,22 @@ LLInvFVBridge* LLRecentInventoryBridgeBuilder::createBridge( return new_listener; } +LLFolderViewGroupedItemBridge::LLFolderViewGroupedItemBridge() +{ +} + +void LLFolderViewGroupedItemBridge::groupFilterContextMenu(folder_view_item_deque& selected_items, LLMenuGL& menu) +{ + uuid_vec_t ids; + menuentry_vec_t disabled_items; + if (get_selection_item_uuids(selected_items, ids)) + { + if (!LLWearableItemsList::ContextMenu::canAddWearables(ids)) + { + disabled_items.push_back(std::string("Wearable Add")); + } + } + disable_context_entries_if_present(menu, disabled_items); +} + // EOF diff --git a/indra/newview/llinventorybridge.h b/indra/newview/llinventorybridge.h index e8d5db4437..6a8478e64b 100755 --- a/indra/newview/llinventorybridge.h +++ b/indra/newview/llinventorybridge.h @@ -37,6 +37,7 @@ #include "llviewerwearable.h" #include "lltooldraganddrop.h" #include "lllandmarklist.h" +#include "llfolderviewitem.h" class LLInventoryFilter; class LLInventoryPanel; @@ -687,4 +688,11 @@ void hide_context_entries(LLMenuGL& menu, const menuentry_vec_t &entries_to_show, const menuentry_vec_t &disabled_entries); +class LLFolderViewGroupedItemBridge: public LLFolderViewGroupedItemModel +{ +public: + LLFolderViewGroupedItemBridge(); + virtual void groupFilterContextMenu(folder_view_item_deque& selected_items, LLMenuGL& menu); +}; + #endif // LL_LLINVENTORYBRIDGE_H diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp index 3546317471..4a230accb6 100755 --- a/indra/newview/llinventorypanel.cpp +++ b/indra/newview/llinventorypanel.cpp @@ -146,7 +146,8 @@ LLInventoryPanel::LLInventoryPanel(const LLInventoryPanel::Params& p) : mShowEmptyMessage(p.show_empty_message), mViewsInitialized(false), mInvFVBridgeBuilder(NULL), - mInventoryViewModel(p.name) + mInventoryViewModel(p.name), + mGroupedItemBridge(new LLFolderViewGroupedItemBridge) { mInvFVBridgeBuilder = &INVENTORY_BRIDGE_BUILDER; @@ -186,6 +187,7 @@ LLFolderView * LLInventoryPanel::createFolderRoot(LLUUID root_id ) NULL, root_id); p.view_model = &mInventoryViewModel; + p.grouped_item_model = mGroupedItemBridge; p.use_label_suffix = mParams.use_label_suffix; p.allow_multiselect = mAllowMultiSelect; p.show_empty_message = mShowEmptyMessage; diff --git a/indra/newview/llinventorypanel.h b/indra/newview/llinventorypanel.h index a490dfce5d..bc4c10e441 100755 --- a/indra/newview/llinventorypanel.h +++ b/indra/newview/llinventorypanel.h @@ -43,6 +43,7 @@ class LLInvFVBridge; class LLInventoryFolderViewModelBuilder; class LLInvPanelComplObserver; class LLFolderViewModelInventory; +class LLFolderViewGroupedItemBridge; namespace LLInitParam { @@ -240,6 +241,7 @@ protected: LLScrollContainer* mScroller; LLFolderViewModelInventory mInventoryViewModel; + LLPointer<LLFolderViewGroupedItemBridge> mGroupedItemBridge; Params mParams; // stored copy of parameter block std::map<LLUUID, LLFolderViewItem*> mItemMap; diff --git a/indra/newview/llwearableitemslist.h b/indra/newview/llwearableitemslist.h index 58a00c5be0..eb975b6301 100755 --- a/indra/newview/llwearableitemslist.h +++ b/indra/newview/llwearableitemslist.h @@ -410,6 +410,8 @@ public: ContextMenu(); /*virtual*/ void show(LLView* spawning_view, const uuid_vec_t& uuids, S32 x, S32 y); + // FIXME logic should live somewhere more generally useful. + static bool canAddWearables(const uuid_vec_t& item_ids); protected: enum { MASK_CLOTHING = 0x01, @@ -425,7 +427,6 @@ public: static void setMenuItemEnabled(LLContextMenu* menu, const std::string& name, bool val); static void updateMask(U32& mask, LLAssetType::EType at); static void createNewWearable(const LLUUID& item_id); - static bool canAddWearables(const uuid_vec_t& item_ids); LLWearableItemsList* mParent; }; |