From 9940ca5ae7698e89c0587733f7ab922027c8ddcc Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 15 Jun 2012 09:44:27 -0700 Subject: CHUI-101 WIP Make LLFolderView general purpose llfolderview refactornig --- indra/newview/llfolderviewitem.cpp | 554 +++++++++++-------------------------- 1 file changed, 163 insertions(+), 391 deletions(-) (limited to 'indra/newview/llfolderviewitem.cpp') diff --git a/indra/newview/llfolderviewitem.cpp b/indra/newview/llfolderviewitem.cpp index 43d3675d17..f452ae25c3 100644 --- a/indra/newview/llfolderviewitem.cpp +++ b/indra/newview/llfolderviewitem.cpp @@ -29,6 +29,7 @@ // viewer includes #include "llfolderview.h" // Items depend extensively on LLFolderViews +#include "llfolderview.h" #include "llfoldervieweventlistener.h" #include "llviewerfoldertype.h" #include "llinventorybridge.h" // for LLItemBridge in LLInventorySort::operator() @@ -121,15 +122,12 @@ LLFolderViewItem::LLFolderViewItem(const LLFolderViewItem::Params& p) mStringMatchOffset(std::string::npos), mControlLabelRotation(0.f), mDragAndDropTarget(FALSE), - mIsLoading(FALSE), mLabel(p.name), mRoot(p.root), - mCreationDate(p.creation_date), mIcon(p.icon), mIconOpen(p.icon_open), mIconOverlay(p.icon_overlay), mListener(p.listener), - mShowLoadStatus(false), mIsMouseOverTitle(false) { } @@ -218,14 +216,13 @@ LLFolderViewItem* LLFolderViewItem::getPreviousOpenNode(BOOL include_children) // until we find out otherwise BOOL LLFolderViewItem::potentiallyVisible() { - // we haven't been checked against min required filter - // or we have and we passed - return getLastFilterGeneration() < getRoot()->getFilter()->getMinRequiredGeneration() || getFiltered(); + return getFiltered() // we've passed the filter + || getLastFilterGeneration() < getRoot()->getFilter()->getFirstSuccessGeneration()); // or we don't know yet } BOOL LLFolderViewItem::getFiltered() { - return mPassedFilter && mLastFilterGeneration >= getRoot()->getFilter()->getMinRequiredGeneration(); + return mPassedFilter && mLastFilterGeneration >= getRoot()->getFilter()->getFirstSuccessGeneration(); } BOOL LLFolderViewItem::getFiltered(S32 filter_generation) @@ -244,60 +241,47 @@ void LLFolderViewItem::setIcon(LLUIImagePtr icon) mIcon = icon; } -// refresh information from the listener -void LLFolderViewItem::refreshFromListener() +void LLFolderViewItem::refresh() { - if(mListener) - { - mLabel = mListener->getDisplayName(); - LLFolderType::EType preferred_type = mListener->getPreferredType(); - - // *TODO: to be removed when database supports multi language. This is a - // temporary attempt to display the inventory folder in the user locale. - // mantipov: *NOTE: be sure this code is synchronized with LLFriendCardsManager::findChildFolderUUID - // it uses the same way to find localized string + if(!getListener()) return; - // HACK: EXT - 6028 ([HARD CODED]? Inventory > Library > "Accessories" folder) - // Translation of Accessories folder in Library inventory folder - bool accessories = false; - if(mLabel == std::string("Accessories")) - { - //To ensure that Accessories folder is in Library we have to check its parent folder. - //Due to parent LLFolderViewFloder is not set to this item yet we have to check its parent via Inventory Model - LLInventoryCategory* cat = gInventory.getCategory(mListener->getUUID()); - if(cat) - { - const LLUUID& parent_folder_id = cat->getParentUUID(); - accessories = (parent_folder_id == gInventory.getLibraryRootFolderID()); - } - } + mLabel = getListener()->getDisplayName(); + LLFolderType::EType preferred_type = getListener()->getPreferredType(); - //"Accessories" inventory category has folder type FT_NONE. So, this folder - //can not be detected as protected with LLFolderType::lookupIsProtectedType - if (accessories || LLFolderType::lookupIsProtectedType(preferred_type)) - { - LLTrans::findString(mLabel, "InvFolder " + mLabel); - }; + // *TODO: to be removed when database supports multi language. This is a + // temporary attempt to display the inventory folder in the user locale. + // mantipov: *NOTE: be sure this code is synchronized with LLFriendCardsManager::findChildFolderUUID + // it uses the same way to find localized string - setToolTip(mLabel); - setIcon(mListener->getIcon()); - time_t creation_date = mListener->getCreationDate(); - if ((creation_date > 0) && (mCreationDate != creation_date)) - { - setCreationDate(creation_date); - dirtyFilter(); - } - if (mRoot->useLabelSuffix()) + // HACK: EXT - 6028 ([HARD CODED]? Inventory > Library > "Accessories" folder) + // Translation of Accessories folder in Library inventory folder + bool accessories = false; + if(mLabel == std::string("Accessories")) + { + //To ensure that Accessories folder is in Library we have to check its parent folder. + //Due to parent LLFolderViewFloder is not set to this item yet we have to check its parent via Inventory Model + LLInventoryCategory* cat = gInventory.getCategory(getListener()->getUUID()); + if(cat) { - mLabelStyle = mListener->getLabelStyle(); - mLabelSuffix = mListener->getLabelSuffix(); + const LLUUID& parent_folder_id = cat->getParentUUID(); + accessories = (parent_folder_id == gInventory.getLibraryRootFolderID()); } } -} -void LLFolderViewItem::refresh() -{ - refreshFromListener(); + //"Accessories" inventory category has folder type FT_NONE. So, this folder + //can not be detected as protected with LLFolderType::lookupIsProtectedType + if (accessories || LLFolderType::lookupIsProtectedType(preferred_type)) + { + LLTrans::findString(mLabel, "InvFolder " + mLabel); + }; + + setToolTip(mLabel); + setIcon(getListener()->getIcon()); + if (mRoot->useLabelSuffix()) + { + mLabelStyle = getListener()->getLabelStyle(); + mLabelSuffix = getListener()->getLabelSuffix(); + } std::string searchable_label(mLabel); searchable_label.append(mLabelSuffix); @@ -316,11 +300,7 @@ void LLFolderViewItem::refresh() } mLabelWidthDirty = true; -} - -void LLFolderViewItem::applyListenerFunctorRecursively(LLFolderViewListenerFunctor& functor) -{ - functor(mListener); + dirtyFilter(); } // This function is called when items are added or view filters change. It's @@ -386,19 +366,14 @@ void LLFolderViewItem::changeSelectionFromRoot(LLFolderViewItem* selection, BOOL getRoot()->changeSelection(selection, selected); } -std::set LLFolderViewItem::getSelectionList() const +std::set LLFolderViewItem::getSelectionList() const { - std::set selection; + std::set selection; return selection; } -EInventorySortGroup LLFolderViewItem::getSortGroup() const -{ - return SG_ITEM; -} - // addToFolder() returns TRUE if it succeeds. FALSE otherwise -BOOL LLFolderViewItem::addToFolder(LLFolderViewFolder* folder, LLFolderView* root) +BOOL LLFolderViewItem::addToFolder(LLFolderViewFolder* folder) { if (!folder) { @@ -459,7 +434,7 @@ void LLFolderViewItem::filter( LLInventoryFilter& filter) } setFiltered(passed_filter, filter.getCurrentGeneration()); - mStringMatchOffset = filter.getStringMatchOffset(); + mStringMatchOffset = filter.getStringMatchOffset(this); filter.decrementFilterCount(); if (getRoot()->getDebugFilters()) @@ -522,9 +497,9 @@ void LLFolderViewItem::selectItem(void) { if (mIsSelected == FALSE) { - if (mListener) + if (getListener()) { - mListener->selectItem(); + getListener()->selectItem(); } mIsSelected = TRUE; } @@ -532,9 +507,9 @@ void LLFolderViewItem::selectItem(void) BOOL LLFolderViewItem::isMovable() { - if( mListener ) + if( getListener() ) { - return mListener->isItemMovable(); + return getListener()->isItemMovable(); } else { @@ -544,9 +519,9 @@ BOOL LLFolderViewItem::isMovable() BOOL LLFolderViewItem::isRemovable() { - if( mListener ) + if( getListener() ) { - return mListener->isItemRemovable(); + return getListener()->isItemRemovable(); } else { @@ -572,9 +547,9 @@ BOOL LLFolderViewItem::remove() { return FALSE; } - if(mListener) + if(getListener()) { - return mListener->removeItem(); + return getListener()->removeItem(); } return TRUE; } @@ -582,25 +557,25 @@ BOOL LLFolderViewItem::remove() // Build an appropriate context menu for the item. void LLFolderViewItem::buildContextMenu(LLMenuGL& menu, U32 flags) { - if(mListener) + if(getListener()) { - mListener->buildContextMenu(menu, flags); + getListener()->buildContextMenu(menu, flags); } } void LLFolderViewItem::openItem( void ) { - if( mListener ) + if( getListener() ) { - mListener->openItem(); + getListener()->openItem(); } } void LLFolderViewItem::preview( void ) { - if (mListener) + if (getListener()) { - mListener->previewItem(); + getListener()->previewItem(); } } @@ -608,9 +583,9 @@ void LLFolderViewItem::rename(const std::string& new_name) { if( !new_name.empty() ) { - if( mListener ) + if( getListener() ) { - mListener->renameItem(new_name); + getListener()->renameItem(new_name); if(mParentFolder) { @@ -633,11 +608,11 @@ LLViewerInventoryItem * LLFolderViewItem::getInventoryItem(void) const std::string& LLFolderViewItem::getName( void ) const { - if(mListener) + if(getListener()) { - return mListener->getName(); + return getListener()->getName(); } - return mLabel; + return z; } // LLView functionality @@ -713,21 +688,19 @@ BOOL LLFolderViewItem::handleHover( S32 x, S32 y, MASK mask ) // *TODO: push this into listener and remove // dependency on llagent - if (mListener - && gInventory.isObjectDescendentOf(mListener->getUUID(), gInventory.getRootFolderID())) + if (getListener()) { - src = LLToolDragAndDrop::SOURCE_AGENT; + src = getListener()->getDragSource(); } - else if (mListener - && gInventory.isObjectDescendentOf(mListener->getUUID(), gInventory.getLibraryRootFolderID())) + else { - src = LLToolDragAndDrop::SOURCE_LIBRARY; + src = LLToolDragAndDrop::SOURCE_VIEWER; } can_drag = root->startDrag(src); if (can_drag) { - // if (mListener) mListener->startDrag(); + // if (getListener()) getListener()->startDrag(); // RN: when starting drag and drop, clear out last auto-open root->autoOpenTest(NULL); root->setShowSelectionContext(TRUE); @@ -816,9 +789,9 @@ BOOL LLFolderViewItem::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, { BOOL accepted = FALSE; BOOL handled = FALSE; - if(mListener) + if(getListener()) { - accepted = mListener->dragOrDrop(mask,drop,cargo_type,cargo_data, tooltip_msg); + accepted = getListener()->dragOrDrop(mask,drop,cargo_type,cargo_data, tooltip_msg); handled = accepted; if (accepted) { @@ -864,15 +837,14 @@ void LLFolderViewItem::draw() const S32 FOCUS_LEFT = 1; const LLFontGL* font = getLabelFontForStyle(mLabelStyle); - const BOOL in_inventory = getListener() && gInventory.isObjectDescendentOf(getListener()->getUUID(), gInventory.getRootFolderID()); - const BOOL in_library = getListener() && gInventory.isObjectDescendentOf(getListener()->getUUID(), gInventory.getLibraryRootFolderID()); + getListener()->update(); //--------------------------------------------------------------------------------// // Draw open folder arrow // - const bool up_to_date = mListener && mListener->isUpToDate(); + const bool up_to_date = getListener() && getListener()->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) + || (!up_to_date && getListener() && getListener()->hasChildren())); // ...or we know we have children but haven't fetched them (doesn't obey filter) if (possibly_has_children) { LLUIImage* arrow_image = default_params.folder_arrow_image; @@ -1030,30 +1002,6 @@ void LLFolderViewItem::draw() LLFontGL::LEFT, LLFontGL::BOTTOM, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, S32_MAX, getRect().getWidth() - (S32) text_left, &right_x, TRUE); - //--------------------------------------------------------------------------------// - // Draw "Loading..." text - // - bool root_is_loading = false; - if (in_inventory) - { - root_is_loading = LLInventoryModelBackgroundFetch::instance().inventoryFetchInProgress(); - } - if (in_library) - { - root_is_loading = LLInventoryModelBackgroundFetch::instance().libraryFetchInProgress(); - } - if ((mIsLoading - && mTimeSinceRequestStart.getElapsedTimeF32() >= gSavedSettings.getF32("FolderLoadingMessageWaitTime")) - || (LLInventoryModelBackgroundFetch::instance().folderFetchActive() - && root_is_loading - && mShowLoadStatus)) - { - std::string load_string = " ( " + LLTrans::getString("LoadingData") + " ) "; - font->renderUTF8(load_string, 0, right_x, y, sSearchStatusColor, - LLFontGL::LEFT, LLFontGL::BOTTOM, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, - S32_MAX, S32_MAX, &right_x, FALSE); - } - //--------------------------------------------------------------------------------// // Draw label suffix // @@ -1067,28 +1015,29 @@ void LLFolderViewItem::draw() //--------------------------------------------------------------------------------// // Highlight string match // - if (mStringMatchOffset != std::string::npos) - { - // don't draw backgrounds for zero-length strings - S32 filter_string_length = getRoot()->getFilterSubString().size(); - if (filter_string_length > 0) - { - std::string combined_string = mLabel + mLabelSuffix; - S32 left = llround(text_left) + font->getWidth(combined_string, 0, mStringMatchOffset) - 1; - S32 right = left + font->getWidth(combined_string, mStringMatchOffset, filter_string_length) + 2; - S32 bottom = llfloor(getRect().getHeight() - font->getLineHeight() - 3 - TOP_PAD); - S32 top = getRect().getHeight() - TOP_PAD; - - LLUIImage* box_image = default_params.selection_image; - LLRect box_rect(left, top, right, bottom); - box_image->draw(box_rect, sFilterBGColor); - F32 match_string_left = text_left + font->getWidthF32(combined_string, 0, mStringMatchOffset); - F32 yy = (F32)getRect().getHeight() - font->getLineHeight() - (F32)TEXT_PAD - (F32)TOP_PAD; - font->renderUTF8( combined_string, mStringMatchOffset, match_string_left, yy, - sFilterTextColor, LLFontGL::LEFT, LLFontGL::BOTTOM, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, - filter_string_length, S32_MAX, &right_x, FALSE ); - } - } + RN: expose interface for highlighting + //if (mStringMatchOffset != std::string::npos) + //{ + // // don't draw backgrounds for zero-length strings + // S32 filter_string_length = getRoot()->getFilterSubString().size(); + // if (filter_string_length > 0) + // { + // std::string combined_string = mLabel + mLabelSuffix; + // S32 left = llround(text_left) + font->getWidth(combined_string, 0, mStringMatchOffset) - 1; + // S32 right = left + font->getWidth(combined_string, mStringMatchOffset, filter_string_length) + 2; + // S32 bottom = llfloor(getRect().getHeight() - font->getLineHeight() - 3 - TOP_PAD); + // S32 top = getRect().getHeight() - TOP_PAD; + // + // LLUIImage* box_image = default_params.selection_image; + // LLRect box_rect(left, top, right, bottom); + // box_image->draw(box_rect, sFilterBGColor); + // F32 match_string_left = text_left + font->getWidthF32(combined_string, 0, mStringMatchOffset); + // F32 yy = (F32)getRect().getHeight() - font->getLineHeight() - (F32)TEXT_PAD - (F32)TOP_PAD; + // font->renderUTF8( combined_string, mStringMatchOffset, match_string_left, yy, + // sFilterTextColor, LLFontGL::LEFT, LLFontGL::BOTTOM, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, + // filter_string_length, S32_MAX, &right_x, FALSE ); + // } + //} } @@ -1097,19 +1046,16 @@ void LLFolderViewItem::draw() ///---------------------------------------------------------------------------- LLFolderViewFolder::LLFolderViewFolder( const LLFolderViewItem::Params& p ): - LLFolderViewItem( p ), // 0 = no create time + LLFolderViewItem( p ), mIsOpen(FALSE), mExpanderHighlighted(FALSE), mCurHeight(0.f), mTargetHeight(0.f), mAutoOpenCountdown(0.f), - mSubtreeCreationDate(0), - mAmTrash(LLFolderViewFolder::UNKNOWN), mLastArrangeGeneration( -1 ), mLastCalculatedWidth(0), mCompletedFilterGeneration(-1), mMostFilteredDescendantGeneration(-1), - mNeedsSort(false), mPassedFolderFilter(FALSE) { } @@ -1130,32 +1076,30 @@ void LLFolderViewFolder::setFilteredFolder(bool filtered, S32 filter_generation) bool LLFolderViewFolder::getFilteredFolder(S32 filter_generation) { - return mPassedFolderFilter && mLastFilterGeneration >= getRoot()->getFilter()->getMinRequiredGeneration(); + return mPassedFolderFilter && mLastFilterGeneration >= getRoot()->getFilter()->getFirstSuccessGeneration(); } // addToFolder() returns TRUE if it succeeds. FALSE otherwise -BOOL LLFolderViewFolder::addToFolder(LLFolderViewFolder* folder, LLFolderView* root) +BOOL LLFolderViewFolder::addToFolder(LLFolderViewFolder* folder) { if (!folder) { return FALSE; } mParentFolder = folder; - root->addItemID(getListener()->getUUID(), this); return folder->addFolder(this); } +static LLFastTimer::DeclareTimer FTM_ARRANGE("Arrange"); + // Finds width and height of this object and its children. Also // makes sure that this view and its children are the right size. S32 LLFolderViewFolder::arrange( S32* width, S32* height, S32 filter_generation) { // sort before laying out contents - if (mNeedsSort) - { - mFolders.sort(mSortFunction); - mItems.sort(mSortFunction); - mNeedsSort = false; - } + getRoot->getViewModel()->sort(this); + + LLFastTimer t2(FTM_ARRANGE); mHasVisibleChildren = hasFilteredDescendants(filter_generation); @@ -1166,7 +1110,6 @@ S32 LLFolderViewFolder::arrange( S32* width, S32* height, S32 filter_generation) mCurHeight = llmax((F32)*height, mCurHeight); // initialize running height value as height of single item in case we have no children - *height = getItemHeight(); F32 running_height = (F32)*height; F32 target_height = (F32)*height; @@ -1176,7 +1119,7 @@ S32 LLFolderViewFolder::arrange( S32* width, S32* height, S32 filter_generation) // set last arrange generation first, in case children are animating // and need to be arranged again mLastArrangeGeneration = getRoot()->getArrangeGeneration(); - if (mIsOpen) + if (isOpen()) { // Add sizes of children S32 parent_item_height = getRect().getHeight(); @@ -1252,7 +1195,7 @@ S32 LLFolderViewFolder::arrange( S32* width, S32* height, S32 filter_generation) // animate current height towards target height if (llabs(mCurHeight - mTargetHeight) > 1.f) { - mCurHeight = lerp(mCurHeight, mTargetHeight, LLCriticalDamp::getInterpolant(mIsOpen ? FOLDER_OPEN_TIME_CONSTANT : FOLDER_CLOSE_TIME_CONSTANT)); + mCurHeight = lerp(mCurHeight, mTargetHeight, LLCriticalDamp::getInterpolant(isOpen() ? FOLDER_OPEN_TIME_CONSTANT : FOLDER_CLOSE_TIME_CONSTANT)); requestArrange(); @@ -1303,9 +1246,7 @@ BOOL LLFolderViewFolder::needsArrange() void LLFolderViewFolder::requestSort() { - mNeedsSort = true; - // whenever item order changes, we need to lay things out again - requestArrange(); + getRoot()->getViewModel()->requestSort(this); } void LLFolderViewFolder::setCompletedFilterGeneration(S32 generation, BOOL recurse_up) @@ -1327,7 +1268,7 @@ void LLFolderViewFolder::filter( LLInventoryFilter& filter) // if failed to pass filter newer than must_pass_generation // you will automatically fail this time, so we only // check against items that have passed the filter - S32 must_pass_generation = filter.getMustPassGeneration(); + S32 must_pass_generation = filter.getFirstRequiredGeneration(); bool autoopen_folders = (filter.hasFilterString()); @@ -1380,11 +1321,11 @@ void LLFolderViewFolder::filter( LLInventoryFilter& filter) // when applying a filter, matching folders get their contents downloaded first if (filter.isNotDefault() - && getFiltered(filter.getMinRequiredGeneration()) - && (mListener - && !gInventory.isCategoryComplete(mListener->getUUID()))) + && getFiltered(filter.getFirstSuccessGeneration()) + && (getListener() + && !gInventory.isCategoryComplete(getListener()->getUUID()))) { - LLInventoryModelBackgroundFetch::instance().start(mListener->getUUID()); + LLInventoryModelBackgroundFetch::instance().start(getListener()->getUUID()); } // now query children @@ -1405,7 +1346,7 @@ void LLFolderViewFolder::filter( LLInventoryFilter& filter) if (folder->getCompletedFilterGeneration() >= filter_generation) { // track latest generation to pass any child items - if (folder->getFiltered() || folder->hasFilteredDescendants(filter.getMinRequiredGeneration())) + if (folder->getFiltered() || folder->hasFilteredDescendants(filter.getFirstSuccessGeneration())) { mMostFilteredDescendantGeneration = filter_generation; requestArrange(); @@ -1459,7 +1400,7 @@ void LLFolderViewFolder::filter( LLInventoryFilter& filter) item->filter( filter ); - if (item->getFiltered(filter.getMinRequiredGeneration())) + if (item->getFiltered(filter.getFirstSuccessGeneration())) { mMostFilteredDescendantGeneration = filter_generation; requestArrange(); @@ -1524,8 +1465,8 @@ void LLFolderViewFolder::dirtyFilter() BOOL LLFolderViewFolder::getFiltered() { - return getFilteredFolder(getRoot()->getFilter()->getMinRequiredGeneration()) - && LLFolderViewItem::getFiltered(); + return getFilteredFolder(getRoot()->getFilter()->getFirstSuccessGeneration()) + && LLFolderViewItem::getFiltered(); } BOOL LLFolderViewFolder::getFiltered(S32 filter_generation) @@ -1541,7 +1482,7 @@ BOOL LLFolderViewFolder::hasFilteredDescendants(S32 filter_generation) BOOL LLFolderViewFolder::hasFilteredDescendants() { - return mMostFilteredDescendantGeneration >= getRoot()->getFilter()->getCurrentGeneration(); + return mMostFilteredDescendantGeneration >= getRoot()->getFilter()->getFirstSuccessGeneration(); } // Passes selection information on to children and record selection @@ -1896,14 +1837,6 @@ void LLFolderViewFolder::extendSelectionTo(LLFolderViewItem* new_selection) void LLFolderViewFolder::destroyView() { - for (items_t::iterator iter = mItems.begin(); - iter != mItems.end();) - { - items_t::iterator iit = iter++; - LLFolderViewItem* item = (*iit); - getRoot()->removeItemID(item->getListener()->getUUID()); - } - std::for_each(mItems.begin(), mItems.end(), DeletePointer()); mItems.clear(); @@ -1913,8 +1846,6 @@ void LLFolderViewFolder::destroyView() folderp->destroyView(); // removes entry from mFolders } - //deleteAllChildren(); - if (mParentFolder) { mParentFolder->removeView(this); @@ -1976,103 +1907,14 @@ void LLFolderViewFolder::extractItem( LLFolderViewItem* item ) dirtyFilter(); //because an item is going away regardless of filter status, force rearrange requestArrange(); - getRoot()->removeItemID(item->getListener()->getUUID()); removeChild(item); } -bool LLFolderViewFolder::isTrash() const -{ - if (mAmTrash == LLFolderViewFolder::UNKNOWN) - { - mAmTrash = mListener->getUUID() == gInventory.findCategoryUUIDForType(LLFolderType::FT_TRASH, false) ? LLFolderViewFolder::TRASH : LLFolderViewFolder::NOT_TRASH; - } - return mAmTrash == LLFolderViewFolder::TRASH; -} - -void LLFolderViewFolder::sortBy(U32 order) -{ - if (!mSortFunction.updateSort(order)) - { - // No changes. - return; - } - - // Propagate this change to sub folders - for (folders_t::iterator iter = mFolders.begin(); - iter != mFolders.end();) - { - folders_t::iterator fit = iter++; - (*fit)->sortBy(order); - } - - // Don't sort the topmost folders (My Inventory and Library) - if (mListener->getUUID().notNull()) - { - mFolders.sort(mSortFunction); - mItems.sort(mSortFunction); - } - - if (order & LLInventoryFilter::SO_DATE) - { - time_t latest = 0; - - if (!mItems.empty()) - { - LLFolderViewItem* item = *(mItems.begin()); - latest = item->getCreationDate(); - } - - if (!mFolders.empty()) - { - LLFolderViewFolder* folder = *(mFolders.begin()); - if (folder->getCreationDate() > latest) - { - latest = folder->getCreationDate(); - } - } - mSubtreeCreationDate = latest; - } -} - -void LLFolderViewFolder::setItemSortOrder(U32 ordering) -{ - if (mSortFunction.updateSort(ordering)) - { - for (folders_t::iterator iter = mFolders.begin(); - iter != mFolders.end();) - { - folders_t::iterator fit = iter++; - (*fit)->setItemSortOrder(ordering); - } - - mFolders.sort(mSortFunction); - mItems.sort(mSortFunction); - } -} - -EInventorySortGroup LLFolderViewFolder::getSortGroup() const -{ - if (isTrash()) - { - return SG_TRASH_FOLDER; - } - - if( mListener ) - { - if(LLFolderType::lookupIsProtectedType(mListener->getPreferredType())) - { - return SG_SYSTEM_FOLDER; - } - } - - return SG_NORMAL_FOLDER; -} - BOOL LLFolderViewFolder::isMovable() { - if( mListener ) + if( getListener() ) { - if( !(mListener->isItemMovable()) ) + if( !(getListener()->isItemMovable()) ) { return FALSE; } @@ -2103,9 +1945,9 @@ BOOL LLFolderViewFolder::isMovable() BOOL LLFolderViewFolder::isRemovable() { - if( mListener ) + if( getListener() ) { - if( !(mListener->isItemRemovable()) ) + if( !(getListener()->isItemRemovable()) ) { return FALSE; } @@ -2145,37 +1987,23 @@ BOOL LLFolderViewFolder::addItem(LLFolderViewItem* item) item->dirtyFilter(); - // Update the folder creation date if the folder has no creation date - bool setting_date = false; - const time_t item_creation_date = item->getCreationDate(); - if ((item_creation_date > 0) && (mCreationDate == 0)) - { - setCreationDate(item_creation_date); - setting_date = true; - } - // Handle sorting requestArrange(); requestSort(); - // Traverse parent folders and update creation date and resort, if necessary - LLFolderViewFolder* parentp = getParentFolder(); - while (parentp) - { - // Update the parent folder creation date - if (setting_date && (parentp->mCreationDate == 0)) - { - parentp->setCreationDate(item_creation_date); - } + FIXME: RN - make sort bubble up as long as parent Folder doesn't have anything matching sort criteria + //// Traverse parent folders and update creation date and resort, if necessary + //LLFolderViewFolder* parentp = this; + //while (parentp) + //{ + // if (parentp->mSortFunction.isByDate()) + // { + // // parent folder doesn't have a time stamp yet, so get it from us + // parentp->requestSort(); + // } - if (parentp->mSortFunction.isByDate()) - { - // parent folder doesn't have a time stamp yet, so get it from us - parentp->requestSort(); - } - - parentp = parentp->getParentFolder(); - } + // parentp = parentp->getParentFolder(); + //} return TRUE; } @@ -2192,12 +2020,15 @@ BOOL LLFolderViewFolder::addFolder(LLFolderViewFolder* folder) // rearrange all descendants too, as our indentation level might have changed folder->requestArrange(TRUE); requestSort(); - LLFolderViewFolder* parentp = getParentFolder(); - while (parentp && !parentp->mSortFunction.isByDate()) + if (getRoot()->getSortFunction().isByDate()) { - // parent folder doesn't have a time stamp yet, so get it from us - parentp->requestSort(); - parentp = parentp->getParentFolder(); + LLFolderViewFolder* parentp = getParentFolder(); + while(parentp) + { + // parent folder doesn't have a time stamp yet, so get it from us + parentp->requestSort(); + parentp = parentp->getParentFolder(); + } } return TRUE; } @@ -2224,7 +2055,7 @@ void LLFolderViewFolder::requestArrange(BOOL include_descendants) void LLFolderViewFolder::toggleOpen() { - setOpen(!mIsOpen); + setOpen(!isOpen()); } // Force a folder open or closed @@ -2235,17 +2066,17 @@ void LLFolderViewFolder::setOpen(BOOL openitem) void LLFolderViewFolder::setOpenArrangeRecursively(BOOL openitem, ERecurseType recurse) { - BOOL was_open = mIsOpen; + BOOL was_open = isOpen(); mIsOpen = openitem; - if (mListener) + if (getListener()) { if(!was_open && openitem) { - mListener->openItem(); + getListener()->openItem(); } else if(was_open && !openitem) { - mListener->closeItem(); + getListener()->closeItem(); } } @@ -2265,7 +2096,7 @@ void LLFolderViewFolder::setOpenArrangeRecursively(BOOL openitem, ERecurseType r mParentFolder->setOpenArrangeRecursively(openitem, RECURSE_UP); } - if (was_open != mIsOpen) + if (was_open != isOpen()) { requestArrange(); } @@ -2334,23 +2165,6 @@ void LLFolderViewFolder::applyFunctorRecursively(LLFolderViewFunctor& functor) } } -void LLFolderViewFolder::applyListenerFunctorRecursively(LLFolderViewListenerFunctor& functor) -{ - functor(mListener); - for (folders_t::iterator iter = mFolders.begin(); - iter != mFolders.end();) - { - folders_t::iterator fit = iter++; - (*fit)->applyListenerFunctorRecursively(functor); - } - for (items_t::iterator iter = mItems.begin(); - iter != mItems.end();) - { - items_t::iterator iit = iter++; - (*iit)->applyListenerFunctorRecursively(functor); - } -} - // LLView functionality BOOL LLFolderViewFolder::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, @@ -2361,7 +2175,7 @@ BOOL LLFolderViewFolder::handleDragAndDrop(S32 x, S32 y, MASK mask, { BOOL handled = FALSE; - if (mIsOpen) + if (isOpen()) { handled = (childrenHandleDragAndDrop(x, y, mask, drop, cargo_type, cargo_data, accept, tooltip_msg) != NULL); } @@ -2383,7 +2197,7 @@ BOOL LLFolderViewFolder::handleDragAndDropToThisFolder(MASK mask, EAcceptance* accept, std::string& tooltip_msg) { - BOOL accepted = mListener && mListener->dragOrDrop(mask, drop, cargo_type, cargo_data, tooltip_msg); + BOOL accepted = getListener() && getListener()->dragOrDrop(mask,drop,c_type,cargo_data, tooltip_msg); if (accepted) { @@ -2409,9 +2223,9 @@ BOOL LLFolderViewFolder::handleRightMouseDown( S32 x, S32 y, MASK mask ) BOOL handled = FALSE; // fetch contents of this folder, as context menu can depend on contents // still, user would have to open context menu again to see the changes - gInventory.fetchDescendentsOf(mListener->getUUID()); + gInventory.fetchDescendentsOf(getListener()->getUUID()); - if( mIsOpen ) + if( isOpen() ) { handled = childrenHandleRightMouseDown( x, y, mask ) != NULL; } @@ -2441,7 +2255,7 @@ BOOL LLFolderViewFolder::handleHover(S32 x, S32 y, MASK mask) BOOL LLFolderViewFolder::handleMouseDown( S32 x, S32 y, MASK mask ) { BOOL handled = FALSE; - if( mIsOpen ) + if( isOpen() ) { handled = childrenHandleMouseDown(x,y,mask) != NULL; } @@ -2475,7 +2289,7 @@ BOOL LLFolderViewFolder::handleDoubleClick( S32 x, S32 y, MASK mask ) */ BOOL handled = FALSE; - if( mIsOpen ) + if( isOpen() ) { handled = childrenHandleDoubleClick( x, y, mask ) != NULL; } @@ -2503,7 +2317,7 @@ void LLFolderViewFolder::draw() { mControlLabelRotation = mAutoOpenCountdown * -90.f; } - else if (mIsOpen) + else if (isOpen()) { mControlLabelRotation = lerp(mControlLabelRotation, -90.f, LLCriticalDamp::getInterpolant(0.04f)); } @@ -2512,31 +2326,10 @@ void LLFolderViewFolder::draw() mControlLabelRotation = lerp(mControlLabelRotation, 0.f, LLCriticalDamp::getInterpolant(0.025f)); } - bool possibly_has_children = false; - bool up_to_date = mListener && mListener->isUpToDate(); - if(!up_to_date - && mListener->hasChildren()) // we know we have children but haven't fetched them (doesn't obey filter) - { - possibly_has_children = true; - } - - - BOOL loading = (mIsOpen - && possibly_has_children - && !up_to_date ); - - if ( loading && !mIsLoading ) - { - // Measure how long we've been in the loading state - mTimeSinceRequestStart.reset(); - } - - mIsLoading = loading; - LLFolderViewItem::draw(); // draw children if root folder, or any other folder that is open or animating to closed state - if( getRoot() == this || (mIsOpen || mCurHeight != mTargetHeight )) + if( getRoot() == this || (isOpen() || mCurHeight != mTargetHeight )) { LLView::draw(); } @@ -2544,20 +2337,14 @@ void LLFolderViewFolder::draw() mExpanderHighlighted = FALSE; } -time_t LLFolderViewFolder::getCreationDate() const -{ - return llmax(mCreationDate, mSubtreeCreationDate); -} - - BOOL LLFolderViewFolder::potentiallyVisible() { // folder should be visible by it's own filter status return LLFolderViewItem::potentiallyVisible() // or one or more of its descendants have passed the minimum filter requirement - || hasFilteredDescendants(getRoot()->getFilter()->getMinRequiredGeneration()) + || hasFilteredDescendants() // or not all of its descendants have been checked against minimum filter requirement - || getCompletedFilterGeneration() < getRoot()->getFilter()->getMinRequiredGeneration(); + || getCompletedFilterGeneration() < getRoot()->getFilter()->getFirstSuccessGeneration(); } // this does prefix traversal, as folders are listed above their contents @@ -2771,41 +2558,27 @@ LLFolderViewItem* LLFolderViewFolder::getPreviousFromChild( LLFolderViewItem* it return result; } - -bool LLInventorySort::updateSort(U32 order) -{ - if (order != mSortOrder) - { - mSortOrder = order; - mByDate = (order & LLInventoryFilter::SO_DATE); - mSystemToTop = (order & LLInventoryFilter::SO_SYSTEM_FOLDERS_TO_TOP); - mFoldersByName = (order & LLInventoryFilter::SO_FOLDERS_BY_NAME); - return true; - } - return false; -} - -bool LLInventorySort::operator()(const LLFolderViewItem* const& a, const LLFolderViewItem* const& b) +bool LLInventorySort::operator()(const LLFolderViewModelItemInventory* const& a, const LLFolderViewModelItemInventory* const& b) { // ignore sort order for landmarks in the Favorites folder. // they should be always sorted as in Favorites bar. See EXT-719 if (a->getSortGroup() == SG_ITEM && b->getSortGroup() == SG_ITEM - && a->getListener()->getInventoryType() == LLInventoryType::IT_LANDMARK - && b->getListener()->getInventoryType() == LLInventoryType::IT_LANDMARK) + && a->getInventoryType() == LLInventoryType::IT_LANDMARK + && b->getInventoryType() == LLInventoryType::IT_LANDMARK) { static const LLUUID& favorites_folder_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_FAVORITE); - LLUUID a_uuid = a->getParentFolder()->getListener()->getUUID(); - LLUUID b_uuid = b->getParentFolder()->getListener()->getUUID(); + LLUUID a_uuid = a->getParentFolder()->getUUID(); + LLUUID b_uuid = b->getParentFolder()->getUUID(); if ((a_uuid == favorites_folder_id && b_uuid == favorites_folder_id)) { // *TODO: mantipov: probably it is better to add an appropriate method to LLFolderViewItem // or to LLInvFVBridge - LLViewerInventoryItem* aitem = (static_cast(a->getListener()))->getItem(); - LLViewerInventoryItem* bitem = (static_cast(b->getListener()))->getItem(); + LLViewerInventoryItem* aitem = (static_cast(a))->getItem(); + LLViewerInventoryItem* bitem = (static_cast(b))->getItem(); if (!aitem || !bitem) return false; S32 a_sort = aitem->getSortField(); @@ -2852,8 +2625,6 @@ bool LLInventorySort::operator()(const LLFolderViewItem* const& a, const LLFolde } else { - // BUG: This is very very slow. The getCreationDate() is log n in number - // of inventory items. time_t first_create = a->getCreationDate(); time_t second_create = b->getCreationDate(); if (first_create == second_create) @@ -2866,3 +2637,4 @@ bool LLInventorySort::operator()(const LLFolderViewItem* const& a, const LLFolde } } } + -- cgit v1.2.3 From 379eec8841212665881569c69804fafd96152387 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 15 Jun 2012 13:35:39 -0700 Subject: CHUI-101 WIP Make LLFolderView general purpose continuing fixing build errors renamed llfoldervieweventlistener.h to llfolderviewmodel.h --- indra/newview/llfolderviewitem.cpp | 290 +++++++++++++++---------------------- 1 file changed, 115 insertions(+), 175 deletions(-) (limited to 'indra/newview/llfolderviewitem.cpp') diff --git a/indra/newview/llfolderviewitem.cpp b/indra/newview/llfolderviewitem.cpp index 13b721fa23..0a3c03e868 100644 --- a/indra/newview/llfolderviewitem.cpp +++ b/indra/newview/llfolderviewitem.cpp @@ -30,10 +30,9 @@ // viewer includes #include "llfolderview.h" // Items depend extensively on LLFolderViews #include "llfolderview.h" -#include "llfoldervieweventlistener.h" +#include "llfolderviewmodel.h" #include "llviewerfoldertype.h" #include "llinventorybridge.h" // for LLItemBridge in LLInventorySort::operator() -#include "llinventoryfilter.h" #include "llinventoryfunctions.h" #include "llinventorymodelbackgroundfetch.h" #include "llpanel.h" @@ -120,7 +119,8 @@ LLFolderViewItem::LLFolderViewItem(const LLFolderViewItem::Params& p) mItemHeight(p.item_height), mPassedFilter(FALSE), mLastFilterGeneration(-1), - mStringMatchOffset(std::string::npos), + //TODO RN: create interface for string highlighting + //mStringMatchOffset(std::string::npos), mControlLabelRotation(0.f), mDragAndDropTarget(FALSE), mLabel(p.name), @@ -218,7 +218,7 @@ LLFolderViewItem* LLFolderViewItem::getPreviousOpenNode(BOOL include_children) BOOL LLFolderViewItem::potentiallyVisible() { return getFiltered() // we've passed the filter - || getLastFilterGeneration() < getRoot()->getFilter()->getFirstSuccessGeneration()); // or we don't know yet + || getLastFilterGeneration() < getRoot()->getFilter()->getFirstSuccessGeneration(); // or we don't know yet } BOOL LLFolderViewItem::getFiltered() @@ -244,45 +244,17 @@ void LLFolderViewItem::setIcon(LLUIImagePtr icon) void LLFolderViewItem::refresh() { - if(!getListener()) return; + if(!getViewModelItem()) return; - mLabel = getListener()->getDisplayName(); - LLFolderType::EType preferred_type = getListener()->getPreferredType(); + mLabel = getViewModelItem()->getDisplayName(); - // *TODO: to be removed when database supports multi language. This is a - // temporary attempt to display the inventory folder in the user locale. - // mantipov: *NOTE: be sure this code is synchronized with LLFriendCardsManager::findChildFolderUUID - // it uses the same way to find localized string - - // HACK: EXT - 6028 ([HARD CODED]? Inventory > Library > "Accessories" folder) - // Translation of Accessories folder in Library inventory folder - bool accessories = false; - if(mLabel == std::string("Accessories")) - { - //To ensure that Accessories folder is in Library we have to check its parent folder. - //Due to parent LLFolderViewFloder is not set to this item yet we have to check its parent via Inventory Model - LLInventoryCategory* cat = gInventory.getCategory(getListener()->getUUID()); - if(cat) - { - const LLUUID& parent_folder_id = cat->getParentUUID(); - accessories = (parent_folder_id == gInventory.getLibraryRootFolderID()); - } - } - - //"Accessories" inventory category has folder type FT_NONE. So, this folder - //can not be detected as protected with LLFolderType::lookupIsProtectedType - if (accessories || LLFolderType::lookupIsProtectedType(preferred_type)) - { - LLTrans::findString(mLabel, "InvFolder " + mLabel); - }; - - setToolTip(mLabel); - setIcon(getListener()->getIcon()); - if (mRoot->useLabelSuffix()) - { - mLabelStyle = getListener()->getLabelStyle(); - mLabelSuffix = getListener()->getLabelSuffix(); -} + setToolTip(mLabel); + setIcon(getViewModelItem()->getIcon()); + if (mRoot->useLabelSuffix()) + { + mLabelStyle = getViewModelItem()->getLabelStyle(); + mLabelSuffix = getViewModelItem()->getLabelSuffix(); + } std::string searchable_label(mLabel); searchable_label.append(mLabelSuffix); @@ -381,7 +353,6 @@ BOOL LLFolderViewItem::addToFolder(LLFolderViewFolder* folder) return FALSE; } mParentFolder = folder; - root->addItemID(getListener()->getUUID(), this); return folder->addItem(this); } @@ -420,7 +391,7 @@ S32 LLFolderViewItem::getItemHeight() return mItemHeight; } -void LLFolderViewItem::filter( LLInventoryFilter& filter) +void LLFolderViewItem::filter( LLFolderViewFilter& filter) { const BOOL previous_passed_filter = mPassedFilter; const BOOL passed_filter = filter.check(this); @@ -435,7 +406,8 @@ void LLFolderViewItem::filter( LLInventoryFilter& filter) } setFiltered(passed_filter, filter.getCurrentGeneration()); - mStringMatchOffset = filter.getStringMatchOffset(this); + //TODO RN: create interface for string highlighting + //mStringMatchOffset = filter.getStringMatchOffset(this); filter.decrementFilterCount(); if (getRoot()->getDebugFilters()) @@ -498,9 +470,9 @@ void LLFolderViewItem::selectItem(void) { if (mIsSelected == FALSE) { - if (getListener()) + if (getViewModelItem()) { - getListener()->selectItem(); + getViewModelItem()->selectItem(); } mIsSelected = TRUE; } @@ -508,9 +480,9 @@ void LLFolderViewItem::selectItem(void) BOOL LLFolderViewItem::isMovable() { - if( getListener() ) + if( getViewModelItem() ) { - return getListener()->isItemMovable(); + return getViewModelItem()->isItemMovable(); } else { @@ -520,9 +492,9 @@ BOOL LLFolderViewItem::isMovable() BOOL LLFolderViewItem::isRemovable() { - if( getListener() ) + if( getViewModelItem() ) { - return getListener()->isItemRemovable(); + return getViewModelItem()->isItemRemovable(); } else { @@ -548,9 +520,9 @@ BOOL LLFolderViewItem::remove() { return FALSE; } - if(getListener()) + if(getViewModelItem()) { - return getListener()->removeItem(); + return getViewModelItem()->removeItem(); } return TRUE; } @@ -558,25 +530,17 @@ BOOL LLFolderViewItem::remove() // Build an appropriate context menu for the item. void LLFolderViewItem::buildContextMenu(LLMenuGL& menu, U32 flags) { - if(getListener()) + if(getViewModelItem()) { - getListener()->buildContextMenu(menu, flags); + getViewModelItem()->buildContextMenu(menu, flags); } } void LLFolderViewItem::openItem( void ) { - if( getListener() ) + if( getViewModelItem() ) { - getListener()->openItem(); - } -} - -void LLFolderViewItem::preview( void ) -{ - if (getListener()) - { - getListener()->previewItem(); + getViewModelItem()->openItem(); } } @@ -584,9 +548,9 @@ void LLFolderViewItem::rename(const std::string& new_name) { if( !new_name.empty() ) { - if( getListener() ) + if( getViewModelItem() ) { - getListener()->renameItem(new_name); + getViewModelItem()->renameItem(new_name); if(mParentFolder) { @@ -601,19 +565,13 @@ const std::string& LLFolderViewItem::getSearchableLabel() const return mSearchableLabel; } -LLViewerInventoryItem * LLFolderViewItem::getInventoryItem(void) -{ - if (!getListener()) return NULL; - return gInventory.getItem(getListener()->getUUID()); -} - const std::string& LLFolderViewItem::getName( void ) const { - if(getListener()) + if(getViewModelItem()) { - return getListener()->getName(); + return getViewModelItem()->getName(); } - return z; + return LLStringUtil::null; } // LLView functionality @@ -689,9 +647,9 @@ BOOL LLFolderViewItem::handleHover( S32 x, S32 y, MASK mask ) // *TODO: push this into listener and remove // dependency on llagent - if (getListener()) + if (getViewModelItem()) { - src = getListener()->getDragSource(); + src = getViewModelItem()->getDragSource(); } else { @@ -701,7 +659,7 @@ BOOL LLFolderViewItem::handleHover( S32 x, S32 y, MASK mask ) can_drag = root->startDrag(src); if (can_drag) { - // if (getListener()) getListener()->startDrag(); + // if (getViewModelItem()) getViewModelItem()->startDrag(); // RN: when starting drag and drop, clear out last auto-open root->autoOpenTest(NULL); root->setShowSelectionContext(TRUE); @@ -738,7 +696,10 @@ BOOL LLFolderViewItem::handleHover( S32 x, S32 y, MASK mask ) BOOL LLFolderViewItem::handleDoubleClick( S32 x, S32 y, MASK mask ) { - preview(); + if (getViewModelItem()) + { + getViewModelItem()->openItem(); + } return TRUE; } @@ -790,9 +751,9 @@ BOOL LLFolderViewItem::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, { BOOL accepted = FALSE; BOOL handled = FALSE; - if(getListener()) + if(getViewModelItem()) { - accepted = getListener()->dragOrDrop(mask,drop,cargo_type,cargo_data, tooltip_msg); + accepted = getViewModelItem()->dragOrDrop(mask,drop,cargo_type,cargo_data, tooltip_msg); handled = accepted; if (accepted) { @@ -838,15 +799,12 @@ void LLFolderViewItem::draw() const S32 FOCUS_LEFT = 1; const LLFontGL* font = getLabelFontForStyle(mLabelStyle); - getListener()->update(); + getViewModelItem()->update(); //--------------------------------------------------------------------------------// // Draw open folder arrow // - const bool up_to_date = getListener() && getListener()->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 && getListener() && getListener()->hasChildren())); // ...or we know we have children but haven't fetched them (doesn't obey filter) - if (possibly_has_children) + if (hasVisibleChildren() || getViewModelItem()->hasChildren()) { LLUIImage* arrow_image = default_params.folder_arrow_image; gl_draw_scaled_rotated_image( @@ -943,25 +901,27 @@ void LLFolderViewItem::draw() mDragAndDropTarget = FALSE; } - 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); - } + //TODO RN: implement this in terms of getIcon() and getIconOverlay() - if (highlight_link) - { - mIconOverlay->draw(icon_x, getRect().getHeight() - mIcon->getHeight() - TOP_PAD + 1); - } + //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); + // } + + //if (highlight_link) + //{ + // mIconOverlay->draw(icon_x, getRect().getHeight() - mIcon->getHeight() - TOP_PAD + 1); + //} //--------------------------------------------------------------------------------// // Exit if no label to draw @@ -972,8 +932,9 @@ void LLFolderViewItem::draw() } LLColor4 color = (mIsSelected && filled) ? sHighlightFgColor : sFgColor; - if (highlight_link) color = sLinkColor; - if (in_library) color = sLibraryColor; + //TODO RN: implement this in terms of getColor() + //if (highlight_link) color = sLinkColor; + //if (getViewModelItem() && gInventory.isObjectDescendentOf(getViewModelItem()->getUUID(), gInventory.getLibraryRootFolderID())) color = sLibraryColor; F32 right_x = 0; F32 y = (F32)getRect().getHeight() - font->getLineHeight() - (F32)TEXT_PAD - (F32)TOP_PAD; @@ -984,7 +945,7 @@ void LLFolderViewItem::draw() // if (getRoot()->getDebugFilters()) { - if (!getFiltered() && !possibly_has_children) + if (!getFiltered() && !getViewModelItem()->hasChildren()) { color.mV[VALPHA] *= 0.5f; } @@ -1016,7 +977,7 @@ void LLFolderViewItem::draw() //--------------------------------------------------------------------------------// // Highlight string match // - RN: expose interface for highlighting + //TODO RN: expose interface for highlighting //if (mStringMatchOffset != std::string::npos) //{ // // don't draw backgrounds for zero-length strings @@ -1098,7 +1059,7 @@ static LLFastTimer::DeclareTimer FTM_ARRANGE("Arrange"); S32 LLFolderViewFolder::arrange( S32* width, S32* height, S32 filter_generation) { // sort before laying out contents - getRoot->getViewModel()->sort(this); + getRoot()->getFolderViewModel()->sort(this); LLFastTimer t2(FTM_ARRANGE); @@ -1122,8 +1083,7 @@ S32 LLFolderViewFolder::arrange( S32* width, S32* height, S32 filter_generation) for (folders_t::iterator fit = mFolders.begin(); fit != mFolders.end(); ++fit) { LLFolderViewFolder* folderp = (*fit); - found = ( folderp->getListener() - && (folderp->getFiltered(filter_generation) + found = ( (folderp->getFiltered(filter_generation) || (folderp->getFilteredFolder(filter_generation) && folderp->hasFilteredDescendants(filter_generation)))); if (found) @@ -1164,10 +1124,9 @@ S32 LLFolderViewFolder::arrange( S32* width, S32* height, S32 filter_generation) } else { - folderp->setVisible( folderp->getListener() - && (folderp->getFiltered(filter_generation) + folderp->setVisible( folderp->getFiltered(filter_generation) || (folderp->getFilteredFolder(filter_generation) - && folderp->hasFilteredDescendants(filter_generation)))); // passed filter or has descendants that passed filter + && folderp->hasFilteredDescendants(filter_generation))); // passed filter or has descendants that passed filter } if (folderp->getVisible()) @@ -1277,7 +1236,7 @@ BOOL LLFolderViewFolder::needsArrange() void LLFolderViewFolder::requestSort() { - getRoot()->getViewModel()->requestSort(this); + getRoot()->getFolderViewModel()->requestSort(this); } void LLFolderViewFolder::setCompletedFilterGeneration(S32 generation, BOOL recurse_up) @@ -1293,7 +1252,7 @@ void LLFolderViewFolder::setCompletedFilterGeneration(S32 generation, BOOL recur } } -void LLFolderViewFolder::filter( LLInventoryFilter& filter) +void LLFolderViewFolder::filter( LLFolderViewFilter& filter) { S32 filter_generation = filter.getCurrentGeneration(); // if failed to pass filter newer than must_pass_generation @@ -1301,7 +1260,7 @@ void LLFolderViewFolder::filter( LLInventoryFilter& filter) // check against items that have passed the filter S32 must_pass_generation = filter.getFirstRequiredGeneration(); - bool autoopen_folders = (filter.hasFilterString()); + bool autoopen_folders = filter.showAllResults(); // if we have already been filtered against this generation, skip out if (getCompletedFilterGeneration() >= filter_generation) @@ -1317,7 +1276,8 @@ void LLFolderViewFolder::filter( LLInventoryFilter& filter) { // go ahead and flag this folder as done mLastFilterGeneration = filter_generation; - mStringMatchOffset = std::string::npos; + //TODO RN: create interface for string highlighting + //mStringMatchOffset = std::string::npos; } else // filter self only on first pass through { @@ -1351,15 +1311,6 @@ void LLFolderViewFolder::filter( LLInventoryFilter& filter) return; } - // when applying a filter, matching folders get their contents downloaded first - if (filter.isNotDefault() - && getFiltered(filter.getFirstSuccessGeneration()) - && (getListener() - && !gInventory.isCategoryComplete(getListener()->getUUID()))) - { - LLInventoryModelBackgroundFetch::instance().start(getListener()->getUUID()); - } - // now query children for (folders_t::iterator iter = mFolders.begin(); iter != mFolders.end(); @@ -1449,7 +1400,7 @@ void LLFolderViewFolder::filter( LLInventoryFilter& filter) } } -void LLFolderViewFolder::filterFolder(LLInventoryFilter& filter) +void LLFolderViewFolder::filterFolder(LLFolderViewFilter& filter) { const BOOL previous_passed_filter = mPassedFolderFilter; const BOOL passed_filter = filter.checkFolder(this); @@ -1944,9 +1895,9 @@ void LLFolderViewFolder::extractItem( LLFolderViewItem* item ) BOOL LLFolderViewFolder::isMovable() { - if( getListener() ) + if( getViewModelItem() ) { - if( !(getListener()->isItemMovable()) ) + if( !(getViewModelItem()->isItemMovable()) ) { return FALSE; } @@ -1977,9 +1928,9 @@ BOOL LLFolderViewFolder::isMovable() BOOL LLFolderViewFolder::isRemovable() { - if( getListener() ) + if( getViewModelItem() ) { - if( !(getListener()->isItemRemovable()) ) + if( !(getViewModelItem()->isItemRemovable()) ) { return FALSE; } @@ -2023,7 +1974,7 @@ BOOL LLFolderViewFolder::addItem(LLFolderViewItem* item) requestArrange(); requestSort(); - FIXME: RN - make sort bubble up as long as parent Folder doesn't have anything matching sort criteria + //TODO RN - make sort bubble up as long as parent Folder doesn't have anything matching sort criteria //// Traverse parent folders and update creation date and resort, if necessary //LLFolderViewFolder* parentp = this; //while (parentp) @@ -2052,16 +2003,7 @@ BOOL LLFolderViewFolder::addFolder(LLFolderViewFolder* folder) // rearrange all descendants too, as our indentation level might have changed folder->requestArrange(TRUE); requestSort(); - if (getRoot()->getSortFunction().isByDate()) - { - LLFolderViewFolder* parentp = getParentFolder(); - while(parentp) - { - // parent folder doesn't have a time stamp yet, so get it from us - parentp->requestSort(); - parentp = parentp->getParentFolder(); - } - } + return TRUE; } @@ -2100,15 +2042,15 @@ void LLFolderViewFolder::setOpenArrangeRecursively(BOOL openitem, ERecurseType r { BOOL was_open = isOpen(); mIsOpen = openitem; - if (getListener()) + if (getViewModelItem()) { if(!was_open && openitem) { - getListener()->openItem(); + getViewModelItem()->openItem(); } else if(was_open && !openitem) { - getListener()->closeItem(); + getViewModelItem()->closeItem(); } } @@ -2229,7 +2171,7 @@ BOOL LLFolderViewFolder::handleDragAndDropToThisFolder(MASK mask, EAcceptance* accept, std::string& tooltip_msg) { - BOOL accepted = getListener() && getListener()->dragOrDrop(mask,drop,c_type,cargo_data, tooltip_msg); + BOOL accepted = getViewModelItem() && getViewModelItem()->dragOrDrop(mask,drop,cargo_type,cargo_data, tooltip_msg); if (accepted) { @@ -2253,9 +2195,6 @@ BOOL LLFolderViewFolder::handleDragAndDropToThisFolder(MASK mask, BOOL LLFolderViewFolder::handleRightMouseDown( S32 x, S32 y, MASK mask ) { BOOL handled = FALSE; - // fetch contents of this folder, as context menu can depend on contents - // still, user would have to open context menu again to see the changes - gInventory.fetchDescendentsOf(getListener()->getUUID()); if( isOpen() ) { @@ -2311,11 +2250,11 @@ BOOL LLFolderViewFolder::handleMouseDown( S32 x, S32 y, MASK mask ) BOOL LLFolderViewFolder::handleDoubleClick( S32 x, S32 y, MASK mask ) { /* Disable outfit double click to wear - const LLUUID &cat_uuid = getListener()->getUUID(); + const LLUUID &cat_uuid = getViewModelItem()->getUUID(); const LLViewerInventoryCategory *cat = gInventory.getCategory(cat_uuid); if (cat && cat->getPreferredType() == LLFolderType::FT_OUTFIT) { - getListener()->performAction(NULL, NULL,"replaceoutfit"); + getViewModelItem()->performAction(NULL, NULL,"replaceoutfit"); return TRUE; } */ @@ -2594,30 +2533,31 @@ bool LLInventorySort::operator()(const LLFolderViewModelItemInventory* const& a, { // ignore sort order for landmarks in the Favorites folder. // they should be always sorted as in Favorites bar. See EXT-719 - if (a->getSortGroup() == SG_ITEM - && b->getSortGroup() == SG_ITEM - && a->getInventoryType() == LLInventoryType::IT_LANDMARK - && b->getInventoryType() == LLInventoryType::IT_LANDMARK) - { + //TODO RN: fix sorting in favorites folder + //if (a->getSortGroup() == SG_ITEM + // && b->getSortGroup() == SG_ITEM + // && a->getInventoryType() == LLInventoryType::IT_LANDMARK + // && b->getInventoryType() == LLInventoryType::IT_LANDMARK) + //{ - static const LLUUID& favorites_folder_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_FAVORITE); + // static const LLUUID& favorites_folder_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_FAVORITE); - LLUUID a_uuid = a->getParentFolder()->getUUID(); - LLUUID b_uuid = b->getParentFolder()->getUUID(); + // LLUUID a_uuid = a->getParentFolder()->getUUID(); + // LLUUID b_uuid = b->getParentFolder()->getUUID(); - if ((a_uuid == favorites_folder_id && b_uuid == favorites_folder_id)) - { - // *TODO: mantipov: probably it is better to add an appropriate method to LLFolderViewItem - // or to LLInvFVBridge - LLViewerInventoryItem* aitem = (static_cast(a))->getItem(); - LLViewerInventoryItem* bitem = (static_cast(b))->getItem(); - if (!aitem || !bitem) - return false; - S32 a_sort = aitem->getSortField(); - S32 b_sort = bitem->getSortField(); - return a_sort < b_sort; - } - } + // if ((a_uuid == favorites_folder_id && b_uuid == favorites_folder_id)) + // { + // // *TODO: mantipov: probably it is better to add an appropriate method to LLFolderViewItem + // // or to LLInvFVBridge + // LLViewerInventoryItem* aitem = (static_cast(a))->getItem(); + // LLViewerInventoryItem* bitem = (static_cast(b))->getItem(); + // if (!aitem || !bitem) + // return false; + // S32 a_sort = aitem->getSortField(); + // S32 b_sort = bitem->getSortField(); + // return a_sort < b_sort; + // } + //} // We sort by name if we aren't sorting by date // OR if these are folders and we are sorting folders by name. @@ -2645,7 +2585,7 @@ bool LLInventorySort::operator()(const LLFolderViewModelItemInventory* const& a, if (by_name) { - S32 compare = LLStringUtil::compareDict(a->getLabel(), b->getLabel()); + S32 compare = LLStringUtil::compareDict(a->getDisplayName(), b->getDisplayName()); if (0 == compare) { return (a->getCreationDate() > b->getCreationDate()); @@ -2661,7 +2601,7 @@ bool LLInventorySort::operator()(const LLFolderViewModelItemInventory* const& a, time_t second_create = b->getCreationDate(); if (first_create == second_create) { - return (LLStringUtil::compareDict(a->getLabel(), b->getLabel()) < 0); + return (LLStringUtil::compareDict(a->getDisplayName(), b->getDisplayName()) < 0); } else { -- cgit v1.2.3 From 59987bb051ed39146ec9b3831eec81434779a73f Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 18 Jun 2012 19:01:59 -0700 Subject: CHUI-101 WIP Make LLFolderView general purpose continuing fixing build errors general cleanup --- indra/newview/llfolderviewitem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llfolderviewitem.cpp') diff --git a/indra/newview/llfolderviewitem.cpp b/indra/newview/llfolderviewitem.cpp index 0a3c03e868..6e60ec5e1a 100644 --- a/indra/newview/llfolderviewitem.cpp +++ b/indra/newview/llfolderviewitem.cpp @@ -2529,7 +2529,7 @@ LLFolderViewItem* LLFolderViewFolder::getPreviousFromChild( LLFolderViewItem* it return result; } -bool LLInventorySort::operator()(const LLFolderViewModelItemInventory* const& a, const LLFolderViewModelItemInventory* const& b) +bool LLInventorySort::operator()(const LLFolderViewModelItemInventory* const& a, const LLFolderViewModelItemInventory* const& b) const { // ignore sort order for landmarks in the Favorites folder. // they should be always sorted as in Favorites bar. See EXT-719 -- cgit v1.2.3 From 3882e9c177190b22276e1ef3fc39e4cb910820fd Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 20 Jun 2012 00:19:05 -0700 Subject: CHUI-101 WIP Make LLFolderview general purpose more compilation fixes, just need to add getName() back to LLInventoryFilter et al --- indra/newview/llfolderviewitem.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'indra/newview/llfolderviewitem.cpp') diff --git a/indra/newview/llfolderviewitem.cpp b/indra/newview/llfolderviewitem.cpp index 6e60ec5e1a..5b73a34d29 100644 --- a/indra/newview/llfolderviewitem.cpp +++ b/indra/newview/llfolderviewitem.cpp @@ -221,6 +221,12 @@ BOOL LLFolderViewItem::potentiallyVisible() || getLastFilterGeneration() < getRoot()->getFilter()->getFirstSuccessGeneration(); // or we don't know yet } +BOOL LLFolderViewItem::potentiallyHidden() +{ + return !mPassedFilter // didn't pass the filter + || getLastFilterGeneration() < getRoot()->getFilter()->getFirstSuccessGeneration(); // or we don't know yet +} + BOOL LLFolderViewItem::getFiltered() { return mPassedFilter && mLastFilterGeneration >= getRoot()->getFilter()->getFirstSuccessGeneration(); -- cgit v1.2.3 From 4775084000233ec9f0770f421771215397b987e7 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 21 Jun 2012 23:28:24 -0700 Subject: CHUI-101 WIP Make LLFolderview general purpose inventory item labels and icons displaying again --- indra/newview/llfolderviewitem.cpp | 71 ++++++++++++++------------------------ 1 file changed, 25 insertions(+), 46 deletions(-) (limited to 'indra/newview/llfolderviewitem.cpp') 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() -- cgit v1.2.3 From cb865a7e1300d4ce0bedae7c856fb210b68a43f8 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 27 Jun 2012 18:56:10 -0700 Subject: CHUI-101 WIP Make LLFolderView general purpose moved filtering logic to viewmodel --- indra/newview/llfolderviewitem.cpp | 787 ++++++++----------------------------- 1 file changed, 172 insertions(+), 615 deletions(-) (limited to 'indra/newview/llfolderviewitem.cpp') diff --git a/indra/newview/llfolderviewitem.cpp b/indra/newview/llfolderviewitem.cpp index 3f0b493986..f65a13be1e 100644 --- a/indra/newview/llfolderviewitem.cpp +++ b/indra/newview/llfolderviewitem.cpp @@ -114,8 +114,6 @@ LLFolderViewItem::LLFolderViewItem(const LLFolderViewItem::Params& p) mHasVisibleChildren(FALSE), mIndentation(0), mItemHeight(p.item_height), - mPassedFilter(FALSE), - mLastFilterGeneration(-1), //TODO RN: create interface for string highlighting //mStringMatchOffset(std::string::npos), mControlLabelRotation(0.f), @@ -146,6 +144,10 @@ LLFolderView* LLFolderViewItem::getRoot() return mRoot; } +const LLFolderView* LLFolderViewItem::getRoot() const +{ + return mRoot; +} // Returns true if this object is a child (or grandchild, etc.) of potential_ancestor. BOOL LLFolderViewItem::isDescendantOf( const LLFolderViewFolder* potential_ancestor ) { @@ -207,99 +209,47 @@ LLFolderViewItem* LLFolderViewItem::getPreviousOpenNode(BOOL include_children) return itemp; } -// is this item something we think we should be showing? -// for example, if we haven't gotten around to filtering it yet, then the answer is yes -// until we find out otherwise -BOOL LLFolderViewItem::potentiallyVisible() -{ - return getFiltered() // we've passed the filter - || getLastFilterGeneration() < getRoot()->getFilter()->getFirstSuccessGeneration(); // or we don't know yet -} - -BOOL LLFolderViewItem::potentiallyHidden() +BOOL LLFolderViewItem::passedFilter(S32 filter_generation) { - return !mPassedFilter // didn't pass the filter - || getLastFilterGeneration() < getRoot()->getFilter()->getFirstSuccessGeneration(); // or we don't know yet -} - -BOOL LLFolderViewItem::getFiltered() -{ - return mPassedFilter && mLastFilterGeneration >= getRoot()->getFilter()->getFirstSuccessGeneration(); -} - -BOOL LLFolderViewItem::getFiltered(S32 filter_generation) -{ - return mPassedFilter && mLastFilterGeneration >= filter_generation; -} - -void LLFolderViewItem::setFiltered(BOOL filtered, S32 filter_generation) -{ - mPassedFilter = filtered; - mLastFilterGeneration = filter_generation; + return getViewModelItem()->passedFilter(filter_generation); } void LLFolderViewItem::refresh() { - if(!getViewModelItem()) return; + LLFolderViewModelItem& vmi = *getViewModelItem(); - mLabel = getViewModelItem()->getDisplayName(); + mLabel = vmi.getDisplayName(); setToolTip(mLabel); - mIcon = getViewModelItem()->getIcon(); - mIconOpen = getViewModelItem()->getIconOpen(); - mIconOverlay = getViewModelItem()->getIconOverlay(); + mIcon = vmi.getIcon(); + mIconOpen = vmi.getIconOpen(); + mIconOverlay = vmi.getIconOverlay(); if (mRoot->useLabelSuffix()) { - mLabelStyle = getViewModelItem()->getLabelStyle(); - mLabelSuffix = getViewModelItem()->getLabelSuffix(); + mLabelStyle = vmi.getLabelStyle(); + mLabelSuffix = vmi.getLabelSuffix(); } - std::string searchable_label(mLabel); - searchable_label.append(mLabelSuffix); - LLStringUtil::toUpper(searchable_label); + //TODO RN: make sure this logic still fires + //std::string searchable_label(mLabel); + //searchable_label.append(mLabelSuffix); + //LLStringUtil::toUpper(searchable_label); - if (mSearchableLabel.compare(searchable_label)) - { - mSearchableLabel.assign(searchable_label); - dirtyFilter(); - // some part of label has changed, so overall width has potentially changed, and sort order too - if (mParentFolder) - { - mParentFolder->requestSort(); - mParentFolder->requestArrange(); - } - } + //if (mSearchableLabel.compare(searchable_label)) + //{ + // mSearchableLabel.assign(searchable_label); + // vmi.dirtyFilter(); + // // some part of label has changed, so overall width has potentially changed, and sort order too + // if (mParentFolder) + // { + // mParentFolder->requestSort(); + // mParentFolder->requestArrange(); + // } + //} mLabelWidthDirty = true; - dirtyFilter(); -} - -// This function is called when items are added or view filters change. It's -// implemented here but called by derived classes when folding the -// views. -void LLFolderViewItem::filterFromRoot( void ) -{ - LLFolderViewItem* root = getRoot(); - - root->filter(*((LLFolderView*)root)->getFilter()); -} - -// This function is called when the folder view is dirty. It's -// implemented here but called by derived classes when folding the -// views. -void LLFolderViewItem::arrangeFromRoot() -{ - LLFolderViewItem* root = getRoot(); - - S32 height = 0; - S32 width = 0; - S32 total_height = root->arrange( &width, &height, 0 ); - - LLSD params; - params["action"] = "size_changes"; - params["height"] = total_height; - getParent()->notifyParent(params); + vmi.dirtyFilter(); } // Utility function for LLFolderView @@ -313,7 +263,7 @@ void LLFolderViewItem::arrangeAndSet(BOOL set_selection, } if(set_selection) { - setSelectionFromRoot(this, TRUE, take_keyboard_focus); + getRoot()->setSelection(this, TRUE, take_keyboard_focus); if(root) { root->scrollToShowSelection(); @@ -321,22 +271,6 @@ void LLFolderViewItem::arrangeAndSet(BOOL set_selection, } } -// This function clears the currently selected item, and records the -// specified selected item appropriately for display and use in the -// UI. If open is TRUE, then folders are opened up along the way to -// the selection. -void LLFolderViewItem::setSelectionFromRoot(LLFolderViewItem* selection, - BOOL openitem, - BOOL take_keyboard_focus) -{ - getRoot()->setSelection(selection, openitem, take_keyboard_focus); -} - -// helper function to change the selection from the root. -void LLFolderViewItem::changeSelectionFromRoot(LLFolderViewItem* selection, BOOL selected) -{ - getRoot()->changeSelection(selection, selected); -} std::set LLFolderViewItem::getSelectionList() const { @@ -347,18 +281,13 @@ std::set LLFolderViewItem::getSelectionList() const // addToFolder() returns TRUE if it succeeds. FALSE otherwise BOOL LLFolderViewItem::addToFolder(LLFolderViewFolder* folder) { - if (!folder) - { - return FALSE; - } - mParentFolder = folder; return folder->addItem(this); } // Finds width and height of this object and its children. Also // makes sure that this view and its children are the right size. -S32 LLFolderViewItem::arrange( S32* width, S32* height, S32 filter_generation) +S32 LLFolderViewItem::arrange( S32* width, S32* height ) { const Params& p = LLUICtrlFactory::getDefaultParams(); S32 indentation = p.folder_indentation(); @@ -390,41 +319,6 @@ S32 LLFolderViewItem::getItemHeight() return mItemHeight; } -void LLFolderViewItem::filter( LLFolderViewFilter& filter) -{ - const BOOL previous_passed_filter = mPassedFilter; - const BOOL passed_filter = filter.check(this); - - // If our visibility will change as a result of this filter, then - // we need to be rearranged in our parent folder - if (mParentFolder) - { - if (getVisible() != passed_filter - || previous_passed_filter != passed_filter ) - mParentFolder->requestArrange(); - } - - setFiltered(passed_filter, filter.getCurrentGeneration()); - //TODO RN: create interface for string highlighting - //mStringMatchOffset = filter.getStringMatchOffset(this); - filter.decrementFilterCount(); - - if (getRoot()->getDebugFilters()) - { - mStatusText = llformat("%d", mLastFilterGeneration); - } -} - -void LLFolderViewItem::dirtyFilter() -{ - mLastFilterGeneration = -1; - // bubble up dirty flag all the way to root - if (getParentFolder()) - { - getParentFolder()->setCompletedFilterGeneration(-1, TRUE); - } -} - // *TODO: This can be optimized a lot by simply recording that it is // selected in the appropriate places, and assuming that set selection // means 'deselect' for a leaf item. Do this optimization after @@ -469,45 +363,31 @@ void LLFolderViewItem::selectItem(void) { if (mIsSelected == FALSE) { - if (getViewModelItem()) - { - getViewModelItem()->selectItem(); - } + getViewModelItem()->selectItem(); mIsSelected = TRUE; } } BOOL LLFolderViewItem::isMovable() { - if( getViewModelItem() ) - { - return getViewModelItem()->isItemMovable(); - } - else - { - return TRUE; - } + return getViewModelItem()->isItemMovable(); } BOOL LLFolderViewItem::isRemovable() { - if( getViewModelItem() ) - { - return getViewModelItem()->isItemRemovable(); - } - else - { - return TRUE; - } + return getViewModelItem()->isItemRemovable(); } void LLFolderViewItem::destroyView() { + getRoot()->removeFromSelectionList(this); + if (mParentFolder) { // removeView deletes me - mParentFolder->removeView(this); + mParentFolder->extractItem(this); } + delete this; } // Call through to the viewed object and return true if it can be @@ -519,58 +399,36 @@ BOOL LLFolderViewItem::remove() { return FALSE; } - if(getViewModelItem()) - { - return getViewModelItem()->removeItem(); - } - return TRUE; + return getViewModelItem()->removeItem(); } // Build an appropriate context menu for the item. void LLFolderViewItem::buildContextMenu(LLMenuGL& menu, U32 flags) { - if(getViewModelItem()) - { - getViewModelItem()->buildContextMenu(menu, flags); - } + getViewModelItem()->buildContextMenu(menu, flags); } void LLFolderViewItem::openItem( void ) { - if( getViewModelItem() ) - { - getViewModelItem()->openItem(); - } + getViewModelItem()->openItem(); } void LLFolderViewItem::rename(const std::string& new_name) { if( !new_name.empty() ) { - if( getViewModelItem() ) - { - getViewModelItem()->renameItem(new_name); + getViewModelItem()->renameItem(new_name); - if(mParentFolder) - { - mParentFolder->requestSort(); - } + if(mParentFolder) + { + mParentFolder->requestSort(); } } } -const std::string& LLFolderViewItem::getSearchableLabel() const -{ - return mSearchableLabel; -} - const std::string& LLFolderViewItem::getName( void ) const { - if(getViewModelItem()) - { - return getViewModelItem()->getName(); - } - return LLStringUtil::null; + return getViewModelItem()->getName(); } // LLView functionality @@ -578,7 +436,7 @@ BOOL LLFolderViewItem::handleRightMouseDown( S32 x, S32 y, MASK mask ) { if(!mIsSelected) { - setSelectionFromRoot(this, FALSE); + getRoot()->setSelection(this, FALSE); } make_ui_sound("UISndClick"); return TRUE; @@ -599,7 +457,7 @@ BOOL LLFolderViewItem::handleMouseDown( S32 x, S32 y, MASK mask ) { if(mask & MASK_CONTROL) { - changeSelectionFromRoot(this, !mIsSelected); + getRoot()->changeSelection(this, !mIsSelected); } else if (mask & MASK_SHIFT) { @@ -607,7 +465,7 @@ BOOL LLFolderViewItem::handleMouseDown( S32 x, S32 y, MASK mask ) } else { - setSelectionFromRoot(this, FALSE); + getRoot()->setSelection(this, FALSE); } make_ui_sound("UISndClick"); } @@ -646,14 +504,7 @@ BOOL LLFolderViewItem::handleHover( S32 x, S32 y, MASK mask ) // *TODO: push this into listener and remove // dependency on llagent - if (getViewModelItem()) - { - src = getViewModelItem()->getDragSource(); - } - else - { - src = LLToolDragAndDrop::SOURCE_VIEWER; - } + src = getViewModelItem()->getDragSource(); can_drag = root->startDrag(src); if (can_drag) @@ -695,10 +546,7 @@ BOOL LLFolderViewItem::handleHover( S32 x, S32 y, MASK mask ) BOOL LLFolderViewItem::handleDoubleClick( S32 x, S32 y, MASK mask ) { - if (getViewModelItem()) - { - getViewModelItem()->openItem(); - } + getViewModelItem()->openItem(); return TRUE; } @@ -715,7 +563,7 @@ BOOL LLFolderViewItem::handleMouseUp( S32 x, S32 y, MASK mask ) //...then select if(mask & MASK_CONTROL) { - changeSelectionFromRoot(this, !mIsSelected); + getRoot()->changeSelection(this, !mIsSelected); } else if (mask & MASK_SHIFT) { @@ -723,7 +571,7 @@ BOOL LLFolderViewItem::handleMouseUp( S32 x, S32 y, MASK mask ) } else { - setSelectionFromRoot(this, FALSE); + getRoot()->setSelection(this, FALSE); } } @@ -748,21 +596,17 @@ BOOL LLFolderViewItem::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EAcceptance* accept, std::string& tooltip_msg) { - BOOL accepted = FALSE; BOOL handled = FALSE; - if(getViewModelItem()) + BOOL accepted = getViewModelItem()->dragOrDrop(mask,drop,cargo_type,cargo_data, tooltip_msg); + handled = accepted; + if (accepted) { - accepted = getViewModelItem()->dragOrDrop(mask,drop,cargo_type,cargo_data, tooltip_msg); - handled = accepted; - if (accepted) - { - mDragAndDropTarget = TRUE; - *accept = ACCEPT_YES_MULTI; - } - else - { - *accept = ACCEPT_NO; - } + mDragAndDropTarget = TRUE; + *accept = ACCEPT_YES_MULTI; + } + else + { + *accept = ACCEPT_NO; } if(mParentFolder && !handled) { @@ -781,17 +625,17 @@ BOOL LLFolderViewItem::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, void LLFolderViewItem::draw() { - static LLUIColor sFgColor = LLUIColorTable::instance().getColor("MenuItemEnabledColor", DEFAULT_WHITE); - static LLUIColor sHighlightBgColor = LLUIColorTable::instance().getColor("MenuItemHighlightBgColor", DEFAULT_WHITE); - static LLUIColor sHighlightFgColor = LLUIColorTable::instance().getColor("MenuItemHighlightFgColor", DEFAULT_WHITE); + static LLUIColor sFgColor = LLUIColorTable::instance().getColor("MenuItemEnabledColor", DEFAULT_WHITE); + static LLUIColor sHighlightBgColor = LLUIColorTable::instance().getColor("MenuItemHighlightBgColor", DEFAULT_WHITE); + static LLUIColor sHighlightFgColor = LLUIColorTable::instance().getColor("MenuItemHighlightFgColor", DEFAULT_WHITE); static LLUIColor sFocusOutlineColor = LLUIColorTable::instance().getColor("InventoryFocusOutlineColor", DEFAULT_WHITE); - static LLUIColor sFilterBGColor = LLUIColorTable::instance().getColor("FilterBackgroundColor", DEFAULT_WHITE); - static LLUIColor sFilterTextColor = LLUIColorTable::instance().getColor("FilterTextColor", DEFAULT_WHITE); - static LLUIColor sSuffixColor = LLUIColorTable::instance().getColor("InventoryItemColor", DEFAULT_WHITE); - static LLUIColor sLibraryColor = LLUIColorTable::instance().getColor("InventoryItemLibraryColor", DEFAULT_WHITE); - static LLUIColor sLinkColor = LLUIColorTable::instance().getColor("InventoryItemLinkColor", DEFAULT_WHITE); + static LLUIColor sFilterBGColor = LLUIColorTable::instance().getColor("FilterBackgroundColor", DEFAULT_WHITE); + static LLUIColor sFilterTextColor = LLUIColorTable::instance().getColor("FilterTextColor", DEFAULT_WHITE); + static LLUIColor sSuffixColor = LLUIColorTable::instance().getColor("InventoryItemColor", DEFAULT_WHITE); + static LLUIColor sLibraryColor = LLUIColorTable::instance().getColor("InventoryItemLibraryColor", DEFAULT_WHITE); + static LLUIColor sLinkColor = LLUIColorTable::instance().getColor("InventoryItemLinkColor", DEFAULT_WHITE); static LLUIColor sSearchStatusColor = LLUIColorTable::instance().getColor("InventorySearchStatusColor", DEFAULT_WHITE); - static LLUIColor sMouseOverColor = LLUIColorTable::instance().getColor("InventoryMouseOverColor", DEFAULT_WHITE); + static LLUIColor sMouseOverColor = LLUIColorTable::instance().getColor("InventoryMouseOverColor", DEFAULT_WHITE); const Params& default_params = LLUICtrlFactory::getDefaultParams(); const S32 TOP_PAD = default_params.item_top_pad; @@ -929,29 +773,12 @@ void LLFolderViewItem::draw() LLColor4 color = (mIsSelected && filled) ? sHighlightFgColor : sFgColor; //TODO RN: implement this in terms of getColor() //if (highlight_link) color = sLinkColor; - //if (getViewModelItem() && gInventory.isObjectDescendentOf(getViewModelItem()->getUUID(), gInventory.getLibraryRootFolderID())) color = sLibraryColor; + //if (gInventory.isObjectDescendentOf(getViewModelItem()->getUUID(), gInventory.getLibraryRootFolderID())) color = sLibraryColor; F32 right_x = 0; F32 y = (F32)getRect().getHeight() - font->getLineHeight() - (F32)TEXT_PAD - (F32)TOP_PAD; F32 text_left = (F32)(ARROW_SIZE + TEXT_PAD + ICON_WIDTH + ICON_PAD + mIndentation); - //--------------------------------------------------------------------------------// - // Highlight filtered text - // - if (getRoot()->getDebugFilters()) - { - if (!getFiltered() && !getViewModelItem()->hasChildren()) - { - color.mV[VALPHA] *= 0.5f; - } - LLColor4 filter_color = mLastFilterGeneration >= getRoot()->getFilter()->getCurrentGeneration() ? - LLColor4(0.5f, 0.8f, 0.5f, 1.f) : - LLColor4(0.8f, 0.5f, 0.5f, 1.f); - LLFontGL::getFontMonospace()->renderUTF8(mStatusText, 0, text_left, y, filter_color, - LLFontGL::LEFT, LLFontGL::BOTTOM, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, - S32_MAX, S32_MAX, &right_x, FALSE ); - text_left = right_x; - } //--------------------------------------------------------------------------------// // Draw the actual label text // @@ -997,6 +824,22 @@ void LLFolderViewItem::draw() //} } +const LLFolderViewModelInterface* LLFolderViewItem::getFolderViewModel( void ) const +{ + return getRoot()->getFolderViewModel(); +} + +LLFolderViewModelInterface* LLFolderViewItem::getFolderViewModel( void ) +{ + return getRoot()->getFolderViewModel(); +} + +S32 LLFolderViewItem::getLastFilterGeneration() const +{ + return getViewModelItem()->getLastFilterGeneration(); +} + + ///---------------------------------------------------------------------------- /// Class LLFolderViewFolder @@ -1010,10 +853,7 @@ LLFolderViewFolder::LLFolderViewFolder( const LLFolderViewItem::Params& p ): mTargetHeight(0.f), mAutoOpenCountdown(0.f), mLastArrangeGeneration( -1 ), - mLastCalculatedWidth(0), - mCompletedFilterGeneration(-1), - mMostFilteredDescendantGeneration(-1), - mPassedFolderFilter(FALSE) + mLastCalculatedWidth(0) { } @@ -1025,25 +865,9 @@ LLFolderViewFolder::~LLFolderViewFolder( void ) gFocusMgr.releaseFocusIfNeeded( this ); // calls onCommit() } -void LLFolderViewFolder::setFilteredFolder(bool filtered, S32 filter_generation) -{ - mPassedFolderFilter = filtered; - mLastFilterGeneration = filter_generation; -} - -bool LLFolderViewFolder::getFilteredFolder(S32 filter_generation) -{ - return mPassedFolderFilter && mLastFilterGeneration >= getRoot()->getFilter()->getFirstSuccessGeneration(); -} - // addToFolder() returns TRUE if it succeeds. FALSE otherwise BOOL LLFolderViewFolder::addToFolder(LLFolderViewFolder* folder) { - if (!folder) - { - return FALSE; - } - mParentFolder = folder; return folder->addFolder(this); } @@ -1051,7 +875,7 @@ static LLFastTimer::DeclareTimer FTM_ARRANGE("Arrange"); // Finds width and height of this object and its children. Also // makes sure that this view and its children are the right size. -S32 LLFolderViewFolder::arrange( S32* width, S32* height, S32 filter_generation) +S32 LLFolderViewFolder::arrange( S32* width, S32* height ) { // sort before laying out contents getRoot()->getFolderViewModel()->sort(this); @@ -1060,7 +884,7 @@ S32 LLFolderViewFolder::arrange( S32* width, S32* height, S32 filter_generation) // evaluate mHasVisibleChildren mHasVisibleChildren = false; - if (hasFilteredDescendants(filter_generation)) + if (getViewModelItem()->descendantsPassedFilter()) { // We have to verify that there's at least one child that's not filtered out bool found = false; @@ -1068,7 +892,7 @@ S32 LLFolderViewFolder::arrange( S32* width, S32* height, S32 filter_generation) for (items_t::iterator iit = mItems.begin(); iit != mItems.end(); ++iit) { LLFolderViewItem* itemp = (*iit); - found = (itemp->getFiltered(filter_generation)); + found = itemp->passedFilter(); if (found) break; } @@ -1078,9 +902,7 @@ S32 LLFolderViewFolder::arrange( S32* width, S32* height, S32 filter_generation) for (folders_t::iterator fit = mFolders.begin(); fit != mFolders.end(); ++fit) { LLFolderViewFolder* folderp = (*fit); - found = ( (folderp->getFiltered(filter_generation) - || (folderp->getFilteredFolder(filter_generation) - && folderp->hasFilteredDescendants(filter_generation)))); + found = folderp->passedFilter(); if (found) break; } @@ -1090,7 +912,7 @@ S32 LLFolderViewFolder::arrange( S32* width, S32* height, S32 filter_generation) } // calculate height as a single item (without any children), and reshapes rectangle to match - LLFolderViewItem::arrange( width, height, filter_generation ); + LLFolderViewItem::arrange( width, height ); // clamp existing animated height so as to never get smaller than a single item mCurHeight = llmax((F32)*height, mCurHeight); @@ -1113,16 +935,7 @@ S32 LLFolderViewFolder::arrange( S32* width, S32* height, S32 filter_generation) for(folders_t::iterator fit = mFolders.begin(); fit != mFolders.end(); ++fit) { LLFolderViewFolder* folderp = (*fit); - if (getRoot()->getDebugFilters()) - { - folderp->setVisible(TRUE); - } - else - { - folderp->setVisible( folderp->getFiltered(filter_generation) - || (folderp->getFilteredFolder(filter_generation) - && folderp->hasFilteredDescendants(filter_generation))); // passed filter or has descendants that passed filter - } + folderp->setVisible(folderp->passedFilter()); // passed filter or has descendants that passed filter if (folderp->getVisible()) { @@ -1130,7 +943,7 @@ S32 LLFolderViewFolder::arrange( S32* width, S32* height, S32 filter_generation) S32 child_height = 0; S32 child_top = parent_item_height - llround(running_height); - target_height += folderp->arrange( &child_width, &child_height, filter_generation ); + target_height += folderp->arrange( &child_width, &child_height ); running_height += (F32)child_height; *width = llmax(*width, child_width); @@ -1141,14 +954,7 @@ S32 LLFolderViewFolder::arrange( S32* width, S32* height, S32 filter_generation) iit != mItems.end(); ++iit) { LLFolderViewItem* itemp = (*iit); - if (getRoot()->getDebugFilters()) - { - itemp->setVisible(TRUE); - } - else - { - itemp->setVisible(itemp->getFiltered(filter_generation)); - } + itemp->setVisible(itemp->passedFilter()); if (itemp->getVisible()) { @@ -1156,7 +962,7 @@ S32 LLFolderViewFolder::arrange( S32* width, S32* height, S32 filter_generation) S32 child_height = 0; S32 child_top = parent_item_height - llround(running_height); - target_height += itemp->arrange( &child_width, &child_height, filter_generation ); + target_height += itemp->arrange( &child_width, &child_height ); // don't change width, as this item is as wide as its parent folder by construction itemp->reshape( itemp->getRect().getWidth(), child_height); @@ -1234,234 +1040,21 @@ void LLFolderViewFolder::requestSort() getViewModelItem()->requestSort(); } -void LLFolderViewFolder::setCompletedFilterGeneration(S32 generation, BOOL recurse_up) -{ - //mMostFilteredDescendantGeneration = llmin(mMostFilteredDescendantGeneration, generation); - mCompletedFilterGeneration = generation; - // only aggregate up if we are a lower (older) value - if (recurse_up - && mParentFolder - && generation < mParentFolder->getCompletedFilterGeneration()) - { - mParentFolder->setCompletedFilterGeneration(generation, TRUE); - } -} +//TODO RN: get height resetting working +//void LLFolderViewFolder::setPassedFilter(BOOL passed, BOOL passed_folder, S32 filter_generation) +//{ +// // if this folder is now filtered, but wasn't before +// // (it just passed) +// if (passed && !passedFilter(filter_generation)) +// { +// // reset current height, because last time we drew it +// // it might have had more visible items than now +// mCurHeight = 0.f; +// } +// +// LLFolderViewItem::setPassedFilter(passed, passed_folder, filter_generation); +//} -void LLFolderViewFolder::filter( LLFolderViewFilter& filter) -{ - S32 filter_generation = filter.getCurrentGeneration(); - // if failed to pass filter newer than must_pass_generation - // you will automatically fail this time, so we only - // check against items that have passed the filter - S32 must_pass_generation = filter.getFirstRequiredGeneration(); - - bool autoopen_folders = filter.showAllResults(); - - // if we have already been filtered against this generation, skip out - if (getCompletedFilterGeneration() >= filter_generation) - { - return; - } - - // filter folder itself - if (getLastFilterGeneration() < filter_generation) - { - if (getLastFilterGeneration() >= must_pass_generation // folder has been compared to a valid precursor filter - && !mPassedFilter) // and did not pass the filter - { - // go ahead and flag this folder as done - mLastFilterGeneration = filter_generation; - //TODO RN: create interface for string highlighting - //mStringMatchOffset = std::string::npos; - } - else // filter self only on first pass through - { - // filter against folder rules - filterFolder(filter); - // and then item rules - LLFolderViewItem::filter( filter ); - } - } - - if (getRoot()->getDebugFilters()) - { - mStatusText = llformat("%d", mLastFilterGeneration); - mStatusText += llformat("(%d)", mCompletedFilterGeneration); - mStatusText += llformat("+%d", mMostFilteredDescendantGeneration); - } - - // all descendants have been filtered later than must pass generation - // but none passed - if(getCompletedFilterGeneration() >= must_pass_generation && !hasFilteredDescendants(must_pass_generation)) - { - // don't traverse children if we've already filtered them since must_pass_generation - // and came back with nothing - return; - } - - // we entered here with at least one filter iteration left - // check to see if we have any more before continuing on to children - if (filter.getFilterCount() < 0) - { - return; - } - - // now query children - for (folders_t::iterator iter = mFolders.begin(); - iter != mFolders.end(); - ++iter) - { - LLFolderViewFolder* folder = (*iter); - // have we run out of iterations this frame? - if (filter.getFilterCount() < 0) - { - break; - } - - // mMostFilteredDescendantGeneration might have been reset - // in which case we need to update it even for folders that - // don't need to be filtered anymore - if (folder->getCompletedFilterGeneration() >= filter_generation) - { - // track latest generation to pass any child items - if (folder->getFiltered() || folder->hasFilteredDescendants(filter.getFirstSuccessGeneration())) - { - mMostFilteredDescendantGeneration = filter_generation; - requestArrange(); - } - // just skip it, it has already been filtered - continue; - } - - // update this folders filter status (and children) - folder->filter( filter ); - - // track latest generation to pass any child items - if (folder->getFiltered() || folder->hasFilteredDescendants(filter_generation)) - { - mMostFilteredDescendantGeneration = filter_generation; - requestArrange(); - if (getRoot()->needsAutoSelect() && autoopen_folders) - { - folder->setOpenArrangeRecursively(TRUE); - } - } - } - - for (items_t::iterator iter = mItems.begin(); - iter != mItems.end(); - ++iter) - { - LLFolderViewItem* item = (*iter); - if (filter.getFilterCount() < 0) - { - break; - } - if (item->getLastFilterGeneration() >= filter_generation) - { - if (item->getFiltered()) - { - mMostFilteredDescendantGeneration = filter_generation; - requestArrange(); - } - continue; - } - - if (item->getLastFilterGeneration() >= must_pass_generation && - !item->getFiltered(must_pass_generation)) - { - // failed to pass an earlier filter that was a subset of the current one - // go ahead and flag this item as done - item->setFiltered(FALSE, filter_generation); - continue; - } - - item->filter( filter ); - - if (item->getFiltered(filter.getFirstSuccessGeneration())) - { - mMostFilteredDescendantGeneration = filter_generation; - requestArrange(); - } - } - - // if we didn't use all filter iterations - // that means we filtered all of our descendants - // instead of exhausting the filter count for this frame - if (filter.getFilterCount() > 0) - { - // flag this folder as having completed filter pass for all descendants - setCompletedFilterGeneration(filter_generation, FALSE/*dont recurse up to root*/); - } -} - -void LLFolderViewFolder::filterFolder(LLFolderViewFilter& filter) -{ - const BOOL previous_passed_filter = mPassedFolderFilter; - const BOOL passed_filter = filter.checkFolder(this); - - // If our visibility will change as a result of this filter, then - // we need to be rearranged in our parent folder - if (mParentFolder) - { - if (getVisible() != passed_filter - || previous_passed_filter != passed_filter ) - { - mParentFolder->requestArrange(); - } - } - - setFilteredFolder(passed_filter, filter.getCurrentGeneration()); - filter.decrementFilterCount(); - - if (getRoot()->getDebugFilters()) - { - mStatusText = llformat("%d", mLastFilterGeneration); - } -} - -void LLFolderViewFolder::setFiltered(BOOL filtered, S32 filter_generation) -{ - // if this folder is now filtered, but wasn't before - // (it just passed) - if (filtered && !mPassedFilter) - { - // reset current height, because last time we drew it - // it might have had more visible items than now - mCurHeight = 0.f; - } - - LLFolderViewItem::setFiltered(filtered, filter_generation); -} - -void LLFolderViewFolder::dirtyFilter() -{ - // we're a folder, so invalidate our completed generation - setCompletedFilterGeneration(-1, FALSE); - LLFolderViewItem::dirtyFilter(); -} - -BOOL LLFolderViewFolder::getFiltered() -{ - return getFilteredFolder(getRoot()->getFilter()->getFirstSuccessGeneration()) - && LLFolderViewItem::getFiltered(); -} - -BOOL LLFolderViewFolder::getFiltered(S32 filter_generation) -{ - return getFilteredFolder(filter_generation) && LLFolderViewItem::getFiltered(filter_generation); -} - -BOOL LLFolderViewFolder::hasFilteredDescendants(S32 filter_generation) -{ - return mMostFilteredDescendantGeneration >= filter_generation; -} - - -BOOL LLFolderViewFolder::hasFilteredDescendants() -{ - return mMostFilteredDescendantGeneration >= getRoot()->getFilter()->getFirstSuccessGeneration(); -} // Passes selection information on to children and record selection // information if necessary. @@ -1824,39 +1417,7 @@ void LLFolderViewFolder::destroyView() folderp->destroyView(); // removes entry from mFolders } - if (mParentFolder) - { - mParentFolder->removeView(this); - } -} - -// remove the specified item (and any children) if possible. Return -// TRUE if the item was deleted. -BOOL LLFolderViewFolder::removeItem(LLFolderViewItem* item) -{ - if(item->remove()) - { - return TRUE; - } - return FALSE; -} - -// simply remove the view (and any children) Don't bother telling the -// listeners. -void LLFolderViewFolder::removeView(LLFolderViewItem* item) -{ - if (!item || item->getParentFolder() != this) - { - return; - } - // deselect without traversing hierarchy - if (item->isSelected()) - { - item->deselectItem(); - } - getRoot()->removeFromSelectionList(item); - extractItem(item); - delete item; + LLFolderViewItem::destroyView(); } // extractItem() removes the specified item from the folder, but @@ -1882,7 +1443,7 @@ void LLFolderViewFolder::extractItem( LLFolderViewItem* item ) mItems.erase(it); } //item has been removed, need to update filter - dirtyFilter(); + getViewModelItem()->dirtyFilter(); //because an item is going away regardless of filter status, force rearrange requestArrange(); removeChild(item); @@ -1890,31 +1451,28 @@ void LLFolderViewFolder::extractItem( LLFolderViewItem* item ) BOOL LLFolderViewFolder::isMovable() { - if( getViewModelItem() ) + if( !(getViewModelItem()->isItemMovable()) ) { - if( !(getViewModelItem()->isItemMovable()) ) - { - return FALSE; - } + return FALSE; + } - for (items_t::iterator iter = mItems.begin(); - iter != mItems.end();) + for (items_t::iterator iter = mItems.begin(); + iter != mItems.end();) + { + items_t::iterator iit = iter++; + if(!(*iit)->isMovable()) { - items_t::iterator iit = iter++; - if(!(*iit)->isMovable()) - { - return FALSE; - } + return FALSE; } + } - for (folders_t::iterator iter = mFolders.begin(); - iter != mFolders.end();) + for (folders_t::iterator iter = mFolders.begin(); + iter != mFolders.end();) + { + folders_t::iterator fit = iter++; + if(!(*fit)->isMovable()) { - folders_t::iterator fit = iter++; - if(!(*fit)->isMovable()) - { - return FALSE; - } + return FALSE; } } return TRUE; @@ -1923,31 +1481,28 @@ BOOL LLFolderViewFolder::isMovable() BOOL LLFolderViewFolder::isRemovable() { - if( getViewModelItem() ) + if( !(getViewModelItem()->isItemRemovable()) ) { - if( !(getViewModelItem()->isItemRemovable()) ) - { - return FALSE; - } + return FALSE; + } - for (items_t::iterator iter = mItems.begin(); - iter != mItems.end();) + for (items_t::iterator iter = mItems.begin(); + iter != mItems.end();) + { + items_t::iterator iit = iter++; + if(!(*iit)->isRemovable()) { - items_t::iterator iit = iter++; - if(!(*iit)->isRemovable()) - { - return FALSE; - } + return FALSE; } + } - for (folders_t::iterator iter = mFolders.begin(); - iter != mFolders.end();) + for (folders_t::iterator iter = mFolders.begin(); + iter != mFolders.end();) + { + folders_t::iterator fit = iter++; + if(!(*fit)->isRemovable()) { - folders_t::iterator fit = iter++; - if(!(*fit)->isRemovable()) - { - return FALSE; - } + return FALSE; } } return TRUE; @@ -1956,6 +1511,12 @@ BOOL LLFolderViewFolder::isRemovable() // this is an internal method used for adding items to folders. BOOL LLFolderViewFolder::addItem(LLFolderViewItem* item) { + if (item->getParentFolder()) + { + item->getParentFolder()->extractItem(item); + } + item->setParentFolder(this); + mItems.push_back(item); item->setRect(LLRect(0, 0, getRect().getWidth(), 0)); @@ -1963,12 +1524,14 @@ BOOL LLFolderViewFolder::addItem(LLFolderViewItem* item) addChild(item); - item->dirtyFilter(); + item->getViewModelItem()->dirtyFilter(); // Handle sorting requestArrange(); requestSort(); + getViewModelItem()->addChild(item->getViewModelItem()); + //TODO RN - make sort bubble up as long as parent Folder doesn't have anything matching sort criteria //// Traverse parent folders and update creation date and resort, if necessary //LLFolderViewFolder* parentp = this; @@ -1989,16 +1552,23 @@ BOOL LLFolderViewFolder::addItem(LLFolderViewItem* item) // this is an internal method used for adding items to folders. BOOL LLFolderViewFolder::addFolder(LLFolderViewFolder* folder) { + if (folder->mParentFolder) + { + folder->mParentFolder->extractItem(folder); + } + folder->mParentFolder = this; mFolders.push_back(folder); folder->setOrigin(0, 0); folder->reshape(getRect().getWidth(), 0); folder->setVisible(FALSE); addChild( folder ); - folder->dirtyFilter(); + folder->getViewModelItem()->dirtyFilter(); // rearrange all descendants too, as our indentation level might have changed folder->requestArrange(); requestSort(); + getViewModelItem()->addChild(folder->getViewModelItem()); + return TRUE; } @@ -2027,16 +1597,13 @@ void LLFolderViewFolder::setOpenArrangeRecursively(BOOL openitem, ERecurseType r { BOOL was_open = isOpen(); mIsOpen = openitem; - if (getViewModelItem()) + if(!was_open && openitem) { - if(!was_open && openitem) - { - getViewModelItem()->openItem(); - } - else if(was_open && !openitem) - { - getViewModelItem()->closeItem(); - } + getViewModelItem()->openItem(); + } + else if(was_open && !openitem) + { + getViewModelItem()->closeItem(); } if (recurse == RECURSE_DOWN || recurse == RECURSE_UP_DOWN) @@ -2068,7 +1635,7 @@ BOOL LLFolderViewFolder::handleDragAndDropFromChild(MASK mask, EAcceptance* accept, std::string& tooltip_msg) { - BOOL accepted = mListener && mListener->dragOrDrop(mask,drop,c_type,cargo_data, tooltip_msg); + BOOL accepted = mListener->dragOrDrop(mask,drop,c_type,cargo_data, tooltip_msg); if (accepted) { mDragAndDropTarget = TRUE; @@ -2156,7 +1723,7 @@ BOOL LLFolderViewFolder::handleDragAndDropToThisFolder(MASK mask, EAcceptance* accept, std::string& tooltip_msg) { - BOOL accepted = getViewModelItem() && getViewModelItem()->dragOrDrop(mask,drop,cargo_type,cargo_data, tooltip_msg); + BOOL accepted = getViewModelItem()->dragOrDrop(mask,drop,cargo_type,cargo_data, tooltip_msg); if (accepted) { @@ -2259,7 +1826,7 @@ BOOL LLFolderViewFolder::handleDoubleClick( S32 x, S32 y, MASK mask ) } else { - setSelectionFromRoot(this, FALSE); + getRoot()->setSelection(this, FALSE); toggleOpen(); } handled = TRUE; @@ -2293,16 +1860,6 @@ void LLFolderViewFolder::draw() mExpanderHighlighted = FALSE; } -BOOL LLFolderViewFolder::potentiallyVisible() -{ - // folder should be visible by it's own filter status - return LLFolderViewItem::potentiallyVisible() - // or one or more of its descendants have passed the minimum filter requirement - || hasFilteredDescendants() - // or not all of its descendants have been checked against minimum filter requirement - || getCompletedFilterGeneration() < getRoot()->getFilter()->getFirstSuccessGeneration(); -} - // this does prefix traversal, as folders are listed above their contents LLFolderViewItem* LLFolderViewFolder::getNextFromChild( LLFolderViewItem* item, BOOL include_children ) { -- cgit v1.2.3 From ed7173c987cf4a5de2f3c9b9d792e5ac4006e833 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 28 Jun 2012 23:29:58 -0700 Subject: CHUI-101 WIP Make LLFolderview general purpose filtering mostly working --- indra/newview/llfolderviewitem.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'indra/newview/llfolderviewitem.cpp') diff --git a/indra/newview/llfolderviewitem.cpp b/indra/newview/llfolderviewitem.cpp index f65a13be1e..685a4cbf49 100644 --- a/indra/newview/llfolderviewitem.cpp +++ b/indra/newview/llfolderviewitem.cpp @@ -123,7 +123,10 @@ LLFolderViewItem::LLFolderViewItem(const LLFolderViewItem::Params& p) mListener(p.listener), mIsMouseOverTitle(false) { - mListener->setFolderViewItem(this); + if (mListener) + { + mListener->setFolderViewItem(this); + } } BOOL LLFolderViewItem::postBuild() -- cgit v1.2.3 From 1bd52dfbdc3607bbd9ea86c715ce63b17d5a557f Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 2 Jul 2012 17:57:29 -0700 Subject: CHUI-101 WIP Make LLFolderView general purpose refactored source files, moving logic into llfolderviewmodel*.cpp filter logic tweaks purging and moving inventory now properly cleans up view model --- indra/newview/llfolderviewitem.cpp | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'indra/newview/llfolderviewitem.cpp') diff --git a/indra/newview/llfolderviewitem.cpp b/indra/newview/llfolderviewitem.cpp index 685a4cbf49..ac389c9189 100644 --- a/indra/newview/llfolderviewitem.cpp +++ b/indra/newview/llfolderviewitem.cpp @@ -120,12 +120,12 @@ LLFolderViewItem::LLFolderViewItem(const LLFolderViewItem::Params& p) mDragAndDropTarget(FALSE), mLabel(p.name), mRoot(p.root), - mListener(p.listener), + mViewModelItem(p.listener), mIsMouseOverTitle(false) { - if (mListener) + if (mViewModelItem) { - mListener->setFolderViewItem(this); + mViewModelItem->setFolderViewItem(this); } } @@ -138,8 +138,8 @@ BOOL LLFolderViewItem::postBuild() // Destroys the object LLFolderViewItem::~LLFolderViewItem( void ) { - delete mListener; - mListener = NULL; + delete mViewModelItem; + mViewModelItem = NULL; } LLFolderView* LLFolderViewItem::getRoot() @@ -837,12 +837,6 @@ LLFolderViewModelInterface* LLFolderViewItem::getFolderViewModel( void ) return getRoot()->getFolderViewModel(); } -S32 LLFolderViewItem::getLastFilterGeneration() const -{ - return getViewModelItem()->getLastFilterGeneration(); -} - - ///---------------------------------------------------------------------------- /// Class LLFolderViewFolder @@ -1446,6 +1440,7 @@ void LLFolderViewFolder::extractItem( LLFolderViewItem* item ) mItems.erase(it); } //item has been removed, need to update filter + getViewModelItem()->removeChild(item->getViewModelItem()); getViewModelItem()->dirtyFilter(); //because an item is going away regardless of filter status, force rearrange requestArrange(); @@ -1638,7 +1633,7 @@ BOOL LLFolderViewFolder::handleDragAndDropFromChild(MASK mask, EAcceptance* accept, std::string& tooltip_msg) { - BOOL accepted = mListener->dragOrDrop(mask,drop,c_type,cargo_data, tooltip_msg); + BOOL accepted = mViewModelItem->dragOrDrop(mask,drop,c_type,cargo_data, tooltip_msg); if (accepted) { mDragAndDropTarget = TRUE; -- cgit v1.2.3