summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxim Nikolenko <maximnproductengine@lindenlab.com>2023-06-19 23:03:06 +0300
committerMaxim Nikolenko <maximnproductengine@lindenlab.com>2023-06-19 23:03:06 +0300
commit93ab02b672efc5388230629bafb5519e725a3683 (patch)
tree4146e96e18c8b1484095914ad6976c74ef03260f
parentb721d20ea9999abbc3fdc72a6eb83fc331b962c7 (diff)
SL-19885 add sorting by date for Gallery view
-rw-r--r--indra/newview/llinventorygallery.cpp48
-rw-r--r--indra/newview/llinventorygallery.h9
-rw-r--r--indra/newview/llpanelmaininventory.cpp15
3 files changed, 64 insertions, 8 deletions
diff --git a/indra/newview/llinventorygallery.cpp b/indra/newview/llinventorygallery.cpp
index 347611dfe2..d76f0a45b2 100644
--- a/indra/newview/llinventorygallery.cpp
+++ b/indra/newview/llinventorygallery.cpp
@@ -87,7 +87,8 @@ LLInventoryGallery::LLInventoryGallery(const LLInventoryGallery::Params& p)
mIsInitialized(false),
mRootDirty(false),
mNeedsArrange(false),
- mSearchType(LLInventoryFilter::SEARCHTYPE_NAME)
+ mSearchType(LLInventoryFilter::SEARCHTYPE_NAME),
+ mSortOrder(LLInventoryFilter::SO_DATE)
{
updateGalleryWidth();
mFilter = new LLInventoryFilter();
@@ -369,19 +370,35 @@ bool LLInventoryGallery::updateRowsIfNeeded()
return false;
}
-bool compareGalleryItem(LLInventoryGalleryItem* item1, LLInventoryGalleryItem* item2)
+bool compareGalleryItem(LLInventoryGalleryItem* item1, LLInventoryGalleryItem* item2, bool sort_by_date, bool sort_folders_by_name)
{
if (item1->getSortGroup() != item2->getSortGroup())
{
return (item1->getSortGroup() < item2->getSortGroup());
}
- if(((item1->isDefaultImage() && item2->isDefaultImage()) || (!item1->isDefaultImage() && !item2->isDefaultImage())))
+
+ if(sort_folders_by_name && (item1->getSortGroup() != LLInventoryGalleryItem::SG_ITEM))
{
std::string name1 = item1->getItemName();
std::string name2 = item2->getItemName();
return (LLStringUtil::compareDict(name1, name2) < 0);
}
+
+ if(((item1->isDefaultImage() && item2->isDefaultImage()) || (!item1->isDefaultImage() && !item2->isDefaultImage())))
+ {
+ if(sort_by_date)
+ {
+ return item1->getCreationDate() > item2->getCreationDate();
+ }
+ else
+ {
+ std::string name1 = item1->getItemName();
+ std::string name2 = item2->getItemName();
+
+ return (LLStringUtil::compareDict(name1, name2) < 0);
+ }
+ }
else
{
return item2->isDefaultImage();
@@ -403,7 +420,13 @@ void LLInventoryGallery::reArrangeRows(S32 row_diff)
mItemsInRow+= row_diff;
updateGalleryWidth();
- std::sort(buf_items.begin(), buf_items.end(), compareGalleryItem);
+
+ bool sort_by_date = (mSortOrder & LLInventoryFilter::SO_DATE);
+ bool sort_folders_by_name = (mSortOrder & LLInventoryFilter::SO_FOLDERS_BY_NAME);
+ std::sort(buf_items.begin(), buf_items.end(), [sort_by_date, sort_folders_by_name](LLInventoryGalleryItem* item1, LLInventoryGalleryItem* item2)
+ {
+ return compareGalleryItem(item1, item2, sort_by_date, sort_folders_by_name);
+ });
for (std::vector<LLInventoryGalleryItem*>::const_iterator it = buf_items.begin(); it != buf_items.end(); ++it)
{
@@ -573,7 +596,7 @@ void LLInventoryGallery::removeFromLastRow(LLInventoryGalleryItem* item)
mItemPanels.pop_back();
}
-LLInventoryGalleryItem* LLInventoryGallery::buildGalleryItem(std::string name, LLUUID item_id, LLAssetType::EType type, LLUUID thumbnail_id, LLInventoryType::EType inventory_type, U32 flags, bool is_link, bool is_worn)
+LLInventoryGalleryItem* LLInventoryGallery::buildGalleryItem(std::string name, LLUUID item_id, LLAssetType::EType type, LLUUID thumbnail_id, LLInventoryType::EType inventory_type, U32 flags, time_t creation_date, bool is_link, bool is_worn)
{
LLInventoryGalleryItem::Params giparams;
giparams.visible = true;
@@ -589,6 +612,7 @@ LLInventoryGalleryItem* LLInventoryGallery::buildGalleryItem(std::string name, L
gitem->setCreatorName(get_searchable_creator_name(&gInventory, item_id));
gitem->setDescription(get_searchable_description(&gInventory, item_id));
gitem->setAssetIDStr(get_searchable_UUID(&gInventory, item_id));
+ gitem->setCreationDate(creation_date);
return gitem;
}
@@ -857,7 +881,8 @@ bool LLInventoryGallery::updateAddedItem(LLUUID item_id)
}
bool res = false;
- LLInventoryGalleryItem* item = buildGalleryItem(name, item_id, obj->getType(), thumbnail_id, inventory_type, misc_flags, obj->getIsLinkType(), is_worn);
+
+ LLInventoryGalleryItem* item = buildGalleryItem(name, item_id, obj->getType(), thumbnail_id, inventory_type, misc_flags, obj->getCreationDate(), obj->getIsLinkType(), is_worn);
mItemMap.insert(LLInventoryGallery::gallery_item_map_t::value_type(item_id, item));
item->setRightMouseDownCallback(boost::bind(&LLInventoryGallery::showContextMenu, this, _1, _2, _3, item_id));
item->setFocusReceivedCallback(boost::bind(&LLInventoryGallery::changeItemSelection, this, item_id, false));
@@ -2006,6 +2031,17 @@ void LLInventoryGallery::handleModifiedFilter()
}
}
+void LLInventoryGallery::setSortOrder(U32 order, bool update)
+{
+ bool dirty = (mSortOrder != order);
+
+ mSortOrder = order;
+ if(update && dirty)
+ {
+ mNeedsArrange = true;
+ gIdleCallbacks.addFunction(onIdle, (void*)this);
+ }
+}
//-----------------------------
// LLInventoryGalleryItem
//-----------------------------
diff --git a/indra/newview/llinventorygallery.h b/indra/newview/llinventorygallery.h
index cb95f61255..f686d8aa2b 100644
--- a/indra/newview/llinventorygallery.h
+++ b/indra/newview/llinventorygallery.h
@@ -157,6 +157,9 @@ public:
bool canDeleteSelection();
void pasteAsLink();
+ void setSortOrder(U32 order, bool update = false);
+ U32 getSortOrder() { return mSortOrder; };
+
void claimEditHandler();
static bool isItemCopyable(const LLUUID & item_id);
@@ -202,7 +205,7 @@ private:
bool updateRowsIfNeeded();
void updateGalleryWidth();
- LLInventoryGalleryItem* buildGalleryItem(std::string name, LLUUID item_id, LLAssetType::EType type, LLUUID thumbnail_id, LLInventoryType::EType inventory_type, U32 flags, bool is_link, bool is_worn);
+ LLInventoryGalleryItem* buildGalleryItem(std::string name, LLUUID item_id, LLAssetType::EType type, LLUUID thumbnail_id, LLInventoryType::EType inventory_type, U32 flags, time_t creation_date, bool is_link, bool is_worn);
void buildGalleryPanel(int row_count);
void reshapeGalleryPanel(int row_count);
@@ -242,6 +245,7 @@ private:
LLInventoryGalleryContextMenu* mRootGalleryMenu;
std::string mFilterSubString;
LLInventoryFilter* mFilter;
+ U32 mSortOrder;
typedef std::map<LLUUID, LLInventoryGalleryItem*> gallery_item_map_t;
gallery_item_map_t mItemMap;
@@ -300,6 +304,8 @@ public:
std::string getDescription() { return mDesc;}
void setCreatorName(std::string name) {mCreatorName = name;}
std::string getCreatorName() { return mCreatorName;}
+ void setCreationDate(time_t date) {mCreationDate = date;}
+ time_t getCreationDate() { return mCreationDate;}
std::string getItemName() {return mItemName;}
std::string getItemNameSuffix() {return mPermSuffix + mWornSuffix;}
@@ -332,6 +338,7 @@ private:
std::string mAssetIDStr;
std::string mDesc;
std::string mCreatorName;
+ time_t mCreationDate;
EInventorySortGroup mSortGroup;
LLAssetType::EType mType;
diff --git a/indra/newview/llpanelmaininventory.cpp b/indra/newview/llpanelmaininventory.cpp
index 107a00f35a..30364e06eb 100644
--- a/indra/newview/llpanelmaininventory.cpp
+++ b/indra/newview/llpanelmaininventory.cpp
@@ -265,6 +265,7 @@ BOOL LLPanelMainInventory::postBuild()
mListViewRootUpdatedConnection = mCombinationInventoryPanel->setRootChangedCallback(boost::bind(&LLPanelMainInventory::onCombinationRootChanged, this, false));
mCombinationGalleryPanel = getChild<LLInventoryGallery>("comb_gallery_view_inv");
+ mCombinationGalleryPanel->setSortOrder(mCombinationInventoryPanel->getSortOrder());
LLInventoryFilter& comb_gallery_filter = mCombinationGalleryPanel->getFilter();
comb_gallery_filter.setFilterThumbnails(LLInventoryFilter::FILTER_ONLY_THUMBNAILS);
comb_gallery_filter.markDefault();
@@ -631,6 +632,10 @@ void LLPanelMainInventory::setSortBy(const LLSD& userdata)
sort_order_mask |= LLInventoryFilter::SO_SYSTEM_FOLDERS_TO_TOP;
}
}
+ if(mSingleFolderMode && !isListViewMode())
+ {
+ mCombinationGalleryPanel->setSortOrder(sort_order_mask, true);
+ }
getActivePanel()->setSortOrder(sort_order_mask);
if (isRecentItemsPanelSelected())
@@ -2150,7 +2155,7 @@ bool LLPanelMainInventory::isActionVisible(const LLSD& userdata)
BOOL LLPanelMainInventory::isActionChecked(const LLSD& userdata)
{
- U32 sort_order_mask = getActivePanel()->getSortOrder();
+ U32 sort_order_mask = (mSingleFolderMode && isGalleryViewMode()) ? mCombinationGalleryPanel->getSortOrder() : getActivePanel()->getSortOrder();
const std::string command_name = userdata.asString();
if (command_name == "sort_by_name")
{
@@ -2500,20 +2505,24 @@ void LLPanelMainInventory::setViewMode(EViewModeType mode)
{
std::list<LLUUID> forward_history;
std::list<LLUUID> backward_history;
+ U32 sort_order;
switch(mViewMode)
{
case MODE_LIST:
forward_history = mCombinationInventoryPanel->getNavForwardList();
backward_history = mCombinationInventoryPanel->getNavBackwardList();
+ sort_order = mCombinationInventoryPanel->getSortOrder();
break;
case MODE_GALLERY:
forward_history = mCombinationGalleryPanel->getNavForwardList();
backward_history = mCombinationGalleryPanel->getNavBackwardList();
+ sort_order = mCombinationGalleryPanel->getSortOrder();
break;
case MODE_COMBINATION:
forward_history = mCombinationInventoryPanel->getNavForwardList();
backward_history = mCombinationInventoryPanel->getNavBackwardList();
mCombinationInventoryPanel->getRootFolder()->setForceArrange(false);
+ sort_order = mCombinationInventoryPanel->getSortOrder();
break;
}
@@ -2527,12 +2536,14 @@ void LLPanelMainInventory::setViewMode(EViewModeType mode)
mCombinationInventoryPanel->changeFolderRoot(cur_root);
mCombinationInventoryPanel->setNavForwardList(forward_history);
mCombinationInventoryPanel->setNavBackwardList(backward_history);
+ mCombinationInventoryPanel->setSortOrder(sort_order);
}
if(isGalleryViewMode())
{
mCombinationGalleryPanel->setRootFolder(cur_root);
mCombinationGalleryPanel->setNavForwardList(forward_history);
mCombinationGalleryPanel->setNavBackwardList(backward_history);
+ mCombinationGalleryPanel->setSortOrder(sort_order, true);
}
if(isCombinationViewMode())
{
@@ -2542,6 +2553,8 @@ void LLPanelMainInventory::setViewMode(EViewModeType mode)
mCombinationInventoryPanel->setNavBackwardList(backward_history);
mCombinationGalleryPanel->setNavForwardList(forward_history);
mCombinationGalleryPanel->setNavBackwardList(backward_history);
+ mCombinationInventoryPanel->setSortOrder(sort_order);
+ mCombinationGalleryPanel->setSortOrder(sort_order, true);
}
updateNavButtons();