Commits

Merov Linden  committed 51ea8aa

MAINT-1197 : Fix inventory deselection/reselection when cutting items

  • Participants
  • Parent commits 7d090db

Comments (0)

Files changed (5)

File indra/newview/llfolderview.cpp

 		LLFastTimer t3(FTM_AUTO_SELECT);
 		// select new item only if a filtered item not currently selected
 		LLFolderViewItem* selected_itemp = mSelectedItems.empty() ? NULL : mSelectedItems.back();
-		if (!mAutoSelectOverride && (!selected_itemp || !selected_itemp->potentiallyFiltered()))
+		if (!mAutoSelectOverride && (!selected_itemp || !selected_itemp->potentiallyVisible()))
 		{
 			// these are named variables to get around gcc not binding non-const references to rvalues
 			// and functor application is inherently non-const to allow for stateful functors
 
 		// Open filtered folders for folder views with mAutoSelectOverride=TRUE.
 		// Used by LLPlacesFolderView.
-		if (mAutoSelectOverride && !mFilter->getFilterSubString().empty())
+		if (!mFilter->getFilterSubString().empty())
 		{
 			// these are named variables to get around gcc not binding non-const references to rvalues
 			// and functor application is inherently non-const to allow for stateful functors
 	}
 }
 
+LLFolderViewItem* LLFolderView::getNextUnselectedItem()
+{
+	LLFolderViewItem* last_item = *mSelectedItems.rbegin();
+	LLFolderViewItem* new_selection = last_item->getNextOpenNode(FALSE);
+	while(new_selection && new_selection->isSelected())
+	{
+		new_selection = new_selection->getNextOpenNode(FALSE);
+	}
+	if (!new_selection)
+	{
+		new_selection = last_item->getPreviousOpenNode(FALSE);
+		while (new_selection && (new_selection->isInSelection()))
+		{
+			new_selection = new_selection->getPreviousOpenNode(FALSE);
+		}
+	}
+	return new_selection;
+}
+
 LLInventoryFilter* LLFolderView::getFilter()
 {
 	return mFilter;

File indra/newview/llfolderview.h

 	virtual void	doDelete();
 	virtual BOOL	canDoDelete() const;
 
+	LLFolderViewItem* getNextUnselectedItem();
+	
 	// Public rename functionality - can only start the process
 	void startRenamingSelectedItem( void );
 

File indra/newview/llfolderviewitem.cpp

 	}
 }
 
+bool LLFolderViewItem::isInSelection() const
+{
+	return mIsSelected || (mParentFolder && mParentFolder->isInSelection());
+}
 
 ///----------------------------------------------------------------------------
 /// Class LLFolderViewFolder

File indra/newview/llfolderviewitem.h

 	virtual void destroyView();
 
 	BOOL isSelected() const { return mIsSelected; }
+	bool isInSelection() const;
 
 	void setUnselected() { mIsSelected = FALSE; }
 

File indra/newview/llinventorybridge.cpp

 	else if ("cut" == action)
 	{
 		cutToClipboard();
+		// MAINT-1197: This is temp code to work around a deselection/reselection bug. Please discard when merging CHUI.
+		LLFolderViewItem* item_to_select = mRoot->getNextUnselectedItem();
 		LLFolderView::removeCutItems();
+		mRoot->setSelection(item_to_select, item_to_select ? item_to_select->isOpen() : false, false);
 		return;
 	}
 	else if ("copy" == action)
 	else if ("cut" == action)
 	{
 		cutToClipboard();
+		// MAINT-1197: This is temp code to work around a deselection/reselection bug. Please discard when merging CHUI.
+		LLFolderViewItem* item_to_select = mRoot->getNextUnselectedItem();
 		LLFolderView::removeCutItems();
+		mRoot->setSelection(item_to_select, item_to_select ? item_to_select->isOpen() : false, false);
 		return;
 	}
 	else if ("copy" == action)