summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Linden <none@none>2012-06-21 23:28:24 -0700
committerRichard Linden <none@none>2012-06-21 23:28:24 -0700
commit4775084000233ec9f0770f421771215397b987e7 (patch)
treec6068ee7eb24b950438fed2317390cf0cef963e5
parenta02f2e63f20021d007a6a20c33cc961500b14236 (diff)
CHUI-101 WIP Make LLFolderview general purpose
inventory item labels and icons displaying again
-rw-r--r--indra/newview/llfavoritesbar.cpp308
-rw-r--r--indra/newview/llfavoritesbar.h111
-rw-r--r--indra/newview/llfolderview.cpp2
-rw-r--r--indra/newview/llfolderview.h6
-rw-r--r--indra/newview/llfolderviewitem.cpp71
-rw-r--r--indra/newview/llfolderviewitem.h11
-rw-r--r--indra/newview/llfolderviewmodel.h38
-rw-r--r--indra/newview/llinventorybridge.cpp24
-rw-r--r--indra/newview/llinventorybridge.h7
-rw-r--r--indra/newview/llinventorymodel.cpp61
-rw-r--r--indra/newview/llinventorymodel.h9
-rw-r--r--indra/newview/llinventorypanel.cpp44
-rw-r--r--indra/newview/llinventorypanel.h2
-rw-r--r--indra/newview/llpanelmarketplaceinboxinventory.cpp16
-rw-r--r--indra/newview/llpanelmarketplaceoutboxinventory.cpp16
-rw-r--r--indra/newview/llpanelobjectinventory.cpp16
-rw-r--r--indra/newview/llviewerinventory.cpp341
-rw-r--r--indra/newview/llviewerinventory.h17
18 files changed, 512 insertions, 588 deletions
diff --git a/indra/newview/llfavoritesbar.cpp b/indra/newview/llfavoritesbar.cpp
index 575b613ccf..4a96de942d 100644
--- a/indra/newview/llfavoritesbar.cpp
+++ b/indra/newview/llfavoritesbar.cpp
@@ -38,6 +38,7 @@
#include "lltooltip.h"
#include "llagent.h"
+#include "llavatarnamecache.h"
#include "llclipboard.h"
#include "llclipboard.h"
#include "llinventorybridge.h"
@@ -45,12 +46,14 @@
#include "llfloatersidepanelcontainer.h"
#include "llfloaterworldmap.h"
#include "lllandmarkactions.h"
+#include "lllogininstance.h"
#include "llnotificationsutil.h"
#include "lltoggleablemenu.h"
#include "llviewerinventory.h"
#include "llviewermenu.h"
#include "llviewermenu.h"
#include "lltooldraganddrop.h"
+#include "llsdserialize.h"
static LLDefaultChildRegistry::Register<LLFavoritesBarCtrl> r("favorites_bar");
@@ -317,7 +320,8 @@ public:
if (item)
{
- item->setSortField(mSortField);
+ LLFavoritesOrderStorage::instance().setSortIndex(item, mSortField);
+
item->setComplete(TRUE);
item->updateServer(FALSE);
@@ -339,8 +343,8 @@ struct LLFavoritesSort
// TODO - made it customizible using gSavedSettings
bool operator()(const LLViewerInventoryItem* const& a, const LLViewerInventoryItem* const& b)
{
- S32 sortField1 = a->getSortField();
- S32 sortField2 = b->getSortField();
+ S32 sortField1 = LLFavoritesOrderStorage::instance().getSortIndex(a->getUUID());
+ S32 sortField2 = LLFavoritesOrderStorage::instance().getSortIndex(b->getUUID());
if (!(sortField1 < 0 && sortField2 < 0))
{
@@ -528,7 +532,7 @@ void LLFavoritesBarCtrl::handleExistingFavoriteDragAndDrop(S32 x, S32 y)
mItems.push_back(gInventory.getItem(mDragItemId));
}
- gInventory.saveItemsOrder(mItems);
+ LLFavoritesOrderStorage::instance().saveItemsOrder(mItems);
LLToggleableMenu* menu = (LLToggleableMenu*) mOverflowMenuHandle.get();
@@ -587,7 +591,8 @@ void LLFavoritesBarCtrl::handleNewFavoriteDragAndDrop(LLInventoryItem *item, con
}
else
{
- currItem->setSortField(++sortField);
+ LLFavoritesOrderStorage::instance().setSortIndex(currItem, ++sortField);
+
currItem->setComplete(TRUE);
currItem->updateServer(FALSE);
@@ -640,7 +645,7 @@ void LLFavoritesBarCtrl::changed(U32 mask)
for (LLInventoryModel::item_array_t::iterator i = items.begin(); i != items.end(); ++i)
{
- (*i)->getSLURL();
+ LLFavoritesOrderStorage::instance().getSLURL((*i)->getAssetUUID());
}
updateButtons();
}
@@ -909,7 +914,7 @@ BOOL LLFavoritesBarCtrl::collectFavoriteItems(LLInventoryModel::item_array_t &it
S32 sortField = 0;
for (LLInventoryModel::item_array_t::iterator i = items.begin(); i != items.end(); ++i)
{
- (*i)->setSortField(++sortField);
+ LLFavoritesOrderStorage::instance().setSortIndex((*i), ++sortField);
}
}
@@ -1355,7 +1360,7 @@ BOOL LLFavoritesBarCtrl::needToSaveItemsOrder(const LLInventoryModel::item_array
// if there is an item without sort order field set, we need to save items order
for (LLInventoryModel::item_array_t::const_iterator i = items.begin(); i != items.end(); ++i)
{
- if ((*i)->getSortField() < 0)
+ if (LLFavoritesOrderStorage::instance().getSortIndex((*i)->getUUID()) < 0)
{
result = TRUE;
break;
@@ -1390,4 +1395,291 @@ void LLFavoritesBarCtrl::insertItem(LLInventoryModel::item_array_t& items, const
}
}
+const std::string LLFavoritesOrderStorage::SORTING_DATA_FILE_NAME = "landmarks_sorting.xml";
+const S32 LLFavoritesOrderStorage::NO_INDEX = -1;
+
+void LLFavoritesOrderStorage::setSortIndex(const LLViewerInventoryItem* inv_item, S32 sort_index)
+{
+ mSortIndexes[inv_item->getUUID()] = sort_index;
+ mIsDirty = true;
+ getSLURL(inv_item->getAssetUUID());
+}
+
+S32 LLFavoritesOrderStorage::getSortIndex(const LLUUID& inv_item_id)
+{
+ sort_index_map_t::const_iterator it = mSortIndexes.find(inv_item_id);
+ if (it != mSortIndexes.end())
+ {
+ return it->second;
+ }
+ return NO_INDEX;
+}
+
+void LLFavoritesOrderStorage::removeSortIndex(const LLUUID& inv_item_id)
+{
+ mSortIndexes.erase(inv_item_id);
+ mIsDirty = true;
+}
+
+void LLFavoritesOrderStorage::getSLURL(const LLUUID& asset_id)
+{
+ slurls_map_t::iterator slurl_iter = mSLURLs.find(asset_id);
+ if (slurl_iter != mSLURLs.end()) return; // SLURL for current landmark is already cached
+
+ LLLandmark* lm = gLandmarkList.getAsset(asset_id,
+ boost::bind(&LLFavoritesOrderStorage::onLandmarkLoaded, this, asset_id, _1));
+ if (lm)
+ {
+ onLandmarkLoaded(asset_id, lm);
+ }
+}
+
+// static
+void LLFavoritesOrderStorage::destroyClass()
+{
+ LLFavoritesOrderStorage::instance().cleanup();
+ if (gSavedPerAccountSettings.getBOOL("ShowFavoritesOnLogin"))
+ {
+ LLFavoritesOrderStorage::instance().saveFavoritesSLURLs();
+ }
+ else
+ {
+ LLFavoritesOrderStorage::instance().removeFavoritesRecordOfUser();
+ }
+}
+
+void LLFavoritesOrderStorage::load()
+{
+ // load per-resident sorting information
+ std::string filename = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, SORTING_DATA_FILE_NAME);
+
+ LLSD settings_llsd;
+ llifstream file;
+ file.open(filename);
+ if (file.is_open())
+ {
+ LLSDSerialize::fromXML(settings_llsd, file);
+ }
+
+ for (LLSD::map_const_iterator iter = settings_llsd.beginMap();
+ iter != settings_llsd.endMap(); ++iter)
+ {
+ mSortIndexes.insert(std::make_pair(LLUUID(iter->first), (S32)iter->second.asInteger()));
+ }
+}
+
+void LLFavoritesOrderStorage::saveFavoritesSLURLs()
+{
+ // Do not change the file if we are not logged in yet.
+ if (!LLLoginInstance::getInstance()->authSuccess())
+ {
+ llwarns << "Cannot save favorites: not logged in" << llendl;
+ return;
+ }
+
+ std::string user_dir = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "");
+ if (user_dir.empty())
+ {
+ llwarns << "Cannot save favorites: empty user dir name" << llendl;
+ return;
+ }
+
+ std::string filename = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "stored_favorites.xml");
+ llifstream in_file;
+ in_file.open(filename);
+ LLSD fav_llsd;
+ if (in_file.is_open())
+ {
+ LLSDSerialize::fromXML(fav_llsd, in_file);
+ }
+
+ const LLUUID fav_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_FAVORITE);
+ LLInventoryModel::cat_array_t cats;
+ LLInventoryModel::item_array_t items;
+ gInventory.collectDescendents(fav_id, cats, items, LLInventoryModel::EXCLUDE_TRASH);
+
+ LLSD user_llsd;
+ for (LLInventoryModel::item_array_t::iterator it = items.begin(); it != items.end(); it++)
+ {
+ LLSD value;
+ value["name"] = (*it)->getName();
+ value["asset_id"] = (*it)->getAssetUUID();
+
+ slurls_map_t::iterator slurl_iter = mSLURLs.find(value["asset_id"]);
+ if (slurl_iter != mSLURLs.end())
+ {
+ lldebugs << "Saving favorite: idx=" << LLFavoritesOrderStorage::instance().getSortIndex((*it)->getUUID()) << ", SLURL=" << slurl_iter->second << ", value=" << value << llendl;
+ value["slurl"] = slurl_iter->second;
+ user_llsd[LLFavoritesOrderStorage::instance().getSortIndex((*it)->getUUID())] = value;
+ }
+ else
+ {
+ llwarns << "Not saving favorite " << value["name"] << ": no matching SLURL" << llendl;
+ }
+ }
+
+ LLAvatarName av_name;
+ LLAvatarNameCache::get( gAgentID, &av_name );
+ lldebugs << "Saved favorites for " << av_name.getLegacyName() << llendl;
+ fav_llsd[av_name.getLegacyName()] = user_llsd;
+
+ llofstream file;
+ file.open(filename);
+ LLSDSerialize::toPrettyXML(fav_llsd, file);
+}
+
+void LLFavoritesOrderStorage::removeFavoritesRecordOfUser()
+{
+ std::string filename = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "stored_favorites.xml");
+ LLSD fav_llsd;
+ llifstream file;
+ file.open(filename);
+ if (!file.is_open()) return;
+ LLSDSerialize::fromXML(fav_llsd, file);
+
+ LLAvatarName av_name;
+ LLAvatarNameCache::get( gAgentID, &av_name );
+ lldebugs << "Removed favorites for " << av_name.getLegacyName() << llendl;
+ if (fav_llsd.has(av_name.getLegacyName()))
+ {
+ fav_llsd.erase(av_name.getLegacyName());
+ }
+
+ llofstream out_file;
+ out_file.open(filename);
+ LLSDSerialize::toPrettyXML(fav_llsd, out_file);
+
+}
+
+void LLFavoritesOrderStorage::onLandmarkLoaded(const LLUUID& asset_id, LLLandmark* landmark)
+{
+ if (!landmark) return;
+
+ LLVector3d pos_global;
+ if (!landmark->getGlobalPos(pos_global))
+ {
+ // If global position was unknown on first getGlobalPos() call
+ // it should be set for the subsequent calls.
+ landmark->getGlobalPos(pos_global);
+ }
+
+ if (!pos_global.isExactlyZero())
+ {
+ LLLandmarkActions::getSLURLfromPosGlobal(pos_global,
+ boost::bind(&LLFavoritesOrderStorage::storeFavoriteSLURL, this, asset_id, _1));
+ }
+}
+
+void LLFavoritesOrderStorage::storeFavoriteSLURL(const LLUUID& asset_id, std::string& slurl)
+{
+ lldebugs << "Saving landmark SLURL: " << slurl << llendl;
+ mSLURLs[asset_id] = slurl;
+}
+
+void LLFavoritesOrderStorage::save()
+{
+ // nothing to save if clean
+ if (!mIsDirty) return;
+
+ // If we quit from the login screen we will not have an SL account
+ // name. Don't try to save, otherwise we'll dump a file in
+ // C:\Program Files\SecondLife\ or similar. JC
+ std::string user_dir = gDirUtilp->getLindenUserDir();
+ if (!user_dir.empty())
+ {
+ std::string filename = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, SORTING_DATA_FILE_NAME);
+ LLSD settings_llsd;
+
+ for(sort_index_map_t::const_iterator iter = mSortIndexes.begin(); iter != mSortIndexes.end(); ++iter)
+ {
+ settings_llsd[iter->first.asString()] = iter->second;
+ }
+
+ llofstream file;
+ file.open(filename);
+ LLSDSerialize::toPrettyXML(settings_llsd, file);
+ }
+}
+
+void LLFavoritesOrderStorage::cleanup()
+{
+ // nothing to clean
+ if (!mIsDirty) return;
+
+ const LLUUID fav_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_FAVORITE);
+ LLInventoryModel::cat_array_t cats;
+ LLInventoryModel::item_array_t items;
+ gInventory.collectDescendents(fav_id, cats, items, LLInventoryModel::EXCLUDE_TRASH);
+
+ IsNotInFavorites is_not_in_fav(items);
+
+ sort_index_map_t aTempMap;
+ //copy unremoved values from mSortIndexes to aTempMap
+ std::remove_copy_if(mSortIndexes.begin(), mSortIndexes.end(),
+ inserter(aTempMap, aTempMap.begin()),
+ is_not_in_fav);
+
+ //Swap the contents of mSortIndexes and aTempMap
+ mSortIndexes.swap(aTempMap);
+}
+
+void LLFavoritesOrderStorage::saveItemsOrder( const LLInventoryModel::item_array_t& items )
+{
+ int sortField = 0;
+
+ // current order is saved by setting incremental values (1, 2, 3, ...) for the sort field
+ for (LLInventoryModel::item_array_t::const_iterator i = items.begin(); i != items.end(); ++i)
+ {
+ LLViewerInventoryItem* item = *i;
+
+ setSortIndex(item, ++sortField);
+
+ item->setComplete(TRUE);
+ item->updateServer(FALSE);
+
+ gInventory.updateItem(item);
+
+ // Tell the parent folder to refresh its sort order.
+ gInventory.addChangedMask(LLInventoryObserver::SORT, item->getParentUUID());
+ }
+
+ gInventory.notifyObservers();
+}
+
+// See also LLInventorySort where landmarks in the Favorites folder are sorted.
+class LLViewerInventoryItemSort
+{
+public:
+ bool operator()(const LLPointer<LLViewerInventoryItem>& a, const LLPointer<LLViewerInventoryItem>& b)
+ {
+ return LLFavoritesOrderStorage::instance().getSortIndex(a->getUUID())
+ < LLFavoritesOrderStorage::instance().getSortIndex(b->getUUID());
+ }
+};
+
+// * @param source_item_id - LLUUID of the source item to be moved into new position
+// * @param target_item_id - LLUUID of the target item before which source item should be placed.
+void LLFavoritesOrderStorage::rearrangeFavoriteLandmarks(const LLUUID& source_item_id, const LLUUID& target_item_id)
+{
+ LLInventoryModel::cat_array_t cats;
+ LLInventoryModel::item_array_t items;
+ LLIsType is_type(LLAssetType::AT_LANDMARK);
+ LLUUID favorites_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_FAVORITE);
+ gInventory.collectDescendentsIf(favorites_id, cats, items, LLInventoryModel::EXCLUDE_TRASH, is_type);
+
+ // ensure items are sorted properly before changing order. EXT-3498
+ std::sort(items.begin(), items.end(), LLViewerInventoryItemSort());
+
+ // update order
+ gInventory.updateItemsOrder(items, source_item_id, target_item_id);
+
+ saveItemsOrder(items);
+}
+
+void AddFavoriteLandmarkCallback::fire(const LLUUID& inv_item_id)
+{
+ if (mTargetLandmarkId.isNull()) return;
+
+ LLFavoritesOrderStorage::instance().rearrangeFavoriteLandmarks(inv_item_id, mTargetLandmarkId);
+}
// EOF
diff --git a/indra/newview/llfavoritesbar.h b/indra/newview/llfavoritesbar.h
index 2f75b3bb0e..60e02b661e 100644
--- a/indra/newview/llfavoritesbar.h
+++ b/indra/newview/llfavoritesbar.h
@@ -33,6 +33,7 @@
#include "llinventoryobserver.h"
#include "llinventorymodel.h"
+#include "llviewerinventory.h"
class LLMenuItemCallGL;
class LLToggleableMenu;
@@ -161,5 +162,115 @@ private:
boost::signals2::connection mEndDragConnection;
};
+class AddFavoriteLandmarkCallback : public LLInventoryCallback
+{
+public:
+ AddFavoriteLandmarkCallback() : mTargetLandmarkId(LLUUID::null) {}
+ void setTargetLandmarkId(const LLUUID& target_uuid) { mTargetLandmarkId = target_uuid; }
+
+private:
+ void fire(const LLUUID& inv_item);
+
+ LLUUID mTargetLandmarkId;
+};
+
+/**
+ * Class to store sorting order of favorites landmarks in a local file. EXT-3985.
+ * It replaced previously implemented solution to store sort index in landmark's name as a "<N>@" prefix.
+ * Data are stored in user home directory.
+ */
+class LLFavoritesOrderStorage : public LLSingleton<LLFavoritesOrderStorage>
+ , public LLDestroyClass<LLFavoritesOrderStorage>
+{
+ LOG_CLASS(LLFavoritesOrderStorage);
+public:
+ /**
+ * Sets sort index for specified with LLUUID favorite landmark
+ */
+ void setSortIndex(const LLViewerInventoryItem* inv_item, S32 sort_index);
+
+ /**
+ * Gets sort index for specified with LLUUID favorite landmark
+ */
+ S32 getSortIndex(const LLUUID& inv_item_id);
+ void removeSortIndex(const LLUUID& inv_item_id);
+
+ void getSLURL(const LLUUID& asset_id);
+
+ // Saves current order of the passed items using inventory item sort field.
+ // Resets 'items' sort fields and saves them on server.
+ // Is used to save order for Favorites folder.
+ void saveItemsOrder(const LLInventoryModel::item_array_t& items);
+
+ void rearrangeFavoriteLandmarks(const LLUUID& source_item_id, const LLUUID& target_item_id);
+
+ /**
+ * Implementation of LLDestroyClass. Calls cleanup() instance method.
+ *
+ * It is important this callback is called before gInventory is cleaned.
+ * For now it is called from LLAppViewer::cleanup() -> LLAppViewer::disconnectViewer(),
+ * Inventory is cleaned later from LLAppViewer::cleanup() after LLAppViewer::disconnectViewer() is called.
+ * @see cleanup()
+ */
+ static void destroyClass();
+
+ const static S32 NO_INDEX;
+private:
+ friend class LLSingleton<LLFavoritesOrderStorage>;
+ LLFavoritesOrderStorage() : mIsDirty(false) { load(); }
+ ~LLFavoritesOrderStorage() { save(); }
+
+ /**
+ * Removes sort indexes for items which are not in Favorites bar for now.
+ */
+ void cleanup();
+
+ const static std::string SORTING_DATA_FILE_NAME;
+
+ void load();
+ void save();
+
+ void saveFavoritesSLURLs();
+
+ // Remove record of current user's favorites from file on disk.
+ void removeFavoritesRecordOfUser();
+
+ void onLandmarkLoaded(const LLUUID& asset_id, class LLLandmark* landmark);
+ void storeFavoriteSLURL(const LLUUID& asset_id, std::string& slurl);
+
+ typedef std::map<LLUUID, S32> sort_index_map_t;
+ sort_index_map_t mSortIndexes;
+
+ typedef std::map<LLUUID, std::string> slurls_map_t;
+ slurls_map_t mSLURLs;
+
+ bool mIsDirty;
+
+ struct IsNotInFavorites
+ {
+ IsNotInFavorites(const LLInventoryModel::item_array_t& items)
+ : mFavoriteItems(items)
+ {
+
+ }
+
+ /**
+ * Returns true if specified item is not found among inventory items
+ */
+ bool operator()(const sort_index_map_t::value_type& id_index_pair) const
+ {
+ LLPointer<LLViewerInventoryItem> item = gInventory.getItem(id_index_pair.first);
+ if (item.isNull()) return true;
+
+ LLInventoryModel::item_array_t::const_iterator found_it =
+ std::find(mFavoriteItems.begin(), mFavoriteItems.end(), item);
+
+ return found_it == mFavoriteItems.end();
+ }
+ private:
+ LLInventoryModel::item_array_t mFavoriteItems;
+ };
+
+};
#endif // LL_LLFAVORITESBARCTRL_H
diff --git a/indra/newview/llfolderview.cpp b/indra/newview/llfolderview.cpp
index 6bae1d5644..ee8c94a2dd 100644
--- a/indra/newview/llfolderview.cpp
+++ b/indra/newview/llfolderview.cpp
@@ -195,8 +195,10 @@ LLFolderView::LLFolderView(const Params& p)
mUseEllipses(p.use_ellipses),
mDraggingOverItem(NULL),
mStatusTextBox(NULL),
+ mShowItemLinkOverlays(p.show_item_link_overlays),
mViewModel(p.view_model)
{
+ mViewModel->setFolderView(this);
mRoot = this;
LLRect rect = p.rect;
diff --git a/indra/newview/llfolderview.h b/indra/newview/llfolderview.h
index 813b4d130f..8b58da9f45 100644
--- a/indra/newview/llfolderview.h
+++ b/indra/newview/llfolderview.h
@@ -96,7 +96,8 @@ public:
Optional<bool> use_label_suffix,
allow_multiselect,
show_empty_message,
- use_ellipses;
+ use_ellipses,
+ show_item_link_overlays;
Mandatory<LLFolderViewModelInterface*> view_model;
Params();
@@ -239,6 +240,8 @@ public:
void setPinningSelectedItem(BOOL val) { mPinningSelectedItem = val; }
void setAutoSelectOverride(BOOL val) { mAutoSelectOverride = val; }
+ bool showItemLinkOverlays() { return mShowItemLinkOverlays; }
+
void setCallbackRegistrar(LLUICtrl::CommitCallbackRegistry::ScopedRegistrar* registrar) { mCallbackRegistrar = registrar; }
BOOL getDebugFilters() { return mDebugFilters; }
@@ -294,6 +297,7 @@ protected:
BOOL mAutoSelectOverride;
BOOL mNeedsAutoRename;
bool mUseLabelSuffix;
+ bool mShowItemLinkOverlays;
BOOL mDebugFilters;
U32 mSortOrder;
diff --git a/indra/newview/llfolderviewitem.cpp b/indra/newview/llfolderviewitem.cpp
index 5b73a34d29..3f0b493986 100644
--- a/indra/newview/llfolderviewitem.cpp
+++ b/indra/newview/llfolderviewitem.cpp
@@ -91,10 +91,7 @@ void LLFolderViewItem::cleanupClass()
// NOTE: Optimize this, we call it a *lot* when opening a large inventory
LLFolderViewItem::Params::Params()
-: icon(),
- icon_open(),
- icon_overlay(),
- root(),
+: root(),
listener(),
folder_arrow_image("folder_arrow_image"),
folder_indentation("folder_indentation"),
@@ -125,12 +122,10 @@ LLFolderViewItem::LLFolderViewItem(const LLFolderViewItem::Params& p)
mDragAndDropTarget(FALSE),
mLabel(p.name),
mRoot(p.root),
- mIcon(p.icon),
- mIconOpen(p.icon_open),
- mIconOverlay(p.icon_overlay),
mListener(p.listener),
mIsMouseOverTitle(false)
{
+ mListener->setFolderViewItem(this);
}
BOOL LLFolderViewItem::postBuild()
@@ -243,11 +238,6 @@ void LLFolderViewItem::setFiltered(BOOL filtered, S32 filter_generation)
mLastFilterGeneration = filter_generation;
}
-void LLFolderViewItem::setIcon(LLUIImagePtr icon)
-{
- mIcon = icon;
-}
-
void LLFolderViewItem::refresh()
{
if(!getViewModelItem()) return;
@@ -255,7 +245,10 @@ void LLFolderViewItem::refresh()
mLabel = getViewModelItem()->getDisplayName();
setToolTip(mLabel);
- setIcon(getViewModelItem()->getIcon());
+ mIcon = getViewModelItem()->getIcon();
+ mIconOpen = getViewModelItem()->getIconOpen();
+ mIconOverlay = getViewModelItem()->getIconOverlay();
+
if (mRoot->useLabelSuffix())
{
mLabelStyle = getViewModelItem()->getLabelStyle();
@@ -907,27 +900,23 @@ void LLFolderViewItem::draw()
mDragAndDropTarget = FALSE;
}
- //TODO RN: implement this in terms of getIcon() and getIconOverlay()
-
- //const LLViewerInventoryItem *item = getInventoryItem();
- //const BOOL highlight_link = mIconOverlay && item && item->getIsLinkType();
- ////--------------------------------------------------------------------------------//
- //// Draw open icon
- ////
- //const S32 icon_x = mIndentation + ARROW_SIZE + TEXT_PAD;
- //if (!mIconOpen.isNull() && (llabs(mControlLabelRotation) > 80)) // For open folders
- // {
- // mIconOpen->draw(icon_x, getRect().getHeight() - mIconOpen->getHeight() - TOP_PAD + 1);
- //}
- //else if (mIcon)
- //{
- // mIcon->draw(icon_x, getRect().getHeight() - mIcon->getHeight() - TOP_PAD + 1);
- // }
+ //--------------------------------------------------------------------------------//
+ // Draw open icon
+ //
+ const S32 icon_x = mIndentation + ARROW_SIZE + TEXT_PAD;
+ if (!mIconOpen.isNull() && (llabs(mControlLabelRotation) > 80)) // For open folders
+ {
+ mIconOpen->draw(icon_x, getRect().getHeight() - mIconOpen->getHeight() - TOP_PAD + 1);
+ }
+ else if (mIcon)
+ {
+ mIcon->draw(icon_x, getRect().getHeight() - mIcon->getHeight() - TOP_PAD + 1);
+ }
- //if (highlight_link)
- //{
- // mIconOverlay->draw(icon_x, getRect().getHeight() - mIcon->getHeight() - TOP_PAD + 1);
- //}
+ if (mIconOverlay && getRoot()->showItemLinkOverlays())
+ {
+ mIconOverlay->draw(icon_x, getRect().getHeight() - mIcon->getHeight() - TOP_PAD + 1);
+ }
//--------------------------------------------------------------------------------//
// Exit if no label to draw
@@ -1242,7 +1231,7 @@ BOOL LLFolderViewFolder::needsArrange()
void LLFolderViewFolder::requestSort()
{
- getRoot()->getFolderViewModel()->requestSort(this);
+ getViewModelItem()->requestSort();
}
void LLFolderViewFolder::setCompletedFilterGeneration(S32 generation, BOOL recurse_up)
@@ -2007,13 +1996,13 @@ BOOL LLFolderViewFolder::addFolder(LLFolderViewFolder* folder)
addChild( folder );
folder->dirtyFilter();
// rearrange all descendants too, as our indentation level might have changed
- folder->requestArrange(TRUE);
+ folder->requestArrange();
requestSort();
return TRUE;
}
-void LLFolderViewFolder::requestArrange(BOOL include_descendants)
+void LLFolderViewFolder::requestArrange()
{
mLastArrangeGeneration = -1;
// flag all items up to root
@@ -2021,16 +2010,6 @@ void LLFolderViewFolder::requestArrange(BOOL include_descendants)
{
mParentFolder->requestArrange();
}
-
- if (include_descendants)
- {
- for (folders_t::iterator iter = mFolders.begin();
- iter != mFolders.end();
- ++iter)
- {
- (*iter)->requestArrange(TRUE);
- }
- }
}
void LLFolderViewFolder::toggleOpen()
diff --git a/indra/newview/llfolderviewitem.h b/indra/newview/llfolderviewitem.h
index feba32e31d..fd2948f34e 100644
--- a/indra/newview/llfolderviewitem.h
+++ b/indra/newview/llfolderviewitem.h
@@ -51,10 +51,7 @@ public:
struct Params : public LLInitParam::Block<Params, LLView::Params>
{
- Optional<LLUIImage*> icon,
- icon_open, // used for folders
- icon_overlay, // for links
- folder_arrow_image,
+ Optional<LLUIImage*> folder_arrow_image,
selection_image;
Optional<LLFolderView*> root;
Mandatory<LLFolderViewModelItem*> listener;
@@ -252,9 +249,6 @@ public:
virtual BOOL getFiltered(S32 filter_generation);
virtual void setFiltered(BOOL filtered, S32 filter_generation);
- // change the icon
- void setIcon(LLUIImagePtr icon);
-
// refresh information from the object being viewed.
virtual void refresh();
@@ -416,8 +410,7 @@ public:
virtual void setOpen(BOOL openitem = TRUE);
// Called when a child is refreshed.
- // don't rearrange child folder contents unless explicitly requested
- virtual void requestArrange(BOOL include_descendants = FALSE);
+ virtual void requestArrange();
virtual void requestSort();
diff --git a/indra/newview/llfolderviewmodel.h b/indra/newview/llfolderviewmodel.h
index 930c26384c..c3dcfed97c 100644
--- a/indra/newview/llfolderviewmodel.h
+++ b/indra/newview/llfolderviewmodel.h
@@ -120,18 +120,20 @@ class LLFolderViewModelInterface
{
public:
virtual void requestSortAll() = 0;
- virtual void requestSort(class LLFolderViewFolder*) = 0;
virtual void sort(class LLFolderViewFolder*) = 0;
virtual void filter(class LLFolderViewFolder*) = 0;
virtual bool contentsReady() = 0;
+ virtual void setFolderView(LLFolderView* folder_view) = 0;
};
-struct LLFolderViewModelCommon : public LLFolderViewModelInterface
+class LLFolderViewModelCommon : public LLFolderViewModelInterface
{
+public:
LLFolderViewModelCommon()
- : mTargetSortVersion(0)
+ : mTargetSortVersion(0),
+ mFolderView(NULL)
{}
virtual void requestSortAll()
@@ -140,15 +142,14 @@ struct LLFolderViewModelCommon : public LLFolderViewModelInterface
mTargetSortVersion++;
}
- virtual void requestSort(class LLFolderViewFolder* folder)
- {
- folder->requestSort();
- }
-
+ void setFolderView(LLFolderView* folder_view) { mFolderView = folder_view;}
+
protected:
bool needsSort(class LLFolderViewModelItem* item);
S32 mTargetSortVersion;
+ LLFolderView* mFolderView;
+
};
// This is am abstract base class that users of the folderview classes
@@ -156,6 +157,10 @@ protected:
class LLFolderViewModelItem
{
public:
+ LLFolderViewModelItem()
+ : mFolderViewItem(NULL)
+ {}
+
virtual ~LLFolderViewModelItem( void ) {};
virtual void update() {} //called when drawing
@@ -163,7 +168,8 @@ public:
virtual const std::string& getDisplayName() const = 0;
virtual LLPointer<LLUIImage> getIcon() const = 0;
- virtual LLPointer<LLUIImage> getOpenIcon() const { return getIcon(); }
+ virtual LLPointer<LLUIImage> getIconOpen() const { return getIcon(); }
+ virtual LLPointer<LLUIImage> getIconOverlay() const { return NULL; }
virtual LLFontGL::StyleFlags getLabelStyle() const = 0;
virtual std::string getLabelSuffix() const = 0;
@@ -211,6 +217,11 @@ public:
virtual void requestSort() = 0;
virtual S32 getSortVersion() = 0;
virtual void setSortVersion(S32 version) = 0;
+protected:
+ friend LLFolderViewItem;
+ void setFolderViewItem(LLFolderViewItem* folder_view_item) { mFolderViewItem = folder_view_item;}
+ LLFolderViewItem* mFolderViewItem;
+
};
class LLFolderViewModelItemCommon : public LLFolderViewModelItem
@@ -225,6 +236,7 @@ public:
void setSortVersion(S32 version) { mSortVersion = version;}
protected:
+
S32 mSortVersion;
};
@@ -232,7 +244,7 @@ template <typename SORT_TYPE, typename ITEM_TYPE, typename FOLDER_TYPE, typename
class LLFolderViewModel : public LLFolderViewModelCommon
{
public:
- LLFolderViewModel() {}
+ LLFolderViewModel(){}
virtual ~LLFolderViewModel() {}
typedef SORT_TYPE SortType;
@@ -247,6 +259,8 @@ public:
virtual const FilterType& getFilter() const { return mFilter; }
virtual void setFilter(const FilterType& filter) { mFilter = filter; }
+ // TODO RN: remove this and put all filtering logic in view model
+ // add getStatusText and isFiltering()
virtual bool contentsReady() { return true; }
struct ViewModelCompare
@@ -301,8 +315,8 @@ public:
}
protected:
- SortType mSorter;
- FilterType mFilter;
+ SortType mSorter;
+ FilterType mFilter;
};
#endif
diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp
index 44d0fdd3dd..c0670b71d4 100644
--- a/indra/newview/llinventorybridge.cpp
+++ b/indra/newview/llinventorybridge.cpp
@@ -37,6 +37,7 @@
#include "llappearancemgr.h"
#include "llattachmentsmgr.h"
#include "llavataractions.h"
+#include "llfavoritesbar.h" // management of favorites folder
#include "llfloateropenobject.h"
#include "llfloaterreg.h"
#include "llfloatersidepanelcontainer.h"
@@ -1846,7 +1847,11 @@ void LLFolderBridge::buildDisplayName() const
if (accessories || LLFolderType::lookupIsProtectedType(preferred_type))
{
LLTrans::findString(mDisplayName, std::string("InvFolder ") + getName(), LLSD());
- };
+ }
+ else
+ {
+ mDisplayName.assign(getName());
+ }
}
@@ -2993,17 +2998,24 @@ LLUIImagePtr LLFolderBridge::getIcon() const
LLUIImagePtr LLFolderBridge::getIcon(LLFolderType::EType preferred_type)
{
return LLUI::getUIImage(LLViewerFolderType::lookupIconName(preferred_type, FALSE));
- /*case LLAssetType::AT_MESH:
- control = "inv_folder_mesh.tga";
- break;*/
}
-LLUIImagePtr LLFolderBridge::getOpenIcon() const
+LLUIImagePtr LLFolderBridge::getIconOpen() const
{
return LLUI::getUIImage(LLViewerFolderType::lookupIconName(getPreferredType(), TRUE));
}
+LLUIImagePtr LLFolderBridge::getIconOverlay() const
+{
+ if (getInventoryObject() && getInventoryObject()->getIsLinkType())
+ {
+ return LLUI::getUIImage("Inv_Link");
+ }
+ return NULL;
+}
+
+
BOOL LLFolderBridge::renameItem(const std::string& new_name)
{
rename_category(getInventoryModel(), mUUID, new_name);
@@ -4017,7 +4029,7 @@ BOOL LLFolderBridge::dragItemIntoFolder(LLInventoryItem* inv_item,
{
LLUUID srcItemId = inv_item->getUUID();
LLUUID destItemId = static_cast<LLFolderViewModelItemInventory*>(itemp->getViewModelItem())->getUUID();
- gInventory.rearrangeFavoriteLandmarks(srcItemId, destItemId);
+ LLFavoritesOrderStorage::instance().rearrangeFavoriteLandmarks(srcItemId, destItemId);
}
}
diff --git a/indra/newview/llinventorybridge.h b/indra/newview/llinventorybridge.h
index 111735e198..26789627f7 100644
--- a/indra/newview/llinventorybridge.h
+++ b/indra/newview/llinventorybridge.h
@@ -260,7 +260,9 @@ public:
virtual LLFolderType::EType getPreferredType() const;
virtual LLUIImagePtr getIcon() const;
- virtual LLUIImagePtr getOpenIcon() const;
+ virtual LLUIImagePtr getIconOpen() const;
+ virtual LLUIImagePtr getIconOverlay() const;
+
static LLUIImagePtr getIcon(LLFolderType::EType preferred_type);
virtual BOOL renameItem(const std::string& new_name);
@@ -338,8 +340,7 @@ private:
bool mWearables;
bool mIsLoading;
LLTimer mTimeSinceRequestStart;
- mutable std::string mDisplayName;
- LLRootHandle<LLFolderBridge> mHandle;
+ LLRootHandle<LLFolderBridge> mHandle;
};
class LLTextureBridge : public LLItemBridge
diff --git a/indra/newview/llinventorymodel.cpp b/indra/newview/llinventorymodel.cpp
index 85ecb133d0..9b0d12b353 100644
--- a/indra/newview/llinventorymodel.cpp
+++ b/indra/newview/llinventorymodel.cpp
@@ -3201,68 +3201,7 @@ void LLInventoryModel::updateItemsOrder(LLInventoryModel::item_array_t& items, c
}
}
-//* @param[in] items vector of items in order to be saved.
-void LLInventoryModel::saveItemsOrder(const LLInventoryModel::item_array_t& items)
-{
- int sortField = 0;
-
- // current order is saved by setting incremental values (1, 2, 3, ...) for the sort field
- for (item_array_t::const_iterator i = items.begin(); i != items.end(); ++i)
- {
- LLViewerInventoryItem* item = *i;
-
- item->setSortField(++sortField);
- item->setComplete(TRUE);
- item->updateServer(FALSE);
-
- updateItem(item);
-
- // Tell the parent folder to refresh its sort order.
- addChangedMask(LLInventoryObserver::SORT, item->getParentUUID());
- }
-
- notifyObservers();
-}
-
-// See also LLInventorySort where landmarks in the Favorites folder are sorted.
-class LLViewerInventoryItemSort
-{
-public:
- bool operator()(const LLPointer<LLViewerInventoryItem>& a, const LLPointer<LLViewerInventoryItem>& b)
- {
- return a->getSortField() < b->getSortField();
- }
-};
-/**
- * Sorts passed items by LLViewerInventoryItem sort field.
- *
- * @param[in, out] items - array of items, not sorted.
- */
-static void rearrange_item_order_by_sort_field(LLInventoryModel::item_array_t& items)
-{
- static LLViewerInventoryItemSort sort_functor;
- std::sort(items.begin(), items.end(), sort_functor);
-}
-
-// * @param source_item_id - LLUUID of the source item to be moved into new position
-// * @param target_item_id - LLUUID of the target item before which source item should be placed.
-void LLInventoryModel::rearrangeFavoriteLandmarks(const LLUUID& source_item_id, const LLUUID& target_item_id)
-{
- LLInventoryModel::cat_array_t cats;
- LLInventoryModel::item_array_t items;
- LLIsType is_type(LLAssetType::AT_LANDMARK);
- LLUUID favorites_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_FAVORITE);
- gInventory.collectDescendentsIf(favorites_id, cats, items, LLInventoryModel::EXCLUDE_TRASH, is_type);
-
- // ensure items are sorted properly before changing order. EXT-3498
- rearrange_item_order_by_sort_field(items);
-
- // update order
- updateItemsOrder(items, source_item_id, target_item_id);
-
- saveItemsOrder(items);
-}
//----------------------------------------------------------------------------
diff --git a/indra/newview/llinventorymodel.h b/indra/newview/llinventorymodel.h
index 8382e875b4..3613bc4917 100644
--- a/indra/newview/llinventorymodel.h
+++ b/indra/newview/llinventorymodel.h
@@ -362,15 +362,6 @@ public:
// Returns end() of the vector if not found.
static LLInventoryModel::item_array_t::iterator findItemIterByUUID(LLInventoryModel::item_array_t& items, const LLUUID& id);
- // Saves current order of the passed items using inventory item sort field.
- // Resets 'items' sort fields and saves them on server.
- // Is used to save order for Favorites folder.
- void saveItemsOrder(const LLInventoryModel::item_array_t& items);
-
- // Rearranges Landmarks inside Favorites folder.
- // Moves source landmark before target one.
- void rearrangeFavoriteLandmarks(const LLUUID& source_item_id, const LLUUID& target_item_id);
-
//--------------------------------------------------------------------
// Creation
//--------------------------------------------------------------------
diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp
index d576160277..74492e0005 100644
--- a/indra/newview/llinventorypanel.cpp
+++ b/indra/newview/llinventorypanel.cpp
@@ -59,17 +59,6 @@ static const LLInventoryFVBridgeBuilder INVENTORY_BRIDGE_BUILDER;
//
// class LLFolderViewModelInventory
//
-void LLFolderViewModelInventory::requestSort(class LLFolderViewFolder* folder)
-{
- base_t::requestSort(folder);
- if (getSorter().isByDate())
- {
- // sort by date potentially affects parent folders which use a date
- // derived from newest item in them
- requestSort(folder->getParentFolder());
- }
-}
-
static LLFastTimer::DeclareTimer FTM_INVENTORY_SORT("Sort");
void LLFolderViewModelInventory::sort( LLFolderViewFolder* folder )
@@ -690,6 +679,7 @@ LLFolderView * LLInventoryPanel::createFolderView(LLInvFVBridge * bridge, bool u
p.use_label_suffix = useLabelSuffix;
p.allow_multiselect = mAllowMultiSelect;
p.show_empty_message = mShowEmptyMessage;
+ p.show_item_link_overlays = mShowItemLinkOverlays;
return LLUICtrlFactory::create<LLFolderView>(p);
}
@@ -699,14 +689,6 @@ LLFolderViewFolder * LLInventoryPanel::createFolderViewFolder(LLInvFVBridge * br
LLFolderViewFolder::Params params;
params.name = bridge->getDisplayName();
- params.icon = bridge->getIcon();
- params.icon_open = bridge->getOpenIcon();
-
- if (mShowItemLinkOverlays) // if false, then links show up just like normal items
- {
- params.icon_overlay = LLUI::getUIImage("Inv_Link");
- }
-
params.root = mFolderRoot;
params.listener = bridge;
params.tool_tip = params.name;
@@ -719,14 +701,6 @@ LLFolderViewItem * LLInventoryPanel::createFolderViewItem(LLInvFVBridge * bridge
LLFolderViewItem::Params params;
params.name = bridge->getDisplayName();
- params.icon = bridge->getIcon();
- params.icon_open = bridge->getOpenIcon();
-
- if (mShowItemLinkOverlays) // if false, then links show up just like normal items
- {
- params.icon_overlay = LLUI::getUIImage("Inv_Link");
- }
-
params.creation_date = bridge->getCreationDate();
params.root = mFolderRoot;
params.listener = bridge;
@@ -743,7 +717,9 @@ LLFolderViewItem* LLInventoryPanel::buildNewViews(const LLUUID& id)
if (!objectp) return NULL;
LLFolderViewItem* folder_view_item = getItemByID(id);
- LLFolderViewFolder* parent_folder = folder_view_item->getParentFolder();
+
+ const LLUUID &parent_id = objectp->getParentUUID();
+ LLFolderViewFolder* parent_folder = (LLFolderViewFolder*)getItemByID(parent_id);
if (!folder_view_item && parent_folder)
{
@@ -1370,3 +1346,15 @@ LLInventoryRecentItemsPanel::LLInventoryRecentItemsPanel( const Params& params)
mInvFVBridgeBuilder = &RECENT_ITEMS_BUILDER;
}
+
+void LLFolderViewModelItemInventory::requestSort()
+{
+ LLFolderViewModelItemCommon::requestSort();
+ //TODO RN: need better way to get to root viewmodel, also consider reflecting hierarchy in viewmodel space as well
+ if (static_cast<LLFolderViewModelInventory*>(mFolderViewItem->getRoot()->getFolderViewModel())->getSorter().isByDate())
+ {
+ // sort by date potentially affects parent folders which use a date
+ // derived from newest item in them
+ mFolderViewItem->getParentFolder()->getViewModelItem()->requestSort();
+ }
+}
diff --git a/indra/newview/llinventorypanel.h b/indra/newview/llinventorypanel.h
index 2aa05e1b61..645e2f6d76 100644
--- a/indra/newview/llinventorypanel.h
+++ b/indra/newview/llinventorypanel.h
@@ -61,6 +61,7 @@ public:
virtual LLWearableType::EType getWearableType() const = 0;
virtual EInventorySortGroup getSortGroup() const = 0;
virtual LLInventoryObject* getInventoryObject() const = 0;
+ virtual void requestSort();
};
class LLInventorySort
@@ -97,7 +98,6 @@ public:
virtual ~LLFolderViewModelInventory() {}
void sort(LLFolderViewFolder* folder);
- void requestSort(LLFolderViewFolder* folder);
bool contentsReady();
diff --git a/indra/newview/llpanelmarketplaceinboxinventory.cpp b/indra/newview/llpanelmarketplaceinboxinventory.cpp
index d2143783ad..f3096e862d 100644
--- a/indra/newview/llpanelmarketplaceinboxinventory.cpp
+++ b/indra/newview/llpanelmarketplaceinboxinventory.cpp
@@ -122,14 +122,6 @@ LLFolderViewFolder * LLInboxInventoryPanel::createFolderViewFolder(LLInvFVBridge
LLInboxFolderViewFolder::Params params;
params.name = bridge->getDisplayName();
- params.icon = bridge->getIcon();
- params.icon_open = bridge->getOpenIcon();
-
- if (mShowItemLinkOverlays) // if false, then links show up just like normal items
- {
- params.icon_overlay = LLUI::getUIImage("Inv_Link");
- }
-
params.root = mFolderRoot;
params.listener = bridge;
params.tool_tip = params.name;
@@ -142,14 +134,6 @@ LLFolderViewItem * LLInboxInventoryPanel::createFolderViewItem(LLInvFVBridge * b
LLInboxFolderViewItem::Params params;
params.name = bridge->getDisplayName();
- params.icon = bridge->getIcon();
- params.icon_open = bridge->getOpenIcon();
-
- if (mShowItemLinkOverlays) // if false, then links show up just like normal items
- {
- params.icon_overlay = LLUI::getUIImage("Inv_Link");
- }
-
params.creation_date = bridge->getCreationDate();
params.root = mFolderRoot;
params.listener = bridge;
diff --git a/indra/newview/llpanelmarketplaceoutboxinventory.cpp b/indra/newview/llpanelmarketplaceoutboxinventory.cpp
index 7db01d9059..783eeb11b8 100644
--- a/indra/newview/llpanelmarketplaceoutboxinventory.cpp
+++ b/indra/newview/llpanelmarketplaceoutboxinventory.cpp
@@ -88,14 +88,6 @@ LLFolderViewFolder * LLOutboxInventoryPanel::createFolderViewFolder(LLInvFVBridg
LLOutboxFolderViewFolder::Params params;
params.name = bridge->getDisplayName();
- params.icon = bridge->getIcon();
- params.icon_open = bridge->getOpenIcon();
-
- if (mShowItemLinkOverlays) // if false, then links show up just like normal items
- {
- params.icon_overlay = LLUI::getUIImage("Inv_Link");
- }
-
params.root = mFolderRoot;
params.listener = bridge;
params.tool_tip = params.name;
@@ -108,14 +100,6 @@ LLFolderViewItem * LLOutboxInventoryPanel::createFolderViewItem(LLInvFVBridge *
LLFolderViewItem::Params params;
params.name = bridge->getDisplayName();
- params.icon = bridge->getIcon();
- params.icon_open = bridge->getOpenIcon();
-
- if (mShowItemLinkOverlays) // if false, then links show up just like normal items
- {
- params.icon_overlay = LLUI::getUIImage("Inv_Link");
- }
-
params.creation_date = bridge->getCreationDate();
params.root = mFolderRoot;
params.listener = bridge;
diff --git a/indra/newview/llpanelobjectinventory.cpp b/indra/newview/llpanelobjectinventory.cpp
index 0ba8c1ce6d..da82d70f22 100644
--- a/indra/newview/llpanelobjectinventory.cpp
+++ b/indra/newview/llpanelobjectinventory.cpp
@@ -1551,6 +1551,7 @@ void LLPanelObjectInventory::reset()
p.tool_tip= LLTrans::getString("PanelContentsTooltip");
p.listener = LLTaskInvFVBridge::createObjectBridge(this, NULL);
p.folder_indentation = -14; // subtract space normally reserved for folder expanders
+ p.view_model = new LLFolderViewModelInventory();
mFolders = LLUICtrlFactory::create<LLFolderView>(p);
// this ensures that we never say "searching..." or "no items found"
//TODO RN: make this happen by manipulating filter object directly
@@ -1693,18 +1694,6 @@ void LLPanelObjectInventory::createFolderViews(LLInventoryObject* inventory_root
bridge = LLTaskInvFVBridge::createObjectBridge(this, inventory_root);
if(bridge)
{
- //LLFolderViewFolder* new_folder = NULL;
- //LLFolderViewFolder::Params p;
- //p.name = inventory_root->getName();
- //p.icon = LLUI::getUIImage("Inv_FolderClosed");
- //p.icon_open = LLUI::getUIImage("Inv_FolderOpen");
- //p.root = mFolders;
- //p.listener = bridge;
- //p.tool_tip = p.name;
- //new_folder = LLUICtrlFactory::create<LLFolderViewFolder>(p);
- //new_folder->addToFolder(mFolders, mFolders);
- //new_folder->toggleOpen();
-
createViewsForCategory(&contents, inventory_root, mFolders);
}
}
@@ -1737,8 +1726,6 @@ void LLPanelObjectInventory::createViewsForCategory(LLInventoryObject::object_li
{
LLFolderViewFolder::Params p;
p.name = obj->getName();
- p.icon = LLUI::getUIImage("Inv_FolderClosed");
- p.icon_open = LLUI::getUIImage("Inv_FolderOpen");
p.root = mFolders;
p.listener = bridge;
p.tool_tip = p.name;
@@ -1750,7 +1737,6 @@ void LLPanelObjectInventory::createViewsForCategory(LLInventoryObject::object_li
{
LLFolderViewItem::Params params;
params.name(obj->getName());
- params.icon(bridge->getIcon());
params.creation_date(bridge->getCreationDate());
params.root(mFolders);
params.listener(bridge);
diff --git a/indra/newview/llviewerinventory.cpp b/indra/newview/llviewerinventory.cpp
index 749a6d22e0..d81b016fc1 100644
--- a/indra/newview/llviewerinventory.cpp
+++ b/indra/newview/llviewerinventory.cpp
@@ -1030,12 +1030,7 @@ void CreateGestureCallback::fire(const LLUUID& inv_item)
gFloaterView->adjustToFitScreen(preview, FALSE);
}
-void AddFavoriteLandmarkCallback::fire(const LLUUID& inv_item_id)
-{
- if (mTargetLandmarkId.isNull()) return;
- gInventory.rearrangeFavoriteLandmarks(inv_item_id, mTargetLandmarkId);
-}
LLInventoryCallbackManager gInventoryCallbacks;
@@ -1449,342 +1444,6 @@ const std::string& LLViewerInventoryItem::getName() const
return LLInventoryItem::getName();
}
-/**
- * Class to store sorting order of favorites landmarks in a local file. EXT-3985.
- * It replaced previously implemented solution to store sort index in landmark's name as a "<N>@" prefix.
- * Data are stored in user home directory.
- */
-class LLFavoritesOrderStorage : public LLSingleton<LLFavoritesOrderStorage>
- , public LLDestroyClass<LLFavoritesOrderStorage>
-{
- LOG_CLASS(LLFavoritesOrderStorage);
-public:
- /**
- * Sets sort index for specified with LLUUID favorite landmark
- */
- void setSortIndex(const LLUUID& inv_item_id, S32 sort_index);
-
- /**
- * Gets sort index for specified with LLUUID favorite landmark
- */
- S32 getSortIndex(const LLUUID& inv_item_id);
- void removeSortIndex(const LLUUID& inv_item_id);
-
- void getSLURL(const LLUUID& asset_id);
-
- /**
- * Implementation of LLDestroyClass. Calls cleanup() instance method.
- *
- * It is important this callback is called before gInventory is cleaned.
- * For now it is called from LLAppViewer::cleanup() -> LLAppViewer::disconnectViewer(),
- * Inventory is cleaned later from LLAppViewer::cleanup() after LLAppViewer::disconnectViewer() is called.
- * @see cleanup()
- */
- static void destroyClass();
-
- const static S32 NO_INDEX;
-private:
- friend class LLSingleton<LLFavoritesOrderStorage>;
- LLFavoritesOrderStorage() : mIsDirty(false) { load(); }
- ~LLFavoritesOrderStorage() { save(); }
-
- /**
- * Removes sort indexes for items which are not in Favorites bar for now.
- */
- void cleanup();
-
- const static std::string SORTING_DATA_FILE_NAME;
-
- void load();
- void save();
-
- void saveFavoritesSLURLs();
-
- // Remove record of current user's favorites from file on disk.
- void removeFavoritesRecordOfUser();
-
- void onLandmarkLoaded(const LLUUID& asset_id, LLLandmark* landmark);
- void storeFavoriteSLURL(const LLUUID& asset_id, std::string& slurl);
-
- typedef std::map<LLUUID, S32> sort_index_map_t;
- sort_index_map_t mSortIndexes;
-
- typedef std::map<LLUUID, std::string> slurls_map_t;
- slurls_map_t mSLURLs;
-
- bool mIsDirty;
-
- struct IsNotInFavorites
- {
- IsNotInFavorites(const LLInventoryModel::item_array_t& items)
- : mFavoriteItems(items)
- {
-
- }
-
- /**
- * Returns true if specified item is not found among inventory items
- */
- bool operator()(const sort_index_map_t::value_type& id_index_pair) const
- {
- LLPointer<LLViewerInventoryItem> item = gInventory.getItem(id_index_pair.first);
- if (item.isNull()) return true;
-
- LLInventoryModel::item_array_t::const_iterator found_it =
- std::find(mFavoriteItems.begin(), mFavoriteItems.end(), item);
-
- return found_it == mFavoriteItems.end();
- }
- private:
- LLInventoryModel::item_array_t mFavoriteItems;
- };
-
-};
-
-const std::string LLFavoritesOrderStorage::SORTING_DATA_FILE_NAME = "landmarks_sorting.xml";
-const S32 LLFavoritesOrderStorage::NO_INDEX = -1;
-
-void LLFavoritesOrderStorage::setSortIndex(const LLUUID& inv_item_id, S32 sort_index)
-{
- mSortIndexes[inv_item_id] = sort_index;
- mIsDirty = true;
-}
-
-S32 LLFavoritesOrderStorage::getSortIndex(const LLUUID& inv_item_id)
-{
- sort_index_map_t::const_iterator it = mSortIndexes.find(inv_item_id);
- if (it != mSortIndexes.end())
- {
- return it->second;
- }
- return NO_INDEX;
-}
-
-void LLFavoritesOrderStorage::removeSortIndex(const LLUUID& inv_item_id)
-{
- mSortIndexes.erase(inv_item_id);
- mIsDirty = true;
-}
-
-void LLFavoritesOrderStorage::getSLURL(const LLUUID& asset_id)
-{
- slurls_map_t::iterator slurl_iter = mSLURLs.find(asset_id);
- if (slurl_iter != mSLURLs.end()) return; // SLURL for current landmark is already cached
-
- LLLandmark* lm = gLandmarkList.getAsset(asset_id,
- boost::bind(&LLFavoritesOrderStorage::onLandmarkLoaded, this, asset_id, _1));
- if (lm)
- {
- onLandmarkLoaded(asset_id, lm);
- }
-}
-
-// static
-void LLFavoritesOrderStorage::destroyClass()
-{
- LLFavoritesOrderStorage::instance().cleanup();
- if (gSavedPerAccountSettings.getBOOL("ShowFavoritesOnLogin"))
- {
- LLFavoritesOrderStorage::instance().saveFavoritesSLURLs();
- }
- else
- {
- LLFavoritesOrderStorage::instance().removeFavoritesRecordOfUser();
- }
-}
-
-void LLFavoritesOrderStorage::load()
-{
- // load per-resident sorting information
- std::string filename = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, SORTING_DATA_FILE_NAME);
-
- LLSD settings_llsd;
- llifstream file;
- file.open(filename);
- if (file.is_open())
- {
- LLSDSerialize::fromXML(settings_llsd, file);
- }
-
- for (LLSD::map_const_iterator iter = settings_llsd.beginMap();
- iter != settings_llsd.endMap(); ++iter)
- {
- mSortIndexes.insert(std::make_pair(LLUUID(iter->first), (S32)iter->second.asInteger()));
- }
-}
-
-void LLFavoritesOrderStorage::saveFavoritesSLURLs()
-{
- // Do not change the file if we are not logged in yet.
- if (!LLLoginInstance::getInstance()->authSuccess())
- {
- llwarns << "Cannot save favorites: not logged in" << llendl;
- return;
- }
-
- std::string user_dir = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "");
- if (user_dir.empty())
- {
- llwarns << "Cannot save favorites: empty user dir name" << llendl;
- return;
- }
-
- std::string filename = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "stored_favorites.xml");
- llifstream in_file;
- in_file.open(filename);
- LLSD fav_llsd;
- if (in_file.is_open())
- {
- LLSDSerialize::fromXML(fav_llsd, in_file);
- }
-
- const LLUUID fav_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_FAVORITE);
- LLInventoryModel::cat_array_t cats;
- LLInventoryModel::item_array_t items;
- gInventory.collectDescendents(fav_id, cats, items, LLInventoryModel::EXCLUDE_TRASH);
-
- LLSD user_llsd;
- for (LLInventoryModel::item_array_t::iterator it = items.begin(); it != items.end(); it++)
- {
- LLSD value;
- value["name"] = (*it)->getName();
- value["asset_id"] = (*it)->getAssetUUID();
-
- slurls_map_t::iterator slurl_iter = mSLURLs.find(value["asset_id"]);
- if (slurl_iter != mSLURLs.end())
- {
- lldebugs << "Saving favorite: idx=" << (*it)->getSortField() << ", SLURL=" << slurl_iter->second << ", value=" << value << llendl;
- value["slurl"] = slurl_iter->second;
- user_llsd[(*it)->getSortField()] = value;
- }
- else
- {
- llwarns << "Not saving favorite " << value["name"] << ": no matching SLURL" << llendl;
- }
- }
-
- LLAvatarName av_name;
- LLAvatarNameCache::get( gAgentID, &av_name );
- lldebugs << "Saved favorites for " << av_name.getLegacyName() << llendl;
- fav_llsd[av_name.getLegacyName()] = user_llsd;
-
- llofstream file;
- file.open(filename);
- LLSDSerialize::toPrettyXML(fav_llsd, file);
-}
-
-void LLFavoritesOrderStorage::removeFavoritesRecordOfUser()
-{
- std::string filename = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "stored_favorites.xml");
- LLSD fav_llsd;
- llifstream file;
- file.open(filename);
- if (!file.is_open()) return;
- LLSDSerialize::fromXML(fav_llsd, file);
-
- LLAvatarName av_name;
- LLAvatarNameCache::get( gAgentID, &av_name );
- lldebugs << "Removed favorites for " << av_name.getLegacyName() << llendl;
- if (fav_llsd.has(av_name.getLegacyName()))
- {
- fav_llsd.erase(av_name.getLegacyName());
- }
-
- llofstream out_file;
- out_file.open(filename);
- LLSDSerialize::toPrettyXML(fav_llsd, out_file);
-
-}
-
-void LLFavoritesOrderStorage::onLandmarkLoaded(const LLUUID& asset_id, LLLandmark* landmark)
-{
- if (!landmark) return;
-
- LLVector3d pos_global;
- if (!landmark->getGlobalPos(pos_global))
- {
- // If global position was unknown on first getGlobalPos() call
- // it should be set for the subsequent calls.
- landmark->getGlobalPos(pos_global);
- }
-
- if (!pos_global.isExactlyZero())
- {
- LLLandmarkActions::getSLURLfromPosGlobal(pos_global,
- boost::bind(&LLFavoritesOrderStorage::storeFavoriteSLURL, this, asset_id, _1));
- }
-}
-
-void LLFavoritesOrderStorage::storeFavoriteSLURL(const LLUUID& asset_id, std::string& slurl)
-{
- lldebugs << "Saving landmark SLURL: " << slurl << llendl;
- mSLURLs[asset_id] = slurl;
-}
-
-void LLFavoritesOrderStorage::save()
-{
- // nothing to save if clean
- if (!mIsDirty) return;
-
- // If we quit from the login screen we will not have an SL account
- // name. Don't try to save, otherwise we'll dump a file in
- // C:\Program Files\SecondLife\ or similar. JC
- std::string user_dir = gDirUtilp->getLindenUserDir();
- if (!user_dir.empty())
- {
- std::string filename = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, SORTING_DATA_FILE_NAME);
- LLSD settings_llsd;
-
- for(sort_index_map_t::const_iterator iter = mSortIndexes.begin(); iter != mSortIndexes.end(); ++iter)
- {
- settings_llsd[iter->first.asString()] = iter->second;
- }
-
- llofstream file;
- file.open(filename);
- LLSDSerialize::toPrettyXML(settings_llsd, file);
- }
-}
-
-void LLFavoritesOrderStorage::cleanup()
-{
- // nothing to clean
- if (!mIsDirty) return;
-
- const LLUUID fav_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_FAVORITE);
- LLInventoryModel::cat_array_t cats;
- LLInventoryModel::item_array_t items;
- gInventory.collectDescendents(fav_id, cats, items, LLInventoryModel::EXCLUDE_TRASH);
-
- IsNotInFavorites is_not_in_fav(items);
-
- sort_index_map_t aTempMap;
- //copy unremoved values from mSortIndexes to aTempMap
- std::remove_copy_if(mSortIndexes.begin(), mSortIndexes.end(),
- inserter(aTempMap, aTempMap.begin()),
- is_not_in_fav);
-
- //Swap the contents of mSortIndexes and aTempMap
- mSortIndexes.swap(aTempMap);
-}
-
-
-S32 LLViewerInventoryItem::getSortField() const
-{
- return LLFavoritesOrderStorage::instance().getSortIndex(mUUID);
-}
-
-void LLViewerInventoryItem::setSortField(S32 sortField)
-{
- LLFavoritesOrderStorage::instance().setSortIndex(mUUID, sortField);
- getSLURL();
-}
-
-void LLViewerInventoryItem::getSLURL()
-{
- LLFavoritesOrderStorage::instance().getSLURL(mAssetUUID);
-}
-
const LLUUID& LLViewerInventoryItem::getCreatorUUID() const
{
if (const LLViewerInventoryItem *linked_item = getLinkedItem())
diff --git a/indra/newview/llviewerinventory.h b/indra/newview/llviewerinventory.h
index d66362d544..3cf03c3bc5 100644
--- a/indra/newview/llviewerinventory.h
+++ b/indra/newview/llviewerinventory.h
@@ -60,9 +60,6 @@ public:
virtual const LLUUID& getAssetUUID() const;
virtual const LLUUID& getProtectedAssetUUID() const; // returns LLUUID::null if current agent does not have permission to expose this asset's UUID to the user
virtual const std::string& getName() const;
- virtual S32 getSortField() const;
- virtual void setSortField(S32 sortField);
- virtual void getSLURL(); //Caches SLURL for landmark. //*TODO: Find a better way to do it and remove this method from here.
virtual const bool getIsFullPerm() const; // 'fullperm' in the popular sense: modify-ok & copy-ok & transfer-ok, no special god rules applied
virtual const LLUUID& getCreatorUUID() const;
virtual const std::string& getDescription() const;
@@ -72,7 +69,7 @@ public:
virtual LLWearableType::EType getWearableType() const;
virtual U32 getFlags() const;
- using LLInventoryItem::getPermissions;
+ using LLInventoryItem::getPermissions;
using LLInventoryItem::getCreationDate;
using LLInventoryItem::setCreationDate;
using LLInventoryItem::getCRC32;
@@ -287,18 +284,6 @@ public:
void fire(const LLUUID& inv_item);
};
-class AddFavoriteLandmarkCallback : public LLInventoryCallback
-{
-public:
- AddFavoriteLandmarkCallback() : mTargetLandmarkId(LLUUID::null) {}
- void setTargetLandmarkId(const LLUUID& target_uuid) { mTargetLandmarkId = target_uuid; }
-
-private:
- void fire(const LLUUID& inv_item);
-
- LLUUID mTargetLandmarkId;
-};
-
// misc functions
//void inventory_reliable_callback(void**, S32 status);