summaryrefslogtreecommitdiff
path: root/indra/newview/llfavoritesbar.cpp
diff options
context:
space:
mode:
authorSteven Bennetts <steve@lindenlab.com>2009-09-09 04:12:50 +0000
committerSteven Bennetts <steve@lindenlab.com>2009-09-09 04:12:50 +0000
commit579d8447d3269fc6ed747774f1b612a88d850781 (patch)
treedb741511a681ae711aecb665b5be1eb6fdd4e062 /indra/newview/llfavoritesbar.cpp
parentbc022a04605c1e0f3c08dfc75c6f49fc9def02c7 (diff)
merge merge https://svn.aws.productengine.com/secondlife/export-from-ll/viewer-2-0@1581 https://svn.aws.productengine.com/secondlife/pe/stable-2@1585 -> viewer-2.0.0-3
* Bugs: EXT-838 EXT-815 EXT-872 * New Dev: IM Floater Docking
Diffstat (limited to 'indra/newview/llfavoritesbar.cpp')
-rw-r--r--indra/newview/llfavoritesbar.cpp56
1 files changed, 52 insertions, 4 deletions
diff --git a/indra/newview/llfavoritesbar.cpp b/indra/newview/llfavoritesbar.cpp
index df2bf53a05..ef71e35254 100644
--- a/indra/newview/llfavoritesbar.cpp
+++ b/indra/newview/llfavoritesbar.cpp
@@ -218,6 +218,36 @@ private:
LLSLURLGetter mUrlGetter;
};
+/**
+ * This class is needed to update an item being copied to the favorites folder
+ * with a sort field value (required to save favorites bar's tabs order).
+ * See method handleNewFavoriteDragAndDrop for more details on how this class is used.
+ */
+class LLItemCopiedCallback : public LLInventoryCallback
+{
+public:
+ LLItemCopiedCallback(S32 sortField): mSortField(sortField) {}
+
+ virtual void fire(const LLUUID& inv_item)
+ {
+ LLViewerInventoryItem* item = gInventory.getItem(inv_item);
+
+ if (item)
+ {
+ item->setSortField(mSortField);
+ item->setComplete(TRUE);
+ item->updateServer(FALSE);
+
+ gInventory.updateItem(item);
+ gInventory.notifyObservers();
+ }
+
+ LLView::getWindow()->setCursor(UI_CURSOR_ARROW);
+ }
+
+private:
+ S32 mSortField;
+};
// updateButtons's helper
struct LLFavoritesSort
@@ -369,7 +399,27 @@ void LLFavoritesBarCtrl::handleNewFavoriteDragAndDrop(LLInventoryItem *item, con
mItems.push_back(gInventory.getItem(item->getUUID()));
}
- saveItemsOrder(mItems);
+ int sortField = 0;
+ LLPointer<LLItemCopiedCallback> cb;
+
+ // current order is saved by setting incremental values (1, 2, 3, ...) for the sort field
+ for (LLInventoryModel::item_array_t::iterator i = mItems.begin(); i != mItems.end(); ++i)
+ {
+ LLViewerInventoryItem* currItem = *i;
+
+ if (currItem->getUUID() == item->getUUID())
+ {
+ cb = new LLItemCopiedCallback(++sortField);
+ }
+ else
+ {
+ currItem->setSortField(++sortField);
+ currItem->setComplete(TRUE);
+ currItem->updateServer(FALSE);
+
+ gInventory.updateItem(currItem);
+ }
+ }
copy_inventory_item(
gAgent.getID(),
@@ -377,9 +427,7 @@ void LLFavoritesBarCtrl::handleNewFavoriteDragAndDrop(LLInventoryItem *item, con
item->getUUID(),
favorites_id,
std::string(),
- LLPointer<LLInventoryCallback>(NULL));
-
- getWindow()->setCursor(UI_CURSOR_ARROW);
+ cb);
llinfos << "Copied inventory item #" << item->getUUID() << " to favorites." << llendl;
}