summaryrefslogtreecommitdiff
path: root/indra/newview/llfolderviewmodelinventory.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llfolderviewmodelinventory.cpp')
-rw-r--r--indra/newview/llfolderviewmodelinventory.cpp49
1 files changed, 38 insertions, 11 deletions
diff --git a/indra/newview/llfolderviewmodelinventory.cpp b/indra/newview/llfolderviewmodelinventory.cpp
index d40a7234e2..b6d856e31b 100644
--- a/indra/newview/llfolderviewmodelinventory.cpp
+++ b/indra/newview/llfolderviewmodelinventory.cpp
@@ -66,7 +66,7 @@ void LLFolderViewModelInventory::sort( LLFolderViewFolder* folder )
{
LL_RECORD_BLOCK_TIME(FTM_INVENTORY_SORT);
- if (!needsSort(folder->getViewModelItem())) return;
+ if (!folder->areChildrenInited() || !needsSort(folder->getViewModelItem())) return;
LLFolderViewModelItemInventory* modelp = static_cast<LLFolderViewModelItemInventory*>(folder->getViewModelItem());
if (modelp->getUUID().isNull()) return;
@@ -132,6 +132,16 @@ bool LLFolderViewModelInventory::isFolderComplete(LLFolderViewFolder* folder)
return false;
}
+//virtual
+void LLFolderViewModelItemInventory::addChild(LLFolderViewModelItem* child)
+{
+ LLFolderViewModelItemInventory* model_child = static_cast<LLFolderViewModelItemInventory*>(child);
+ mLastAddedChildCreationDate = model_child->getCreationDate();
+
+ // this will requestSort()
+ LLFolderViewModelItemCommon::addChild(child);
+}
+
void LLFolderViewModelItemInventory::requestSort()
{
LLFolderViewModelItemCommon::requestSort();
@@ -140,15 +150,31 @@ void LLFolderViewModelItemInventory::requestSort()
{
folderp->requestArrange();
}
- if (static_cast<LLFolderViewModelInventory&>(mRootViewModel).getSorter().isByDate())
- {
- // sort by date potentially affects parent folders which use a date
- // derived from newest item in them
- if (mParent)
- {
- mParent->requestSort();
- }
- }
+ LLInventorySort sorter = static_cast<LLFolderViewModelInventory&>(mRootViewModel).getSorter();
+
+ // Sort by date potentially affects parent folders which use a date
+ // derived from newest item in them
+ if (sorter.isByDate() && mParent)
+ {
+ // If this is an item, parent needs to be resorted
+ // This case shouldn't happen, unless someone calls item->requestSort()
+ if (!folderp)
+ {
+ mParent->requestSort();
+ }
+ // if this is a folder, check sort rules for folder first
+ else if (sorter.isFoldersByDate())
+ {
+ if (mLastAddedChildCreationDate == -1 // nothing was added, some other reason for resort
+ || mLastAddedChildCreationDate > getCreationDate()) // newer child
+ {
+ LLFolderViewModelItemInventory* model_parent = static_cast<LLFolderViewModelItemInventory*>(mParent);
+ model_parent->mLastAddedChildCreationDate = mLastAddedChildCreationDate;
+ mParent->requestSort();
+ }
+ }
+ }
+ mLastAddedChildCreationDate = -1;
}
void LLFolderViewModelItemInventory::setPassedFilter(bool passed, S32 filter_generation, std::string::size_type string_offset, std::string::size_type string_size)
@@ -387,6 +413,7 @@ bool LLInventorySort::operator()(const LLFolderViewModelItemInventory* const& a,
LLFolderViewModelItemInventory::LLFolderViewModelItemInventory( class LLFolderViewModelInventory& root_view_model ) :
LLFolderViewModelItemCommon(root_view_model),
- mPrevPassedAllFilters(false)
+ mPrevPassedAllFilters(false),
+ mLastAddedChildCreationDate(-1)
{
}