summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
authorLoren Shih <seraph@lindenlab.com>2010-05-12 13:46:21 -0400
committerLoren Shih <seraph@lindenlab.com>2010-05-12 13:46:21 -0400
commitdbaaebfe5b2847a258019cd82a2abe044e3d3140 (patch)
tree8e18f997c0a5d1f9ecae88627bcac6c069a4d75a /indra/newview
parentf1c775b7be55731475796b6b3b63eef1b2e290ef (diff)
EXT-7319 : FIXED : INFRASTRUCTURE : LLInventoryBridge cleanup
Const correctness, logic cleanup, took out subclasses redefining same variable as base class (!!!).
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/llinventorybridge.cpp45
-rw-r--r--indra/newview/llinventorybridge.h99
-rw-r--r--indra/newview/llinventoryfunctions.cpp21
-rw-r--r--indra/newview/llinventoryfunctions.h2
4 files changed, 62 insertions, 105 deletions
diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp
index 64379f4ce7..973257b19c 100644
--- a/indra/newview/llinventorybridge.cpp
+++ b/indra/newview/llinventorybridge.cpp
@@ -997,46 +997,36 @@ void LLInvFVBridge::purgeItem(LLInventoryModel *model, const LLUUID &uuid)
}
}
-bool LLInvFVBridge::isInOutfitsSidePanel() const
+BOOL LLInvFVBridge::isInOutfitsSidePanel() const
{
LLInventoryPanel *my_panel = dynamic_cast<LLInventoryPanel*>(mInventoryPanel.get());
LLPanelOutfitsInventory *outfit_panel =
dynamic_cast<LLPanelOutfitsInventory*>(LLSideTray::getInstance()->getPanel("panel_outfits_inventory"));
if (!outfit_panel)
- return false;
+ return FALSE;
return outfit_panel->isTabPanel(my_panel);
}
-bool LLInvFVBridge::canShare()
+BOOL LLInvFVBridge::canShare() const
{
const LLInventoryModel* model = getInventoryModel();
- if(!model)
- {
- return false;
- }
+ if (!model) return FALSE;
- LLViewerInventoryItem *item = model->getItem(mUUID);
+ const LLViewerInventoryItem *item = model->getItem(mUUID);
if (item)
{
- bool allowed = false;
- allowed = LLInventoryCollectFunctor::itemTransferCommonlyAllowed(item);
- if (allowed &&
- !item->getPermissions().allowOperationBy(PERM_TRANSFER, gAgent.getID()))
- {
- allowed = false;
- }
- if (allowed &&
- !item->getPermissions().allowCopyBy(gAgent.getID()))
- {
- allowed = false;
- }
- return allowed;
+ if (!LLInventoryCollectFunctor::itemTransferCommonlyAllowed(item))
+ return FALSE;
+ if (!item->getPermissions().allowOperationBy(PERM_TRANSFER, gAgent.getID()))
+ return FALSE;
+ if (!item->getPermissions().allowCopyBy(gAgent.getID()))
+ return FALSE;
+ return TRUE;
}
- LLViewerInventoryCategory* cat = model->getCategory(mUUID);
-
// All categories can be given.
- return cat != NULL;
+ const LLViewerInventoryCategory* cat = model->getCategory(mUUID);
+ return (cat != NULL);
}
// +=================================================+
@@ -4095,12 +4085,11 @@ LLObjectBridge::LLObjectBridge(LLInventoryPanel* inventory,
const LLUUID& uuid,
LLInventoryType::EType type,
U32 flags) :
- LLItemBridge(inventory, root, uuid),
- mInvType(type)
+ LLItemBridge(inventory, root, uuid)
{
mAttachPt = (flags & 0xff); // low bye of inventory flags
-
mIsMultiObject = ( flags & LLInventoryItemFlags::II_FLAGS_OBJECT_HAS_MULTIPLE_ITEMS ) ? TRUE: FALSE;
+ mInvType = type;
}
LLUIImagePtr LLObjectBridge::getIcon() const
@@ -4447,9 +4436,9 @@ LLWearableBridge::LLWearableBridge(LLInventoryPanel* inventory,
LLWearableType::EType wearable_type) :
LLItemBridge(inventory, root, uuid),
mAssetType( asset_type ),
- mInvType(inv_type),
mWearableType(wearable_type)
{
+ mInvType = inv_type;
}
// *NOTE: hack to get from avatar inventory to avatar
diff --git a/indra/newview/llinventorybridge.h b/indra/newview/llinventorybridge.h
index 1c85dc8d7e..c5efefac7e 100644
--- a/indra/newview/llinventorybridge.h
+++ b/indra/newview/llinventorybridge.h
@@ -74,13 +74,19 @@ public:
U32 flags = 0x00);
virtual ~LLInvFVBridge() {}
- virtual const LLUUID& getUUID() const { return mUUID; }
+ BOOL isInOutfitsSidePanel() const; // allow context menus to be customized for side panel
+ BOOL canShare() const;
+ //--------------------------------------------------------------------
+ // LLInvFVBridge functionality
+ //--------------------------------------------------------------------
+ virtual const LLUUID& getUUID() const { return mUUID; }
+ virtual void clearDisplayName() {}
virtual void restoreItem() {}
virtual void restoreToWorld() {}
//--------------------------------------------------------------------
- // LLFolderViewEventListener functions
+ // Inherited LLFolderViewEventListener functions
//--------------------------------------------------------------------
virtual const std::string& getName() const;
virtual const std::string& getDisplayName() const;
@@ -99,7 +105,6 @@ public:
virtual BOOL isItemMovable() const;
virtual BOOL isItemInTrash() const;
virtual BOOL isLink() const;
-
//virtual BOOL removeItem() = 0;
virtual void removeBatch(LLDynamicArray<LLFolderViewEventListener*>& batch);
virtual void move(LLFolderViewEventListener* new_parent_bridge) {}
@@ -120,15 +125,6 @@ public:
virtual LLInventoryType::EType getInventoryType() const { return mInvType; }
//--------------------------------------------------------------------
- // LLInvFVBridge functionality
- //--------------------------------------------------------------------
- virtual void clearDisplayName() {}
-
- bool isInOutfitsSidePanel() const; // allow context menus to be customized for side panel
-
- bool canShare();
-
- //--------------------------------------------------------------------
// Convenience functions for adding various common menu options.
//--------------------------------------------------------------------
protected:
@@ -195,7 +191,6 @@ public:
LLInvFVBridge(inventory, root, uuid) {}
virtual void performAction(LLInventoryModel* model, std::string action);
-
virtual void selectItem();
virtual void restoreItem();
virtual void restoreToWorld();
@@ -214,20 +209,17 @@ public:
virtual BOOL hasChildren() const { return FALSE; }
virtual BOOL isUpToDate() const { return TRUE; }
- // Override for LLInvFVBridge
- virtual void clearDisplayName() { mDisplayName.clear(); }
+ /*virtual*/ void clearDisplayName() { mDisplayName.clear(); }
LLViewerInventoryItem* getItem() const;
-
bool isAddAction(std::string action) const;
bool isRemoveAction(std::string action) const;
-
protected:
+ BOOL confirmRemoveItem(const LLSD& notification, const LLSD& response);
virtual BOOL isItemPermissive() const;
static void buildDisplayName(LLInventoryItem* item, std::string& name);
- mutable std::string mDisplayName;
- BOOL confirmRemoveItem(const LLSD& notification, const LLSD& response);
+ mutable std::string mDisplayName;
};
class LLFolderBridge : public LLInvFVBridge
@@ -240,10 +232,9 @@ public:
mCallingCards(FALSE),
mWearables(FALSE),
mMenu(NULL) {}
- BOOL dragItemIntoFolder(LLInventoryItem* inv_item,
- BOOL drop);
- BOOL dragCategoryIntoFolder(LLInventoryCategory* inv_category,
- BOOL drop);
+ BOOL dragItemIntoFolder(LLInventoryItem* inv_item, BOOL drop);
+ BOOL dragCategoryIntoFolder(LLInventoryCategory* inv_category, BOOL drop);
+
virtual void performAction(LLInventoryModel* model, std::string action);
virtual void openItem();
virtual void closeItem();
@@ -311,10 +302,15 @@ protected:
menuentry_vec_t getMenuItems() { return mItems; } // returns a copy of current menu items
+
+ //--------------------------------------------------------------------
+ // Messy hacks for handling folder options
+ //--------------------------------------------------------------------
public:
static LLFolderBridge* sSelf;
static void staticFolderOptionsMenu();
void folderOptionsMenu();
+
private:
BOOL mCallingCards;
BOOL mWearables;
@@ -330,15 +326,15 @@ public:
LLFolderView* root,
const LLUUID& uuid,
LLInventoryType::EType type) :
- LLItemBridge(inventory, root, uuid),
- mInvType(type) {}
+ LLItemBridge(inventory, root, uuid)
+ {
+ mInvType = type;
+ }
virtual LLUIImagePtr getIcon() const;
virtual void openItem();
virtual void buildContextMenu(LLMenuGL& menu, U32 flags);
virtual void performAction(LLInventoryModel* model, std::string action);
-
bool canSaveTexture(void);
- LLInventoryType::EType mInvType;
};
class LLSoundBridge : public LLItemBridge
@@ -447,8 +443,7 @@ public:
virtual BOOL renameItem(const std::string& new_name);
LLInventoryObject* getObject() const;
protected:
- static LLUUID sContextMenuItemID; // Only valid while the context menu is open.
- LLInventoryType::EType mInvType;
+ static LLUUID sContextMenuItemID; // Only valid while the context menu is open.
U32 mAttachPt;
BOOL mIsMultiObject;
};
@@ -499,7 +494,6 @@ public:
void removeFromAvatar();
protected:
LLAssetType::EType mAssetType;
- LLInventoryType::EType mInvType;
LLWearableType::EType mWearableType;
};
@@ -563,47 +557,33 @@ protected:
LLInventoryModel* mModel;
};
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// Recent Inventory Panel related classes
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-/************************************************************************/
-/* Recent Inventory Panel related classes */
-/************************************************************************/
-class LLRecentInventoryBridgeBuilder;
-/**
- * Overridden version of the Inventory-Folder-View-Bridge for Folders
- */
+// Overridden version of the Inventory-Folder-View-Bridge for Folders
class LLRecentItemsFolderBridge : public LLFolderBridge
{
- friend class LLRecentInventoryBridgeBuilder;
-
public:
- /**
- * Creates context menu for Folders related to Recent Inventory Panel.
- *
- * It uses base logic and than removes from visible items "New..." menu items.
- */
- /*virtual*/ void buildContextMenu(LLMenuGL& menu, U32 flags);
-
-protected:
+ // Creates context menu for Folders related to Recent Inventory Panel.
+ // Uses base logic and than removes from visible items "New..." menu items.
LLRecentItemsFolderBridge(LLInventoryType::EType type,
- LLInventoryPanel* inventory,
- LLFolderView* root,
- const LLUUID& uuid) :
+ LLInventoryPanel* inventory,
+ LLFolderView* root,
+ const LLUUID& uuid) :
LLFolderBridge(inventory, root, uuid)
{
mInvType = type;
}
+ /*virtual*/ void buildContextMenu(LLMenuGL& menu, U32 flags);
};
-/**
- * Bridge builder to create Inventory-Folder-View-Bridge for Recent Inventory Panel
- */
+// Bridge builder to create Inventory-Folder-View-Bridge for Recent Inventory Panel
class LLRecentInventoryBridgeBuilder : public LLInventoryFVBridgeBuilder
{
- /**
- * Overrides FolderBridge for Recent Inventory Panel.
- *
- * It use base functionality for bridges other than FolderBridge.
- */
+public:
+ // Overrides FolderBridge for Recent Inventory Panel.
+ // It use base functionality for bridges other than FolderBridge.
virtual LLInvFVBridge* createBridge(LLAssetType::EType asset_type,
LLAssetType::EType actual_asset_type,
LLInventoryType::EType inv_type,
@@ -611,11 +591,8 @@ class LLRecentInventoryBridgeBuilder : public LLInventoryFVBridgeBuilder
LLFolderView* root,
const LLUUID& uuid,
U32 flags = 0x00) const;
-
};
-
-
void wear_inventory_item_on_avatar(LLInventoryItem* item);
void rez_attachment(LLViewerInventoryItem* item,
diff --git a/indra/newview/llinventoryfunctions.cpp b/indra/newview/llinventoryfunctions.cpp
index 35ad8b64da..f1520d34df 100644
--- a/indra/newview/llinventoryfunctions.cpp
+++ b/indra/newview/llinventoryfunctions.cpp
@@ -92,39 +92,30 @@ LLUUID LLInventoryState::sWearNewClothingTransactionID;
///----------------------------------------------------------------------------
// static
-bool LLInventoryCollectFunctor::itemTransferCommonlyAllowed(LLInventoryItem* item)
+bool LLInventoryCollectFunctor::itemTransferCommonlyAllowed(const LLInventoryItem* item)
{
if (!item)
return false;
- bool allowed = false;
-
switch(item->getType())
{
case LLAssetType::AT_CALLINGCARD:
- // not allowed
+ return false;
break;
-
case LLAssetType::AT_OBJECT:
if (isAgentAvatarValid() && !gAgentAvatarp->isWearingAttachment(item->getUUID()))
- {
- allowed = true;
- }
+ return true;
break;
-
case LLAssetType::AT_BODYPART:
case LLAssetType::AT_CLOTHING:
if(!gAgentWearables.isWearingItem(item->getUUID()))
- {
- allowed = true;
- }
+ return true;
break;
default:
- allowed = true;
+ return true;
break;
}
-
- return allowed;
+ return false;
}
bool LLIsType::operator()(LLInventoryCategory* cat, LLInventoryItem* item)
diff --git a/indra/newview/llinventoryfunctions.h b/indra/newview/llinventoryfunctions.h
index 1e2b4ff09c..02a5fc9224 100644
--- a/indra/newview/llinventoryfunctions.h
+++ b/indra/newview/llinventoryfunctions.h
@@ -58,7 +58,7 @@ public:
virtual ~LLInventoryCollectFunctor(){};
virtual bool operator()(LLInventoryCategory* cat, LLInventoryItem* item) = 0;
- static bool itemTransferCommonlyAllowed(LLInventoryItem* item);
+ static bool itemTransferCommonlyAllowed(const LLInventoryItem* item);
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~