summaryrefslogtreecommitdiff
path: root/indra/newview/llfolderview.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llfolderview.cpp')
-rw-r--r--indra/newview/llfolderview.cpp76
1 files changed, 58 insertions, 18 deletions
diff --git a/indra/newview/llfolderview.cpp b/indra/newview/llfolderview.cpp
index e90b6c1c3d..8b72d83830 100644
--- a/indra/newview/llfolderview.cpp
+++ b/indra/newview/llfolderview.cpp
@@ -181,6 +181,7 @@ LLFolderView::Params::Params()
// Default constructor
LLFolderView::LLFolderView(const Params& p)
: LLFolderViewFolder(p),
+ mRunningHeight(0),
mScrollContainer( NULL ),
mPopupMenuHandle(),
mAllowMultiSelect(p.allow_multiselect),
@@ -369,16 +370,6 @@ void LLFolderView::closeAllFolders()
arrangeAll();
}
-void LLFolderView::openFolder(const std::string& foldername)
-{
- LLFolderViewFolder* inv = findChild<LLFolderViewFolder>(foldername);
- if (inv)
- {
- setSelection(inv, FALSE, FALSE);
- inv->setOpen(TRUE);
- }
-}
-
void LLFolderView::openTopLevelFolders()
{
for (folders_t::iterator iter = mFolders.begin();
@@ -402,6 +393,16 @@ static LLFastTimer::DeclareTimer FTM_ARRANGE("Arrange");
// This view grows and shinks to enclose all of its children items and folders.
S32 LLFolderView::arrange( S32* unused_width, S32* unused_height, S32 filter_generation )
{
+ if (getListener()->getUUID().notNull())
+ {
+ if (mNeedsSort)
+ {
+ mFolders.sort(mSortFunction);
+ mItems.sort(mSortFunction);
+ mNeedsSort = false;
+ }
+ }
+
LLFastTimer t2(FTM_ARRANGE);
filter_generation = mFilter->getMinRequiredGeneration();
@@ -479,6 +480,7 @@ S32 LLFolderView::arrange( S32* unused_width, S32* unused_height, S32 filter_gen
target_height = running_height;
}
+ mRunningHeight = running_height;
LLRect scroll_rect = mScrollContainer->getContentWindowRect();
reshape( llmax(scroll_rect.getWidth(), total_width), running_height );
@@ -524,9 +526,11 @@ void LLFolderView::reshape(S32 width, S32 height, BOOL called_from_parent)
LLRect scroll_rect;
if (mScrollContainer)
{
+ LLView::reshape(width, height, called_from_parent);
scroll_rect = mScrollContainer->getContentWindowRect();
}
width = llmax(mMinWidth, scroll_rect.getWidth());
+ height = llmax(mRunningHeight, scroll_rect.getHeight());
// restrict width with scroll container's width
if (mUseEllipses)
@@ -710,8 +714,10 @@ void LLFolderView::extendSelection(LLFolderViewItem* selection, LLFolderViewItem
mSignalSelectCallback = SIGNAL_KEYBOARD_FOCUS;
}
+static LLFastTimer::DeclareTimer FTM_SANITIZE_SELECTION("Sanitize Selection");
void LLFolderView::sanitizeSelection()
{
+ LLFastTimer _(FTM_SANITIZE_SELECTION);
// store off current item in case it is automatically deselected
// and we want to preserve context
LLFolderViewItem* original_selected_item = getCurSelectedItem();
@@ -1004,6 +1010,33 @@ void LLFolderView::removeSelectedItems( void )
LLNotificationsUtil::add("DeleteItems", args, LLSD(), boost::bind(&LLFolderView::onItemsRemovalConfirmation, this, _1, _2));
}
+bool isDescendantOfASelectedItem(LLFolderViewItem* item, const std::vector<LLFolderViewItem*>& selectedItems)
+{
+ LLFolderViewItem* item_parent = dynamic_cast<LLFolderViewItem*>(item->getParent());
+
+ if (item_parent)
+ {
+ for(std::vector<LLFolderViewItem*>::const_iterator it = selectedItems.begin(); it != selectedItems.end(); ++it)
+ {
+ const LLFolderViewItem* const selected_item = (*it);
+
+ LLFolderViewItem* parent = item_parent;
+
+ while (parent)
+ {
+ if (selected_item == parent)
+ {
+ return true;
+ }
+
+ parent = dynamic_cast<LLFolderViewItem*>(parent->getParent());
+ }
+ }
+ }
+
+ return false;
+}
+
void LLFolderView::onItemsRemovalConfirmation(const LLSD& notification, const LLSD& response)
{
S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
@@ -1078,7 +1111,7 @@ void LLFolderView::onItemsRemovalConfirmation(const LLSD& notification, const LL
if (!new_selection)
{
new_selection = last_item->getPreviousOpenNode(FALSE);
- while (new_selection && new_selection->isSelected())
+ while (new_selection && (new_selection->isSelected() || isDescendantOfASelectedItem(new_selection, items)))
{
new_selection = new_selection->getPreviousOpenNode(FALSE);
}
@@ -1903,20 +1936,25 @@ BOOL LLFolderView::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
std::string& tooltip_msg)
{
mDragAndDropThisFrame = TRUE;
+ // have children handle it first
BOOL handled = LLView::handleDragAndDrop(x, y, mask, drop, cargo_type, cargo_data,
accept, tooltip_msg);
- // When there are no visible children drag and drop is handled
+ // when drop is not handled by child, it should be handled
// by the folder which is the hierarchy root.
- if (!handled && !hasVisibleChildren())
+ if (!handled)
{
- if (mFolders.empty())
- {
- handled = handleDragAndDropFromChild(mask,drop,cargo_type,cargo_data,accept,tooltip_msg);
- }
+ if (getListener()->getUUID().notNull())
+ {
+ handled = LLFolderViewFolder::handleDragAndDrop(x, y, mask, drop, cargo_type, cargo_data, accept, tooltip_msg);
+ }
else
{
- handled = mFolders.front()->handleDragAndDropFromChild(mask,drop,cargo_type,cargo_data,accept,tooltip_msg);
+ if (!mFolders.empty())
+ {
+ // dispatch to last folder as a hack to support "Contents" folder in object inventory
+ handled = mFolders.back()->handleDragAndDropFromChild(mask,drop,cargo_type,cargo_data,accept,tooltip_msg);
+ }
}
}
@@ -2038,8 +2076,10 @@ void LLFolderView::removeItemID(const LLUUID& id)
mItemMap.erase(id);
}
+LLFastTimer::DeclareTimer FTM_GET_ITEM_BY_ID("Get FolderViewItem by ID");
LLFolderViewItem* LLFolderView::getItemByID(const LLUUID& id)
{
+ LLFastTimer _(FTM_GET_ITEM_BY_ID);
if (id == getListener()->getUUID())
{
return this;