summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
authorVadim ProductEngine <vsavchuk@productengine.com>2010-09-28 22:14:22 +0300
committerVadim ProductEngine <vsavchuk@productengine.com>2010-09-28 22:14:22 +0300
commitb0cadec6fbd3c8d0ca21d5804061d2ce366b52dc (patch)
treeffcc103ffa227e52134ce414fdfb0766db2b2626 /indra/newview
parentdf290ee4d45481144e7cc7675d11575b0eea2c78 (diff)
STORM-248 FIXED The 'Share' button in My Inventory now respects multiple selection.
- The button is now enabled only if all selected items are shareable. (it had checked only one currently selected item) - Eliminated some copy&paste.
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/llavataractions.cpp80
-rw-r--r--indra/newview/llavataractions.h11
-rw-r--r--indra/newview/llsidepanelinventory.cpp19
3 files changed, 85 insertions, 25 deletions
diff --git a/indra/newview/llavataractions.cpp b/indra/newview/llavataractions.cpp
index b9ae976e58..79b0c63b38 100644
--- a/indra/newview/llavataractions.cpp
+++ b/indra/newview/llavataractions.cpp
@@ -49,6 +49,7 @@
#include "llfloaterpay.h"
#include "llfloaterworldmap.h"
#include "llgiveinventory.h"
+#include "llinventorybridge.h"
#include "llinventorymodel.h" // for gInventory.findCategoryUUIDForType
#include "llinventorypanel.h"
#include "llimview.h" // for gIMMgr
@@ -443,17 +444,27 @@ namespace action_give_inventory
}
/**
- * Checks My Inventory visibility.
+ * @return active inventory panel, or NULL if there's no such panel
*/
- static bool is_give_inventory_acceptable()
+ static LLInventoryPanel* get_active_inventory_panel()
{
LLInventoryPanel* active_panel = LLInventoryPanel::getActiveInventoryPanel(FALSE);
if (!active_panel)
{
active_panel = get_outfit_editor_inventory_panel();
- if (!active_panel) return false;
}
+ return active_panel;
+ }
+
+ /**
+ * Checks My Inventory visibility.
+ */
+ static bool is_give_inventory_acceptable()
+ {
+ LLInventoryPanel* active_panel = get_active_inventory_panel();
+ if (!active_panel) return false;
+
// check selection in the panel
const uuid_set_t inventory_selected_uuids = active_panel->getRootFolder()->getSelectionList();
if (inventory_selected_uuids.empty()) return false; // nothing selected
@@ -543,12 +554,8 @@ namespace action_give_inventory
return;
}
- LLInventoryPanel* active_panel = LLInventoryPanel::getActiveInventoryPanel(FALSE);
- if (!active_panel)
- {
- active_panel = get_outfit_editor_inventory_panel();
- if (!active_panel) return;
- }
+ LLInventoryPanel* active_panel = get_active_inventory_panel();
+ if (!active_panel) return;
const uuid_set_t inventory_selected_uuids = active_panel->getRootFolder()->getSelectionList();
if (inventory_selected_uuids.empty())
@@ -632,12 +639,8 @@ namespace action_give_inventory
llassert(avatar_names.size() == avatar_uuids.size());
- LLInventoryPanel* active_panel = LLInventoryPanel::getActiveInventoryPanel(FALSE);
- if (!active_panel)
- {
- active_panel = get_outfit_editor_inventory_panel();
- if (!active_panel) return;
- }
+ LLInventoryPanel* active_panel = get_active_inventory_panel();
+ if (!active_panel) return;
const uuid_set_t inventory_selected_uuids = active_panel->getRootFolder()->getSelectionList();
if (inventory_selected_uuids.empty())
@@ -672,6 +675,53 @@ void LLAvatarActions::shareWithAvatars()
LLNotificationsUtil::add("ShareNotification");
}
+
+// static
+bool LLAvatarActions::canShareSelectedItems(LLInventoryPanel* inv_panel /* = NULL*/)
+{
+ using namespace action_give_inventory;
+
+ if (!inv_panel)
+ {
+ LLInventoryPanel* active_panel = get_active_inventory_panel();
+ if (!active_panel) return false;
+ inv_panel = active_panel;
+ }
+
+ // check selection in the panel
+ LLFolderView* root_folder = inv_panel->getRootFolder();
+ const uuid_set_t inventory_selected_uuids = root_folder->getSelectionList();
+ if (inventory_selected_uuids.empty()) return false; // nothing selected
+
+ bool can_share = true;
+ uuid_set_t::const_iterator it = inventory_selected_uuids.begin();
+ const uuid_set_t::const_iterator it_end = inventory_selected_uuids.end();
+ for (; it != it_end; ++it)
+ {
+ LLViewerInventoryCategory* inv_cat = gInventory.getCategory(*it);
+ // any category can be offered.
+ if (inv_cat)
+ {
+ continue;
+ }
+
+ // check if inventory item can be given
+ LLFolderViewItem* item = root_folder->getItemByID(*it);
+ if (!item) return false;
+ LLInvFVBridge* bridge = dynamic_cast<LLInvFVBridge*>(item->getListener());
+ if (bridge && bridge->canShare())
+ {
+ continue;
+ }
+
+ // there are neither item nor category in inventory
+ can_share = false;
+ break;
+ }
+
+ return can_share;
+}
+
// static
void LLAvatarActions::toggleBlock(const LLUUID& id)
{
diff --git a/indra/newview/llavataractions.h b/indra/newview/llavataractions.h
index 6313ae0759..44bd3778da 100644
--- a/indra/newview/llavataractions.h
+++ b/indra/newview/llavataractions.h
@@ -34,6 +34,8 @@
#include <string>
#include <vector>
+class LLInventoryPanel;
+
/**
* Friend-related actions (add, remove, offer teleport, etc)
*/
@@ -183,6 +185,15 @@ public:
*/
static bool canOfferTeleport(const uuid_vec_t& ids);
+ /**
+ * Checks whether all items selected in the given inventory panel can be shared
+ *
+ * @param inv_panel Inventory panel to get selection from. If NULL, the active inventory panel is used.
+ *
+ * @return false if the selected items cannot be shared or the active inventory panel cannot be obtained
+ */
+ static bool canShareSelectedItems(LLInventoryPanel* inv_panel = NULL);
+
private:
static bool callbackAddFriend(const LLSD& notification, const LLSD& response);
static bool callbackAddFriendWithMessage(const LLSD& notification, const LLSD& response);
diff --git a/indra/newview/llsidepanelinventory.cpp b/indra/newview/llsidepanelinventory.cpp
index 23e96c22fa..1e585ece23 100644
--- a/indra/newview/llsidepanelinventory.cpp
+++ b/indra/newview/llsidepanelinventory.cpp
@@ -311,18 +311,17 @@ bool LLSidepanelInventory::canShare()
LLPanelMainInventory* panel_main_inventory =
mInventoryPanel->findChild<LLPanelMainInventory>("panel_main_inventory");
- LLFolderView* root_folder =
- panel_main_inventory->getActivePanel()->getRootFolder();
-
- LLFolderViewItem* current_item = root_folder->hasVisibleChildren()
- ? root_folder->getCurSelectedItem()
- : NULL;
+ if (!panel_main_inventory)
+ {
+ llwarns << "Failed to get the main inventory panel" << llendl;
+ return false;
+ }
- LLInvFVBridge* bridge = current_item
- ? dynamic_cast <LLInvFVBridge*> (current_item->getListener())
- : NULL;
+ LLInventoryPanel* active_panel = panel_main_inventory->getActivePanel();
+ // Avoid flicker in the Recent tab while inventory is being loaded.
+ if (!active_panel->getRootFolder()->hasVisibleChildren()) return false;
- return bridge ? bridge->canShare() : false;
+ return LLAvatarActions::canShareSelectedItems(active_panel);
}
LLInventoryItem *LLSidepanelInventory::getSelectedItem()