summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorRichard Linden <none@none>2012-08-01 20:07:42 -0700
committerRichard Linden <none@none>2012-08-01 20:07:42 -0700
commit88e81f99293c992944787289699bf885568bf327 (patch)
treedfef61dd4aad6a5681122497678b263ab93449cd /indra
parentc009cf4f7656ec27347e1e9c740da26c12726c99 (diff)
CHUI-223 WIP Selecting to cut an inventory item causes all open inventory windows to refresh
avoid moving selection when cutting
Diffstat (limited to 'indra')
-rw-r--r--indra/llui/llfolderview.cpp57
-rw-r--r--indra/llui/llfolderviewitem.cpp6
-rw-r--r--indra/llui/llfolderviewitem.h1
-rw-r--r--indra/newview/llinventorypanel.cpp17
4 files changed, 44 insertions, 37 deletions
diff --git a/indra/llui/llfolderview.cpp b/indra/llui/llfolderview.cpp
index d714d4623d..5d98dc9663 100644
--- a/indra/llui/llfolderview.cpp
+++ b/indra/llui/llfolderview.cpp
@@ -717,33 +717,6 @@ void LLFolderView::closeRenamer( void )
}
}
-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::removeSelectedItems()
{
if(getVisible() && getEnabled())
@@ -815,7 +788,7 @@ void LLFolderView::removeSelectedItems()
if (!new_selection)
{
new_selection = last_item->getPreviousOpenNode(FALSE);
- while (new_selection && (new_selection->isSelected() || isDescendantOfASelectedItem(new_selection, items)))
+ while (new_selection && (new_selection->isInSelection()))
{
new_selection = new_selection->getPreviousOpenNode(FALSE);
}
@@ -1060,16 +1033,42 @@ void LLFolderView::cut()
if(getVisible() && getEnabled() && (count > 0))
{
LLFolderViewModelItem* listener = NULL;
+
+ 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);
+ }
+ }
+
selected_items_t::iterator item_it;
for (item_it = mSelectedItems.begin(); item_it != mSelectedItems.end(); ++item_it)
{
- listener = (*item_it)->getViewModelItem();
+ LLFolderViewItem* item_to_cut = *item_it;
+ listener = item_to_cut->getViewModelItem();
if(listener)
{
listener->cutToClipboard();
listener->removeItem();
}
}
+
+ if (new_selection)
+ {
+ setSelection(new_selection, new_selection->isOpen(), mParentPanel->hasFocus());
+ }
+ else
+ {
+ setSelection(NULL, mParentPanel->hasFocus());
+ }
}
mSearchString.clear();
}
diff --git a/indra/llui/llfolderviewitem.cpp b/indra/llui/llfolderviewitem.cpp
index 5238bfd7e4..68b442dd9a 100644
--- a/indra/llui/llfolderviewitem.cpp
+++ b/indra/llui/llfolderviewitem.cpp
@@ -810,6 +810,12 @@ LLFolderViewModelInterface* LLFolderViewItem::getFolderViewModel( void )
return getRoot()->getFolderViewModel();
}
+bool LLFolderViewItem::isInSelection() const
+{
+ return mIsSelected || (mParentFolder && mParentFolder->isInSelection());
+}
+
+
///----------------------------------------------------------------------------
/// Class LLFolderViewFolder
diff --git a/indra/llui/llfolderviewitem.h b/indra/llui/llfolderviewitem.h
index 4eda02f13f..e75059bc01 100644
--- a/indra/llui/llfolderviewitem.h
+++ b/indra/llui/llfolderviewitem.h
@@ -164,6 +164,7 @@ public:
virtual void destroyView();
BOOL isSelected() const { return mIsSelected; }
+ bool isInSelection() const;
void setUnselected() { mIsSelected = FALSE; }
diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp
index 1b3391f7ee..9403ccdabe 100644
--- a/indra/newview/llinventorypanel.cpp
+++ b/indra/newview/llinventorypanel.cpp
@@ -281,13 +281,6 @@ void LLInventoryPanel::draw()
// Select the desired item (in case it wasn't loaded when the selection was requested)
updateSelection();
- // Nudge the filter if the clipboard state changed
- if (mClipboardState != LLClipboard::instance().getGeneration())
- {
- mClipboardState = LLClipboard::instance().getGeneration();
- getFilter().setModified(LLClipboard::instance().isCutMode() ? LLInventoryFilter::FILTER_MORE_RESTRICTIVE : LLInventoryFilter::FILTER_LESS_RESTRICTIVE);
- }
-
LLPanel::draw();
}
@@ -586,7 +579,6 @@ LLUUID LLInventoryPanel::getRootFolderID()
}
}
-
// static
void LLInventoryPanel::onIdle(void *userdata)
{
@@ -608,6 +600,15 @@ void LLInventoryPanel::onIdle(void *userdata)
void LLInventoryPanel::idle(void* user_data)
{
LLInventoryPanel* panel = (LLInventoryPanel*)user_data;
+ // Nudge the filter if the clipboard state changed
+ if (panel->mClipboardState != LLClipboard::instance().getGeneration())
+ {
+ panel->mClipboardState = LLClipboard::instance().getGeneration();
+ panel->getFilter().setModified(LLClipboard::instance().isCutMode()
+ ? LLInventoryFilter::FILTER_MORE_RESTRICTIVE
+ : LLInventoryFilter::FILTER_LESS_RESTRICTIVE);
+ }
+
panel->mFolderRoot->update();
// while dragging, update selection rendering to reflect single/multi drag status
if (LLToolDragAndDrop::getInstance()->hasMouseCapture())