diff --git a/indra/newview/llfolderviewitem.cpp b/indra/newview/llfolderviewitem.cpp index f86d4824bf..35745b5e2e 100644 --- a/indra/newview/llfolderviewitem.cpp +++ b/indra/newview/llfolderviewitem.cpp @@ -45,6 +45,8 @@ #include "llfocusmgr.h" // gFocusMgr #include "lltrans.h" +#include "llinventorypanel.h" + ///---------------------------------------------------------------------------- /// Class LLFolderViewItem ///---------------------------------------------------------------------------- @@ -897,7 +899,7 @@ void LLFolderViewItem::draw() const bool up_to_date = mListener && mListener->isUpToDate(); const bool possibly_has_children = ((up_to_date && hasVisibleChildren()) // we fetched our children and some of them have passed the filter... || (!up_to_date && mListener && mListener->hasChildren())); // ...or we know we have children but haven't fetched them (doesn't obey filter) - if (possibly_has_children) + if (possibly_has_children || isPreCreatedFolder() ) // JIT folders / support for isPreCreatedFolder { LLUIImage* arrow_image = default_params.folder_arrow_image; gl_draw_scaled_rotated_image( @@ -1144,7 +1146,9 @@ LLFolderViewFolder::LLFolderViewFolder( const LLFolderViewItem::Params& p ): mCompletedFilterGeneration(-1), mMostFilteredDescendantGeneration(-1), mNeedsSort(false), - mPassedFolderFilter(FALSE) + mPassedFolderFilter(FALSE), + mIsPopulated( false ), + mParentPanel(0) { } @@ -2139,6 +2143,15 @@ void LLFolderViewFolder::setOpen(BOOL openitem) void LLFolderViewFolder::setOpenArrangeRecursively(BOOL openitem, ERecurseType recurse) { + // JIT Folders + if( !mIsPopulated && mParentPanel ) + { + llinfos << "Lazy populating " << getName() << llendl; + mParentPanel->addSubItems( mFolderId ); + mIsPopulated = true; + } + // + BOOL was_open = mIsOpen; mIsOpen = openitem; if (mListener) diff --git a/indra/newview/llfolderviewitem.h b/indra/newview/llfolderviewitem.h index dac0c3032c..03eb1b4363 100644 --- a/indra/newview/llfolderviewitem.h +++ b/indra/newview/llfolderviewitem.h @@ -338,6 +338,10 @@ public: EAcceptance* accept, std::string& tooltip_msg); + // JIT folders + virtual bool isPreCreatedFolder() + { return false; } + private: static std::map sFonts; // map of styles to fonts }; @@ -357,6 +361,12 @@ typedef bool (*sort_order_f)(LLFolderViewItem* a, LLFolderViewItem* b); class LLFolderViewFolder : public LLFolderViewItem { + // JIT folders + LLUUID mFolderId; + class LLInventoryPanel *mParentPanel; + bool mIsPopulated; + // + protected: LLFolderViewFolder( const LLFolderViewItem::Params& ); friend class LLUICtrlFactory; @@ -377,6 +387,17 @@ public: // Accessed needed by LLFolderViewItem void recursiveIncrementNumDescendantsSelected(S32 increment); S32 numSelected(void) const { return mNumDescendantsSelected + (isSelected() ? 1 : 0); } + // JIT Folders + void setPanel( LLInventoryPanel* aPanel ) + { mParentPanel = aPanel; } + + void setFolderId( LLUUID const &aFolderId ) + { mFolderId = aFolderId; } + + virtual bool isPreCreatedFolder() + { return !mIsPopulated; } + // + protected: items_t mItems; folders_t mFolders; diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp index a2c7110d74..b874db6816 100644 --- a/indra/newview/llinventorypanel.cpp +++ b/indra/newview/llinventorypanel.cpp @@ -740,6 +740,10 @@ LLFolderViewItem* LLInventoryPanel::buildNewViews(const LLUUID& id) if (new_listener) { LLFolderViewFolder* folderp = createFolderViewFolder(new_listener); + // Subfolder JIT + folderp->setPanel(this); + folderp->setFolderId( id ); + // folderp->setItemSortOrder(mFolderRoot->getSortOrder()); itemp = folderp; } @@ -769,6 +773,19 @@ LLFolderViewItem* LLInventoryPanel::buildNewViews(const LLUUID& id) } } + // Subfolder JIT + if( id == getRootFolderID() ) + addSubItems( id ); + // + + return itemp; +} + +// JIT subfolder processing +void LLInventoryPanel::addSubItems(const LLUUID& id) +{ + LLInventoryObject const* objectp = gInventory.getObject(id); + // If this is a folder, add the children of the folder and recursively add any // child folders. if (id.isNull() @@ -778,7 +795,11 @@ LLFolderViewItem* LLInventoryPanel::buildNewViews(const LLUUID& id) LLViewerInventoryCategory::cat_array_t* categories; LLViewerInventoryItem::item_array_t* items; mInventory->lockDirectDescendentArrays(id, categories, items); - + LLFolderViewFolder *parent_folder(0); + + if( items && objectp ) + parent_folder = (LLFolderViewFolder*)mFolderRoot->getItemByID(objectp->getParentUUID()); + if(categories) { for (LLViewerInventoryCategory::cat_array_t::const_iterator cat_iter = categories->begin(); @@ -786,7 +807,9 @@ LLFolderViewItem* LLInventoryPanel::buildNewViews(const LLUUID& id) ++cat_iter) { const LLViewerInventoryCategory* cat = (*cat_iter); - buildNewViews(cat->getUUID()); + //buildNewViews(cat->getUUID()); + if( !mFolderRoot->getItemByID( cat->getUUID() ) ) //ND + buildNewViews(cat->getUUID()); } } @@ -797,13 +820,13 @@ LLFolderViewItem* LLInventoryPanel::buildNewViews(const LLUUID& id) ++item_iter) { const LLViewerInventoryItem* item = (*item_iter); - buildNewViews(item->getUUID()); + //buildNewViews(cat->getUUID()); + if( !mFolderRoot->getItemByID( item->getUUID() ) ) //ND + buildNewViews(item->getUUID()); } } mInventory->unlockDirectDescendentArrays(id); } - - return itemp; } // bit of a hack to make sure the inventory is open. diff --git a/indra/newview/llinventorypanel.h b/indra/newview/llinventorypanel.h index 0485666d73..662f53e358 100644 --- a/indra/newview/llinventorypanel.h +++ b/indra/newview/llinventorypanel.h @@ -226,6 +226,9 @@ public: public: BOOL getIsViewsInitialized() const { return mViewsInitialized; } const LLUUID& getRootFolderID() const; + + void addSubItems(const LLUUID& id); //ND Just-In-Time subfolder load + protected: // Builds the UI. Call this once the inventory is usable. void initializeViews();