diff options
Diffstat (limited to 'indra/newview/llfolderviewitem.cpp')
-rw-r--r-- | indra/newview/llfolderviewitem.cpp | 451 |
1 files changed, 199 insertions, 252 deletions
diff --git a/indra/newview/llfolderviewitem.cpp b/indra/newview/llfolderviewitem.cpp index 4b48626b22..3208218302 100644 --- a/indra/newview/llfolderviewitem.cpp +++ b/indra/newview/llfolderviewitem.cpp @@ -38,9 +38,9 @@ #include "llfoldervieweventlistener.h" #include "llinventorybridge.h" // for LLItemBridge in LLInventorySort::operator() #include "llinventoryfilter.h" +#include "llinventorymodelbackgroundfetch.h" #include "llpanel.h" #include "llviewercontrol.h" // gSavedSettings -#include "llviewerinventory.h" #include "llviewerwindow.h" // Argh, only for setCursor() // linden library includes @@ -122,7 +122,6 @@ LLFolderViewItem::LLFolderViewItem(const LLFolderViewItem::Params& p) mHasVisibleChildren(FALSE), mIndentation(0), mItemHeight(p.item_height), - mNumDescendantsSelected(0), mPassedFilter(FALSE), mLastFilterGeneration(-1), mStringMatchOffset(std::string::npos), @@ -257,11 +256,30 @@ void LLFolderViewItem::refreshFromListener() // 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 (LLFolderType::lookupIsProtectedType(preferred_type)) + + // 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()); + } + } + + //"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(mListener->getIcon()); time_t creation_date = mListener->getCreationDate(); if (mCreationDate != creation_date) @@ -419,11 +437,8 @@ S32 LLFolderViewItem::arrange( S32* width, S32* height, S32 filter_generation) S32 LLFolderViewItem::getItemHeight() { - if (mHidden) return 0; + if (getHidden()) return 0; - //S32 icon_height = mIcon->getHeight(); - //S32 label_height = llround(getLabelFontForStyle(mLabelStyle)->getLineHeight()); - //return llmax( icon_height, label_height ) + ICON_PAD; return mItemHeight; } @@ -498,22 +513,6 @@ BOOL LLFolderViewItem::changeSelection(LLFolderViewItem* selection, BOOL selecte return FALSE; } -void LLFolderViewItem::recursiveDeselect(BOOL deselect_self) -{ - if (mIsSelected && deselect_self) - { - mIsSelected = FALSE; - - // update ancestors' count of selected descendents - LLFolderViewFolder* parent_folder = getParentFolder(); - while(parent_folder) - { - parent_folder->mNumDescendantsSelected--; - parent_folder = parent_folder->getParentFolder(); - } - } -} - BOOL LLFolderViewItem::isMovable() { @@ -822,32 +821,38 @@ BOOL LLFolderViewItem::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, return handled; } - void LLFolderViewItem::draw() { - if (mHidden) return; + if (getHidden()) + { + return; + } 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 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("InventoryItemSuffixColor", DEFAULT_WHITE); + static LLUIColor sSuffixColor = LLUIColorTable::instance().getColor("InventoryItemColor", DEFAULT_WHITE); + static LLUIColor sLibraryColor = LLUIColorTable::instance().getColor("InventoryItemLibraryColor", DEFAULT_WHITE); static LLUIColor sSearchStatusColor = LLUIColorTable::instance().getColor("InventorySearchStatusColor", DEFAULT_WHITE); const Params& default_params = LLUICtrlFactory::getDefaultParams<LLFolderViewItem>(); const S32 TOP_PAD = default_params.item_top_pad; + const S32 FOCUS_LEFT = 1; + const LLFontGL* font = getLabelFontForStyle(mLabelStyle); - bool possibly_has_children = false; - bool up_to_date = mListener && mListener->isUpToDate(); - if((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) - { - possibly_has_children = true; - } - if(/*mControlLabel[0] != '\0' && */possibly_has_children) + const BOOL in_inventory = getListener() && gInventory.isObjectDescendentOf(getListener()->getUUID(), gInventory.getRootFolderID()); + const BOOL in_library = getListener() && gInventory.isObjectDescendentOf(getListener()->getUUID(), gInventory.getLibraryRootFolderID()); + + //--------------------------------------------------------------------------------// + // Draw open folder arrow + // + const bool up_to_date = mListener && mListener->isUpToDate(); + const bool possibly_has_children = ((up_to_date && hasVisibleChildren()) || // we fetched our children and some of them have passed the filter... + (!up_to_date && mListener && mListener->hasChildren())); // ...or we know we have children but haven't fetched them (doesn't obey filter) + if (possibly_has_children) { LLUIImage* arrow_image = default_params.folder_arrow_image; gl_draw_scaled_rotated_image( @@ -855,22 +860,16 @@ void LLFolderViewItem::draw() ARROW_SIZE, ARROW_SIZE, mControlLabelRotation, arrow_image->getImage(), sFgColor); } - // See also LLFolderView::updateRenamerPosition() - F32 text_left = (F32)(ARROW_SIZE + TEXT_PAD + ICON_WIDTH + ICON_PAD + mIndentation); - - LLFontGL* font = getLabelFontForStyle(mLabelStyle); - // If we have keyboard focus, draw selection filled - BOOL show_context = getRoot()->getShowSelectionContext(); - BOOL filled = show_context || (getRoot()->getParentPanel()->hasFocus()); - const S32 FOCUS_LEFT = 1; - S32 focus_top = getRect().getHeight(); - S32 focus_bottom = getRect().getHeight() - mItemHeight; - bool folder_open = (getRect().getHeight() > mItemHeight + 4); - - // always render "current" item, only render other selected items if - // mShowSingleSelection is FALSE - if( mIsSelected ) + //--------------------------------------------------------------------------------// + // Draw highlight for selected items + // + const BOOL show_context = getRoot()->getShowSelectionContext(); + const BOOL filled = show_context || (getRoot()->getParentPanel()->hasFocus()); // If we have keyboard focus, draw selection filled + const S32 focus_top = getRect().getHeight(); + const S32 focus_bottom = getRect().getHeight() - mItemHeight; + const bool folder_open = (getRect().getHeight() > mItemHeight + 4); + if (mIsSelected) // always render "current" item. Only render other selected items if mShowSingleSelection is FALSE { gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); LLColor4 bg_color = sHighlightBgColor; @@ -889,152 +888,167 @@ void LLFolderViewItem::draw() bg_color.mV[VALPHA] = clamp_rescale(fade_time, 0.f, 0.4f, 0.f, bg_color.mV[VALPHA]); } } - - gl_rect_2d( - FOCUS_LEFT, - focus_top, - getRect().getWidth() - 2, - focus_bottom, - bg_color, filled); + gl_rect_2d(FOCUS_LEFT, + focus_top, + getRect().getWidth() - 2, + focus_bottom, + bg_color, filled); if (mIsCurSelection) { - gl_rect_2d( - FOCUS_LEFT, - focus_top, - getRect().getWidth() - 2, - focus_bottom, - sFocusOutlineColor, FALSE); + gl_rect_2d(FOCUS_LEFT, + focus_top, + getRect().getWidth() - 2, + focus_bottom, + sFocusOutlineColor, FALSE); } if (folder_open) { - gl_rect_2d( - FOCUS_LEFT, - focus_bottom + 1, // overlap with bottom edge of above rect - getRect().getWidth() - 2, - 0, - sFocusOutlineColor, FALSE); + gl_rect_2d(FOCUS_LEFT, + focus_bottom + 1, // overlap with bottom edge of above rect + getRect().getWidth() - 2, + 0, + sFocusOutlineColor, FALSE); if (show_context) { - gl_rect_2d( - FOCUS_LEFT, - focus_bottom + 1, - getRect().getWidth() - 2, - 0, - sHighlightBgColor, TRUE); + gl_rect_2d(FOCUS_LEFT, + focus_bottom + 1, + getRect().getWidth() - 2, + 0, + sHighlightBgColor, TRUE); } } } + + //--------------------------------------------------------------------------------// + // Draw DragNDrop highlight + // if (mDragAndDropTarget) { gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - gl_rect_2d( - FOCUS_LEFT, - focus_top, - getRect().getWidth() - 2, - focus_bottom, - sHighlightBgColor, FALSE); + gl_rect_2d(FOCUS_LEFT, + focus_top, + getRect().getWidth() - 2, + focus_bottom, + sHighlightBgColor, FALSE); if (folder_open) { - gl_rect_2d( - FOCUS_LEFT, - focus_bottom + 1, // overlap with bottom edge of above rect - getRect().getWidth() - 2, - 0, - sHighlightBgColor, FALSE); + gl_rect_2d(FOCUS_LEFT, + focus_bottom + 1, // overlap with bottom edge of above rect + getRect().getWidth() - 2, + 0, + sHighlightBgColor, FALSE); } mDragAndDropTarget = FALSE; } - S32 icon_x = mIndentation + ARROW_SIZE + TEXT_PAD; - // First case is used for open folders - if (!mIconOpen.isNull() && (llabs(mControlLabelRotation) > 80)) + + //--------------------------------------------------------------------------------// + // 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) + else if (mIcon) { mIcon->draw(icon_x, getRect().getHeight() - mIcon->getHeight() - TOP_PAD + 1); } - if (!mLabel.empty()) - { - // highlight filtered text - BOOL debug_filters = getRoot()->getDebugFilters(); - LLColor4 color = ( (mIsSelected && filled) ? sHighlightFgColor : sFgColor ); - F32 right_x; - F32 y = (F32)getRect().getHeight() - font->getLineHeight() - (F32)TEXT_PAD - (F32)TOP_PAD; - - if (debug_filters) - { - if (!getFiltered() && !possibly_has_children) - { - 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; - } + //--------------------------------------------------------------------------------// + // Exit if no label to draw + // + if (mLabel.empty()) + { + return; + } + LLColor4 color = (mIsSelected && filled) ? sHighlightFgColor : sFgColor; + if (in_library) color = sLibraryColor; - font->renderUTF8( mLabel, 0, text_left, y, color, - LLFontGL::LEFT, LLFontGL::BOTTOM, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, - S32_MAX, getRect().getWidth() - (S32) text_left, &right_x, TRUE); + 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); -// LLViewerInventoryCategory *item = 0; -// if (getListener()) -// item = gInventory.getCategory(getListener()->getUUID()); - bool root_is_loading = false; - if (getListener() && gInventory.isObjectDescendentOf(getListener()->getUUID(),gInventory.getRootFolderID())) - { - // Descendent of my inventory. - root_is_loading = gInventory.myInventoryFetchInProgress(); - } - if (getListener() && gInventory.isObjectDescendentOf(getListener()->getUUID(),gInventory.getLibraryRootFolderID())) - { - // Descendent of library - root_is_loading = gInventory.libraryFetchInProgress(); - } - - if ( (mIsLoading && mTimeSinceRequestStart.getElapsedTimeF32() >= gSavedSettings.getF32("FolderLoadingMessageWaitTime")) - || (LLInventoryModel::backgroundFetchActive() && root_is_loading && mShowLoadStatus) ) + //--------------------------------------------------------------------------------// + // Highlight filtered text + // + if (getRoot()->getDebugFilters()) + { + if (!getFiltered() && !possibly_has_children) { - 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); + 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 + // + font->renderUTF8(mLabel, 0, text_left, y, color, + LLFontGL::LEFT, LLFontGL::BOTTOM, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, + S32_MAX, getRect().getWidth() - (S32) text_left, &right_x, TRUE); - if (!mLabelSuffix.empty()) - { - font->renderUTF8( mLabelSuffix, 0, right_x, y, sSuffixColor, - LLFontGL::LEFT, LLFontGL::BOTTOM, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, - S32_MAX, S32_MAX, &right_x, FALSE ); - } + //--------------------------------------------------------------------------------// + // 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().backgroundFetchActive() && root_is_loading && (mShowLoadStatus || mHidden))) + { + 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 + // + if (!mLabelSuffix.empty()) + { + font->renderUTF8( mLabelSuffix, 0, right_x, y, sSuffixColor, + LLFontGL::LEFT, LLFontGL::BOTTOM, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, + S32_MAX, S32_MAX, &right_x, FALSE ); + } - if (mStringMatchOffset != std::string::npos) + //--------------------------------------------------------------------------------// + // 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) { - // 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; + 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 ); - } + 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 ); } } } @@ -1045,20 +1059,21 @@ void LLFolderViewItem::draw() ///---------------------------------------------------------------------------- LLFolderViewFolder::LLFolderViewFolder( const LLFolderViewItem::Params& p ): -LLFolderViewItem( p ), // 0 = no create time -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) -{} + LLFolderViewItem( p ), // 0 = no create time + 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) +{ +} // Destroys the object LLFolderViewFolder::~LLFolderViewFolder( void ) @@ -1316,7 +1331,7 @@ 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()))) { - gInventory.startBackgroundFetch(mListener->getUUID()); + LLInventoryModelBackgroundFetch::instance().start(mListener->getUUID()); } // now query children @@ -1340,10 +1355,6 @@ void LLFolderViewFolder::filter( LLInventoryFilter& filter) if (folder->getFiltered() || folder->hasFilteredDescendants(filter.getMinRequiredGeneration())) { mMostFilteredDescendantGeneration = filter_generation; - if (getRoot()->needsAutoSelect() && autoopen_folders) - { - folder->setOpenArrangeRecursively(TRUE); - } } // just skip it, it has already been filtered continue; @@ -1464,7 +1475,6 @@ BOOL LLFolderViewFolder::setSelection(LLFolderViewItem* selection, BOOL openitem { rv = TRUE; child_selected = TRUE; - mNumDescendantsSelected++; } } for (items_t::iterator iter = mItems.begin(); @@ -1475,7 +1485,6 @@ BOOL LLFolderViewFolder::setSelection(LLFolderViewItem* selection, BOOL openitem { rv = TRUE; child_selected = TRUE; - mNumDescendantsSelected++; } } if(openitem && child_selected) @@ -1508,14 +1517,6 @@ BOOL LLFolderViewFolder::changeSelection(LLFolderViewItem* selection, folders_t::iterator fit = iter++; if((*fit)->changeSelection(selection, selected)) { - if (selected) - { - mNumDescendantsSelected++; - } - else - { - mNumDescendantsSelected--; - } rv = TRUE; } } @@ -1525,14 +1526,6 @@ BOOL LLFolderViewFolder::changeSelection(LLFolderViewItem* selection, items_t::iterator iit = iter++; if((*iit)->changeSelection(selection, selected)) { - if (selected) - { - mNumDescendantsSelected++; - } - else - { - mNumDescendantsSelected--; - } rv = TRUE; } } @@ -1549,7 +1542,6 @@ S32 LLFolderViewFolder::extendSelection(LLFolderViewItem* selection, LLFolderVie { folders_t::iterator fit = iter++; num_selected += (*fit)->extendSelection(selection, last_selected, selected_items); - mNumDescendantsSelected += num_selected; } // handle selection of our immediate children... @@ -1642,7 +1634,6 @@ S32 LLFolderViewFolder::extendSelection(LLFolderViewItem* selection, LLFolderVie if (item->changeSelection(item, TRUE)) { selected_items.put(item); - mNumDescendantsSelected++; num_selected++; } } @@ -1653,7 +1644,6 @@ S32 LLFolderViewFolder::extendSelection(LLFolderViewItem* selection, LLFolderVie if (selection->changeSelection(selection, TRUE)) { selected_items.put(selection); - mNumDescendantsSelected++; num_selected++; } } @@ -1661,47 +1651,6 @@ S32 LLFolderViewFolder::extendSelection(LLFolderViewItem* selection, LLFolderVie return num_selected; } -void LLFolderViewFolder::recursiveDeselect(BOOL deselect_self) -{ - // make sure we don't have negative values - llassert(mNumDescendantsSelected >= 0); - - if (mIsSelected && deselect_self) - { - mIsSelected = FALSE; - - // update ancestors' count of selected descendents - LLFolderViewFolder* parent_folder = getParentFolder(); - while(parent_folder) - { - parent_folder->mNumDescendantsSelected--; - parent_folder = parent_folder->getParentFolder(); - } - } - - if (0 == mNumDescendantsSelected) - { - return; - } - - for (items_t::iterator iter = mItems.begin(); - iter != mItems.end();) - { - items_t::iterator iit = iter++; - LLFolderViewItem* item = (*iit); - item->recursiveDeselect(TRUE); - } - - for (folders_t::iterator iter = mFolders.begin(); - iter != mFolders.end();) - { - folders_t::iterator fit = iter++; - LLFolderViewFolder* folder = (*fit); - folder->recursiveDeselect(TRUE); - } - -} - void LLFolderViewFolder::destroyView() { for (items_t::iterator iter = mItems.begin(); @@ -1735,8 +1684,6 @@ BOOL LLFolderViewFolder::removeItem(LLFolderViewItem* item) { if(item->remove()) { - //RN: this seem unneccessary as remove() moves to trash - //removeView(item); return TRUE; } return FALSE; @@ -1751,7 +1698,6 @@ void LLFolderViewFolder::removeView(LLFolderViewItem* item) return; } // deselect without traversing hierarchy - item->recursiveDeselect(TRUE); getRoot()->removeFromSelectionList(item); extractItem(item); delete item; @@ -1860,10 +1806,9 @@ EInventorySortGroup LLFolderViewFolder::getSortGroup() const return SG_TRASH_FOLDER; } - // Folders that can't be moved are 'system' folders. if( mListener ) { - if( !(mListener->isItemMovable()) ) + if(LLFolderType::lookupIsProtectedType(mListener->getPreferredType())) { return SG_SYSTEM_FOLDER; } @@ -2541,18 +2486,20 @@ bool LLInventorySort::operator()(const LLFolderViewItem* const& a, const LLFolde { static const LLUUID& favorites_folder_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_FAVORITE); - static const LLUUID& landmarks_folder_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_LANDMARK); LLUUID a_uuid = a->getParentFolder()->getListener()->getUUID(); LLUUID b_uuid = b->getParentFolder()->getListener()->getUUID(); - if ((a_uuid == favorites_folder_id && b_uuid == favorites_folder_id) || - (a_uuid == landmarks_folder_id && b_uuid == landmarks_folder_id)) + 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 - S32 a_sort = (static_cast<const LLItemBridge*>(a->getListener()))->getItem()->getSortField(); - S32 b_sort = (static_cast<const LLItemBridge*>(b->getListener()))->getItem()->getSortField(); + LLViewerInventoryItem* aitem = (static_cast<const LLItemBridge*>(a->getListener()))->getItem(); + LLViewerInventoryItem* bitem = (static_cast<const LLItemBridge*>(b->getListener()))->getItem(); + if (!aitem || !bitem) + return false; + S32 a_sort = aitem->getSortField(); + S32 b_sort = bitem->getSortField(); return a_sort < b_sort; } } |