diff options
author | Alexander Gavriliuk <alexandrgproductengine@lindenlab.com> | 2024-09-03 18:05:45 +0200 |
---|---|---|
committer | Guru <alexandrgproductengine@lindenlab.com> | 2024-09-08 00:11:56 +0200 |
commit | 2b7b81fbdbaaaa8698828af9529f9693692da2a2 (patch) | |
tree | a5c5fdfea2b228c347e3fe7b5c8e4fe2e854babf /indra | |
parent | 2e886b7cfef14d087c2167e3384e9e19dcb3ff63 (diff) |
#459 Filters on object inventory
Diffstat (limited to 'indra')
-rw-r--r-- | indra/llui/llfolderviewitem.cpp | 14 | ||||
-rw-r--r-- | indra/llui/llfolderviewitem.h | 4 | ||||
-rw-r--r-- | indra/llui/llfolderviewmodel.h | 1 | ||||
-rw-r--r-- | indra/newview/llfolderviewmodelinventory.cpp | 2 | ||||
-rw-r--r-- | indra/newview/llinventorybridge.cpp | 342 | ||||
-rw-r--r-- | indra/newview/llinventoryfilter.cpp | 94 | ||||
-rw-r--r-- | indra/newview/llinventoryfilter.h | 8 | ||||
-rw-r--r-- | indra/newview/llinventoryfunctions.cpp | 14 | ||||
-rw-r--r-- | indra/newview/llinventorygallery.cpp | 238 | ||||
-rw-r--r-- | indra/newview/llinventorypanel.cpp | 4 | ||||
-rw-r--r-- | indra/newview/llpanelcontents.cpp | 41 | ||||
-rw-r--r-- | indra/newview/llpanelcontents.h | 10 | ||||
-rw-r--r-- | indra/newview/llpanelmaininventory.cpp | 27 | ||||
-rw-r--r-- | indra/newview/llpanelmaininventory.h | 2 | ||||
-rw-r--r-- | indra/newview/llpanelobjectinventory.cpp | 520 | ||||
-rw-r--r-- | indra/newview/llpanelobjectinventory.h | 2 | ||||
-rw-r--r-- | indra/newview/llsettingspicker.cpp | 8 | ||||
-rw-r--r-- | indra/newview/llsidepanelinventory.cpp | 2 | ||||
-rw-r--r-- | indra/newview/llviewerobjectlist.h | 11 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/floater_tools.xml | 20 |
20 files changed, 706 insertions, 658 deletions
diff --git a/indra/llui/llfolderviewitem.cpp b/indra/llui/llfolderviewitem.cpp index 2879f0354f..73803786a6 100644 --- a/indra/llui/llfolderviewitem.cpp +++ b/indra/llui/llfolderviewitem.cpp @@ -777,8 +777,9 @@ void LLFolderViewItem::drawOpenFolderArrow(const Params& default_params, const L return mIsItemCut; } -void LLFolderViewItem::drawHighlight(const bool showContent, const bool hasKeyboardFocus, const LLUIColor &selectColor, const LLUIColor &flashColor, - const LLUIColor &focusOutlineColor, const LLUIColor &mouseOverColor) +void LLFolderViewItem::drawHighlight(bool showContent, bool hasKeyboardFocus, + const LLUIColor& selectColor, const LLUIColor& flashColor, + const LLUIColor& focusOutlineColor, const LLUIColor& mouseOverColor) { const S32 focus_top = getRect().getHeight(); const S32 focus_bottom = getRect().getHeight() - mItemHeight; @@ -786,7 +787,7 @@ void LLFolderViewItem::drawHighlight(const bool showContent, const bool hasKeybo const S32 FOCUS_LEFT = 1; // Determine which background color to use for highlighting - const LLUIColor& bgColor = (isFlashing() ? flashColor : selectColor); + const LLUIColor& bgColor = isFlashing() ? flashColor : selectColor; //--------------------------------------------------------------------------------// // Draw highlight for selected items @@ -794,7 +795,6 @@ void LLFolderViewItem::drawHighlight(const bool showContent, const bool hasKeybo // items if mShowSingleSelection is false. // if (isHighlightAllowed()) - { gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); @@ -803,7 +803,7 @@ void LLFolderViewItem::drawHighlight(const bool showContent, const bool hasKeybo { LLColor4 bg_color = bgColor; // do time-based fade of extra objects - F32 fade_time = (getRoot() ? getRoot()->getSelectionFadeElapsedTime() : 0.0f); + F32 fade_time = getRoot() ? getRoot()->getSelectionFadeElapsedTime() : 0.f; if (getRoot() && getRoot()->getShowSingleSelection()) { // fading out @@ -909,7 +909,7 @@ void LLFolderViewItem::draw() getViewModelItem()->update(); - if(!mSingleFolderMode) + if (!mSingleFolderMode) { drawOpenFolderArrow(default_params, sFgColor); } @@ -942,7 +942,7 @@ void LLFolderViewItem::draw() return; } - auto filter_string_length = mViewModelItem->hasFilterStringMatch() ? static_cast<S32>(mViewModelItem->getFilterStringSize()) : 0; + S32 filter_string_length = mViewModelItem->hasFilterStringMatch() ? (S32)mViewModelItem->getFilterStringSize() : 0; F32 right_x = 0; F32 y = (F32)getRect().getHeight() - font->getLineHeight() - (F32)mTextPad - (F32)TOP_PAD; F32 text_left = (F32)getLabelXPos(); diff --git a/indra/llui/llfolderviewitem.h b/indra/llui/llfolderviewitem.h index c37bf64dee..7ac28b1a8e 100644 --- a/indra/llui/llfolderviewitem.h +++ b/indra/llui/llfolderviewitem.h @@ -298,8 +298,8 @@ public: // virtual void handleDropped(); virtual void draw(); void drawOpenFolderArrow(const Params& default_params, const LLUIColor& fg_color); - void drawHighlight(const bool showContent, const bool hasKeyboardFocus, const LLUIColor &selectColor, const LLUIColor &flashColor, const LLUIColor &outlineColor, const LLUIColor &mouseOverColor); - void drawLabel(const LLFontGL * font, const F32 x, const F32 y, const LLColor4& color, F32 &right_x); + void drawHighlight(bool showContent, bool hasKeyboardFocus, const LLUIColor& selectColor, const LLUIColor& flashColor, const LLUIColor& outlineColor, const LLUIColor& mouseOverColor); + void drawLabel(const LLFontGL* font, const F32 x, const F32 y, const LLColor4& color, F32 &right_x); virtual bool handleDragAndDrop(S32 x, S32 y, MASK mask, bool drop, EDragAndDropType cargo_type, void* cargo_data, diff --git a/indra/llui/llfolderviewmodel.h b/indra/llui/llfolderviewmodel.h index b8d6d89971..9372818ca5 100644 --- a/indra/llui/llfolderviewmodel.h +++ b/indra/llui/llfolderviewmodel.h @@ -292,6 +292,7 @@ public: dirtyFilter(); requestSort(); } + virtual void removeChild(LLFolderViewModelItem* child) { mChildren.remove(child); diff --git a/indra/newview/llfolderviewmodelinventory.cpp b/indra/newview/llfolderviewmodelinventory.cpp index 734f20830d..c668d414d3 100644 --- a/indra/newview/llfolderviewmodelinventory.cpp +++ b/indra/newview/llfolderviewmodelinventory.cpp @@ -234,7 +234,7 @@ bool LLFolderViewModelItemInventory::filterChildItem( LLFolderViewModelItem* ite return continue_filtering; } -bool LLFolderViewModelItemInventory::filter( LLFolderViewFilter& filter) +bool LLFolderViewModelItemInventory::filter(LLFolderViewFilter& filter) { const S32 filter_generation = filter.getCurrentGeneration(); const S32 must_pass_generation = filter.getFirstRequiredGeneration(); diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index c86492f005..2e8b1b94fe 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -1897,20 +1897,24 @@ void LLItemBridge::selectItem() } } +// virtual void LLItemBridge::restoreItem() { - LLViewerInventoryItem* item = static_cast<LLViewerInventoryItem*>(getItem()); - if(item) + if (LLViewerInventoryItem* item = getItem()) { - LLInventoryModel* model = getInventoryModel(); - bool is_snapshot = (item->getInventoryType() == LLInventoryType::IT_SNAPSHOT); + bool is_snapshot = item->getInventoryType() == LLInventoryType::IT_SNAPSHOT; + LLFolderType::EType preferred_type = is_snapshot ? + LLFolderType::FT_SNAPSHOT_CATEGORY : + LLFolderType::assetTypeToFolderType(item->getType()); - const LLUUID new_parent = model->findCategoryUUIDForType(is_snapshot? LLFolderType::FT_SNAPSHOT_CATEGORY : LLFolderType::assetTypeToFolderType(item->getType())); - // do not restamp on restore. + LLInventoryModel* model = getInventoryModel(); + LLUUID new_parent = model->findCategoryUUIDForType(preferred_type); + // Do not restamp on restore. LLInvFVBridge::changeItemParent(model, item, new_parent, false); } } +// virtual void LLItemBridge::restoreToWorld() { //Similar functionality to the drag and drop rez logic @@ -1931,26 +1935,27 @@ void LLItemBridge::restoreToWorld() //remove local inventory copy, sim will deal with permissions and removing the item //from the actual inventory if its a no-copy etc - if(!itemp->getPermissions().allowCopyBy(gAgent.getID())) + if (!itemp->getPermissions().allowCopyBy(gAgent.getID())) { remove_from_inventory = true; } // Check if it's in the trash. (again similar to the normal rez logic) const LLUUID trash_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_TRASH); - if(gInventory.isObjectDescendentOf(itemp->getUUID(), trash_id)) + if (gInventory.isObjectDescendentOf(itemp->getUUID(), trash_id)) { remove_from_inventory = true; } } - if(remove_from_inventory) + if (remove_from_inventory) { gInventory.deleteObject(itemp->getUUID()); gInventory.notifyObservers(); } } +// virtual void LLItemBridge::gotoItem() { LLInventoryObject *obj = getInventoryObject(); @@ -1960,39 +1965,43 @@ void LLItemBridge::gotoItem() } } +// virtual LLUIImagePtr LLItemBridge::getIcon() const { - LLInventoryObject *obj = getInventoryObject(); - if (obj) + if (LLInventoryObject* obj = getInventoryObject()) { - return LLInventoryIcon::getIcon(obj->getType(), - LLInventoryType::IT_NONE, - mIsLink); + return LLInventoryIcon::getIcon(obj->getType(), LLInventoryType::IT_NONE, mIsLink); } return LLInventoryIcon::getIcon(LLInventoryType::ICONNAME_OBJECT); } +// virtual LLUIImagePtr LLItemBridge::getIconOverlay() const { if (getItem() && getItem()->getIsLinkType()) { return LLUI::getUIImage("Inv_Link"); } + return NULL; } +// virtual PermissionMask LLItemBridge::getPermissionMask() const { - LLViewerInventoryItem* item = getItem(); - PermissionMask perm_mask = 0; - if (item) perm_mask = item->getPermissionMask(); - return perm_mask; + if (LLViewerInventoryItem* item = getItem()) + { + return item->getPermissionMask(); + } + + return 0; } +// virtual void LLItemBridge::buildDisplayName() const { - if(getItem()) + if (getItem()) { mDisplayName.assign(getItem()->getName()); } @@ -2005,14 +2014,15 @@ void LLItemBridge::buildDisplayName() const mSearchableName.append(getLabelSuffix()); LLStringUtil::toUpper(mSearchableName); - //Name set, so trigger a sort + // Name set, so trigger a sort LLInventorySort sorter = static_cast<LLFolderViewModelInventory&>(mRootViewModel).getSorter(); - if(mParent && !sorter.isByDate()) + if (mParent && !sorter.isByDate()) { mParent->requestSort(); } } +// virtual LLFontGL::StyleFlags LLItemBridge::getLabelStyle() const { U8 font = LLFontGL::NORMAL; @@ -2023,7 +2033,7 @@ LLFontGL::StyleFlags LLItemBridge::getLabelStyle() const // LL_INFOS() << "BOLD" << LL_ENDL; font |= LLFontGL::BOLD; } - else if(item && item->getIsLinkType()) + else if (item && item->getIsLinkType()) { font |= LLFontGL::ITALIC; } @@ -2031,6 +2041,7 @@ LLFontGL::StyleFlags LLItemBridge::getLabelStyle() const return (LLFontGL::StyleFlags)font; } +// virtual std::string LLItemBridge::getLabelSuffix() const { // String table is loaded before login screen and inventory items are @@ -2040,19 +2051,19 @@ std::string LLItemBridge::getLabelSuffix() const static std::string NO_XFER = LLTrans::getString("no_transfer_lbl"); static std::string LINK = LLTrans::getString("link"); static std::string BROKEN_LINK = LLTrans::getString("broken_link"); + std::string suffix; - LLInventoryItem* item = getItem(); - if(item) + if (LLInventoryItem* item = getItem()) { // Any type can have the link suffix... - bool broken_link = LLAssetType::lookupIsLinkType(item->getType()); - if (broken_link) return BROKEN_LINK; + if (LLAssetType::lookupIsLinkType(item->getType())) + return BROKEN_LINK; - bool link = item->getIsLinkType(); - if (link) return LINK; + if (item->getIsLinkType()) + return LINK; // ...but it's a bit confusing to put nocopy/nomod/etc suffixes on calling cards. - if(LLAssetType::AT_CALLINGCARD != item->getType() + if (LLAssetType::AT_CALLINGCARD != item->getType() && item->getPermissions().getOwner() == gAgent.getID()) { bool copy = item->getPermissions().allowCopyBy(gAgent.getID()); @@ -2067,8 +2078,7 @@ std::string LLItemBridge::getLabelSuffix() const suffix += suffix.empty() ? " " : ","; suffix += NO_MOD; } - bool xfer = item->getPermissions().allowOperationBy(PERM_TRANSFER, - gAgent.getID()); + bool xfer = item->getPermissions().allowOperationBy(PERM_TRANSFER, gAgent.getID()); if (!xfer) { suffix += suffix.empty() ? " " : ","; @@ -2076,24 +2086,25 @@ std::string LLItemBridge::getLabelSuffix() const } } } + return suffix; } +// virtual time_t LLItemBridge::getCreationDate() const { - LLViewerInventoryItem* item = getItem(); - if (item) + if (LLViewerInventoryItem* item = getItem()) { return item->getCreationDate(); } + return 0; } - +// virtual bool LLItemBridge::isItemRenameable() const { - LLViewerInventoryItem* item = getItem(); - if(item) + if (LLViewerInventoryItem* item = getItem()) { // (For now) Don't allow calling card rename since that may confuse users as to // what the calling card points to. @@ -2112,50 +2123,62 @@ bool LLItemBridge::isItemRenameable() const return false; } - return (item->getPermissions().allowModifyBy(gAgent.getID())); + return item->getPermissions().allowModifyBy(gAgent.getID()); } + return false; } +// virtual bool LLItemBridge::renameItem(const std::string& new_name) { - if(!isItemRenameable()) + if (!isItemRenameable()) return false; + LLPreview::dirty(mUUID); LLInventoryModel* model = getInventoryModel(); - if(!model) + if (!model) return false; + LLViewerInventoryItem* item = getItem(); - if(item && (item->getName() != new_name)) + if (item && (item->getName() != new_name)) { LLSD updates; updates["name"] = new_name; update_inventory_item(item->getUUID(),updates, NULL); } - // return false because we either notified observers (& therefore - // rebuilt) or we didn't update. + + // return false because we either notified observers + // (& therefore rebuilt) or we didn't update. return false; } +// virtual bool LLItemBridge::removeItem() { - if(!isItemRemovable()) + if (!isItemRemovable()) { return false; } // move it to the trash LLInventoryModel* model = getInventoryModel(); - if(!model) return false; + if (!model) + return false; + const LLUUID& trash_id = model->findCategoryUUIDForType(LLFolderType::FT_TRASH); LLViewerInventoryItem* item = getItem(); - if (!item) return false; + if (!item) + return false; + if (item->getType() != LLAssetType::AT_LSL_TEXT) { LLPreview::hide(mUUID, true); } + // Already in trash - if (model->isObjectDescendentOf(mUUID, trash_id)) return false; + if (model->isObjectDescendentOf(mUUID, trash_id)) + return false; LLNotification::Params params("ConfirmItemDeleteHasLinks"); params.functor.function(boost::bind(&LLItemBridge::confirmRemoveItem, this, _1, _2)); @@ -2187,26 +2210,31 @@ bool LLItemBridge::removeItem() bool LLItemBridge::confirmRemoveItem(const LLSD& notification, const LLSD& response) { S32 option = LLNotificationsUtil::getSelectedOption(notification, response); - if (option != 0) return false; + if (option != 0) + return false; LLInventoryModel* model = getInventoryModel(); - if (!model) return false; + if (!model) + return false; LLViewerInventoryItem* item = getItem(); - if (!item) return false; + if (!item) + return false; const LLUUID& trash_id = model->findCategoryUUIDForType(LLFolderType::FT_TRASH); // if item is not already in trash - if(item && !model->isObjectDescendentOf(mUUID, trash_id)) + if (item && !model->isObjectDescendentOf(mUUID, trash_id)) { // move to trash, and restamp LLInvFVBridge::changeItemParent(model, item, trash_id, true); // delete was successful return true; } + return false; } +// virtual bool LLItemBridge::isItemCopyable(bool can_copy_as_link) const { LLViewerInventoryItem* item = getItem(); @@ -2214,6 +2242,7 @@ bool LLItemBridge::isItemCopyable(bool can_copy_as_link) const { return false; } + // Can't copy worn objects. // Worn objects are tied to their inworld conterparts // Copy of modified worn object will return object with obsolete asset and inventory @@ -2230,37 +2259,36 @@ bool LLItemBridge::isItemCopyable(bool can_copy_as_link) const LLViewerInventoryItem* LLItemBridge::getItem() const { - LLViewerInventoryItem* item = NULL; - LLInventoryModel* model = getInventoryModel(); - if(model) + if (LLInventoryModel* model = getInventoryModel()) { - item = (LLViewerInventoryItem*)model->getItem(mUUID); + return model->getItem(mUUID); } - return item; + + return NULL; } +// virtual const LLUUID& LLItemBridge::getThumbnailUUID() const { - LLViewerInventoryItem* item = NULL; - LLInventoryModel* model = getInventoryModel(); - if(model) - { - item = (LLViewerInventoryItem*)model->getItem(mUUID); - } - if (item) + if (LLInventoryModel* model = getInventoryModel()) { - return item->getThumbnailUUID(); + if (LLViewerInventoryItem* item = model->getItem(mUUID)) + { + return item->getThumbnailUUID(); + } } + return LLUUID::null; } +// virtual bool LLItemBridge::isItemPermissive() const { - LLViewerInventoryItem* item = getItem(); - if(item) + if (LLViewerInventoryItem* item = getItem()) { return item->getIsFullPerm(); } + return false; } @@ -2583,16 +2611,22 @@ bool LLFolderBridge::dragCategoryIntoFolder(LLInventoryCategory* inv_cat, LLInventoryModel* model = getInventoryModel(); - if (!inv_cat) return false; // shouldn't happen, but in case item is incorrectly parented in which case inv_cat will be NULL - if (!model) return false; - if (!isAgentAvatarValid()) return false; - if (!isAgentInventory()) return false; // cannot drag categories into library + if (!inv_cat) // shouldn't happen, but in case item is incorrectly parented in which case inv_cat will be NULL + return false; + if (!model) + return false; + if (!isAgentAvatarValid()) + return false; + if (!isAgentInventory()) + return false; // cannot drag categories into library LLInventoryPanel* destination_panel = mInventoryPanel.get(); - if (!destination_panel) return false; + if (!destination_panel) + return false; LLInventoryFilter* filter = getInventoryFilter(); - if (!filter) return false; + if (!filter) + return false; const LLUUID &cat_id = inv_cat->getUUID(); const LLUUID ¤t_outfit_id = model->findCategoryUUIDForType(LLFolderType::FT_CURRENT_OUTFIT); @@ -2689,7 +2723,7 @@ bool LLFolderBridge::dragCategoryIntoFolder(LLInventoryCategory* inv_cat, is_movable = false; } } - if(is_movable && move_is_into_current_outfit && is_link) + if (is_movable && move_is_into_current_outfit && is_link) { is_movable = false; } @@ -2717,7 +2751,7 @@ bool LLFolderBridge::dragCategoryIntoFolder(LLInventoryCategory* inv_cat, for (S32 i=0; i < descendent_categories.size(); ++i) { LLInventoryCategory* category = descendent_categories[i]; - if(LLFolderType::lookupIsProtectedType(category->getPreferredType())) + if (LLFolderType::lookupIsProtectedType(category->getPreferredType())) { // Can't move "special folders" (e.g. Textures Folder). is_movable = false; @@ -2749,9 +2783,8 @@ bool LLFolderBridge::dragCategoryIntoFolder(LLInventoryCategory* inv_cat, } if (is_movable && move_is_into_trash) { - for (S32 i=0; i < descendent_items.size(); ++i) + for (LLViewerInventoryItem* item : descendent_items) { - LLInventoryItem* item = descendent_items[i]; if (get_is_item_worn(item->getUUID())) { is_movable = false; @@ -2761,10 +2794,8 @@ bool LLFolderBridge::dragCategoryIntoFolder(LLInventoryCategory* inv_cat, } if (is_movable && move_is_into_landmarks) { - for (S32 i=0; i < descendent_items.size(); ++i) + for (LLViewerInventoryItem* item : descendent_items) { - LLViewerInventoryItem* item = descendent_items[i]; - // Don't move anything except landmarks and categories into Landmarks folder. // We use getType() instead of getActua;Type() to allow links to landmarks and folders. if (LLAssetType::AT_LANDMARK != item->getType() && LLAssetType::AT_CATEGORY != item->getType()) @@ -3055,7 +3086,7 @@ bool move_inv_category_world_to_agent(const LLUUID& object_id, // permissions. // content category has same ID as object itself LLViewerObject* object = gObjectList.findObject(object_id); - if(!object) + if (!object) { LL_INFOS() << "Object not found for drop." << LL_ENDL; return false; @@ -3083,11 +3114,9 @@ bool move_inv_category_world_to_agent(const LLUUID& object_id, // coming from a task. Need to figure out if the person can // move/copy this item. - LLInventoryObject::object_list_t::iterator it = inventory_objects.begin(); - LLInventoryObject::object_list_t::iterator end = inventory_objects.end(); - for ( ; it != end; ++it) + for (LLPointer<LLInventoryObject> obj : inventory_objects) { - LLInventoryItem* item = dynamic_cast<LLInventoryItem*>(it->get()); + LLInventoryItem* item = dynamic_cast<LLInventoryItem*>(obj.get()); if (!item) { LL_WARNS() << "Invalid inventory item for drop" << LL_ENDL; @@ -3097,13 +3126,13 @@ bool move_inv_category_world_to_agent(const LLUUID& object_id, // coming from a task. Need to figure out if the person can // move/copy this item. LLPermissions perm(item->getPermissions()); - if((perm.allowCopyBy(gAgent.getID(), gAgent.getGroupID()) + if ((perm.allowCopyBy(gAgent.getID(), gAgent.getGroupID()) && perm.allowTransferTo(gAgent.getID()))) // || gAgent.isGodlike()) { accept = true; } - else if(object->permYouOwner()) + else if (object->permYouOwner()) { // If the object cannot be copied, but the object the // inventory is owned by the agent, then the item can be @@ -3123,22 +3152,21 @@ bool move_inv_category_world_to_agent(const LLUUID& object_id, } } - if(drop && accept) + if (drop && accept) { - it = inventory_objects.begin(); std::shared_ptr<LLMoveInv> move_inv(new LLMoveInv); move_inv->mObjectID = object_id; move_inv->mCategoryID = category_id; move_inv->mCallback = callback; move_inv->mUserData = user_data; - for ( ; it != end; ++it) + for (LLPointer<LLInventoryObject> obj : inventory_objects) { - two_uuids_t two(category_id, (*it)->getUUID()); + two_uuids_t two(category_id, obj->getUUID()); move_inv->mMoveList.push_back(two); } - if(is_move) + if (is_move) { // Callback called from within here. warn_move_inventory(object, move_inv); @@ -3156,13 +3184,13 @@ bool move_inv_category_world_to_agent(const LLUUID& object_id, void LLRightClickInventoryFetchDescendentsObserver::execute(bool clear_observer) { // Bail out immediately if no descendents - if( mComplete.empty() ) + if (mComplete.empty()) { LL_WARNS() << "LLRightClickInventoryFetchDescendentsObserver::done with empty mCompleteFolders" << LL_ENDL; if (clear_observer) { - gInventory.removeObserver(this); - delete this; + gInventory.removeObserver(this); + delete this; } return; } @@ -3186,13 +3214,13 @@ void LLRightClickInventoryFetchDescendentsObserver::execute(bool clear_observer) gInventory.getDirectDescendentsOf(*current_folder, cat_array, item_array); size_t item_count(0); - if( item_array ) + if (item_array) { item_count = item_array->size(); } size_t cat_count(0); - if( cat_array ) + if (cat_array) { cat_count = cat_array->size(); } @@ -3291,20 +3319,16 @@ protected: }; - void LLInventoryCopyAndWearObserver::changed(U32 mask) { - if((mask & (LLInventoryObserver::ADD)) != 0) + if ((mask & (LLInventoryObserver::ADD)) != 0) { if (!mFolderAdded) { const std::set<LLUUID>& changed_items = gInventory.getChangedIDs(); - - std::set<LLUUID>::const_iterator id_it = changed_items.begin(); - std::set<LLUUID>::const_iterator id_end = changed_items.end(); - for (;id_it != id_end; ++id_it) + for (const LLUUID& item_id : changed_items) { - if ((*id_it) == mCatID) + if (item_id == mCatID) { mFolderAdded = true; break; @@ -3322,8 +3346,7 @@ void LLInventoryCopyAndWearObserver::changed(U32 mask) } else { - if (category->getDescendentCount() == - mContentsCount) + if (category->getDescendentCount() == mContentsCount) { gInventory.removeObserver(this); LLAppearanceMgr::instance().wearInventoryCategory(category, false, !mReplace); @@ -3335,8 +3358,6 @@ void LLInventoryCopyAndWearObserver::changed(U32 mask) } } - - void LLFolderBridge::performAction(LLInventoryModel* model, std::string action) { if ("open" == action) @@ -3429,19 +3450,19 @@ void LLFolderBridge::performAction(LLInventoryModel* model, std::string action) LLMarketplaceValidator::getInstance()->validateMarketplaceListings( version_folder_id, [this](bool result) - { - // todo: might need to ensure bridge/mUUID exists or this will cause crashes - if (!result) { - LLSD subs; - subs["[ERROR_CODE]"] = mMessage; - LLNotificationsUtil::add("MerchantListingFailed", subs); - } - else - { - LLMarketplaceData::instance().activateListing(mUUID, true); - } - }, + // todo: might need to ensure bridge/mUUID exists or this will cause crashes + if (!result) + { + LLSD subs; + subs["[ERROR_CODE]"] = mMessage; + LLNotificationsUtil::add("MerchantListingFailed", subs); + } + else + { + LLMarketplaceData::instance().activateListing(mUUID, true); + } + }, boost::bind(&LLFolderBridge::gatherMessage, this, _1, _2, _3) ); } @@ -3456,19 +3477,19 @@ void LLFolderBridge::performAction(LLInventoryModel* model, std::string action) LLMarketplaceValidator::getInstance()->validateMarketplaceListings( mUUID, [this](bool result) - { - if (!result) { - LLSD subs; - subs["[ERROR_CODE]"] = mMessage; - LLNotificationsUtil::add("MerchantFolderActivationFailed", subs); - } - else - { - LLInventoryCategory* category = gInventory.getCategory(mUUID); - LLMarketplaceData::instance().setVersionFolder(category->getParentUUID(), mUUID); - } - }, + if (!result) + { + LLSD subs; + subs["[ERROR_CODE]"] = mMessage; + LLNotificationsUtil::add("MerchantFolderActivationFailed", subs); + } + else + { + LLInventoryCategory* category = gInventory.getCategory(mUUID); + LLMarketplaceData::instance().setVersionFolder(category->getParentUUID(), mUUID); + } + }, boost::bind(&LLFolderBridge::gatherMessage, this, _1, _2, _3), false, 2); @@ -3500,35 +3521,35 @@ void LLFolderBridge::performAction(LLInventoryModel* model, std::string action) LLMarketplaceValidator::getInstance()->validateMarketplaceListings( mUUID, [this](bool result) - { - if (!result) { - mMessage = ""; - - LLMarketplaceValidator::getInstance()->validateMarketplaceListings( - mUUID, - [this](bool result) + if (!result) { - if (result) - { - LLNotificationsUtil::add("MerchantForceValidateListing"); - LLMarketplaceData::instance().createListing(mUUID); - } - else + mMessage = ""; + + LLMarketplaceValidator::getInstance()->validateMarketplaceListings( + mUUID, + [this](bool result) { - LLSD subs; - subs["[ERROR_CODE]"] = mMessage; - LLNotificationsUtil::add("MerchantListingFailed", subs); - } - }, - boost::bind(&LLFolderBridge::gatherMessage, this, _1, _2, _3), - true); - } - else - { - LLMarketplaceData::instance().createListing(mUUID); - } - }, + if (result) + { + LLNotificationsUtil::add("MerchantForceValidateListing"); + LLMarketplaceData::instance().createListing(mUUID); + } + else + { + LLSD subs; + subs["[ERROR_CODE]"] = mMessage; + LLNotificationsUtil::add("MerchantListingFailed", subs); + } + }, + boost::bind(&LLFolderBridge::gatherMessage, this, _1, _2, _3), + true); + } + else + { + LLMarketplaceData::instance().createListing(mUUID); + } + }, boost::bind(&LLFolderBridge::gatherMessage, this, _1, _2, _3), false); @@ -3607,7 +3628,7 @@ void LLFolderBridge::copyOutfitToClipboard() gInventory.getDirectDescendentsOf(mUUID, cat_array, item_array); size_t item_count(0); - if( item_array ) + if (item_array) { item_count = item_array->size(); } @@ -3699,8 +3720,7 @@ void LLFolderBridge::restoreItem() LLFolderType::EType LLFolderBridge::getPreferredType() const { LLFolderType::EType preferred_type = LLFolderType::FT_NONE; - LLViewerInventoryCategory* cat = getCategory(); - if(cat) + if (LLViewerInventoryCategory* cat = getCategory()) { preferred_type = cat->getPreferredType(); } @@ -3742,7 +3762,6 @@ LLUIImagePtr LLFolderBridge::getIconOverlay() const bool LLFolderBridge::renameItem(const std::string& new_name) { - LLScrollOnRenameObserver *observer = new LLScrollOnRenameObserver(mUUID, mRoot); gInventory.addObserver(observer); @@ -3755,7 +3774,7 @@ bool LLFolderBridge::renameItem(const std::string& new_name) bool LLFolderBridge::removeItem() { - if(!isItemRemovable()) + if (!isItemRemovable()) { return false; } @@ -3771,7 +3790,6 @@ bool LLFolderBridge::removeItem() return true; } - bool LLFolderBridge::removeSystemFolder() { const LLViewerInventoryCategory *cat = getCategory(); diff --git a/indra/newview/llinventoryfilter.cpp b/indra/newview/llinventoryfilter.cpp index e3d4645701..5c0905af3c 100644 --- a/indra/newview/llinventoryfilter.cpp +++ b/indra/newview/llinventoryfilter.cpp @@ -103,7 +103,7 @@ bool LLInventoryFilter::check(const LLFolderViewModelItem* item) } std::string desc = listener->getSearchableCreatorName(); - switch(mSearchType) + switch (mSearchType) { case SEARCHTYPE_CREATOR: desc = listener->getSearchableCreatorName(); @@ -129,7 +129,7 @@ bool LLInventoryFilter::check(const LLFolderViewModelItem* item) boost::char_separator<char> sep(" "); tokenizer tokens(desc, sep); - for (auto token_iter : tokens) + for (const auto& token_iter : tokens) { if (token_iter == mExactToken) { @@ -138,9 +138,9 @@ bool LLInventoryFilter::check(const LLFolderViewModelItem* item) } } } - else if ((mFilterTokens.size() > 0) && (mSearchType == SEARCHTYPE_NAME)) + else if (!mFilterTokens.empty() && mSearchType == SEARCHTYPE_NAME) { - for (auto token_iter : mFilterTokens) + for (const auto& token_iter : mFilterTokens) { if (desc.find(token_iter) == std::string::npos) { @@ -150,7 +150,7 @@ bool LLInventoryFilter::check(const LLFolderViewModelItem* item) } else { - passed = (mFilterSubString.size() ? desc.find(mFilterSubString) != std::string::npos : true); + passed = checkAgainstFilterSubString(desc); } passed = passed && checkAgainstFilterType(listener); @@ -166,7 +166,7 @@ bool LLInventoryFilter::check(const LLFolderViewModelItem* item) bool LLInventoryFilter::check(const LLInventoryItem* item) { - const bool passed_string = (mFilterSubString.size() ? item->getName().find(mFilterSubString) != std::string::npos : true); + const bool passed_string = checkAgainstFilterSubString(item->getName()); const bool passed_filtertype = checkAgainstFilterType(item); const bool passed_permissions = checkAgainstPermissions(item); @@ -295,9 +295,19 @@ bool LLInventoryFilter::checkFolder(const LLUUID& folder_id) const return true; } +bool LLInventoryFilter::checkAgainstFilterSubString(const std::string& desc) const +{ + if (mFilterSubString.empty()) + return true; + + size_t pos = desc.find(mFilterSubString); + return pos != std::string::npos; +} + bool LLInventoryFilter::checkAgainstFilterType(const LLFolderViewModelItemInventory* listener) const { - if (!listener) return false; + if (!listener) + return false; LLInventoryType::EType object_type = listener->getInventoryType(); const LLUUID object_id = listener->getUUID(); @@ -338,7 +348,7 @@ bool LLInventoryFilter::checkAgainstFilterType(const LLFolderViewModelItemInvent } } - if(filterTypes & FILTERTYPE_WORN) + if (filterTypes & FILTERTYPE_WORN) { if (!get_is_item_worn(object_id)) { @@ -351,7 +361,8 @@ bool LLInventoryFilter::checkAgainstFilterType(const LLFolderViewModelItemInvent // Pass if this item is the target UUID or if it links to the target UUID if (filterTypes & FILTERTYPE_UUID) { - if (!object) return false; + if (!object) + return false; if (object->getLinkedUUID() != mFilterOps.mFilterUUID) return false; @@ -363,7 +374,7 @@ bool LLInventoryFilter::checkAgainstFilterType(const LLFolderViewModelItemInvent if (filterTypes & FILTERTYPE_DATE) { const U16 HOURS_TO_SECONDS = 3600; - time_t earliest = time_corrected() - mFilterOps.mHoursAgo * HOURS_TO_SECONDS; + time_t earliest = time_corrected() - (U64)mFilterOps.mHoursAgo * HOURS_TO_SECONDS; if (mFilterOps.mMinDate > time_min() && mFilterOps.mMinDate < earliest) { @@ -494,7 +505,8 @@ bool LLInventoryFilter::checkAgainstFilterType(const LLInventoryItem* item) cons // Pass if this item is the target UUID or if it links to the target UUID if (filterTypes & FILTERTYPE_UUID) { - if (!item) return false; + if (!item) + return false; if (item->getLinkedUUID() != mFilterOps.mFilterUUID) return false; @@ -540,7 +552,8 @@ bool LLInventoryFilter::checkAgainstClipboard(const LLUUID& object_id) const bool LLInventoryFilter::checkAgainstPermissions(const LLFolderViewModelItemInventory* listener) const { - if (!listener) return false; + if (!listener) + return false; PermissionMask perm = listener->getPermissionMask(); const LLInvFVBridge *bridge = dynamic_cast<const LLInvFVBridge *>(listener); @@ -556,7 +569,8 @@ bool LLInventoryFilter::checkAgainstPermissions(const LLFolderViewModelItemInven bool LLInventoryFilter::checkAgainstPermissions(const LLInventoryItem* item) const { - if (!item) return false; + if (!item) + return false; LLPointer<LLViewerInventoryItem> new_item = new LLViewerInventoryItem(item); PermissionMask perm = new_item->getPermissionMask(); @@ -567,11 +581,13 @@ bool LLInventoryFilter::checkAgainstPermissions(const LLInventoryItem* item) con bool LLInventoryFilter::checkAgainstFilterLinks(const LLFolderViewModelItemInventory* listener) const { - if (!listener) return true; + if (!listener) + return true; const LLUUID object_id = listener->getUUID(); const LLInventoryObject *object = gInventory.getObject(object_id); - if (!object) return true; + if (!object) + return true; const bool is_link = object->getIsLinkType(); if (is_link && (mFilterOps.mFilterLinks == FILTERLINK_EXCLUDE_LINKS)) @@ -584,7 +600,8 @@ bool LLInventoryFilter::checkAgainstFilterLinks(const LLFolderViewModelItemInven bool LLInventoryFilter::checkAgainstFilterThumbnails(const LLUUID& object_id) const { const LLInventoryObject *object = gInventory.getObject(object_id); - if (!object) return true; + if (!object) + return true; const bool is_thumbnail = object->getThumbnailUUID().notNull(); if (is_thumbnail && (mFilterOps.mFilterThumbnails == FILTER_EXCLUDE_THUMBNAILS)) @@ -596,16 +613,20 @@ bool LLInventoryFilter::checkAgainstFilterThumbnails(const LLUUID& object_id) co bool LLInventoryFilter::checkAgainstCreator(const LLFolderViewModelItemInventory* listener) const { - if (!listener) return true; + if (!listener) + return true; + const bool is_folder = listener->getInventoryType() == LLInventoryType::IT_CATEGORY; switch (mFilterOps.mFilterCreatorType) { case FILTERCREATOR_SELF: - if(is_folder) return false; - return (listener->getSearchableCreatorName() == mUsername); + if (is_folder) + return false; + return listener->getSearchableCreatorName() == mUsername; case FILTERCREATOR_OTHERS: - if(is_folder) return false; - return (listener->getSearchableCreatorName() != mUsername); + if (is_folder) + return false; + return listener->getSearchableCreatorName() != mUsername; case FILTERCREATOR_ALL: default: return true; @@ -618,7 +639,8 @@ bool LLInventoryFilter::checkAgainstSearchVisibility(const LLFolderViewModelItem const LLUUID object_id = listener->getUUID(); const LLInventoryObject *object = gInventory.getObject(object_id); - if (!object) return true; + if (!object) + return true; const bool is_link = object->getIsLinkType(); if (is_link && ((mFilterOps.mSearchVisibility & VISIBILITY_LINKS) == 0)) @@ -647,10 +669,8 @@ std::string::size_type LLInventoryFilter::getStringMatchOffset(LLFolderViewModel { return mFilterSubString.size() ? item->getSearchableName().find(mFilterSubString) : std::string::npos; } - else - { - return std::string::npos; - } + + return std::string::npos; } bool LLInventoryFilter::isDefault() const @@ -725,7 +745,7 @@ void LLInventoryFilter::updateFilterTypes(U64 types, U64& current_types) void LLInventoryFilter::setSearchType(ESearchType type) { - if(mSearchType != type) + if (mSearchType != type) { mSearchType = type; setModified(); @@ -918,6 +938,7 @@ void LLInventoryFilter::setFilterUUID(const LLUUID& object_id) { setModified(FILTER_RESTART); } + mFilterOps.mFilterUUID = object_id; mFilterOps.mFilterTypes = FILTERTYPE_UUID; } @@ -931,7 +952,6 @@ void LLInventoryFilter::setFilterSubString(const std::string& string) if (mFilterSubString != filter_sub_string_new) { - mFilterTokens.clear(); if (filter_sub_string_new.find_first_of("+") != std::string::npos) { @@ -1243,7 +1263,7 @@ void LLInventoryFilter::setFindAllLinksMode(const std::string &search_name, cons { // Save a copy of settings so that we will be able to restore it later // but make sure we are not searching for links already - if(mFilterOps.mFilterLinks != FILTERLINK_ONLY_LINKS) + if (mFilterOps.mFilterLinks != FILTERLINK_ONLY_LINKS) { mBackupFilterOps = mFilterOps; } @@ -1283,7 +1303,7 @@ void LLInventoryFilter::setModified(EFilterModified behavior) } // if not keeping current filter results, update last valid as well - switch(mFilterModified) + switch (mFilterModified) { case FILTER_RESTART: mFirstRequiredGeneration = mCurrentGeneration; @@ -1499,11 +1519,11 @@ const std::string& LLInventoryFilter::getFilterText() { mFilterText += LLTrans::getString("Since Logoff"); } + return mFilterText; } - -LLInventoryFilter& LLInventoryFilter::operator=( const LLInventoryFilter& other ) +LLInventoryFilter& LLInventoryFilter::operator =(const LLInventoryFilter& other) { setFilterObjectTypes(other.getFilterObjectTypes()); setDateRange(other.getMinDate(), other.getMaxDate()); @@ -1516,7 +1536,6 @@ LLInventoryFilter& LLInventoryFilter::operator=( const LLInventoryFilter& othe return *this; } - void LLInventoryFilter::toParams(Params& params) const { params.filter_ops.types = (U32)getFilterObjectTypes(); @@ -1686,14 +1705,13 @@ std::string LLInventoryFilter::getEmptyLookupMessage(bool is_empty_folder) const return LLTrans::getString(mEmptyLookupMessage, args); } - } bool LLInventoryFilter::areDateLimitsSet() { - return mFilterOps.mMinDate != time_min() - || mFilterOps.mMaxDate != time_max() - || mFilterOps.mHoursAgo != 0; + return mFilterOps.mMinDate != time_min() + || mFilterOps.mMaxDate != time_max() + || mFilterOps.mHoursAgo != 0; } bool LLInventoryFilter::showAllResults() const @@ -1701,8 +1719,6 @@ bool LLInventoryFilter::showAllResults() const return hasFilterString() && !mSingleFolderMode; } - - bool LLInventoryFilter::FilterOps::DateRange::validateBlock( bool emit_errors /*= true*/ ) const { bool valid = LLInitParam::Block<DateRange>::validateBlock(emit_errors); diff --git a/indra/newview/llinventoryfilter.h b/indra/newview/llinventoryfilter.h index 7203c6f743..7e64a03e73 100644 --- a/indra/newview/llinventoryfilter.h +++ b/indra/newview/llinventoryfilter.h @@ -45,7 +45,8 @@ public: SHOW_NO_FOLDERS }; - enum EFilterType { + enum EFilterType + { FILTERTYPE_NONE = 0, FILTERTYPE_OBJECT = 0x1 << 0, // normal default search-by-object-type FILTERTYPE_CATEGORY = 0x1 << 1, // search by folder type @@ -275,9 +276,9 @@ public: // +-------------------------------------------------------------------+ // + Execution And Results // +-------------------------------------------------------------------+ - bool check(const LLFolderViewModelItem* listener); + bool check(const LLFolderViewModelItem* item); bool check(const LLInventoryItem* item); - bool checkFolder(const LLFolderViewModelItem* listener) const; + bool checkFolder(const LLFolderViewModelItem* item) const; bool checkFolder(const LLUUID& folder_id) const; bool showAllResults() const; @@ -341,6 +342,7 @@ public: private: bool areDateLimitsSet(); + bool checkAgainstFilterSubString(const std::string& desc) const; bool checkAgainstFilterType(const class LLFolderViewModelItemInventory* listener) const; bool checkAgainstFilterType(const LLInventoryItem* item) const; bool checkAgainstPermissions(const class LLFolderViewModelItemInventory* listener) const; diff --git a/indra/newview/llinventoryfunctions.cpp b/indra/newview/llinventoryfunctions.cpp index 57c0d57190..dadd0590a9 100644 --- a/indra/newview/llinventoryfunctions.cpp +++ b/indra/newview/llinventoryfunctions.cpp @@ -2400,18 +2400,16 @@ void ungroup_folder_items(const LLUUID& folder_id) LLInventoryModel::cat_array_t cats = *cat_array; LLInventoryModel::item_array_t items = *item_array; - for (LLInventoryModel::cat_array_t::const_iterator cat_iter = cats.begin(); cat_iter != cats.end(); ++cat_iter) + for (const LLPointer<LLViewerInventoryCategory>& cat : cats) { - LLViewerInventoryCategory* cat = *cat_iter; if (cat) { gInventory.changeCategoryParent(cat, new_cat_uuid, false); } } - for (LLInventoryModel::item_array_t::const_iterator item_iter = items.begin(); item_iter != items.end(); ++item_iter) + for (const LLPointer<LLViewerInventoryItem>& item : items) { - LLViewerInventoryItem* item = *item_iter; - if(item) + if (item) { gInventory.changeItemParent(item, new_cat_uuid, false); } @@ -2424,8 +2422,7 @@ std::string get_searchable_description(LLInventoryModel* model, const LLUUID& it { if (model) { - const LLInventoryItem *item = model->getItem(item_id); - if(item) + if (const LLInventoryItem* item = model->getItem(item_id)) { std::string desc = item->getDescription(); LLStringUtil::toUpper(desc); @@ -2439,8 +2436,7 @@ std::string get_searchable_creator_name(LLInventoryModel* model, const LLUUID& i { if (model) { - const LLInventoryItem *item = model->getItem(item_id); - if(item) + if (const LLInventoryItem* item = model->getItem(item_id)) { LLAvatarName av_name; if (LLAvatarNameCache::get(item->getCreatorUUID(), &av_name)) diff --git a/indra/newview/llinventorygallery.cpp b/indra/newview/llinventorygallery.cpp index 46d1e822de..c4f93cee98 100644 --- a/indra/newview/llinventorygallery.cpp +++ b/indra/newview/llinventorygallery.cpp @@ -2649,7 +2649,8 @@ bool LLInventoryGallery::hasDescendents(const LLUUID& cat_id) bool LLInventoryGallery::checkAgainstFilterType(const LLUUID& object_id) { const LLInventoryObject *object = gInventory.getObject(object_id); - if(!object) return false; + if (!object) + return false; LLInventoryType::EType object_type = LLInventoryType::IT_CATEGORY; LLInventoryItem* inv_item = gInventory.getItem(object_id); @@ -2657,8 +2658,8 @@ bool LLInventoryGallery::checkAgainstFilterType(const LLUUID& object_id) { object_type = inv_item->getInventoryType(); } - const U32 filterTypes = (U32)mFilter->getFilterTypes(); + const U32 filterTypes = (U32)mFilter->getFilterTypes(); if ((filterTypes & LLInventoryFilter::FILTERTYPE_OBJECT) && inv_item) { switch (object_type) @@ -2726,7 +2727,7 @@ bool LLInventoryGallery::hasVisibleItems() void LLInventoryGallery::handleModifiedFilter() { - if(mFilter->isModified()) + if (mFilter->isModified()) { reArrangeRows(); } @@ -2737,7 +2738,7 @@ void LLInventoryGallery::setSortOrder(U32 order, bool update) bool dirty = (mSortOrder != order); mSortOrder = order; - if(update && dirty) + if (update && dirty) { mNeedsArrange = true; gIdleCallbacks.addFunction(onIdle, (void*)this); @@ -2789,11 +2790,11 @@ void LLInventoryGalleryItem::setType(LLAssetType::EType type, LLInventoryType::E mIsLink = is_link; std::string icon_name = LLInventoryIcon::getIconName(mType, inventory_type, flags); - if(mIsFolder) + if (mIsFolder) { mSortGroup = SG_NORMAL_FOLDER; LLUUID folder_id = mUUID; - if(mIsLink) + if (mIsLink) { LLInventoryObject* obj = gInventory.getObject(mUUID); if (obj) @@ -2820,7 +2821,7 @@ void LLInventoryGalleryItem::setType(LLAssetType::EType type, LLInventoryType::E else { const LLInventoryItem *item = gInventory.getItem(mUUID); - if(item && (LLAssetType::AT_CALLINGCARD != item->getType()) && !mIsLink) + if (item && (LLAssetType::AT_CALLINGCARD != item->getType()) && !mIsLink) { std::string delim(" --"); bool copy = item->getPermissions().allowCopyBy(gAgent.getID()); @@ -2851,7 +2852,7 @@ void LLInventoryGalleryItem::setType(LLAssetType::EType type, LLInventoryType::E void LLInventoryGalleryItem::setThumbnail(LLUUID id) { mDefaultImage = id.isNull(); - if(mDefaultImage) + if (mDefaultImage) { mThumbnailCtrl->clearTexture(); } @@ -2900,10 +2901,10 @@ void LLInventoryGalleryItem::setSelected(bool value) mSelected = value; mTextBgPanel->setBackgroundVisible(value); - if(mSelected) + if (mSelected) { LLViewerInventoryItem* item = gInventory.getItem(mUUID); - if(item && !item->isFinished()) + if (item && !item->isFinished()) { LLInventoryModelBackgroundFetch::instance().start(mUUID, false); } @@ -2926,6 +2927,7 @@ bool LLInventoryGalleryItem::handleMouseDown(S32 x, S32 y, MASK mask) { mGallery->changeItemSelection(mUUID, false); } + setFocus(true); mGallery->claimEditHandler(); @@ -2958,7 +2960,7 @@ bool LLInventoryGalleryItem::handleRightMouseDown(S32 x, S32 y, MASK mask) bool LLInventoryGalleryItem::handleMouseUp(S32 x, S32 y, MASK mask) { - if(hasMouseCapture()) + if (hasMouseCapture()) { gFocusMgr.setMouseCapture(NULL); return true; @@ -2968,13 +2970,13 @@ bool LLInventoryGalleryItem::handleMouseUp(S32 x, S32 y, MASK mask) bool LLInventoryGalleryItem::handleHover(S32 x, S32 y, MASK mask) { - if(hasMouseCapture()) + if (hasMouseCapture()) { S32 screen_x; S32 screen_y; localPointToScreen(x, y, &screen_x, &screen_y ); - if(LLToolDragAndDrop::getInstance()->isOverThreshold(screen_x, screen_y) && mGallery) + if (LLToolDragAndDrop::getInstance()->isOverThreshold(screen_x, screen_y) && mGallery) { mGallery->startDrag(); return LLToolDragAndDrop::getInstance()->handleHover(x, y, mask); @@ -2993,13 +2995,13 @@ bool LLInventoryGalleryItem::handleDoubleClick(S32 x, S32 y, MASK mask) LLHandle<LLPanel> handle = mGallery->getHandle(); LLUUID navigate_to = mUUID; doOnIdleOneTime([handle, navigate_to]() - { - LLInventoryGallery* gallery = (LLInventoryGallery*)handle.get(); - if (gallery) - { - gallery->setRootFolder(navigate_to); - } - }); + { + LLInventoryGallery* gallery = (LLInventoryGallery*)handle.get(); + if (gallery) + { + gallery->setRootFolder(navigate_to); + } + }); } else { @@ -3078,7 +3080,7 @@ void LLInventoryGalleryItem::setWorn(bool value) { mWorn = value; - if(mWorn) + if (mWorn) { mWornSuffix = (mType == LLAssetType::AT_GESTURE) ? LLTrans::getString("active") : LLTrans::getString("worn"); } @@ -3092,7 +3094,7 @@ void LLInventoryGalleryItem::setWorn(bool value) LLFontGL* LLInventoryGalleryItem::getTextFont() { - if(mWorn) + if (mWorn) { return LLFontGL::getFontSansSerifSmallBold(); } @@ -3127,12 +3129,10 @@ bool LLInventoryGalleryItem::isFadeItem() void LLThumbnailsObserver::changed(U32 mask) { std::vector<LLUUID> deleted_ids; - for (item_map_t::iterator iter = mItemMap.begin(); - iter != mItemMap.end(); - ++iter) + for (item_map_t::value_type& it : mItemMap) { - const LLUUID& obj_id = (*iter).first; - LLItemData& data = (*iter).second; + const LLUUID& obj_id = it.first; + LLItemData& data = it.second; LLInventoryObject* obj = gInventory.getObject(obj_id); if (!obj) @@ -3158,8 +3158,7 @@ void LLThumbnailsObserver::changed(U32 mask) bool LLThumbnailsObserver::addItem(const LLUUID& obj_id, callback_t cb) { - LLInventoryObject* obj = gInventory.getObject(obj_id); - if (obj) + if (LLInventoryObject* obj = gInventory.getObject(obj_id)) { mItemMap.insert(item_map_value_t(obj_id, LLItemData(obj_id, obj->getThumbnailUUID(), cb))); return true; @@ -3190,79 +3189,74 @@ bool LLInventoryGallery::baseHandleDragAndDrop(LLUUID dest_id, bool drop, } bool accepted = false; - switch(cargo_type) - { - case DAD_TEXTURE: - case DAD_SOUND: - case DAD_CALLINGCARD: - case DAD_LANDMARK: - case DAD_SCRIPT: - case DAD_CLOTHING: - case DAD_OBJECT: - case DAD_NOTECARD: - case DAD_BODYPART: - case DAD_ANIMATION: - case DAD_GESTURE: - case DAD_MESH: - case DAD_SETTINGS: + switch (cargo_type) + { + case DAD_TEXTURE: + case DAD_SOUND: + case DAD_CALLINGCARD: + case DAD_LANDMARK: + case DAD_SCRIPT: + case DAD_CLOTHING: + case DAD_OBJECT: + case DAD_NOTECARD: + case DAD_BODYPART: + case DAD_ANIMATION: + case DAD_GESTURE: + case DAD_MESH: + case DAD_SETTINGS: + accepted = dragItemIntoFolder(dest_id, inv_item, drop, tooltip_msg, true); + if (accepted && drop) + { + // Don't select immediately, wait for item to arrive + mItemsToSelect.push_back(inv_item->getUUID()); + } + break; + case DAD_LINK: + // DAD_LINK type might mean one of two asset types: AT_LINK or AT_LINK_FOLDER. + // If we have an item of AT_LINK_FOLDER type we should process the linked + // category being dragged or dropped into folder. + if (inv_item && LLAssetType::AT_LINK_FOLDER == inv_item->getActualType()) + { + LLInventoryCategory* linked_category = gInventory.getCategory(inv_item->getLinkedUUID()); + if (linked_category) + { + accepted = dragCategoryIntoFolder(dest_id, (LLInventoryCategory*)linked_category, drop, tooltip_msg, true); + } + } + else + { accepted = dragItemIntoFolder(dest_id, inv_item, drop, tooltip_msg, true); + } + if (accepted && drop && inv_item) + { + mItemsToSelect.push_back(inv_item->getUUID()); + } + break; + case DAD_CATEGORY: + if (LLFriendCardsManager::instance().isAnyFriendCategory(dest_id)) + { + accepted = false; + } + else + { + LLInventoryCategory* cat_ptr = (LLInventoryCategory*)cargo_data; + accepted = dragCategoryIntoFolder(dest_id, cat_ptr, drop, tooltip_msg, false); if (accepted && drop) { - // Don't select immediately, wait for item to arrive - mItemsToSelect.push_back(inv_item->getUUID()); - } - break; - case DAD_LINK: - // DAD_LINK type might mean one of two asset types: AT_LINK or AT_LINK_FOLDER. - // If we have an item of AT_LINK_FOLDER type we should process the linked - // category being dragged or dropped into folder. - if (inv_item && LLAssetType::AT_LINK_FOLDER == inv_item->getActualType()) - { - LLInventoryCategory* linked_category = gInventory.getCategory(inv_item->getLinkedUUID()); - if (linked_category) - { - accepted = dragCategoryIntoFolder(dest_id, (LLInventoryCategory*)linked_category, drop, tooltip_msg, true); - } - } - else - { - accepted = dragItemIntoFolder(dest_id, inv_item, drop, tooltip_msg, true); - } - if (accepted && drop && inv_item) - { - mItemsToSelect.push_back(inv_item->getUUID()); - } - break; - case DAD_CATEGORY: - if (LLFriendCardsManager::instance().isAnyFriendCategory(dest_id)) - { - accepted = false; - } - else - { - LLInventoryCategory* cat_ptr = (LLInventoryCategory*)cargo_data; - accepted = dragCategoryIntoFolder(dest_id, cat_ptr, drop, tooltip_msg, false); - if (accepted && drop) - { - mItemsToSelect.push_back(cat_ptr->getUUID()); - } + mItemsToSelect.push_back(cat_ptr->getUUID()); } - break; - case DAD_ROOT_CATEGORY: - case DAD_NONE: - break; - default: - LL_WARNS() << "Unhandled cargo type for drag&drop " << cargo_type << LL_ENDL; - break; - } - if (accepted) - { - *accept = ACCEPT_YES_MULTI; - } - else - { - *accept = ACCEPT_NO; + } + break; + case DAD_ROOT_CATEGORY: + case DAD_NONE: + break; + default: + LL_WARNS() << "Unhandled cargo type for drag&drop " << cargo_type << LL_ENDL; + break; } + + *accept = accepted ? ACCEPT_YES_MULTI : ACCEPT_NO; + return accepted; } @@ -3274,16 +3268,20 @@ bool dragItemIntoFolder(LLUUID folder_id, LLInventoryItem* inv_item, bool drop, { return false; } - LLInventoryModel* model = &gInventory; - if (!model || !inv_item) return false; + LLInventoryModel* model = &gInventory; + if (!model || !inv_item) + return false; // cannot drag into library - if((gInventory.getRootFolderID() != folder_id) && !model->isObjectDescendentOf(folder_id, gInventory.getRootFolderID())) + if (gInventory.getRootFolderID() != folder_id && + !model->isObjectDescendentOf(folder_id, gInventory.getRootFolderID())) { return false; } - if (!isAgentAvatarValid()) return false; + + if (!isAgentAvatarValid()) + return false; const LLUUID ¤t_outfit_id = model->findCategoryUUIDForType(LLFolderType::FT_CURRENT_OUTFIT); const LLUUID &favorites_id = model->findCategoryUUIDForType(LLFolderType::FT_FAVORITE); @@ -3302,7 +3300,7 @@ bool dragItemIntoFolder(LLUUID folder_id, LLInventoryItem* inv_item, bool drop, LLToolDragAndDrop::ESource source = LLToolDragAndDrop::getInstance()->getSource(); bool accept = false; LLViewerObject* object = NULL; - if(LLToolDragAndDrop::SOURCE_AGENT == source) + if (LLToolDragAndDrop::SOURCE_AGENT == source) { const LLUUID &trash_id = model->findCategoryUUIDForType(LLFolderType::FT_TRASH); @@ -3317,21 +3315,24 @@ bool dragItemIntoFolder(LLUUID folder_id, LLInventoryItem* inv_item, bool drop, switch (inv_item->getActualType()) { - case LLAssetType::AT_CATEGORY: - is_movable = !LLFolderType::lookupIsProtectedType(((LLInventoryCategory*)inv_item)->getPreferredType()); - break; - default: - break; + case LLAssetType::AT_CATEGORY: + is_movable = !LLFolderType::lookupIsProtectedType(((LLInventoryCategory*)inv_item)->getPreferredType()); + break; + default: + break; } + // Can't explicitly drag things out of the COF. if (move_is_outof_current_outfit) { is_movable = false; } + if (move_is_into_trash) { is_movable &= inv_item->getIsLinkType() || !get_is_item_worn(inv_item->getUUID()); } + if (is_movable) { // Don't allow creating duplicates in the Calling Card/Friends @@ -3540,7 +3541,7 @@ bool dragItemIntoFolder(LLUUID folder_id, LLInventoryItem* inv_item, bool drop, move_inv->mMoveList.push_back(item_pair); move_inv->mCallback = NULL; move_inv->mUserData = NULL; - if(is_move) + if (is_move) { warn_move_inventory(object, move_inv); } @@ -3555,7 +3556,7 @@ bool dragItemIntoFolder(LLUUID folder_id, LLInventoryItem* inv_item, bool drop, } } } - else if(LLToolDragAndDrop::SOURCE_NOTECARD == source) + else if (LLToolDragAndDrop::SOURCE_NOTECARD == source) { if (move_is_into_marketplacelistings) { @@ -3582,7 +3583,7 @@ bool dragItemIntoFolder(LLUUID folder_id, LLInventoryItem* inv_item, bool drop, inv_item); } } - else if(LLToolDragAndDrop::SOURCE_LIBRARY == source) + else if (LLToolDragAndDrop::SOURCE_LIBRARY == source) { LLViewerInventoryItem* item = (LLViewerInventoryItem*)inv_item; if(item && item->isFinished()) @@ -3665,11 +3666,14 @@ bool dragCategoryIntoFolder(LLUUID dest_id, LLInventoryCategory* inv_cat, return false; } - if (!inv_cat) return false; // shouldn't happen, but in case item is incorrectly parented in which case inv_cat will be NULL + if (!inv_cat) // shouldn't happen, but in case item is incorrectly parented in which case inv_cat will be NULL + return false; + + if (!isAgentAvatarValid()) + return false; - if (!isAgentAvatarValid()) return false; // cannot drag into library - if((gInventory.getRootFolderID() != dest_id) && !model->isObjectDescendentOf(dest_id, gInventory.getRootFolderID())) + if ((gInventory.getRootFolderID() != dest_id) && !model->isObjectDescendentOf(dest_id, gInventory.getRootFolderID())) { return false; } @@ -3758,7 +3762,7 @@ bool dragCategoryIntoFolder(LLUUID dest_id, LLInventoryCategory* inv_cat, is_movable = false; } } - else if(dest_cat && dest_cat->getPreferredType() == LLFolderType::FT_NONE) + else if (dest_cat && dest_cat->getPreferredType() == LLFolderType::FT_NONE) { is_movable = ((inv_cat->getPreferredType() == LLFolderType::FT_NONE) || (inv_cat->getPreferredType() == LLFolderType::FT_OUTFIT)); } @@ -3767,7 +3771,7 @@ bool dragCategoryIntoFolder(LLUUID dest_id, LLInventoryCategory* inv_cat, is_movable = false; } } - if(is_movable && move_is_into_current_outfit && is_link) + if (is_movable && move_is_into_current_outfit && is_link) { is_movable = false; } @@ -3795,7 +3799,7 @@ bool dragCategoryIntoFolder(LLUUID dest_id, LLInventoryCategory* inv_cat, for (S32 i=0; i < descendent_categories.size(); ++i) { LLInventoryCategory* category = descendent_categories[i]; - if(LLFolderType::lookupIsProtectedType(category->getPreferredType())) + if (LLFolderType::lookupIsProtectedType(category->getPreferredType())) { // Can't move "special folders" (e.g. Textures Folder). is_movable = false; @@ -4000,7 +4004,6 @@ void outfitFolderCreatedCallback(LLUUID cat_source_id, LLUUID cat_dest_id) LLInventoryObject::const_object_list_t link_array; - LLInventoryModel::item_array_t::iterator iter = items->begin(); LLInventoryModel::item_array_t::iterator end = items->end(); while (iter!=end) @@ -4038,4 +4041,3 @@ void dropToMyOutfits(LLInventoryCategory* inv_cat) inventory_func_type func = boost::bind(&outfitFolderCreatedCallback, inv_cat->getUUID(), _1); gInventory.createNewCategory(dest_id, LLFolderType::FT_OUTFIT, inv_cat->getName(), func, inv_cat->getThumbnailUUID()); } - diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp index 9e4f4c0adc..e4d1010231 100644 --- a/indra/newview/llinventorypanel.cpp +++ b/indra/newview/llinventorypanel.cpp @@ -414,8 +414,10 @@ void LLInventoryPanel::setFilterTypes(U64 types, LLInventoryFilter::EFilterType { getFilter().setFilterObjectTypes(types); } - if (filter_type == LLInventoryFilter::FILTERTYPE_CATEGORY) + else if (filter_type == LLInventoryFilter::FILTERTYPE_CATEGORY) + { getFilter().setFilterCategoryTypes(types); + } } void LLInventoryPanel::setFilterWorn() diff --git a/indra/newview/llpanelcontents.cpp b/indra/newview/llpanelcontents.cpp index 7b78ad2934..dbf56c2b6d 100644 --- a/indra/newview/llpanelcontents.cpp +++ b/indra/newview/llpanelcontents.cpp @@ -31,6 +31,7 @@ // linden library includes #include "llerror.h" +#include "llfiltereditor.h" #include "llfloaterreg.h" #include "llfontgl.h" #include "llinventorydefines.h" @@ -83,8 +84,14 @@ bool LLPanelContents::postBuild() childSetAction("button new script",&LLPanelContents::onClickNewScript, this); childSetAction("button permissions",&LLPanelContents::onClickPermissions, this); + mFilterEditor = getChild<LLFilterEditor>("contents_filter"); + mFilterEditor->setCommitCallback([&](LLUICtrl*, const LLSD&) { onFilterEdit(); }); + mPanelInventoryObject = getChild<LLPanelObjectInventory>("contents_inventory"); + // update permission filter once UI is fully initialized + mSavedFolderState.setApply(false); + return true; } @@ -129,6 +136,38 @@ void LLPanelContents::getState(LLViewerObject *objectp ) mPanelInventoryObject->setEnabled(!objectp->isPermanentEnforced()); } +void LLPanelContents::onFilterEdit() +{ + const std::string& filter_substring = mFilterEditor->getText(); + if (filter_substring.empty()) + { + if (mPanelInventoryObject->getFilter().getFilterSubString().empty()) + { + // The current filter and the new filter are empty, nothing to do + return; + } + + mSavedFolderState.setApply(true); + mPanelInventoryObject->getRootFolder()->applyFunctorRecursively(mSavedFolderState); + + // Add a folder with the current item to the list of previously opened folders + LLOpenFoldersWithSelection opener; + mPanelInventoryObject->getRootFolder()->applyFunctorRecursively(opener); + mPanelInventoryObject->getRootFolder()->scrollToShowSelection(); + } + else if (mPanelInventoryObject->getFilter().getFilterSubString().empty()) + { + // The first letter in search term, save existing folder open state + if (!mPanelInventoryObject->getFilter().isNotDefault()) + { + mSavedFolderState.setApply(false); + mPanelInventoryObject->getRootFolder()->applyFunctorRecursively(mSavedFolderState); + } + } + + mPanelInventoryObject->getFilter().setFilterSubString(filter_substring); +} + void LLPanelContents::refresh() { const bool children_ok = true; @@ -149,7 +188,6 @@ void LLPanelContents::clearContents() } } - // // Static functions // @@ -199,7 +237,6 @@ void LLPanelContents::onClickNewScript(void *userdata) } } - // static void LLPanelContents::onClickPermissions(void *userdata) { diff --git a/indra/newview/llpanelcontents.h b/indra/newview/llpanelcontents.h index 748bb76a82..bb6308e8b8 100644 --- a/indra/newview/llpanelcontents.h +++ b/indra/newview/llpanelcontents.h @@ -27,12 +27,13 @@ #ifndef LL_LLPANELCONTENTS_H #define LL_LLPANELCONTENTS_H -#include "v3math.h" -#include "llpanel.h" +#include "llfolderview.h" #include "llinventory.h" +#include "llpanel.h" #include "lluuid.h" #include "llviewerobject.h" #include "llvoinventorylistener.h" +#include "v3math.h" class LLButton; class LLPanelObjectInventory; @@ -66,9 +67,12 @@ public: static const char* PERMS_ANYONE_CONTROL_KEY; protected: - void getState(LLViewerObject *object); + void getState(LLViewerObject *object); + void onFilterEdit(); public: + class LLFilterEditor* mFilterEditor; + LLSaveFolderState mSavedFolderState; LLPanelObjectInventory* mPanelInventoryObject; }; diff --git a/indra/newview/llpanelmaininventory.cpp b/indra/newview/llpanelmaininventory.cpp index 143873f168..377af4384a 100644 --- a/indra/newview/llpanelmaininventory.cpp +++ b/indra/newview/llpanelmaininventory.cpp @@ -908,12 +908,12 @@ bool LLPanelMainInventory::handleDragAndDrop(S32 x, S32 y, MASK mask, bool drop, EAcceptance* accept, std::string& tooltip_msg) { - // Check to see if we are auto scrolling from the last frame - LLInventoryPanel* panel = (LLInventoryPanel*)this->getActivePanel(); - bool needsToScroll = panel->getScrollableContainer()->canAutoScroll(x, y); - if(mFilterTabs) + if (mFilterTabs) { - if(needsToScroll) + // Check to see if we are auto scrolling from the last frame + LLInventoryPanel* panel = (LLInventoryPanel*)this->getActivePanel(); + bool needsToScroll = panel->getScrollableContainer()->canAutoScroll(x, y); + if (needsToScroll) { mFilterTabs->startDragAndDropDelayTimer(); } @@ -930,9 +930,9 @@ void LLPanelMainInventory::changed(U32) updateItemcountText(); } -void LLPanelMainInventory::setFocusFilterEditor() +void LLPanelMainInventory::setFocusOnFilterEditor() { - if(mFilterEditor) + if (mFilterEditor) { mFilterEditor->setFocus(true); } @@ -1259,7 +1259,6 @@ void LLFloaterInventoryFinder::draw() filtered_by_all_types = false; } - if (!getChild<LLUICtrl>("check_calling_card")->getValue()) { filter &= ~(0x1 << LLInventoryType::IT_CALLINGCARD); @@ -1279,8 +1278,6 @@ void LLFloaterInventoryFinder::draw() } if (!getChild<LLUICtrl>("check_landmark")->getValue()) - - { filter &= ~(0x1 << LLInventoryType::IT_LANDMARK); filtered_by_all_types = false; @@ -1341,9 +1338,8 @@ void LLFloaterInventoryFinder::draw() filter &= ~(0x1 << LLInventoryType::IT_CATEGORY); } - bool is_sf_mode = mPanelMainInventory->isSingleFolderMode(); - if(is_sf_mode && mPanelMainInventory->isGalleryViewMode()) + if (is_sf_mode && mPanelMainInventory->isGalleryViewMode()) { mPanelMainInventory->mCombinationGalleryPanel->getFilter().setShowFolderState(getCheckShowEmpty() ? LLInventoryFilter::SHOW_ALL_FOLDERS : LLInventoryFilter::SHOW_NON_EMPTY_FOLDERS); @@ -1351,7 +1347,7 @@ void LLFloaterInventoryFinder::draw() } else { - if(is_sf_mode && mPanelMainInventory->isCombinationViewMode()) + if (is_sf_mode && mPanelMainInventory->isCombinationViewMode()) { mPanelMainInventory->mCombinationGalleryPanel->getFilter().setShowFolderState(getCheckShowEmpty() ? LLInventoryFilter::SHOW_ALL_FOLDERS : LLInventoryFilter::SHOW_NON_EMPTY_FOLDERS); @@ -1383,9 +1379,8 @@ void LLFloaterInventoryFinder::draw() } hours += days * 24; - mPanelMainInventory->setFilterTextFromFilter(); - if(is_sf_mode && mPanelMainInventory->isGalleryViewMode()) + if (is_sf_mode && mPanelMainInventory->isGalleryViewMode()) { mPanelMainInventory->mCombinationGalleryPanel->getFilter().setHoursAgo(hours); mPanelMainInventory->mCombinationGalleryPanel->getFilter().setDateRangeLastLogoff(getCheckSinceLogoff()); @@ -1393,7 +1388,7 @@ void LLFloaterInventoryFinder::draw() } else { - if(is_sf_mode && mPanelMainInventory->isCombinationViewMode()) + if (is_sf_mode && mPanelMainInventory->isCombinationViewMode()) { mPanelMainInventory->mCombinationGalleryPanel->getFilter().setHoursAgo(hours); mPanelMainInventory->mCombinationGalleryPanel->getFilter().setDateRangeLastLogoff(getCheckSinceLogoff()); diff --git a/indra/newview/llpanelmaininventory.h b/indra/newview/llpanelmaininventory.h index 21100cc03c..a78c0c0fad 100644 --- a/indra/newview/llpanelmaininventory.h +++ b/indra/newview/llpanelmaininventory.h @@ -103,7 +103,7 @@ public: void onFilterEdit(const std::string& search_string ); - void setFocusFilterEditor(); + void setFocusOnFilterEditor(); static LLFloaterSidePanelContainer* newWindow(); static void newFolderWindow(LLUUID folder_id = LLUUID(), LLUUID item_to_select = LLUUID()); diff --git a/indra/newview/llpanelobjectinventory.cpp b/indra/newview/llpanelobjectinventory.cpp index d33ccc0216..ef7986603b 100644 --- a/indra/newview/llpanelobjectinventory.cpp +++ b/indra/newview/llpanelobjectinventory.cpp @@ -173,8 +173,7 @@ LLTaskInvFVBridge::LLTaskInvFVBridge( mAssetType(LLAssetType::AT_NONE), mInventoryType(LLInventoryType::IT_NONE) { - const LLInventoryItem *item = findItem(); - if (item) + if (const LLInventoryItem* item = findItem()) { mAssetType = item->getType(); mInventoryType = item->getInventoryType(); @@ -183,15 +182,15 @@ LLTaskInvFVBridge::LLTaskInvFVBridge( LLInventoryObject* LLTaskInvFVBridge::findInvObject() const { - LLViewerObject* object = gObjectList.findObject(mPanel->getTaskUUID()); - if (object) + const LLUUID& id = mPanel->getTaskUUID(); + if (LLViewerObject* object = gObjectList.findObject(id)) { return object->getInventoryObject(mUUID); } + return NULL; } - LLInventoryItem* LLTaskInvFVBridge::findItem() const { return dynamic_cast<LLInventoryItem*>(findInvObject()); @@ -204,27 +203,24 @@ void LLTaskInvFVBridge::showProperties() S32 LLTaskInvFVBridge::getPrice() { - LLInventoryItem* item = findItem(); - if(item) + if (LLInventoryItem* item = findItem()) { return item->getSaleInfo().getSalePrice(); } - else - { - return -1; - } + + return -1; } +// virtual const std::string& LLTaskInvFVBridge::getName() const { return mName; } +// virtual const std::string& LLTaskInvFVBridge::getDisplayName() const { - LLInventoryItem* item = findItem(); - - if(item) + if (LLInventoryItem* item = findItem()) { mDisplayName.assign(item->getName()); @@ -240,31 +236,32 @@ const std::string& LLTaskInvFVBridge::getDisplayName() const bool mod = gAgent.allowOperation(PERM_MODIFY, perm, GP_OBJECT_MANIPULATE); bool xfer = gAgent.allowOperation(PERM_TRANSFER, perm, GP_OBJECT_MANIPULATE); - if(!copy) + if (!copy) { mDisplayName.append(LLTrans::getString("no_copy")); } - if(!mod) + if (!mod) { mDisplayName.append(LLTrans::getString("no_modify")); } - if(!xfer) + if (!xfer) { mDisplayName.append(LLTrans::getString("no_transfer")); } } mSearchableName.assign(mDisplayName + getLabelSuffix()); + LLStringUtil::toUpper(mSearchableName); return mDisplayName; } +// virtual const std::string& LLTaskInvFVBridge::getSearchableName() const { return mSearchableName; } - // BUG: No creation dates for task inventory time_t LLTaskInvFVBridge::getCreationDate() const { @@ -272,14 +269,14 @@ time_t LLTaskInvFVBridge::getCreationDate() const } void LLTaskInvFVBridge::setCreationDate(time_t creation_date_utc) -{} - +{ +} LLUIImagePtr LLTaskInvFVBridge::getIcon() const { - const bool item_is_multi = (mFlags & LLInventoryItemFlags::II_FLAGS_OBJECT_HAS_MULTIPLE_ITEMS); + const bool item_is_multi = mFlags & LLInventoryItemFlags::II_FLAGS_OBJECT_HAS_MULTIPLE_ITEMS; - return LLInventoryIcon::getIcon(mAssetType, mInventoryType, 0, item_is_multi ); + return LLInventoryIcon::getIcon(mAssetType, mInventoryType, 0, item_is_multi); } void LLTaskInvFVBridge::openItem() @@ -290,38 +287,38 @@ void LLTaskInvFVBridge::openItem() bool LLTaskInvFVBridge::isItemRenameable() const { - if(gAgent.isGodlike()) return true; - LLViewerObject* object = gObjectList.findObject(mPanel->getTaskUUID()); - if(object) + if (gAgent.isGodlike()) + return true; + + if (LLViewerObject* object = gObjectList.findObject(mPanel->getTaskUUID())) { - LLInventoryItem* item = (LLInventoryItem*)(object->getInventoryObject(mUUID)); - if(item && gAgent.allowOperation(PERM_MODIFY, item->getPermissions(), - GP_OBJECT_MANIPULATE, GOD_LIKE)) + if (LLInventoryItem* item = (LLInventoryItem*)(object->getInventoryObject(mUUID))) { - return true; + if (gAgent.allowOperation(PERM_MODIFY, item->getPermissions(), GP_OBJECT_MANIPULATE, GOD_LIKE)) + { + return true; + } } } + return false; } bool LLTaskInvFVBridge::renameItem(const std::string& new_name) { - LLViewerObject* object = gObjectList.findObject(mPanel->getTaskUUID()); - if(object) + if (LLViewerObject* object = gObjectList.findObject(mPanel->getTaskUUID())) { - LLViewerInventoryItem* item = NULL; - item = (LLViewerInventoryItem*)object->getInventoryObject(mUUID); - if(item && (gAgent.allowOperation(PERM_MODIFY, item->getPermissions(), - GP_OBJECT_MANIPULATE, GOD_LIKE))) + if (LLViewerInventoryItem* item = (LLViewerInventoryItem*)object->getInventoryObject(mUUID)) { - LLPointer<LLViewerInventoryItem> new_item = new LLViewerInventoryItem(item); - new_item->rename(new_name); - object->updateInventory( - new_item, - TASK_INVENTORY_ITEM_KEY, - false); + if (gAgent.allowOperation(PERM_MODIFY, item->getPermissions(), GP_OBJECT_MANIPULATE, GOD_LIKE)) + { + LLPointer<LLViewerInventoryItem> new_item = new LLViewerInventoryItem(item); + new_item->rename(new_name); + object->updateInventory(new_item, TASK_INVENTORY_ITEM_KEY, false); + } } } + return true; } @@ -338,33 +335,35 @@ bool LLTaskInvFVBridge::isItemMovable() const bool LLTaskInvFVBridge::isItemRemovable(bool check_worn) const { - const LLViewerObject* object = gObjectList.findObject(mPanel->getTaskUUID()); - if(object - && (object->permModify() || object->permYouOwner())) + if (const LLViewerObject* object = gObjectList.findObject(mPanel->getTaskUUID())) { - return true; + return object->permModify() || object->permYouOwner(); } + return false; } bool remove_task_inventory_callback(const LLSD& notification, const LLSD& response, LLPanelObjectInventory* panel) { S32 option = LLNotificationsUtil::getSelectedOption(notification, response); - LLViewerObject* object = gObjectList.findObject(notification["payload"]["task_id"].asUUID()); - if(option == 0 && object) - { - // yes - LLSD::array_const_iterator list_end = notification["payload"]["inventory_ids"].endArray(); - for (LLSD::array_const_iterator list_it = notification["payload"]["inventory_ids"].beginArray(); - list_it != list_end; - ++list_it) + if (option == 0) + { + if (LLViewerObject* object = gObjectList.findObject(notification["payload"]["task_id"].asUUID())) { - object->removeInventory(list_it->asUUID()); - } + // yes + const LLSD& inventory_ids = notification["payload"]["inventory_ids"]; + LLSD::array_const_iterator list_it = inventory_ids.beginArray(); + LLSD::array_const_iterator list_end = inventory_ids.endArray(); + for (; list_it != list_end; ++list_it) + { + object->removeInventory(list_it->asUUID()); + } - // refresh the UI. - panel->refresh(); + // refresh the UI. + panel->refresh(); + } } + return false; } @@ -374,31 +373,29 @@ typedef std::pair<LLUUID, std::list<LLUUID> > panel_two_uuids_list_t; typedef std::pair<LLPanelObjectInventory*, panel_two_uuids_list_t> remove_data_t; bool LLTaskInvFVBridge::removeItem() { - if(isItemRemovable() && mPanel) + if (isItemRemovable() && mPanel) { - LLViewerObject* object = gObjectList.findObject(mPanel->getTaskUUID()); - if(object) + if (LLViewerObject* object = gObjectList.findObject(mPanel->getTaskUUID())) { - if(object->permModify()) + if (object->permModify()) { // just do it. object->removeInventory(mUUID); return true; } - else - { - LLSD payload; - payload["task_id"] = mPanel->getTaskUUID(); - payload["inventory_ids"].append(mUUID); - LLNotificationsUtil::add("RemoveItemWarn", LLSD(), payload, boost::bind(&remove_task_inventory_callback, _1, _2, mPanel)); - return false; - } + + LLSD payload; + payload["task_id"] = mPanel->getTaskUUID(); + payload["inventory_ids"].append(mUUID); + LLNotificationsUtil::add("RemoveItemWarn", LLSD(), payload, boost::bind(&remove_task_inventory_callback, _1, _2, mPanel)); + return false; } } + return false; } -void LLTaskInvFVBridge::removeBatch(std::vector<LLFolderViewModelItem*>& batch) +void LLTaskInvFVBridge::removeBatch(std::vector<LLFolderViewModelItem*>& batch) { if (!mPanel) { @@ -415,24 +412,21 @@ void LLTaskInvFVBridge::removeBatch(std::vector<LLFolderViewModelItem*>& batch { LLSD payload; payload["task_id"] = mPanel->getTaskUUID(); - for (S32 i = 0; i < (S32)batch.size(); i++) + for (LLFolderViewModelItem* item : batch) { - LLTaskInvFVBridge* itemp = (LLTaskInvFVBridge*)batch[i]; - payload["inventory_ids"].append(itemp->getUUID()); + payload["inventory_ids"].append(((LLTaskInvFVBridge*)item)->getUUID()); } LLNotificationsUtil::add("RemoveItemWarn", LLSD(), payload, boost::bind(&remove_task_inventory_callback, _1, _2, mPanel)); - } else { - for (S32 i = 0; i < (S32)batch.size(); i++) + for (LLFolderViewModelItem* item : batch) { - LLTaskInvFVBridge* itemp = (LLTaskInvFVBridge*)batch[i]; - - if(itemp->isItemRemovable()) + LLTaskInvFVBridge* bridge = (LLTaskInvFVBridge*)item; + if (bridge->isItemRemovable()) { - // just do it. - object->removeInventory(itemp->getUUID()); + // Just do it. + object->removeInventory(bridge->getUUID()); } } } @@ -444,10 +438,12 @@ void LLTaskInvFVBridge::move(LLFolderViewModelItem* parent_listener) bool LLTaskInvFVBridge::isItemCopyable(bool can_link) const { - LLInventoryItem* item = findItem(); - if(!item) return false; - return gAgent.allowOperation(PERM_COPY, item->getPermissions(), - GP_OBJECT_MANIPULATE); + if (LLInventoryItem* item = findItem()) + { + return gAgent.allowOperation(PERM_COPY, item->getPermissions(), GP_OBJECT_MANIPULATE); + } + + return false; } bool LLTaskInvFVBridge::copyToClipboard() const @@ -476,38 +472,35 @@ void LLTaskInvFVBridge::pasteLinkFromClipboard() bool LLTaskInvFVBridge::startDrag(EDragAndDropType* type, LLUUID* id) const { //LL_INFOS() << "LLTaskInvFVBridge::startDrag()" << LL_ENDL; - if(mPanel) + if (!mPanel) + return false; + + if (LLViewerObject* object = gObjectList.findObject(mPanel->getTaskUUID())) { - LLViewerObject* object = gObjectList.findObject(mPanel->getTaskUUID()); - if(object) + if (LLInventoryItem* inv = (LLInventoryItem*)object->getInventoryObject(mUUID)) { - LLInventoryItem* inv = NULL; - if((inv = (LLInventoryItem*)object->getInventoryObject(mUUID))) + const LLPermissions& perm = inv->getPermissions(); + bool can_copy = gAgent.allowOperation(PERM_COPY, perm, GP_OBJECT_MANIPULATE); + if (!can_copy && object->isAttachment()) { - const LLPermissions& perm = inv->getPermissions(); - bool can_copy = gAgent.allowOperation(PERM_COPY, perm, - GP_OBJECT_MANIPULATE); - if (object->isAttachment() && !can_copy) - { - //RN: no copy contents of attachments cannot be dragged out - // due to a race condition and possible exploit where - // attached objects do not update their inventory items - // when their contents are manipulated - return false; - } - if((can_copy && perm.allowTransferTo(gAgent.getID())) - || object->permYouOwner()) -// || gAgent.isGodlike()) - - { - *type = LLViewerAssetType::lookupDragAndDropType(inv->getType()); + //RN: no copy contents of attachments cannot be dragged out + // due to a race condition and possible exploit where + // attached objects do not update their inventory items + // when their contents are manipulated + return false; + } - *id = inv->getUUID(); - return true; - } + if ((can_copy && perm.allowTransferTo(gAgent.getID())) + || object->permYouOwner()) +// || gAgent.isGodlike()) + { + *type = LLViewerAssetType::lookupDragAndDropType(inv->getType()); + *id = inv->getUUID(); + return true; } } } + return false; } @@ -554,7 +547,7 @@ void LLTaskInvFVBridge::buildContextMenu(LLMenuGL& menu, U32 flags) { disabled_items.push_back(std::string("Task Properties")); } - if(isItemRenameable()) + if (isItemRenameable()) { items.push_back(std::string("Task Rename")); if ((flags & FIRST_SELECTED_ITEM) == 0) @@ -562,7 +555,7 @@ void LLTaskInvFVBridge::buildContextMenu(LLMenuGL& menu, U32 flags) disabled_items.push_back(std::string("Task Rename")); } } - if(isItemRemovable()) + if (isItemRemovable()) { items.push_back(std::string("Task Remove")); } @@ -585,10 +578,10 @@ public: virtual LLUIImagePtr getIcon() const; virtual const std::string& getDisplayName() const; - virtual bool isItemRenameable() const; + virtual bool isItemRenameable() const { return false; } // virtual bool isItemCopyable() const { return false; } - virtual bool renameItem(const std::string& new_name); - virtual bool isItemRemovable(bool check_worn = true) const; + virtual bool renameItem(const std::string& new_name) { return false; } + virtual bool isItemRemovable(bool check_worn = true) const { return false; } virtual void buildContextMenu(LLMenuGL& menu, U32 flags); virtual bool hasChildren() const; virtual bool startDrag(EDragAndDropType* type, LLUUID* id) const; @@ -609,6 +602,7 @@ LLTaskCategoryBridge::LLTaskCategoryBridge( { } +// virtual LLUIImagePtr LLTaskCategoryBridge::getIcon() const { return LLUI::getUIImage("Inv_FolderClosed"); @@ -617,9 +611,7 @@ LLUIImagePtr LLTaskCategoryBridge::getIcon() const // virtual const std::string& LLTaskCategoryBridge::getDisplayName() const { - LLInventoryObject* cat = findInvObject(); - - if (cat) + if (LLInventoryObject* cat = findInvObject()) { std::string name = cat->getName(); if (mChildren.size() > 0) @@ -633,26 +625,13 @@ const std::string& LLTaskCategoryBridge::getDisplayName() const name.append(" " + LLTrans::getString("InventoryItemsCount", args)); } mDisplayName.assign(name); + LLStringUtil::toUpper(name); + mSearchableName.assign(name); } return mDisplayName; } -bool LLTaskCategoryBridge::isItemRenameable() const -{ - return false; -} - -bool LLTaskCategoryBridge::renameItem(const std::string& new_name) -{ - return false; -} - -bool LLTaskCategoryBridge::isItemRemovable(bool check_worn) const -{ - return false; -} - void LLTaskCategoryBridge::buildContextMenu(LLMenuGL& menu, U32 flags) { std::vector<std::string> items; @@ -660,6 +639,7 @@ void LLTaskCategoryBridge::buildContextMenu(LLMenuGL& menu, U32 flags) hide_context_entries(menu, items, disabled_items); } +// virtual bool LLTaskCategoryBridge::hasChildren() const { // return true if we have or do know know if we have children. @@ -667,20 +647,21 @@ bool LLTaskCategoryBridge::hasChildren() const return false; } +// virtual void LLTaskCategoryBridge::openItem() { } +// virtual bool LLTaskCategoryBridge::startDrag(EDragAndDropType* type, LLUUID* id) const { //LL_INFOS() << "LLTaskInvFVBridge::startDrag()" << LL_ENDL; - if(mPanel && mUUID.notNull()) + if (mPanel && mUUID.notNull()) { - LLViewerObject* object = gObjectList.findObject(mPanel->getTaskUUID()); - if(object) + if (LLViewerObject* object = gObjectList.findObject(mPanel->getTaskUUID())) { const LLInventoryObject* cat = object->getInventoryObject(mUUID); - if ( (cat) && (move_inv_category_world_to_agent(mUUID, LLUUID::null, false)) ) + if (cat && move_inv_category_world_to_agent(mUUID, LLUUID::null, false)) { *type = LLViewerAssetType::lookupDragAndDropType(cat->getType()); *id = mUUID; @@ -691,6 +672,7 @@ bool LLTaskCategoryBridge::startDrag(EDragAndDropType* type, LLUUID* id) const return false; } +// virtual bool LLTaskCategoryBridge::dragOrDrop(MASK mask, bool drop, EDragAndDropType cargo_type, void* cargo_data, @@ -775,14 +757,13 @@ public: virtual void openItem(); }; +// virtual void LLTaskTextureBridge::openItem() { LL_INFOS() << "LLTaskTextureBridge::openItem()" << LL_ENDL; - LLPreviewTexture* preview = LLFloaterReg::showTypedInstance<LLPreviewTexture>("preview_texture", LLSD(mUUID), TAKE_FOCUS_YES); - if(preview) + if (LLPreviewTexture* preview = LLFloaterReg::showTypedInstance<LLPreviewTexture>("preview_texture", LLSD(mUUID), TAKE_FOCUS_YES)) { - LLInventoryItem* item = findItem(); - if(item) + if (LLInventoryItem* item = findItem()) { preview->setAuxItem(item); } @@ -810,11 +791,13 @@ public: static void openSoundPreview(void* data); }; +// virtual void LLTaskSoundBridge::openItem() { openSoundPreview((void*)this); } +// static void LLTaskSoundBridge::openSoundPreview(void* data) { LLTaskSoundBridge* self = (LLTaskSoundBridge*)data; @@ -842,6 +825,7 @@ void LLTaskSoundBridge::performAction(LLInventoryModel* model, std::string actio LLTaskInvFVBridge::performAction(model, action); } +// virtual void LLTaskSoundBridge::buildContextMenu(LLMenuGL& menu, U32 flags) { LLInventoryItem* item = findItem(); @@ -865,18 +849,17 @@ void LLTaskSoundBridge::buildContextMenu(LLMenuGL& menu, U32 flags) { disabled_items.push_back(std::string("Task Properties")); } - if(isItemRenameable()) + if (isItemRenameable()) { items.push_back(std::string("Task Rename")); } - if(isItemRemovable()) + if (isItemRemovable()) { items.push_back(std::string("Task Remove")); } items.push_back(std::string("Task Play")); - hide_context_entries(menu, items, disabled_items); } @@ -905,20 +888,10 @@ public: const std::string& name) : LLTaskInvFVBridge(panel, uuid, name) {} - virtual bool isItemRenameable() const; - virtual bool renameItem(const std::string& new_name); + virtual bool isItemRenameable() const { return false; } + virtual bool renameItem(const std::string& new_name) { return false; } }; -bool LLTaskCallingCardBridge::isItemRenameable() const -{ - return false; -} - -bool LLTaskCallingCardBridge::renameItem(const std::string& new_name) -{ - return false; -} - ///---------------------------------------------------------------------------- /// Class LLTaskScriptBridge @@ -951,6 +924,7 @@ public: //static void copyToInventory(void* userdata); }; +// virtual void LLTaskLSLBridge::openItem() { LL_INFOS() << "LLTaskLSLBridge::openItem() " << mUUID << LL_ENDL; @@ -982,6 +956,7 @@ void LLTaskLSLBridge::openItem() } } +// virtual bool LLTaskLSLBridge::removeItem() { LLFloaterReg::hideInstance("preview_scriptedit", LLSD(mUUID)); @@ -1019,6 +994,7 @@ public: virtual bool removeItem(); }; +// virtual void LLTaskNotecardBridge::openItem() { LLViewerObject* object = gObjectList.findObject(mPanel->getTaskUUID()); @@ -1045,6 +1021,7 @@ void LLTaskNotecardBridge::openItem() } } +// virtual bool LLTaskNotecardBridge::removeItem() { LLFloaterReg::hideInstance("preview_notecard", LLSD(mUUID)); @@ -1068,6 +1045,7 @@ public: virtual bool removeItem(); }; +// virtual void LLTaskGestureBridge::openItem() { LLViewerObject* object = gObjectList.findObject(mPanel->getTaskUUID()); @@ -1078,6 +1056,7 @@ void LLTaskGestureBridge::openItem() LLPreviewGesture::show(mUUID, mPanel->getTaskUUID()); } +// virtual bool LLTaskGestureBridge::removeItem() { // Don't need to deactivate gesture because gestures inside objects can never be active. @@ -1102,10 +1081,12 @@ public: virtual bool removeItem(); }; +// virtual void LLTaskAnimationBridge::openItem() { - LLViewerObject* object = gObjectList.findObject(mPanel->getTaskUUID()); - if(!object || object->isInventoryPending()) + const LLUUID& task_id = mPanel->getTaskUUID(); + LLViewerObject* object = gObjectList.findObject(task_id); + if (!object || object->isInventoryPending()) { return; } @@ -1117,6 +1098,7 @@ void LLTaskAnimationBridge::openItem() } } +// virtual bool LLTaskAnimationBridge::removeItem() { LLFloaterReg::hideInstance("preview_anim", LLSD(mUUID)); @@ -1139,6 +1121,7 @@ public: virtual LLUIImagePtr getIcon() const; }; +// virtual LLUIImagePtr LLTaskWearableBridge::getIcon() const { return LLInventoryIcon::getIcon(mAssetType, mInventoryType, mFlags, false ); @@ -1161,11 +1144,13 @@ public: virtual LLSettingsType::type_e getSettingsType() const; }; +// virtual LLUIImagePtr LLTaskSettingsBridge::getIcon() const { return LLInventoryIcon::getIcon(mAssetType, mInventoryType, mFlags, false); } +// virtual LLSettingsType::type_e LLTaskSettingsBridge::getSettingsType() const { return LLSettingsType::ST_NONE; @@ -1188,6 +1173,7 @@ public: bool removeItem() override; }; +// virtual void LLTaskMaterialBridge::openItem() { LLViewerObject* object = gObjectList.findObject(mPanel->getTaskUUID()); @@ -1216,13 +1202,13 @@ void LLTaskMaterialBridge::openItem() } } +// virtual bool LLTaskMaterialBridge::removeItem() { LLFloaterReg::hideInstance("material_editor", LLSD(mUUID)); return LLTaskInvFVBridge::removeItem(); } - ///---------------------------------------------------------------------------- /// LLTaskInvFVBridge impl //---------------------------------------------------------------------------- @@ -1402,7 +1388,6 @@ void LLPanelObjectInventory::clearContents() } } - void LLPanelObjectInventory::reset() { clearContents(); @@ -1456,12 +1441,13 @@ void LLPanelObjectInventory::inventoryChanged(LLViewerObject* object, S32 serial_num, void* data) { - if(!object) return; + if (!object) + return; //LL_INFOS() << "invetnory arrived: \n" // << " panel UUID: " << panel->mTaskUUID << "\n" // << " task UUID: " << object->mID << LL_ENDL; - if(mTaskUUID == object->mID) + if (mTaskUUID == object->mID) { mInventoryNeedsUpdate = true; } @@ -1473,23 +1459,19 @@ void LLPanelObjectInventory::updateInventory() // << " panel UUID: " << panel->mTaskUUID << "\n" // << " task UUID: " << object->mID << LL_ENDL; // We're still interested in this task's inventory. + bool inventory_has_focus = mHaveInventory && mFolders && gFocusMgr.childHasKeyboardFocus(mFolders); + std::vector<LLUUID> selected_item_ids; - std::set<LLFolderViewItem*> selected_items; - bool inventory_has_focus = false; if (mHaveInventory && mFolders) { - selected_items = mFolders->getSelectionList(); - inventory_has_focus = gFocusMgr.childHasKeyboardFocus(mFolders); - } - for (std::set<LLFolderViewItem*>::iterator it = selected_items.begin(), end_it = selected_items.end(); - it != end_it; - ++it) - { - selected_item_ids.push_back(static_cast<LLFolderViewModelItemInventory*>((*it)->getViewModelItem())->getUUID()); + std::set<LLFolderViewItem*> selected_items = mFolders->getSelectionList(); + for (LLFolderViewItem* item : selected_items) + { + selected_item_ids.push_back(static_cast<LLFolderViewModelItemInventory*>(item->getViewModelItem())->getUUID()); + } } - LLViewerObject* objectp = gObjectList.findObject(mTaskUUID); - if (objectp) + if (LLViewerObject* objectp = gObjectList.findObject(mTaskUUID)) { LLInventoryObject* inventory_root = objectp->getInventoryRoot(); LLInventoryObject::object_list_t contents; @@ -1525,15 +1507,12 @@ void LLPanelObjectInventory::updateInventory() } // restore previous selection - std::vector<LLUUID>::iterator selection_it; bool first_item = true; - for (selection_it = selected_item_ids.begin(); selection_it != selected_item_ids.end(); ++selection_it) + for (const LLUUID& item_id : selected_item_ids) { - LLFolderViewItem* selected_item = getItemByID(*selection_it); - - if (selected_item) + if (LLFolderViewItem* selected_item = getItemByID(item_id)) { - //HACK: "set" first item then "change" each other one to get keyboard focus right + // HACK: "set" first item then "change" each other one to get keyboard focus right if (first_item) { mFolders->setSelection(selected_item, true, inventory_has_focus); @@ -1550,6 +1529,7 @@ void LLPanelObjectInventory::updateInventory() { mFolders->requestArrange(); } + mInventoryNeedsUpdate = false; // Edit menu handler is set in onFocusReceived } @@ -1565,10 +1545,9 @@ void LLPanelObjectInventory::createFolderViews(LLInventoryObject* inventory_root { return; } + // Create a visible root category. - LLTaskInvFVBridge* bridge = NULL; - bridge = LLTaskInvFVBridge::createObjectBridge(this, inventory_root); - if(bridge) + if (LLTaskInvFVBridge* bridge = LLTaskInvFVBridge::createObjectBridge(this, inventory_root)) { LLUIColor item_color = LLUIColorTable::instance().getColor("MenuItemEnabledColor", DEFAULT_WHITE); @@ -1611,59 +1590,50 @@ void LLPanelObjectInventory::createViewsForCategory(LLInventoryObject::object_li // Find all in the first pass std::vector<obj_folder_pair*> child_categories; - LLTaskInvFVBridge* bridge; - LLFolderViewItem* view; - - LLInventoryObject::object_list_t::iterator it = inventory->begin(); - LLInventoryObject::object_list_t::iterator end = inventory->end(); - for( ; it != end; ++it) + for (const LLPointer<LLInventoryObject>& obj : *inventory) { - LLInventoryObject* obj = *it; - - if(parent->getUUID() == obj->getParentUUID()) + if (parent->getUUID() == obj->getParentUUID()) { - bridge = LLTaskInvFVBridge::createObjectBridge(this, obj); - if(!bridge) + if (LLTaskInvFVBridge* bridge = LLTaskInvFVBridge::createObjectBridge(this, obj)) { - continue; - } - if(LLAssetType::AT_CATEGORY == obj->getType()) - { - LLFolderViewFolder::Params p; - p.name = obj->getName(); - p.root = mFolders; - p.listener = bridge; - p.tool_tip = p.name; - p.font_color = item_color; - p.font_highlight_color = item_color; - view = LLUICtrlFactory::create<LLFolderViewFolder>(p); - child_categories.push_back(new obj_folder_pair(obj, - (LLFolderViewFolder*)view)); - } - else - { - LLFolderViewItem::Params params; - params.name(obj->getName()); - params.creation_date(bridge->getCreationDate()); - params.root(mFolders); - params.listener(bridge); - params.rect(LLRect()); - params.tool_tip = params.name; - params.font_color = item_color; - params.font_highlight_color = item_color; - view = LLUICtrlFactory::create<LLFolderViewItem> (params); + LLFolderViewItem* view; + if (LLAssetType::AT_CATEGORY == obj->getType()) + { + LLFolderViewFolder::Params params; + params.name = obj->getName(); + params.root = mFolders; + params.listener = bridge; + params.tool_tip = params.name; + params.font_color = item_color; + params.font_highlight_color = item_color; + view = LLUICtrlFactory::create<LLFolderViewFolder>(params); + child_categories.push_back(new obj_folder_pair(obj, (LLFolderViewFolder*)view)); + } + else + { + LLFolderViewItem::Params params; + params.name = obj->getName(); + params.root = mFolders; + params.listener = bridge; + params.creation_date = bridge->getCreationDate(); + params.rect = LLRect(); + params.tool_tip = params.name; + params.font_color = item_color; + params.font_highlight_color = item_color; + view = LLUICtrlFactory::create<LLFolderViewItem>(params); + } + + view->addToFolder(folder); + addItemID(obj->getUUID(), view); } - view->addToFolder(folder); - addItemID(obj->getUUID(), view); } } // now, for each category, do the second pass - for(S32 i = 0; i < child_categories.size(); i++) + for (obj_folder_pair* pair : child_categories) { - createViewsForCategory(inventory, child_categories[i]->first, - child_categories[i]->second ); - delete child_categories[i]; + createViewsForCategory(inventory, pair->first, pair->second); + delete pair; } folder->setChildrenInited(true); } @@ -1675,11 +1645,10 @@ void LLPanelObjectInventory::refresh() const bool non_root_ok = true; LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection(); LLSelectNode* node = selection->getFirstRootNode(NULL, non_root_ok); - if(node && node->mValid) + if (node && node->mValid) { LLViewerObject* object = node->getObject(); - if(object && ((selection->getRootObjectCount() == 1) - || (selection->getObjectCount() == 1))) + if (object && ((selection->getRootObjectCount() == 1) || (selection->getObjectCount() == 1))) { // determine if we need to make a request. Start with a // default based on if we have inventory at all. @@ -1687,7 +1656,7 @@ void LLPanelObjectInventory::refresh() // If the task id is different than what we've stored, // then make the request. - if(mTaskUUID != object->mID) + if (mTaskUUID != object->mID) { mTaskUUID = object->mID; mAttachmentUUID = object->getAttachmentItemID(); @@ -1713,26 +1682,28 @@ void LLPanelObjectInventory::refresh() // Based on the node information, we may need to dirty the // object inventory and get it again. - if(node->mValid) + if (node->mValid) { - if(node->mInventorySerial != object->getInventorySerial() || object->isInventoryDirty()) + if (node->mInventorySerial != object->getInventorySerial() || object->isInventoryDirty()) { make_request = true; } } // do the request if necessary. - if(make_request) + if (make_request) { requestVOInventory(); } has_inventory = true; } } - if(!has_inventory) + + if (!has_inventory) { clearInventoryTask(); } + mInventoryViewModel.setTaskID(mTaskUUID); //LL_INFOS() << "LLPanelObjectInventory::refresh() " << mTaskUUID << LL_ENDL; } @@ -1747,7 +1718,7 @@ void LLPanelObjectInventory::clearInventoryTask() void LLPanelObjectInventory::removeSelectedItem() { - if(mFolders) + if (mFolders) { mFolders->removeSelectedItems(); } @@ -1755,7 +1726,7 @@ void LLPanelObjectInventory::removeSelectedItem() void LLPanelObjectInventory::startRenamingSelectedItem() { - if(mFolders) + if (mFolders) { mFolders->startRenamingSelectedItem(); } @@ -1765,25 +1736,26 @@ void LLPanelObjectInventory::draw() { LLPanel::draw(); - if(mIsInventoryEmpty) + if (mIsInventoryEmpty) { - if((LLUUID::null != mTaskUUID) && (!mHaveInventory)) + std::string text; + if (!mHaveInventory && mTaskUUID.notNull()) + { + text = LLTrans::getString("LoadingContents"); + } + else if (mHaveInventory) { - LLFontGL::getFontSansSerif()->renderUTF8(LLTrans::getString("LoadingContents"), 0, - (S32)(getRect().getWidth() * 0.5f), - 10, - LLColor4( 1, 1, 1, 1 ), - LLFontGL::HCENTER, - LLFontGL::BOTTOM); + text = LLTrans::getString("NoContents"); } - else if(mHaveInventory) + + if (!text.empty()) { - LLFontGL::getFontSansSerif()->renderUTF8(LLTrans::getString("NoContents"), 0, - (S32)(getRect().getWidth() * 0.5f), - 10, - LLColor4( 1, 1, 1, 1 ), - LLFontGL::HCENTER, - LLFontGL::BOTTOM); + LLFontGL::getFontSansSerif()->renderUTF8(text, 0, + (S32)(getRect().getWidth() * 0.5f), + 10, + LLColor4(1, 1, 1, 1), + LLFontGL::HCENTER, + LLFontGL::BOTTOM); } } } @@ -1797,31 +1769,21 @@ void LLPanelObjectInventory::deleteAllChildren() bool LLPanelObjectInventory::handleDragAndDrop(S32 x, S32 y, MASK mask, bool drop, EDragAndDropType cargo_type, void *cargo_data, EAcceptance *accept, std::string& tooltip_msg) { - if (mFolders) - { - LLFolderViewItem* folderp = mFolders->getNextFromChild(NULL); - if (!folderp) - { - return false; - } - // Try to pass on unmodified mouse coordinates - S32 local_x = x - mFolders->getRect().mLeft; - S32 local_y = y - mFolders->getRect().mBottom; + LLFolderViewItem* folderp = mFolders ? mFolders->getNextFromChild(NULL) : NULL; + if (!folderp) + return false; - if (mFolders->pointInView(local_x, local_y)) - { - return mFolders->handleDragAndDrop(local_x, local_y, mask, drop, cargo_type, cargo_data, accept, tooltip_msg); - } - else - { - //force mouse coordinates to be inside folder rectangle - return mFolders->handleDragAndDrop(5, 1, mask, drop, cargo_type, cargo_data, accept, tooltip_msg); - } - } - else + // Try to pass on unmodified mouse coordinates + S32 local_x = x - mFolders->getRect().mLeft; + S32 local_y = y - mFolders->getRect().mBottom; + + if (mFolders->pointInView(local_x, local_y)) { - return false; + return mFolders->handleDragAndDrop(local_x, local_y, mask, drop, cargo_type, cargo_data, accept, tooltip_msg); } + + //force mouse coordinates to be inside folder rectangle + return mFolders->handleDragAndDrop(5, 1, mask, drop, cargo_type, cargo_data, accept, tooltip_msg); } //static @@ -1858,11 +1820,9 @@ void LLPanelObjectInventory::onFocusReceived() LLPanel::onFocusReceived(); } - LLFolderViewItem* LLPanelObjectInventory::getItemByID( const LLUUID& id ) { - std::map<LLUUID, LLFolderViewItem*>::iterator map_it; - map_it = mItemMap.find(id); + std::map<LLUUID, LLFolderViewItem*>::iterator map_it = mItemMap.find(id); if (map_it != mItemMap.end()) { return map_it->second; @@ -1913,21 +1873,21 @@ bool LLPanelObjectInventory::isSelectionRemovable() { return false; } + std::set<LLFolderViewItem*> selection_set = mFolders->getRoot()->getSelectionList(); if (selection_set.empty()) { return false; } - for (std::set<LLFolderViewItem*>::iterator iter = selection_set.begin(); - iter != selection_set.end(); - ++iter) + + for (LLFolderViewItem* item : selection_set) { - LLFolderViewItem *item = *iter; const LLFolderViewModelItemInventory *listener = dynamic_cast<const LLFolderViewModelItemInventory*>(item->getViewModelItem()); if (!listener || !listener->isItemRemovable() || listener->isItemInTrash()) { return false; } } + return true; } diff --git a/indra/newview/llpanelobjectinventory.h b/indra/newview/llpanelobjectinventory.h index c150a841ae..abb48dbeed 100644 --- a/indra/newview/llpanelobjectinventory.h +++ b/indra/newview/llpanelobjectinventory.h @@ -73,6 +73,8 @@ public: void startRenamingSelectedItem(); LLFolderView* getRootFolder() const { return mFolders; } + LLInventoryFilter& getFilter() { return mInventoryViewModel.getFilter(); } + const LLInventoryFilter& getFilter() const { return mInventoryViewModel.getFilter(); } virtual void draw(); virtual void deleteAllChildren(); diff --git a/indra/newview/llsettingspicker.cpp b/indra/newview/llsettingspicker.cpp index 24cf543864..619882dc5e 100644 --- a/indra/newview/llsettingspicker.cpp +++ b/indra/newview/llsettingspicker.cpp @@ -98,7 +98,7 @@ bool LLFloaterSettingsPicker::postBuild() setTitle(prefix + " " + label); mFilterEdit = getChild<LLFilterEditor>(FLT_INVENTORY_SEARCH); - mFilterEdit->setCommitCallback([this](LLUICtrl*, const LLSD& param){ onFilterEdit(param.asString()); }); + mFilterEdit->setCommitCallback([this](LLUICtrl*, const LLSD& param) { onFilterEdit(param.asString()); }); mInventoryPanel = getChild<LLInventoryPanel>(PNL_INVENTORY); if (mInventoryPanel) @@ -203,7 +203,6 @@ void LLFloaterSettingsPicker::draw() LLFloater::draw(); } - //========================================================================= void LLFloaterSettingsPicker::onFilterEdit(const std::string& search_string) { @@ -224,7 +223,6 @@ void LLFloaterSettingsPicker::onFilterEdit(const std::string& search_string) LLOpenFoldersWithSelection opener; mInventoryPanel->getRootFolder()->applyFunctorRecursively(opener); mInventoryPanel->getRootFolder()->scrollToShowSelection(); - } else if (mInventoryPanel->getFilterSubString().empty()) { @@ -269,6 +267,7 @@ void LLFloaterSettingsPicker::onSelectionChange(const LLFloaterSettingsPicker::i } } } + bool track_picker_enabled = mTrackMode != TRACK_NONE; getChild<LLView>(CMB_TRACK_SELECTION)->setEnabled(is_item && track_picker_enabled && mSettingAssetID == asset_id); @@ -304,13 +303,14 @@ void LLFloaterSettingsPicker::onAssetLoaded(LLUUID asset_id, LLSettingsBase::ptr LLComboBox* track_selection = getChild<LLComboBox>(CMB_TRACK_SELECTION); track_selection->clear(); track_selection->removeall(); + if (!settings) { LL_WARNS() << "Failed to load asset " << asset_id << LL_ENDL; return; } - LLSettingsDay::ptr_t pday = std::dynamic_pointer_cast<LLSettingsDay>(settings); + LLSettingsDay::ptr_t pday = std::dynamic_pointer_cast<LLSettingsDay>(settings); if (!pday) { LL_WARNS() << "Wrong asset type received by id " << asset_id << LL_ENDL; diff --git a/indra/newview/llsidepanelinventory.cpp b/indra/newview/llsidepanelinventory.cpp index 5693f2808c..b48417bd71 100644 --- a/indra/newview/llsidepanelinventory.cpp +++ b/indra/newview/llsidepanelinventory.cpp @@ -387,7 +387,7 @@ void LLSidepanelInventory::onToggleInboxBtn() void LLSidepanelInventory::onOpen(const LLSD& key) { LLFirstUse::newInventory(false); - mPanelMainInventory->setFocusFilterEditor(); + mPanelMainInventory->setFocusOnFilterEditor(); #if AUTO_EXPAND_INBOX // Expand the inbox if we have fresh items LLPanelMarketplaceInbox * inbox = findChild<LLPanelMarketplaceInbox>(MARKETPLACE_INBOX_PANEL); diff --git a/indra/newview/llviewerobjectlist.h b/indra/newview/llviewerobjectlist.h index 7dfa94b99f..dc31995eb1 100644 --- a/indra/newview/llviewerobjectlist.h +++ b/indra/newview/llviewerobjectlist.h @@ -259,15 +259,16 @@ extern LLViewerObjectList gObjectList; */ inline LLViewerObject *LLViewerObjectList::findObject(const LLUUID &id) { + if (id.isNull()) + return NULL; + auto iter = mUUIDObjectMap.find(id); - if(iter != mUUIDObjectMap.end()) + if (iter != mUUIDObjectMap.end()) { return iter->second; } - else - { - return NULL; - } + + return NULL; } inline LLViewerObject *LLViewerObjectList::getObject(const S32 index) diff --git a/indra/newview/skins/default/xui/en/floater_tools.xml b/indra/newview/skins/default/xui/en/floater_tools.xml index e43143c8c3..d3a872c9d5 100644 --- a/indra/newview/skins/default/xui/en/floater_tools.xml +++ b/indra/newview/skins/default/xui/en/floater_tools.xml @@ -2774,7 +2774,7 @@ even though the user gets a free copy. label="New Script" label_selected="New Script" layout="topleft" - left="10" + left="8" name="button new script" top="10" width="134" /> @@ -2786,16 +2786,28 @@ even though the user gets a free copy. left_pad="8" name="button permissions" width="134" /> - <panel_inventory_object + <filter_editor + follows="left|top|right" + label="Enter filter text" + layout="topleft" + top="40" + left="10" + text_pad_left="10" + max_length_chars="300" + highlight_text_field="true" + name="contents_filter" + height="23" + width="275" /> + <panel_inventory_object border="true" border_visible="true" bevel_style="in" follows="left|top|right" - height="387" + height="367" layout="topleft" left="10" name="contents_inventory" - top="50" + top="70" width="275" /> </panel> </tab_container> |