From c1636911c84f948e542f445d3c7495e6df185912 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Wed, 1 Feb 2012 19:09:29 -0800 Subject: EXP-1862 : Make LLClipboard an LLSingleton and clean up the internals (set up for toolbar and never used) --- indra/llui/llclipboard.cpp | 6 ------ indra/llui/llclipboard.h | 15 ++++----------- indra/llui/lllineeditor.cpp | 14 +++++++------- indra/llui/llscrolllistctrl.cpp | 2 +- indra/llui/lltexteditor.cpp | 14 +++++++------- indra/newview/llfavoritesbar.cpp | 2 +- indra/newview/llfloatergesture.cpp | 2 +- indra/newview/llpanelteleporthistory.cpp | 2 +- indra/newview/llpaneltopinfobar.cpp | 2 +- indra/newview/llpanelwearing.cpp | 2 +- indra/newview/lltoolbarview.cpp | 15 ++++++++++++++- indra/newview/lltoolbarview.h | 3 +++ indra/newview/lltooldraganddrop.cpp | 3 ++- indra/newview/llurllineeditorctrl.cpp | 2 +- 14 files changed, 44 insertions(+), 40 deletions(-) diff --git a/indra/llui/llclipboard.cpp b/indra/llui/llclipboard.cpp index 6910b962a1..984c4ec5fb 100644 --- a/indra/llui/llclipboard.cpp +++ b/indra/llui/llclipboard.cpp @@ -40,7 +40,6 @@ LLClipboard gClipboard; LLClipboard::LLClipboard() { - mSourceItem = NULL; } @@ -135,8 +134,3 @@ BOOL LLClipboard::canPastePrimaryString() const { return LLView::getWindow()->isPrimaryTextAvailable(); } - -void LLClipboard::setSourceObject(const LLUUID& source_id, LLAssetType::EType type) -{ - mSourceItem = new LLInventoryObject (source_id, LLUUID::null, type, ""); -} diff --git a/indra/llui/llclipboard.h b/indra/llui/llclipboard.h index 9371b94284..2567eaab48 100644 --- a/indra/llui/llclipboard.h +++ b/indra/llui/llclipboard.h @@ -31,10 +31,10 @@ #include "llstring.h" #include "lluuid.h" #include "stdenums.h" +#include "llsingleton.h" #include "llinventory.h" - -class LLClipboard +class LLClipboard : public LLSingleton { public: LLClipboard(); @@ -54,19 +54,12 @@ public: BOOL canPastePrimaryString() const; const LLWString& getPastePrimaryWString(LLUUID* source_id = NULL); - // Support clipboard for object known only by their uuid and asset type - void setSourceObject(const LLUUID& source_id, LLAssetType::EType type); - const LLInventoryObject* getSourceObject() { return mSourceItem; } + // Support clipboard for object known only by their uuid + void setSourceObject(const LLUUID& source_id) { mSourceID = source_id; } private: LLUUID mSourceID; LLWString mString; - LLInventoryObject* mSourceItem; }; - -// Global singleton -extern LLClipboard gClipboard; - - #endif // LL_LLCLIPBOARD_H diff --git a/indra/llui/lllineeditor.cpp b/indra/llui/lllineeditor.cpp index 06dfc90d83..9292158b7c 100644 --- a/indra/llui/lllineeditor.cpp +++ b/indra/llui/lllineeditor.cpp @@ -1047,7 +1047,7 @@ void LLLineEditor::cut() // Prepare for possible rollback LLLineEditorRollback rollback( this ); - gClipboard.copyFromSubstring( mText.getWString(), left_pos, length ); + LLClipboard::getInstance()->copyFromSubstring( mText.getWString(), left_pos, length ); deleteSelection(); // Validate new string and rollback the if needed. @@ -1078,13 +1078,13 @@ void LLLineEditor::copy() { S32 left_pos = llmin( mSelectionStart, mSelectionEnd ); S32 length = llabs( mSelectionStart - mSelectionEnd ); - gClipboard.copyFromSubstring( mText.getWString(), left_pos, length ); + LLClipboard::getInstance()->copyFromSubstring( mText.getWString(), left_pos, length ); } } BOOL LLLineEditor::canPaste() const { - return !mReadOnly && gClipboard.canPasteString(); + return !mReadOnly && LLClipboard::getInstance()->canPasteString(); } void LLLineEditor::paste() @@ -1117,11 +1117,11 @@ void LLLineEditor::pasteHelper(bool is_primary) LLWString paste; if (is_primary) { - paste = gClipboard.getPastePrimaryWString(); + paste = LLClipboard::getInstance()->getPastePrimaryWString(); } else { - paste = gClipboard.getPasteWString(); + paste = LLClipboard::getInstance()->getPasteWString(); } if (!paste.empty()) @@ -1209,13 +1209,13 @@ void LLLineEditor::copyPrimary() { S32 left_pos = llmin( mSelectionStart, mSelectionEnd ); S32 length = llabs( mSelectionStart - mSelectionEnd ); - gClipboard.copyFromPrimarySubstring( mText.getWString(), left_pos, length ); + LLClipboard::getInstance()->copyFromPrimarySubstring( mText.getWString(), left_pos, length ); } } BOOL LLLineEditor::canPastePrimary() const { - return !mReadOnly && gClipboard.canPastePrimaryString(); + return !mReadOnly && LLClipboard::getInstance()->canPastePrimaryString(); } void LLLineEditor::updatePrimary() diff --git a/indra/llui/llscrolllistctrl.cpp b/indra/llui/llscrolllistctrl.cpp index 466fac33ea..8cbc2a8f99 100644 --- a/indra/llui/llscrolllistctrl.cpp +++ b/indra/llui/llscrolllistctrl.cpp @@ -2504,7 +2504,7 @@ void LLScrollListCtrl::copy() { buffer += (*itor)->getContentsCSV() + "\n"; } - gClipboard.copyFromSubstring(utf8str_to_wstring(buffer), 0, buffer.length()); + LLClipboard::getInstance()->copyFromSubstring(utf8str_to_wstring(buffer), 0, buffer.length()); } // virtual diff --git a/indra/llui/lltexteditor.cpp b/indra/llui/lltexteditor.cpp index 3a23ce1cac..22a577cda8 100644 --- a/indra/llui/lltexteditor.cpp +++ b/indra/llui/lltexteditor.cpp @@ -1332,7 +1332,7 @@ void LLTextEditor::cut() } S32 left_pos = llmin( mSelectionStart, mSelectionEnd ); S32 length = llabs( mSelectionStart - mSelectionEnd ); - gClipboard.copyFromSubstring( getWText(), left_pos, length, mSourceID ); + LLClipboard::getInstance()->copyFromSubstring( getWText(), left_pos, length, mSourceID ); deleteSelection( FALSE ); onKeyStroke(); @@ -1352,12 +1352,12 @@ void LLTextEditor::copy() } S32 left_pos = llmin( mSelectionStart, mSelectionEnd ); S32 length = llabs( mSelectionStart - mSelectionEnd ); - gClipboard.copyFromSubstring(getWText(), left_pos, length, mSourceID); + LLClipboard::getInstance()->copyFromSubstring(getWText(), left_pos, length, mSourceID); } BOOL LLTextEditor::canPaste() const { - return !mReadOnly && gClipboard.canPasteString(); + return !mReadOnly && LLClipboard::getInstance()->canPasteString(); } // paste from clipboard @@ -1397,11 +1397,11 @@ void LLTextEditor::pasteHelper(bool is_primary) LLWString paste; if (is_primary) { - paste = gClipboard.getPastePrimaryWString(&source_id); + paste = LLClipboard::getInstance()->getPastePrimaryWString(&source_id); } else { - paste = gClipboard.getPasteWString(&source_id); + paste = LLClipboard::getInstance()->getPasteWString(&source_id); } if (paste.empty()) @@ -1475,12 +1475,12 @@ void LLTextEditor::copyPrimary() } S32 left_pos = llmin( mSelectionStart, mSelectionEnd ); S32 length = llabs( mSelectionStart - mSelectionEnd ); - gClipboard.copyFromPrimarySubstring(getWText(), left_pos, length, mSourceID); + LLClipboard::getInstance()->copyFromPrimarySubstring(getWText(), left_pos, length, mSourceID); } BOOL LLTextEditor::canPastePrimary() const { - return !mReadOnly && gClipboard.canPastePrimaryString(); + return !mReadOnly && LLClipboard::getInstance()->canPastePrimaryString(); } void LLTextEditor::updatePrimary() diff --git a/indra/newview/llfavoritesbar.cpp b/indra/newview/llfavoritesbar.cpp index f4b6dc2c81..24bd2cf313 100644 --- a/indra/newview/llfavoritesbar.cpp +++ b/indra/newview/llfavoritesbar.cpp @@ -1118,7 +1118,7 @@ BOOL LLFavoritesBarCtrl::handleRightMouseDown(S32 x, S32 y, MASK mask) } void copy_slurl_to_clipboard_cb(std::string& slurl) { - gClipboard.copyFromString(utf8str_to_wstring(slurl)); + LLClipboard::getInstance()->copyFromString(utf8str_to_wstring(slurl)); LLSD args; args["SLURL"] = slurl; diff --git a/indra/newview/llfloatergesture.cpp b/indra/newview/llfloatergesture.cpp index d495f20a9a..e025d6edb5 100644 --- a/indra/newview/llfloatergesture.cpp +++ b/indra/newview/llfloatergesture.cpp @@ -534,7 +534,7 @@ void LLFloaterGesture::onCopyPasteAction(const LLSD& command) } else if ("copy_uuid" == command_name) { - gClipboard.copyFromString(utf8str_to_wstring(mGestureList->getCurrentID().asString()), mGestureList->getCurrentID()); + LLClipboard::getInstance()->copyFromString(utf8str_to_wstring(mGestureList->getCurrentID().asString()), mGestureList->getCurrentID()); } } diff --git a/indra/newview/llpanelteleporthistory.cpp b/indra/newview/llpanelteleporthistory.cpp index 1f1cccad85..a4c9af3fad 100644 --- a/indra/newview/llpanelteleporthistory.cpp +++ b/indra/newview/llpanelteleporthistory.cpp @@ -358,7 +358,7 @@ void LLTeleportHistoryPanel::ContextMenu::onInfo() //static void LLTeleportHistoryPanel::ContextMenu::gotSLURLCallback(const std::string& slurl) { - gClipboard.copyFromString(utf8str_to_wstring(slurl)); + LLClipboard::getInstance()->copyFromString(utf8str_to_wstring(slurl)); } void LLTeleportHistoryPanel::ContextMenu::onCopyToClipboard() diff --git a/indra/newview/llpaneltopinfobar.cpp b/indra/newview/llpaneltopinfobar.cpp index eb4c7572d4..0e3ff99066 100644 --- a/indra/newview/llpaneltopinfobar.cpp +++ b/indra/newview/llpaneltopinfobar.cpp @@ -467,7 +467,7 @@ void LLPanelTopInfoBar::onContextMenuItemClicked(const LLSD::String& item) LLAgentUI::buildSLURL(slurl, false); LLUIString location_str(slurl.getSLURLString()); - gClipboard.copyFromString(location_str); + LLClipboard::getInstance()->copyFromString(location_str); } } diff --git a/indra/newview/llpanelwearing.cpp b/indra/newview/llpanelwearing.cpp index e2801c09bd..1286756693 100644 --- a/indra/newview/llpanelwearing.cpp +++ b/indra/newview/llpanelwearing.cpp @@ -302,6 +302,6 @@ void LLPanelWearing::copyToClipboard() } } - gClipboard.copyFromString(utf8str_to_wstring(text)); + LLClipboard::getInstance()->copyFromString(utf8str_to_wstring(text)); } // EOF diff --git a/indra/newview/lltoolbarview.cpp b/indra/newview/lltoolbarview.cpp index eccb2cf2f1..8a0b035234 100644 --- a/indra/newview/lltoolbarview.cpp +++ b/indra/newview/lltoolbarview.cpp @@ -75,6 +75,7 @@ LLToolBarView::LLToolBarView(const LLToolBarView::Params& p) mDragStarted(false), mShowToolbars(true), mDragToolbarButton(NULL), + mDragItem(NULL), mToolbarsLoaded(false) { for (S32 i = 0; i < TOOLBAR_COUNT; i++) @@ -579,7 +580,7 @@ BOOL LLToolBarView::handleDragTool( S32 x, S32 y, const LLUUID& uuid, LLAssetTyp uuid_vec_t cargo_ids; types.push_back(DAD_WIDGET); cargo_ids.push_back(uuid); - gClipboard.setSourceObject(uuid,LLAssetType::AT_WIDGET); + LLClipboard::getInstance()->setSourceObject(uuid); LLToolDragAndDrop::ESource src = LLToolDragAndDrop::SOURCE_VIEWER; LLUUID srcID; LLToolDragAndDrop::getInstance()->beginMultiDrag(types, cargo_ids, src, srcID); @@ -662,6 +663,18 @@ void LLToolBarView::resetDragTool(LLToolBarButton* toolbarButton) gToolBarView->mDragToolbarButton = toolbarButton; } +// Provide a handle on a free standing inventory item containing references to the tool. +// This might be used by Drag and Drop to move around references to tool items. +LLInventoryObject* LLToolBarView::getDragItem() +{ + if (mDragToolbarButton) + { + LLUUID item_uuid = mDragToolbarButton->getCommandId().uuid(); + mDragItem = new LLInventoryObject (item_uuid, LLUUID::null, LLAssetType::AT_WIDGET, ""); + } + return mDragItem; +} + void LLToolBarView::setToolBarsVisible(bool visible) { mShowToolbars = visible; diff --git a/indra/newview/lltoolbarview.h b/indra/newview/lltoolbarview.h index be66bcae36..9c4194ebed 100644 --- a/indra/newview/lltoolbarview.h +++ b/indra/newview/lltoolbarview.h @@ -31,6 +31,7 @@ #include "lluictrl.h" #include "lltoolbar.h" #include "llcommandmanager.h" +#include "llinventory.h" class LLUICtrlFactory; @@ -106,6 +107,7 @@ public: static BOOL handleDragTool(S32 x, S32 y, const LLUUID& uuid, LLAssetType::EType type); static BOOL handleDropTool(void* cargo_data, S32 x, S32 y, LLToolBar* toolbar); static void resetDragTool(LLToolBarButton* toolbarButton); + LLInventoryObject* getDragItem(); bool isModified() const; @@ -129,6 +131,7 @@ private: bool mDragStarted; LLToolBarButton* mDragToolbarButton; + LLInventoryObject* mDragItem; bool mShowToolbars; }; diff --git a/indra/newview/lltooldraganddrop.cpp b/indra/newview/lltooldraganddrop.cpp index 8c32dfcb4d..f3637756fe 100644 --- a/indra/newview/lltooldraganddrop.cpp +++ b/indra/newview/lltooldraganddrop.cpp @@ -48,6 +48,7 @@ #include "llpreviewnotecard.h" #include "llrootview.h" #include "llselectmgr.h" +#include "lltoolbarview.h" #include "lltoolmgr.h" #include "lltooltip.h" #include "lltrans.h" @@ -2527,7 +2528,7 @@ LLInventoryObject* LLToolDragAndDrop::locateInventory( } else if(mSource == SOURCE_VIEWER) { - item = (LLViewerInventoryItem*)gClipboard.getSourceObject(); + item = (LLViewerInventoryItem*)gToolBarView->getDragItem(); } if(item) return item; if(cat) return cat; diff --git a/indra/newview/llurllineeditorctrl.cpp b/indra/newview/llurllineeditorctrl.cpp index 56b5bbf942..9d7e26d41c 100644 --- a/indra/newview/llurllineeditorctrl.cpp +++ b/indra/newview/llurllineeditorctrl.cpp @@ -89,5 +89,5 @@ void LLURLLineEditor::copyEscapedURLToClipboard() else // human-readable location text_to_copy = utf8str_to_wstring(unescaped_text); - gClipboard.copyFromString( text_to_copy ); + LLClipboard::getInstance()->copyFromString( text_to_copy ); } -- cgit v1.2.3 From db824cff75696c42fff80ba29dbb60f12d10a1da Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Fri, 3 Feb 2012 18:38:03 -0800 Subject: EXP-1862 : Suppress LLInventoryClipboard, move its functions to the unified LLClipboard and use this only --- indra/llui/llclipboard.cpp | 102 ++++++++++++++++++++++++------ indra/llui/llclipboard.h | 27 +++++++- indra/newview/CMakeLists.txt | 2 - indra/newview/llfavoritesbar.cpp | 10 +-- indra/newview/llfloatergesture.cpp | 15 +++-- indra/newview/llfolderview.cpp | 8 +-- indra/newview/llinventorybridge.cpp | 26 ++++---- indra/newview/llinventoryclipboard.cpp | 110 --------------------------------- indra/newview/llinventoryclipboard.h | 86 -------------------------- indra/newview/llinventoryfunctions.cpp | 1 - indra/newview/lltoolbarview.cpp | 1 - 11 files changed, 138 insertions(+), 250 deletions(-) delete mode 100644 indra/newview/llinventoryclipboard.cpp delete mode 100644 indra/newview/llinventoryclipboard.h diff --git a/indra/llui/llclipboard.cpp b/indra/llui/llclipboard.cpp index 984c4ec5fb..8917dc2d88 100644 --- a/indra/llui/llclipboard.cpp +++ b/indra/llui/llclipboard.cpp @@ -34,44 +34,104 @@ #include "llview.h" #include "llwindow.h" -// Global singleton -LLClipboard gClipboard; +LLClipboard::LLClipboard() +: mCutMode(false) +{ +} +LLClipboard::~LLClipboard() +{ + reset(); +} -LLClipboard::LLClipboard() +void LLClipboard::add(const LLUUID& object) { + mObjects.put(object); } +void LLClipboard::store(const LLUUID& object) +{ + reset(); + mObjects.put(object); +} -LLClipboard::~LLClipboard() +void LLClipboard::store(const LLDynamicArray& inv_objects) { + reset(); + S32 count = inv_objects.count(); + for(S32 i = 0; i < count; i++) + { + mObjects.put(inv_objects[i]); + } +} + +void LLClipboard::cut(const LLUUID& object) +{ + if(!mCutMode && !mObjects.empty()) + { + //looks like there are some stored items, reset clipboard state + reset(); + } + mCutMode = true; + add(object); +} +void LLClipboard::retrieve(LLDynamicArray& inv_objects) const +{ + inv_objects.reset(); + S32 count = mObjects.count(); + for(S32 i = 0; i < count; i++) + { + inv_objects.put(mObjects[i]); + } +} + +void LLClipboard::reset() +{ + mObjects.reset(); + mCutMode = false; +} + +// returns true if the clipboard has something pasteable in it. +BOOL LLClipboard::hasContents() const +{ + return (mObjects.count() > 0); } void LLClipboard::copyFromSubstring(const LLWString &src, S32 pos, S32 len, const LLUUID& source_id ) { - mSourceID = source_id; + reset(); + if (source_id.notNull()) + { + store(source_id); + } mString = src.substr(pos, len); + llinfos << "Merov debug : copyFromSubstring, string = " << wstring_to_utf8str(mString) << ", uuid = " << (hasContents() ? mObjects[0] : LLUUID::null) << llendl; LLView::getWindow()->copyTextToClipboard( mString ); } void LLClipboard::copyFromString(const LLWString &src, const LLUUID& source_id ) { - mSourceID = source_id; + reset(); + if (source_id.notNull()) + { + store(source_id); + } mString = src; + llinfos << "Merov debug : copyFromString, string = " << wstring_to_utf8str(mString) << ", uuid = " << (hasContents() ? mObjects[0] : LLUUID::null) << llendl; LLView::getWindow()->copyTextToClipboard( mString ); } const LLWString& LLClipboard::getPasteWString( LLUUID* source_id ) { - if( mSourceID.notNull() ) + if (hasContents()) { LLWString temp_string; LLView::getWindow()->pasteTextFromClipboard(temp_string); - if( temp_string != mString ) + if (temp_string != mString) { - mSourceID.setNull(); + reset(); mString = temp_string; } } @@ -80,11 +140,13 @@ const LLWString& LLClipboard::getPasteWString( LLUUID* source_id ) LLView::getWindow()->pasteTextFromClipboard(mString); } - if( source_id ) + if (source_id) { - *source_id = mSourceID; + *source_id = (hasContents() ? mObjects[0] : LLUUID::null); } + llinfos << "Merov debug : getPasteWString, string = " << wstring_to_utf8str(mString) << ", uuid = " << (hasContents() ? mObjects[0] : LLUUID::null) << llendl; + return mString; } @@ -97,7 +159,11 @@ BOOL LLClipboard::canPasteString() const void LLClipboard::copyFromPrimarySubstring(const LLWString &src, S32 pos, S32 len, const LLUUID& source_id ) { - mSourceID = source_id; + reset(); + if (source_id.notNull()) + { + store(source_id); + } mString = src.substr(pos, len); LLView::getWindow()->copyTextToPrimary( mString ); } @@ -105,14 +171,14 @@ void LLClipboard::copyFromPrimarySubstring(const LLWString &src, S32 pos, S32 le const LLWString& LLClipboard::getPastePrimaryWString( LLUUID* source_id ) { - if( mSourceID.notNull() ) + if (hasContents()) { LLWString temp_string; LLView::getWindow()->pasteTextFromPrimary(temp_string); - if( temp_string != mString ) + if (temp_string != mString) { - mSourceID.setNull(); + reset(); mString = temp_string; } } @@ -121,11 +187,11 @@ const LLWString& LLClipboard::getPastePrimaryWString( LLUUID* source_id ) LLView::getWindow()->pasteTextFromPrimary(mString); } - if( source_id ) + if (source_id) { - *source_id = mSourceID; + *source_id = (hasContents() ? mObjects[0] : LLUUID::null); } - + return mString; } diff --git a/indra/llui/llclipboard.h b/indra/llui/llclipboard.h index 2567eaab48..2cb857145e 100644 --- a/indra/llui/llclipboard.h +++ b/indra/llui/llclipboard.h @@ -34,6 +34,13 @@ #include "llsingleton.h" #include "llinventory.h" +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// Class LLClipboard +// +// This class is used to cut/copy/paste text strings and inventory items around +// the world. Use LLClipboard::getInstance()->method() to use its methods. +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + class LLClipboard : public LLSingleton { public: @@ -45,20 +52,36 @@ public: which is implicitly copied upon selection on platforms which expect this (i.e. X11/Linux). */ + // Text strings management void copyFromSubstring(const LLWString ©_from, S32 pos, S32 len, const LLUUID& source_id = LLUUID::null ); void copyFromString(const LLWString ©_from, const LLUUID& source_id = LLUUID::null ); BOOL canPasteString() const; const LLWString& getPasteWString(LLUUID* source_id = NULL); + // Primary text string management (Linux gtk implementation) void copyFromPrimarySubstring(const LLWString ©_from, S32 pos, S32 len, const LLUUID& source_id = LLUUID::null ); BOOL canPastePrimaryString() const; const LLWString& getPastePrimaryWString(LLUUID* source_id = NULL); // Support clipboard for object known only by their uuid - void setSourceObject(const LLUUID& source_id) { mSourceID = source_id; } + //void setSourceObject(const LLUUID& source_id) { mSourceID = source_id; } + + // Object list management + void add(const LLUUID& object); // Adds to the current list of objects on the clipboard + void store(const LLUUID& object); // Stores a single inventory object + void store(const LLDynamicArray& inventory_objects); // Stores an array of objects + void cut(const LLUUID& object); // Adds to the current list of cut objects on the clipboard + void retrieve(LLDynamicArray& inventory_objects) const; // Gets a copy of the objects on the clipboard + void reset(); // Clears the clipboard + BOOL hasContents() const; // true if the clipboard has something pasteable in it + bool isCutMode() const { return mCutMode; } + private: - LLUUID mSourceID; + // *TODO: To know if an asset ID can be serialized, check out LLAssetType::lookupIsAssetIDKnowable(EType asset_type) + LLDynamicArray mObjects; + bool mCutMode; + LLWString mString; }; diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 69bf1f15a1..325c2a12a6 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -287,7 +287,6 @@ set(viewer_SOURCE_FILES llinspectremoteobject.cpp llinspecttoast.cpp llinventorybridge.cpp - llinventoryclipboard.cpp llinventoryfilter.cpp llinventoryfunctions.cpp llinventoryicon.cpp @@ -842,7 +841,6 @@ set(viewer_HEADER_FILES llinspectremoteobject.h llinspecttoast.h llinventorybridge.h - llinventoryclipboard.h llinventoryfilter.h llinventoryfunctions.h llinventoryicon.h diff --git a/indra/newview/llfavoritesbar.cpp b/indra/newview/llfavoritesbar.cpp index 24bd2cf313..c81bff4b5d 100644 --- a/indra/newview/llfavoritesbar.cpp +++ b/indra/newview/llfavoritesbar.cpp @@ -39,7 +39,7 @@ #include "llagent.h" #include "llclipboard.h" -#include "llinventoryclipboard.h" +#include "llclipboard.h" #include "llinventorybridge.h" #include "llinventoryfunctions.h" #include "llfloatersidepanelcontainer.h" @@ -1187,7 +1187,7 @@ void LLFavoritesBarCtrl::doToSelected(const LLSD& userdata) } else if (action == "copy") { - LLInventoryClipboard::instance().store(mSelectedItemID); + LLClipboard::getInstance()->store(mSelectedItemID); } else if (action == "paste") { @@ -1211,13 +1211,13 @@ void LLFavoritesBarCtrl::doToSelected(const LLSD& userdata) BOOL LLFavoritesBarCtrl::isClipboardPasteable() const { - if (!LLInventoryClipboard::instance().hasContents()) + if (!LLClipboard::getInstance()->hasContents()) { return FALSE; } LLDynamicArray objects; - LLInventoryClipboard::instance().retrieve(objects); + LLClipboard::getInstance()->retrieve(objects); S32 count = objects.count(); for(S32 i = 0; i < count; i++) { @@ -1246,7 +1246,7 @@ void LLFavoritesBarCtrl::pastFromClipboard() const { LLInventoryItem* item = NULL; LLDynamicArray objects; - LLInventoryClipboard::instance().retrieve(objects); + LLClipboard::getInstance()->retrieve(objects); S32 count = objects.count(); LLUUID parent_id(mFavoriteFolderId); for(S32 i = 0; i < count; i++) diff --git a/indra/newview/llfloatergesture.cpp b/indra/newview/llfloatergesture.cpp index e025d6edb5..281cafa90d 100644 --- a/indra/newview/llfloatergesture.cpp +++ b/indra/newview/llfloatergesture.cpp @@ -32,7 +32,7 @@ #include "llinventorybridge.h" #include "llinventoryfunctions.h" #include "llinventorymodel.h" -#include "llinventoryclipboard.h" +#include "llclipboard.h" #include "llagent.h" #include "llappearancemgr.h" @@ -391,11 +391,11 @@ bool LLFloaterGesture::isActionEnabled(const LLSD& command) std::string command_name = command.asString(); if("paste" == command_name) { - if(!LLInventoryClipboard::instance().hasContents()) + if(!LLClipboard::getInstance()->hasContents()) return false; LLDynamicArray ids; - LLInventoryClipboard::instance().retrieve(ids); + LLClipboard::getInstance()->retrieve(ids); for(LLDynamicArray::iterator it = ids.begin(); it != ids.end(); it++) { LLInventoryItem* item = gInventory.getItem(*it); @@ -496,21 +496,20 @@ void LLFloaterGesture::onCopyPasteAction(const LLSD& command) uuid_vec_t ids; getSelectedIds(ids); // make sure that clopboard is empty - LLInventoryClipboard::instance().reset(); + LLClipboard::getInstance()->reset(); for(uuid_vec_t::iterator it = ids.begin(); it != ids.end(); it++) { LLInventoryItem* item = gInventory.getItem(*it); if(item && item->getInventoryType() == LLInventoryType::IT_GESTURE) { - LLInventoryClipboard::instance().add(item->getUUID()); + LLClipboard::getInstance()->add(item->getUUID()); } } } else if ("paste" == command_name) { - LLInventoryClipboard& clipbord = LLInventoryClipboard::instance(); LLDynamicArray ids; - clipbord.retrieve(ids); + LLClipboard::getInstance()->retrieve(ids); if(ids.empty() || !gInventory.isCategoryComplete(mGestureFolderID)) return; LLInventoryCategory* gesture_dir = gInventory.getCategory(mGestureFolderID); @@ -530,7 +529,7 @@ void LLFloaterGesture::onCopyPasteAction(const LLSD& command) gesture_dir->getUUID(), getString("copy_name", string_args), cb); } } - clipbord.reset(); + LLClipboard::getInstance()->reset(); } else if ("copy_uuid" == command_name) { diff --git a/indra/newview/llfolderview.cpp b/indra/newview/llfolderview.cpp index 79c987fa37..438d7e7ae3 100644 --- a/indra/newview/llfolderview.cpp +++ b/indra/newview/llfolderview.cpp @@ -30,7 +30,7 @@ #include "llcallbacklist.h" #include "llinventorybridge.h" -#include "llinventoryclipboard.h" // *TODO: remove this once hack below gone. +#include "llclipboard.h" // *TODO: remove this once hack below gone. #include "llinventoryfilter.h" #include "llinventoryfunctions.h" #include "llinventorymodelbackgroundfetch.h" @@ -1293,7 +1293,7 @@ BOOL LLFolderView::canCopy() const void LLFolderView::copy() { // *NOTE: total hack to clear the inventory clipboard - LLInventoryClipboard::instance().reset(); + LLClipboard::getInstance()->reset(); S32 count = mSelectedItems.size(); if(getVisible() && getEnabled() && (count > 0)) { @@ -1334,7 +1334,7 @@ BOOL LLFolderView::canCut() const void LLFolderView::cut() { // clear the inventory clipboard - LLInventoryClipboard::instance().reset(); + LLClipboard::getInstance()->reset(); S32 count = mSelectedItems.size(); if(getVisible() && getEnabled() && (count > 0)) { @@ -2111,7 +2111,7 @@ bool LLFolderView::doToSelected(LLInventoryModel* model, const LLSD& userdata) if ("copy" == action) { - LLInventoryClipboard::instance().reset(); + LLClipboard::getInstance()->reset(); } static const std::string change_folder_string = "change_folder_type_"; diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index 869cb735d5..420b834933 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -47,7 +47,7 @@ #include "llgiveinventory.h" #include "llimfloater.h" #include "llimview.h" -#include "llinventoryclipboard.h" +#include "llclipboard.h" #include "llinventorydefines.h" #include "llinventoryfunctions.h" #include "llinventorymodel.h" @@ -212,7 +212,7 @@ void LLInvFVBridge::cutToClipboard() { if(isItemMovable()) { - LLInventoryClipboard::instance().cut(mUUID); + LLClipboard::getInstance()->cut(mUUID); } } // *TODO: make sure this does the right thing @@ -397,7 +397,7 @@ void LLInvFVBridge::removeBatchNoCheck(LLDynamicArrayhasContents() || !isAgentInventory()) { return FALSE; } @@ -410,7 +410,7 @@ BOOL LLInvFVBridge::isClipboardPasteable() const const LLUUID &agent_id = gAgent.getID(); LLDynamicArray objects; - LLInventoryClipboard::instance().retrieve(objects); + LLClipboard::getInstance()->retrieve(objects); S32 count = objects.count(); for(S32 i = 0; i < count; i++) { @@ -437,7 +437,7 @@ BOOL LLInvFVBridge::isClipboardPasteable() const BOOL LLInvFVBridge::isClipboardPasteableAsLink() const { - if (!LLInventoryClipboard::instance().hasContents() || !isAgentInventory()) + if (!LLClipboard::getInstance()->hasContents() || !isAgentInventory()) { return FALSE; } @@ -448,7 +448,7 @@ BOOL LLInvFVBridge::isClipboardPasteableAsLink() const } LLDynamicArray objects; - LLInventoryClipboard::instance().retrieve(objects); + LLClipboard::getInstance()->retrieve(objects); S32 count = objects.count(); for(S32 i = 0; i < count; i++) { @@ -1663,7 +1663,7 @@ BOOL LLItemBridge::copyToClipboard() const { if(isItemCopyable()) { - LLInventoryClipboard::instance().add(mUUID); + LLClipboard::getInstance()->add(mUUID); return TRUE; } return FALSE; @@ -1775,7 +1775,7 @@ BOOL LLFolderBridge::copyToClipboard() const { if(isItemCopyable()) { - LLInventoryClipboard::instance().add(mUUID); + LLClipboard::getInstance()->add(mUUID); return TRUE; } return FALSE; @@ -1796,7 +1796,7 @@ BOOL LLFolderBridge::isClipboardPasteable() const } LLDynamicArray objects; - LLInventoryClipboard::instance().retrieve(objects); + LLClipboard::getInstance()->retrieve(objects); const LLViewerInventoryCategory *current_cat = getCategory(); // Search for the direct descendent of current Friends subfolder among all pasted items, @@ -1834,7 +1834,7 @@ BOOL LLFolderBridge::isClipboardPasteableAsLink() const const BOOL is_in_friend_folder = LLFriendCardsManager::instance().isCategoryInFriendFolder( current_cat ); const LLUUID ¤t_cat_id = current_cat->getUUID(); LLDynamicArray objects; - LLInventoryClipboard::instance().retrieve(objects); + LLClipboard::getInstance()->retrieve(objects); S32 count = objects.count(); for(S32 i = 0; i < count; i++) { @@ -2825,7 +2825,7 @@ void LLFolderBridge::pasteFromClipboard() const LLUUID parent_id(mUUID); LLDynamicArray objects; - LLInventoryClipboard::instance().retrieve(objects); + LLClipboard::getInstance()->retrieve(objects); for (LLDynamicArray::const_iterator iter = objects.begin(); iter != objects.end(); ++iter) @@ -2841,7 +2841,7 @@ void LLFolderBridge::pasteFromClipboard() dropToOutfit(item, move_is_into_current_outfit); } } - else if(LLInventoryClipboard::instance().isCutMode()) + else if (LLClipboard::getInstance()->isCutMode()) { // move_inventory_item() is not enough, //we have to update inventory locally too @@ -2879,7 +2879,7 @@ void LLFolderBridge::pasteLinkFromClipboard() const LLUUID parent_id(mUUID); LLDynamicArray objects; - LLInventoryClipboard::instance().retrieve(objects); + LLClipboard::getInstance()->retrieve(objects); for (LLDynamicArray::const_iterator iter = objects.begin(); iter != objects.end(); ++iter) diff --git a/indra/newview/llinventoryclipboard.cpp b/indra/newview/llinventoryclipboard.cpp deleted file mode 100644 index 53da34f448..0000000000 --- a/indra/newview/llinventoryclipboard.cpp +++ /dev/null @@ -1,110 +0,0 @@ -/** - * @file llinventoryclipboard.cpp - * @brief LLInventoryClipboard class implementation - * - * $LicenseInfo:firstyear=2002&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#include "llviewerprecompiledheaders.h" - -#include "llinventoryclipboard.h" - - -LLInventoryClipboard LLInventoryClipboard::sInstance; - -///---------------------------------------------------------------------------- -/// Local function declarations, constants, enums, and typedefs -///---------------------------------------------------------------------------- - - -///---------------------------------------------------------------------------- -/// Class LLInventoryClipboard -///---------------------------------------------------------------------------- - -LLInventoryClipboard::LLInventoryClipboard() -: mCutMode(false) -{ -} - -LLInventoryClipboard::~LLInventoryClipboard() -{ - reset(); -} - -void LLInventoryClipboard::add(const LLUUID& object) -{ - mObjects.put(object); -} - -// this stores a single inventory object -void LLInventoryClipboard::store(const LLUUID& object) -{ - reset(); - mObjects.put(object); -} - -void LLInventoryClipboard::store(const LLDynamicArray& inv_objects) -{ - reset(); - S32 count = inv_objects.count(); - for(S32 i = 0; i < count; i++) - { - mObjects.put(inv_objects[i]); - } -} - -void LLInventoryClipboard::cut(const LLUUID& object) -{ - if(!mCutMode && !mObjects.empty()) - { - //looks like there are some stored items, reset clipboard state - reset(); - } - mCutMode = true; - add(object); -} -void LLInventoryClipboard::retrieve(LLDynamicArray& inv_objects) const -{ - inv_objects.reset(); - S32 count = mObjects.count(); - for(S32 i = 0; i < count; i++) - { - inv_objects.put(mObjects[i]); - } -} - -void LLInventoryClipboard::reset() -{ - mObjects.reset(); - mCutMode = false; -} - -// returns true if the clipboard has something pasteable in it. -BOOL LLInventoryClipboard::hasContents() const -{ - return (mObjects.count() > 0); -} - - -///---------------------------------------------------------------------------- -/// Local function definitions -///---------------------------------------------------------------------------- diff --git a/indra/newview/llinventoryclipboard.h b/indra/newview/llinventoryclipboard.h deleted file mode 100644 index b9f1451e5c..0000000000 --- a/indra/newview/llinventoryclipboard.h +++ /dev/null @@ -1,86 +0,0 @@ -/** - * @file llinventoryclipboard.h - * @brief LLInventoryClipboard class header file - * - * $LicenseInfo:firstyear=2002&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#ifndef LL_LLINVENTORYCLIPBOARD_H -#define LL_LLINVENTORYCLIPBOARD_H - -#include "lldarray.h" -#include "lluuid.h" - -//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -// Class LLInventoryClipboard -// -// This class is used to cut/copy/paste inventory items around the -// world. This class is accessed through a singleton (only one -// inventory clipboard for now) which can be referenced using the -// instance() method. -//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -class LLInventoryClipboard -{ -public: - // calling this before main() is undefined - static LLInventoryClipboard& instance() { return sInstance; } - - // this method adds to the current list. - void add(const LLUUID& object); - - // this stores a single inventory object - void store(const LLUUID& object); - - // this method stores an array of objects - void store(const LLDynamicArray& inventory_objects); - - void cut(const LLUUID& object); - // this method gets the objects in the clipboard by copying them - // into the array provided. - void retrieve(LLDynamicArray& inventory_objects) const; - - // this method empties out the clipboard - void reset(); - - // returns true if the clipboard has something pasteable in it. - BOOL hasContents() const; - bool isCutMode() const { return mCutMode; } - -protected: - static LLInventoryClipboard sInstance; - - LLDynamicArray mObjects; - bool mCutMode; - -public: - // please don't actually call these - LLInventoryClipboard(); - ~LLInventoryClipboard(); -private: - // please don't implement these - LLInventoryClipboard(const LLInventoryClipboard&); - LLInventoryClipboard& operator=(const LLInventoryClipboard&); -}; - - -#endif // LL_LLINVENTORYCLIPBOARD_H diff --git a/indra/newview/llinventoryfunctions.cpp b/indra/newview/llinventoryfunctions.cpp index dd92188e9d..ea00474b2a 100644 --- a/indra/newview/llinventoryfunctions.cpp +++ b/indra/newview/llinventoryfunctions.cpp @@ -54,7 +54,6 @@ #include "lliconctrl.h" #include "llimview.h" #include "llinventorybridge.h" -#include "llinventoryclipboard.h" #include "llinventorymodel.h" #include "llinventorypanel.h" #include "lllineeditor.h" diff --git a/indra/newview/lltoolbarview.cpp b/indra/newview/lltoolbarview.cpp index 8a0b035234..81ad96f39e 100644 --- a/indra/newview/lltoolbarview.cpp +++ b/indra/newview/lltoolbarview.cpp @@ -580,7 +580,6 @@ BOOL LLToolBarView::handleDragTool( S32 x, S32 y, const LLUUID& uuid, LLAssetTyp uuid_vec_t cargo_ids; types.push_back(DAD_WIDGET); cargo_ids.push_back(uuid); - LLClipboard::getInstance()->setSourceObject(uuid); LLToolDragAndDrop::ESource src = LLToolDragAndDrop::SOURCE_VIEWER; LLUUID srcID; LLToolDragAndDrop::getInstance()->beginMultiDrag(types, cargo_ids, src, srcID); -- cgit v1.2.3 From 9761375ac244af36635899c73e99efc46b68b589 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Mon, 6 Feb 2012 15:43:53 -0800 Subject: EXP-1841 : Refactoring of LLClipboard, simplify the API and make it behave like a normal clipboard. --- indra/llui/llclipboard.cpp | 112 +++++++++---------------------- indra/llui/llclipboard.h | 23 ++----- indra/llui/lllineeditor.cpp | 19 ++---- indra/llui/llscrolllistctrl.cpp | 2 +- indra/llui/lltexteditor.cpp | 20 ++---- indra/newview/llfavoritesbar.cpp | 2 +- indra/newview/llfloatergesture.cpp | 2 +- indra/newview/llinventorybridge.cpp | 3 + indra/newview/llpanelteleporthistory.cpp | 2 +- indra/newview/llpaneltopinfobar.cpp | 2 +- indra/newview/llpanelwearing.cpp | 2 +- indra/newview/llurllineeditorctrl.cpp | 2 +- 12 files changed, 60 insertions(+), 131 deletions(-) diff --git a/indra/llui/llclipboard.cpp b/indra/llui/llclipboard.cpp index 8917dc2d88..5c8db29ae4 100644 --- a/indra/llui/llclipboard.cpp +++ b/indra/llui/llclipboard.cpp @@ -91,112 +91,62 @@ void LLClipboard::reset() mCutMode = false; } -// returns true if the clipboard has something pasteable in it. +// Returns true if the LL Clipboard has pasteable items in it BOOL LLClipboard::hasContents() const { return (mObjects.count() > 0); } - -void LLClipboard::copyFromSubstring(const LLWString &src, S32 pos, S32 len, const LLUUID& source_id ) +// Copy the input string to the LL and the system clipboard +bool LLClipboard::copyToClipboard(const LLWString &src, S32 pos, S32 len, bool use_primary) { reset(); - if (source_id.notNull()) - { - store(source_id); - } mString = src.substr(pos, len); - llinfos << "Merov debug : copyFromSubstring, string = " << wstring_to_utf8str(mString) << ", uuid = " << (hasContents() ? mObjects[0] : LLUUID::null) << llendl; - LLView::getWindow()->copyTextToClipboard( mString ); + return (use_primary ? LLView::getWindow()->copyTextToPrimary(mString) : LLView::getWindow()->copyTextToClipboard(mString)); } -void LLClipboard::copyFromString(const LLWString &src, const LLUUID& source_id ) +// Copy the input uuid to the LL clipboard +// Convert the uuid to string and copy that string to the system clipboard if legit +bool LLClipboard::copyToClipboard(const LLUUID& src, const LLAssetType::EType type) { + bool res = false; reset(); - if (source_id.notNull()) - { - store(source_id); - } - mString = src; - llinfos << "Merov debug : copyFromString, string = " << wstring_to_utf8str(mString) << ", uuid = " << (hasContents() ? mObjects[0] : LLUUID::null) << llendl; - LLView::getWindow()->copyTextToClipboard( mString ); -} - -const LLWString& LLClipboard::getPasteWString( LLUUID* source_id ) -{ - if (hasContents()) + if (src.notNull()) { - LLWString temp_string; - LLView::getWindow()->pasteTextFromClipboard(temp_string); - - if (temp_string != mString) + res = true; + if (LLAssetType::lookupIsAssetIDKnowable(type)) { - reset(); - mString = temp_string; + LLWString source = utf8str_to_wstring(src.asString()); + res = copyToClipboard(source, 0, source.size()); + } + if (res) + { + store(src); } } - else - { - LLView::getWindow()->pasteTextFromClipboard(mString); - } - - if (source_id) - { - *source_id = (hasContents() ? mObjects[0] : LLUUID::null); - } - - llinfos << "Merov debug : getPasteWString, string = " << wstring_to_utf8str(mString) << ", uuid = " << (hasContents() ? mObjects[0] : LLUUID::null) << llendl; - - return mString; -} - - -BOOL LLClipboard::canPasteString() const -{ - return LLView::getWindow()->isClipboardTextAvailable(); -} - - -void LLClipboard::copyFromPrimarySubstring(const LLWString &src, S32 pos, S32 len, const LLUUID& source_id ) -{ - reset(); - if (source_id.notNull()) - { - store(source_id); - } - mString = src.substr(pos, len); - LLView::getWindow()->copyTextToPrimary( mString ); + return res; } - -const LLWString& LLClipboard::getPastePrimaryWString( LLUUID* source_id ) +// Copy the System clipboard to the output string. +// Manage the LL Clipboard / System clipboard consistency +bool LLClipboard::pasteFromClipboard(LLWString &dst, bool use_primary) { - if (hasContents()) + bool res = (use_primary ? LLView::getWindow()->pasteTextFromPrimary(dst) : LLView::getWindow()->pasteTextFromClipboard(dst)); + if (res) { - LLWString temp_string; - LLView::getWindow()->pasteTextFromPrimary(temp_string); - - if (temp_string != mString) + if (dst != mString) { + // Invalidate the LL clipboard if the System had a different string in it (i.e. some copy/cut was done in some other app) reset(); - mString = temp_string; } + mString = dst; } - else - { - LLView::getWindow()->pasteTextFromPrimary(mString); - } - - if (source_id) - { - *source_id = (hasContents() ? mObjects[0] : LLUUID::null); - } - - return mString; + return res; } - -BOOL LLClipboard::canPastePrimaryString() const +// Return true if there's something on the System clipboard +bool LLClipboard::isTextAvailable(bool use_primary) const { - return LLView::getWindow()->isPrimaryTextAvailable(); + return (use_primary ? LLView::getWindow()->isPrimaryTextAvailable() : LLView::getWindow()->isClipboardTextAvailable()); } + diff --git a/indra/llui/llclipboard.h b/indra/llui/llclipboard.h index 2cb857145e..bb2d003703 100644 --- a/indra/llui/llclipboard.h +++ b/indra/llui/llclipboard.h @@ -32,6 +32,7 @@ #include "lluuid.h" #include "stdenums.h" #include "llsingleton.h" +#include "llassettype.h" #include "llinventory.h" //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -52,19 +53,11 @@ public: which is implicitly copied upon selection on platforms which expect this (i.e. X11/Linux). */ - // Text strings management - void copyFromSubstring(const LLWString ©_from, S32 pos, S32 len, const LLUUID& source_id = LLUUID::null ); - void copyFromString(const LLWString ©_from, const LLUUID& source_id = LLUUID::null ); - BOOL canPasteString() const; - const LLWString& getPasteWString(LLUUID* source_id = NULL); - - // Primary text string management (Linux gtk implementation) - void copyFromPrimarySubstring(const LLWString ©_from, S32 pos, S32 len, const LLUUID& source_id = LLUUID::null ); - BOOL canPastePrimaryString() const; - const LLWString& getPastePrimaryWString(LLUUID* source_id = NULL); - - // Support clipboard for object known only by their uuid - //void setSourceObject(const LLUUID& source_id) { mSourceID = source_id; } + // Text strings and single item management + bool copyToClipboard(const LLWString& src, S32 pos, S32 len, bool use_primary = false); + bool copyToClipboard(const LLUUID& src, const LLAssetType::EType type = LLAssetType::AT_NONE); + bool pasteFromClipboard(LLWString& dst, bool use_primary = false); + bool isTextAvailable(bool use_primary = false) const; // Object list management void add(const LLUUID& object); // Adds to the current list of objects on the clipboard @@ -78,11 +71,9 @@ public: bool isCutMode() const { return mCutMode; } private: - // *TODO: To know if an asset ID can be serialized, check out LLAssetType::lookupIsAssetIDKnowable(EType asset_type) LLDynamicArray mObjects; bool mCutMode; - - LLWString mString; + LLWString mString; }; #endif // LL_LLCLIPBOARD_H diff --git a/indra/llui/lllineeditor.cpp b/indra/llui/lllineeditor.cpp index 9292158b7c..e961cfb14f 100644 --- a/indra/llui/lllineeditor.cpp +++ b/indra/llui/lllineeditor.cpp @@ -1047,7 +1047,7 @@ void LLLineEditor::cut() // Prepare for possible rollback LLLineEditorRollback rollback( this ); - LLClipboard::getInstance()->copyFromSubstring( mText.getWString(), left_pos, length ); + LLClipboard::getInstance()->copyToClipboard( mText.getWString(), left_pos, length ); deleteSelection(); // Validate new string and rollback the if needed. @@ -1078,13 +1078,13 @@ void LLLineEditor::copy() { S32 left_pos = llmin( mSelectionStart, mSelectionEnd ); S32 length = llabs( mSelectionStart - mSelectionEnd ); - LLClipboard::getInstance()->copyFromSubstring( mText.getWString(), left_pos, length ); + LLClipboard::getInstance()->copyToClipboard( mText.getWString(), left_pos, length ); } } BOOL LLLineEditor::canPaste() const { - return !mReadOnly && LLClipboard::getInstance()->canPasteString(); + return !mReadOnly && LLClipboard::getInstance()->isTextAvailable(); } void LLLineEditor::paste() @@ -1115,14 +1115,7 @@ void LLLineEditor::pasteHelper(bool is_primary) if (can_paste_it) { LLWString paste; - if (is_primary) - { - paste = LLClipboard::getInstance()->getPastePrimaryWString(); - } - else - { - paste = LLClipboard::getInstance()->getPasteWString(); - } + LLClipboard::getInstance()->pasteFromClipboard(paste, is_primary); if (!paste.empty()) { @@ -1209,13 +1202,13 @@ void LLLineEditor::copyPrimary() { S32 left_pos = llmin( mSelectionStart, mSelectionEnd ); S32 length = llabs( mSelectionStart - mSelectionEnd ); - LLClipboard::getInstance()->copyFromPrimarySubstring( mText.getWString(), left_pos, length ); + LLClipboard::getInstance()->copyToClipboard( mText.getWString(), left_pos, length, true); } } BOOL LLLineEditor::canPastePrimary() const { - return !mReadOnly && LLClipboard::getInstance()->canPastePrimaryString(); + return !mReadOnly && LLClipboard::getInstance()->isTextAvailable(true); } void LLLineEditor::updatePrimary() diff --git a/indra/llui/llscrolllistctrl.cpp b/indra/llui/llscrolllistctrl.cpp index 8cbc2a8f99..0a9d862b66 100644 --- a/indra/llui/llscrolllistctrl.cpp +++ b/indra/llui/llscrolllistctrl.cpp @@ -2504,7 +2504,7 @@ void LLScrollListCtrl::copy() { buffer += (*itor)->getContentsCSV() + "\n"; } - LLClipboard::getInstance()->copyFromSubstring(utf8str_to_wstring(buffer), 0, buffer.length()); + LLClipboard::getInstance()->copyToClipboard(utf8str_to_wstring(buffer), 0, buffer.length()); } // virtual diff --git a/indra/llui/lltexteditor.cpp b/indra/llui/lltexteditor.cpp index 22a577cda8..ffe012c110 100644 --- a/indra/llui/lltexteditor.cpp +++ b/indra/llui/lltexteditor.cpp @@ -1332,7 +1332,7 @@ void LLTextEditor::cut() } S32 left_pos = llmin( mSelectionStart, mSelectionEnd ); S32 length = llabs( mSelectionStart - mSelectionEnd ); - LLClipboard::getInstance()->copyFromSubstring( getWText(), left_pos, length, mSourceID ); + LLClipboard::getInstance()->copyToClipboard( getWText(), left_pos, length); deleteSelection( FALSE ); onKeyStroke(); @@ -1352,12 +1352,12 @@ void LLTextEditor::copy() } S32 left_pos = llmin( mSelectionStart, mSelectionEnd ); S32 length = llabs( mSelectionStart - mSelectionEnd ); - LLClipboard::getInstance()->copyFromSubstring(getWText(), left_pos, length, mSourceID); + LLClipboard::getInstance()->copyToClipboard(getWText(), left_pos, length); } BOOL LLTextEditor::canPaste() const { - return !mReadOnly && LLClipboard::getInstance()->canPasteString(); + return !mReadOnly && LLClipboard::getInstance()->isTextAvailable(); } // paste from clipboard @@ -1393,16 +1393,8 @@ void LLTextEditor::pasteHelper(bool is_primary) return; } - LLUUID source_id; LLWString paste; - if (is_primary) - { - paste = LLClipboard::getInstance()->getPastePrimaryWString(&source_id); - } - else - { - paste = LLClipboard::getInstance()->getPasteWString(&source_id); - } + LLClipboard::getInstance()->pasteFromClipboard(paste, is_primary); if (paste.empty()) { @@ -1475,12 +1467,12 @@ void LLTextEditor::copyPrimary() } S32 left_pos = llmin( mSelectionStart, mSelectionEnd ); S32 length = llabs( mSelectionStart - mSelectionEnd ); - LLClipboard::getInstance()->copyFromPrimarySubstring(getWText(), left_pos, length, mSourceID); + LLClipboard::getInstance()->copyToClipboard(getWText(), left_pos, length, true); } BOOL LLTextEditor::canPastePrimary() const { - return !mReadOnly && LLClipboard::getInstance()->canPastePrimaryString(); + return !mReadOnly && LLClipboard::getInstance()->isTextAvailable(true); } void LLTextEditor::updatePrimary() diff --git a/indra/newview/llfavoritesbar.cpp b/indra/newview/llfavoritesbar.cpp index c81bff4b5d..4308bf2d3c 100644 --- a/indra/newview/llfavoritesbar.cpp +++ b/indra/newview/llfavoritesbar.cpp @@ -1118,7 +1118,7 @@ BOOL LLFavoritesBarCtrl::handleRightMouseDown(S32 x, S32 y, MASK mask) } void copy_slurl_to_clipboard_cb(std::string& slurl) { - LLClipboard::getInstance()->copyFromString(utf8str_to_wstring(slurl)); + LLClipboard::getInstance()->copyToClipboard(utf8str_to_wstring(slurl),0,slurl.size()); LLSD args; args["SLURL"] = slurl; diff --git a/indra/newview/llfloatergesture.cpp b/indra/newview/llfloatergesture.cpp index 281cafa90d..3c647284f6 100644 --- a/indra/newview/llfloatergesture.cpp +++ b/indra/newview/llfloatergesture.cpp @@ -533,7 +533,7 @@ void LLFloaterGesture::onCopyPasteAction(const LLSD& command) } else if ("copy_uuid" == command_name) { - LLClipboard::getInstance()->copyFromString(utf8str_to_wstring(mGestureList->getCurrentID().asString()), mGestureList->getCurrentID()); + LLClipboard::getInstance()->copyToClipboard(mGestureList->getCurrentID(),LLAssetType::AT_GESTURE); } } diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index 420b834933..14f1bb9d41 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -409,6 +409,9 @@ BOOL LLInvFVBridge::isClipboardPasteable() const const LLUUID &agent_id = gAgent.getID(); + // Merov : This should be suppressed for 2 reasons: + // 1. folders should be pastable + // 2. when pasting, we should paste what is authorized and let the rest not pasted LLDynamicArray objects; LLClipboard::getInstance()->retrieve(objects); S32 count = objects.count(); diff --git a/indra/newview/llpanelteleporthistory.cpp b/indra/newview/llpanelteleporthistory.cpp index a4c9af3fad..f92fbf3220 100644 --- a/indra/newview/llpanelteleporthistory.cpp +++ b/indra/newview/llpanelteleporthistory.cpp @@ -358,7 +358,7 @@ void LLTeleportHistoryPanel::ContextMenu::onInfo() //static void LLTeleportHistoryPanel::ContextMenu::gotSLURLCallback(const std::string& slurl) { - LLClipboard::getInstance()->copyFromString(utf8str_to_wstring(slurl)); + LLClipboard::getInstance()->copyToClipboard(utf8str_to_wstring(slurl),0,slurl.size()); } void LLTeleportHistoryPanel::ContextMenu::onCopyToClipboard() diff --git a/indra/newview/llpaneltopinfobar.cpp b/indra/newview/llpaneltopinfobar.cpp index 0e3ff99066..0ad207ef00 100644 --- a/indra/newview/llpaneltopinfobar.cpp +++ b/indra/newview/llpaneltopinfobar.cpp @@ -467,7 +467,7 @@ void LLPanelTopInfoBar::onContextMenuItemClicked(const LLSD::String& item) LLAgentUI::buildSLURL(slurl, false); LLUIString location_str(slurl.getSLURLString()); - LLClipboard::getInstance()->copyFromString(location_str); + LLClipboard::getInstance()->copyToClipboard(location_str,0,location_str.length()); } } diff --git a/indra/newview/llpanelwearing.cpp b/indra/newview/llpanelwearing.cpp index 1286756693..5199bcb6b1 100644 --- a/indra/newview/llpanelwearing.cpp +++ b/indra/newview/llpanelwearing.cpp @@ -302,6 +302,6 @@ void LLPanelWearing::copyToClipboard() } } - LLClipboard::getInstance()->copyFromString(utf8str_to_wstring(text)); + LLClipboard::getInstance()->copyToClipboard(utf8str_to_wstring(text),0,text.size()); } // EOF diff --git a/indra/newview/llurllineeditorctrl.cpp b/indra/newview/llurllineeditorctrl.cpp index 9d7e26d41c..3efebcade9 100644 --- a/indra/newview/llurllineeditorctrl.cpp +++ b/indra/newview/llurllineeditorctrl.cpp @@ -89,5 +89,5 @@ void LLURLLineEditor::copyEscapedURLToClipboard() else // human-readable location text_to_copy = utf8str_to_wstring(unescaped_text); - LLClipboard::getInstance()->copyFromString( text_to_copy ); + LLClipboard::getInstance()->copyToClipboard(text_to_copy, 0, text_to_copy.size()); } -- cgit v1.2.3 From c744603af9b53c6bc73fefbd56de68cf2778ed70 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Tue, 7 Feb 2012 17:13:24 -0800 Subject: EXP-1873 : Implement cut in the inventory contextual menu. Works without deleting the items but simply dimming them and moving them. Doesn't work for folders yet. --- indra/llui/llclipboard.cpp | 6 ++++++ indra/llui/llclipboard.h | 2 ++ indra/newview/llfolderview.cpp | 3 +-- indra/newview/llfolderviewitem.cpp | 9 ++++++++- indra/newview/llinventorybridge.cpp | 22 +++++++++++++++++++++- .../skins/default/xui/en/menu_inventory.xml | 8 ++++++++ 6 files changed, 46 insertions(+), 4 deletions(-) diff --git a/indra/llui/llclipboard.cpp b/indra/llui/llclipboard.cpp index 5c8db29ae4..a2a3f7f285 100644 --- a/indra/llui/llclipboard.cpp +++ b/indra/llui/llclipboard.cpp @@ -97,6 +97,12 @@ BOOL LLClipboard::hasContents() const return (mObjects.count() > 0); } +// Returns true if the input uuid is in the list of clipboard objects +bool LLClipboard::isOnClipboard(const LLUUID& object) const +{ + return (mObjects.find(object) != LLDynamicArray::FAIL); +} + // Copy the input string to the LL and the system clipboard bool LLClipboard::copyToClipboard(const LLWString &src, S32 pos, S32 len, bool use_primary) { diff --git a/indra/llui/llclipboard.h b/indra/llui/llclipboard.h index bb2d003703..8e417a490d 100644 --- a/indra/llui/llclipboard.h +++ b/indra/llui/llclipboard.h @@ -69,6 +69,8 @@ public: BOOL hasContents() const; // true if the clipboard has something pasteable in it bool isCutMode() const { return mCutMode; } + void setCutMode(bool mode) { mCutMode = mode; } + bool isOnClipboard(const LLUUID& object) const; private: LLDynamicArray mObjects; diff --git a/indra/newview/llfolderview.cpp b/indra/newview/llfolderview.cpp index 438d7e7ae3..1d318ca221 100644 --- a/indra/newview/llfolderview.cpp +++ b/indra/newview/llfolderview.cpp @@ -2108,8 +2108,7 @@ bool LLFolderView::doToSelected(LLInventoryModel* model, const LLSD& userdata) removeSelectedItems(); return true; } - - if ("copy" == action) + if (("copy" == action) || ("cut" == action)) { LLClipboard::getInstance()->reset(); } diff --git a/indra/newview/llfolderviewitem.cpp b/indra/newview/llfolderviewitem.cpp index 734adbc648..37ef27a5d7 100644 --- a/indra/newview/llfolderviewitem.cpp +++ b/indra/newview/llfolderviewitem.cpp @@ -40,6 +40,7 @@ #include "llviewerwindow.h" // Argh, only for setCursor() // linden library includes +#include "llclipboard.h" #include "llfocusmgr.h" // gFocusMgr #include "lltrans.h" @@ -1002,7 +1003,13 @@ void LLFolderViewItem::draw() LLColor4 color = (mIsSelected && filled) ? sHighlightFgColor : sFgColor; if (highlight_link) color = sLinkColor; if (in_library) color = sLibraryColor; - + + // Cut state rendering tweak (experimental) + if (LLClipboard::getInstance()->isCutMode() && LLClipboard::getInstance()->isOnClipboard(getListener()->getUUID())) + { + color.setAlpha(0.5); + } + 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); diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index 14f1bb9d41..7ba914eaf6 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -210,7 +210,7 @@ BOOL LLInvFVBridge::isLink() const */ void LLInvFVBridge::cutToClipboard() { - if(isItemMovable()) + if (isItemMovable() && isItemRemovable()) { LLClipboard::getInstance()->cut(mUUID); } @@ -602,6 +602,12 @@ void LLInvFVBridge::getClipboardEntries(bool show_asset_id, disabled_items.push_back(std::string("Copy")); } + items.push_back(std::string("Cut")); + if (!isItemMovable() || !isItemRemovable()) + { + disabled_items.push_back(std::string("Cut")); + } + if (canListOnMarketplace()) { items.push_back(std::string("Marketplace Separator")); @@ -1281,6 +1287,11 @@ void LLItemBridge::performAction(LLInventoryModel* model, std::string action) gViewerWindow->getWindow()->copyTextToClipboard(utf8str_to_wstring(buffer)); return; } + else if ("cut" == action) + { + cutToClipboard(); + return; + } else if ("copy" == action) { copyToClipboard(); @@ -2608,6 +2619,11 @@ void LLFolderBridge::performAction(LLInventoryModel* model, std::string action) modifyOutfit(TRUE); return; } + else if ("cut" == action) + { + cutToClipboard(); + return; + } else if ("copy" == action) { copyToClipboard(); @@ -2867,6 +2883,8 @@ void LLFolderBridge::pasteFromClipboard() } } } + // Change mode to paste for next paste + LLClipboard::getInstance()->setCutMode(false); } } @@ -2920,6 +2938,8 @@ void LLFolderBridge::pasteLinkFromClipboard() LLPointer(NULL)); } } + // Change mode to paste for next paste + LLClipboard::getInstance()->setCutMode(false); } } diff --git a/indra/newview/skins/default/xui/en/menu_inventory.xml b/indra/newview/skins/default/xui/en/menu_inventory.xml index ef4a1bc061..b13bf5b508 100644 --- a/indra/newview/skins/default/xui/en/menu_inventory.xml +++ b/indra/newview/skins/default/xui/en/menu_inventory.xml @@ -452,6 +452,14 @@ + + + Date: Tue, 7 Feb 2012 22:46:04 -0800 Subject: EXP-1841 : Final deep scrub on LLClipboard API, clean up the use of copy and cut everywhere. --- indra/llui/llclipboard.cpp | 96 +++++++++++++++---------------- indra/llui/llclipboard.h | 44 +++++++------- indra/newview/llfavoritesbar.cpp | 6 +- indra/newview/llfloatergesture.cpp | 10 ++-- indra/newview/llfoldervieweventlistener.h | 2 +- indra/newview/llinventorybridge.cpp | 52 ++++++++--------- indra/newview/llinventorybridge.h | 6 +- indra/newview/llpanelobjectinventory.cpp | 5 +- 8 files changed, 107 insertions(+), 114 deletions(-) diff --git a/indra/llui/llclipboard.cpp b/indra/llui/llclipboard.cpp index a2a3f7f285..7794a0537f 100644 --- a/indra/llui/llclipboard.cpp +++ b/indra/llui/llclipboard.cpp @@ -35,8 +35,8 @@ #include "llwindow.h" LLClipboard::LLClipboard() -: mCutMode(false) { + reset(); } LLClipboard::~LLClipboard() @@ -44,55 +44,59 @@ LLClipboard::~LLClipboard() reset(); } -void LLClipboard::add(const LLUUID& object) +void LLClipboard::reset() { - mObjects.put(object); + mObjects.reset(); + mCutMode = false; + mString = LLWString(); } -void LLClipboard::store(const LLUUID& object) +// Copy the input uuid to the LL clipboard +bool LLClipboard::copyToClipboard(const LLUUID& src, const LLAssetType::EType type) { reset(); - mObjects.put(object); + return addToClipboard(src, type); } -void LLClipboard::store(const LLDynamicArray& inv_objects) +// Add the input uuid to the LL clipboard +// Convert the uuid to string and concatenate that string to the system clipboard if legit +bool LLClipboard::addToClipboard(const LLUUID& src, const LLAssetType::EType type) { - reset(); - S32 count = inv_objects.count(); - for(S32 i = 0; i < count; i++) + bool res = false; + if (src.notNull()) { - mObjects.put(inv_objects[i]); + res = true; + if (LLAssetType::lookupIsAssetIDKnowable(type)) + { + LLWString source = utf8str_to_wstring(src.asString()); + res = addToClipboard(source, 0, source.size()); + } + if (res) + { + mObjects.put(src); + } } + return res; } -void LLClipboard::cut(const LLUUID& object) +bool LLClipboard::pasteFromClipboard(LLDynamicArray& inv_objects) const { - if(!mCutMode && !mObjects.empty()) - { - //looks like there are some stored items, reset clipboard state - reset(); - } - mCutMode = true; - add(object); -} -void LLClipboard::retrieve(LLDynamicArray& inv_objects) const -{ - inv_objects.reset(); + bool res = false; S32 count = mObjects.count(); - for(S32 i = 0; i < count; i++) + if (count > 0) { - inv_objects.put(mObjects[i]); + res = true; + inv_objects.reset(); + for (S32 i = 0; i < count; i++) + { + inv_objects.put(mObjects[i]); + } } -} - -void LLClipboard::reset() -{ - mObjects.reset(); - mCutMode = false; + return res; } // Returns true if the LL Clipboard has pasteable items in it -BOOL LLClipboard::hasContents() const +bool LLClipboard::hasContents() const { return (mObjects.count() > 0); } @@ -107,30 +111,22 @@ bool LLClipboard::isOnClipboard(const LLUUID& object) const bool LLClipboard::copyToClipboard(const LLWString &src, S32 pos, S32 len, bool use_primary) { reset(); - mString = src.substr(pos, len); - return (use_primary ? LLView::getWindow()->copyTextToPrimary(mString) : LLView::getWindow()->copyTextToClipboard(mString)); + return addToClipboard(src, pos, len, use_primary); } -// Copy the input uuid to the LL clipboard -// Convert the uuid to string and copy that string to the system clipboard if legit -bool LLClipboard::copyToClipboard(const LLUUID& src, const LLAssetType::EType type) +// Concatenate the input string to the LL and the system clipboard +bool LLClipboard::addToClipboard(const LLWString &src, S32 pos, S32 len, bool use_primary) { - bool res = false; - reset(); - if (src.notNull()) + const LLWString sep(utf8str_to_wstring(std::string(", "))); + if (mString.length() == 0) { - res = true; - if (LLAssetType::lookupIsAssetIDKnowable(type)) - { - LLWString source = utf8str_to_wstring(src.asString()); - res = copyToClipboard(source, 0, source.size()); - } - if (res) - { - store(src); - } + mString = src.substr(pos, len); } - return res; + else + { + mString = mString + sep + src.substr(pos, len); + } + return (use_primary ? LLView::getWindow()->copyTextToPrimary(mString) : LLView::getWindow()->copyTextToClipboard(mString)); } // Copy the System clipboard to the output string. diff --git a/indra/llui/llclipboard.h b/indra/llui/llclipboard.h index 8e417a490d..608ea246a7 100644 --- a/indra/llui/llclipboard.h +++ b/indra/llui/llclipboard.h @@ -48,34 +48,38 @@ public: LLClipboard(); ~LLClipboard(); - /* We support two flavors of clipboard. The default is the explicitly - copy-and-pasted clipboard. The second is the so-called 'primary' clipboard - which is implicitly copied upon selection on platforms which expect this - (i.e. X11/Linux). */ - - // Text strings and single item management - bool copyToClipboard(const LLWString& src, S32 pos, S32 len, bool use_primary = false); - bool copyToClipboard(const LLUUID& src, const LLAssetType::EType type = LLAssetType::AT_NONE); - bool pasteFromClipboard(LLWString& dst, bool use_primary = false); - bool isTextAvailable(bool use_primary = false) const; + // Text strings management: + // ------------------------ + // We support two flavors of text clipboards. The default is the explicitly + // copy-and-pasted clipboard. The second is the so-called 'primary' clipboard + // which is implicitly copied upon selection on platforms which expect this + // (i.e. X11/Linux, Mac). + bool copyToClipboard(const LLWString& src, S32 pos, S32 len, bool use_primary = false); + bool addToClipboard(const LLWString& src, S32 pos, S32 len, bool use_primary = false); + bool pasteFromClipboard(LLWString& dst, bool use_primary = false); + bool isTextAvailable(bool use_primary = false) const; - // Object list management - void add(const LLUUID& object); // Adds to the current list of objects on the clipboard - void store(const LLUUID& object); // Stores a single inventory object - void store(const LLDynamicArray& inventory_objects); // Stores an array of objects - void cut(const LLUUID& object); // Adds to the current list of cut objects on the clipboard - void retrieve(LLDynamicArray& inventory_objects) const; // Gets a copy of the objects on the clipboard - void reset(); // Clears the clipboard + // Object list management: + // ----------------------- + // Clears the clipboard + void reset(); + // Clears and adds one single object to the clipboard + bool copyToClipboard(const LLUUID& src, const LLAssetType::EType type = LLAssetType::AT_NONE); + // Adds one object to the current list of objects on the clipboard + bool addToClipboard(const LLUUID& src, const LLAssetType::EType type = LLAssetType::AT_NONE); + // Gets a copy of the objects on the clipboard + bool pasteFromClipboard(LLDynamicArray& inventory_objects) const; - BOOL hasContents() const; // true if the clipboard has something pasteable in it + bool hasContents() const; // True if the clipboard has pasteable objects + bool isOnClipboard(const LLUUID& object) const; // True if the input object uuid is on the clipboard + bool isCutMode() const { return mCutMode; } void setCutMode(bool mode) { mCutMode = mode; } - bool isOnClipboard(const LLUUID& object) const; private: LLDynamicArray mObjects; - bool mCutMode; LLWString mString; + bool mCutMode; // This is a convenience flag for the viewer. It has no influence on the cliboard management. }; #endif // LL_LLCLIPBOARD_H diff --git a/indra/newview/llfavoritesbar.cpp b/indra/newview/llfavoritesbar.cpp index 4308bf2d3c..d4bce1e3a1 100644 --- a/indra/newview/llfavoritesbar.cpp +++ b/indra/newview/llfavoritesbar.cpp @@ -1187,7 +1187,7 @@ void LLFavoritesBarCtrl::doToSelected(const LLSD& userdata) } else if (action == "copy") { - LLClipboard::getInstance()->store(mSelectedItemID); + LLClipboard::getInstance()->copyToClipboard(mSelectedItemID, LLAssetType::AT_LANDMARK); } else if (action == "paste") { @@ -1217,7 +1217,7 @@ BOOL LLFavoritesBarCtrl::isClipboardPasteable() const } LLDynamicArray objects; - LLClipboard::getInstance()->retrieve(objects); + LLClipboard::getInstance()->pasteFromClipboard(objects); S32 count = objects.count(); for(S32 i = 0; i < count; i++) { @@ -1246,7 +1246,7 @@ void LLFavoritesBarCtrl::pastFromClipboard() const { LLInventoryItem* item = NULL; LLDynamicArray objects; - LLClipboard::getInstance()->retrieve(objects); + LLClipboard::getInstance()->pasteFromClipboard(objects); S32 count = objects.count(); LLUUID parent_id(mFavoriteFolderId); for(S32 i = 0; i < count; i++) diff --git a/indra/newview/llfloatergesture.cpp b/indra/newview/llfloatergesture.cpp index 3c647284f6..d449c4ff1b 100644 --- a/indra/newview/llfloatergesture.cpp +++ b/indra/newview/llfloatergesture.cpp @@ -395,7 +395,7 @@ bool LLFloaterGesture::isActionEnabled(const LLSD& command) return false; LLDynamicArray ids; - LLClipboard::getInstance()->retrieve(ids); + LLClipboard::getInstance()->pasteFromClipboard(ids); for(LLDynamicArray::iterator it = ids.begin(); it != ids.end(); it++) { LLInventoryItem* item = gInventory.getItem(*it); @@ -490,26 +490,26 @@ void LLFloaterGesture::onActivateBtnClick() void LLFloaterGesture::onCopyPasteAction(const LLSD& command) { std::string command_name = command.asString(); - // since we select this comman inventory item had already arrived . + // Since we select this command, the inventory items must have already arrived if("copy_gesture" == command_name) { uuid_vec_t ids; getSelectedIds(ids); - // make sure that clopboard is empty + // Make sure the clipboard is empty LLClipboard::getInstance()->reset(); for(uuid_vec_t::iterator it = ids.begin(); it != ids.end(); it++) { LLInventoryItem* item = gInventory.getItem(*it); if(item && item->getInventoryType() == LLInventoryType::IT_GESTURE) { - LLClipboard::getInstance()->add(item->getUUID()); + LLClipboard::getInstance()->addToClipboard(item->getUUID(),LLAssetType::AT_GESTURE); } } } else if ("paste" == command_name) { LLDynamicArray ids; - LLClipboard::getInstance()->retrieve(ids); + LLClipboard::getInstance()->pasteFromClipboard(ids); if(ids.empty() || !gInventory.isCategoryComplete(mGestureFolderID)) return; LLInventoryCategory* gesture_dir = gInventory.getCategory(mGestureFolderID); diff --git a/indra/newview/llfoldervieweventlistener.h b/indra/newview/llfoldervieweventlistener.h index aee31ca033..06682dcbf1 100644 --- a/indra/newview/llfoldervieweventlistener.h +++ b/indra/newview/llfoldervieweventlistener.h @@ -75,7 +75,7 @@ public: virtual void move( LLFolderViewEventListener* parent_listener ) = 0; virtual BOOL isItemCopyable() const = 0; virtual BOOL copyToClipboard() const = 0; - virtual void cutToClipboard() = 0; + virtual BOOL cutToClipboard() const = 0; virtual BOOL isClipboardPasteable() const = 0; virtual void pasteFromClipboard() = 0; virtual void pasteLinkFromClipboard() = 0; diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index 7ba914eaf6..9775e54d6a 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -208,13 +208,27 @@ BOOL LLInvFVBridge::isLink() const /** * @brief Adds this item into clipboard storage */ -void LLInvFVBridge::cutToClipboard() +BOOL LLInvFVBridge::cutToClipboard() const { - if (isItemMovable() && isItemRemovable()) + LLViewerInventoryItem* inv_item = gInventory.getItem(mUUID); + if (inv_item && isItemMovable() && isItemRemovable()) { - LLClipboard::getInstance()->cut(mUUID); + LLClipboard::getInstance()->setCutMode(true); + return LLClipboard::getInstance()->addToClipboard(mUUID,inv_item->getType()); } + return FALSE; } + +BOOL LLInvFVBridge::copyToClipboard() const +{ + LLViewerInventoryItem* inv_item = gInventory.getItem(mUUID); + if (inv_item && isItemCopyable()) + { + return LLClipboard::getInstance()->addToClipboard(mUUID,inv_item->getType()); + } + return FALSE; +} + // *TODO: make sure this does the right thing void LLInvFVBridge::showProperties() { @@ -413,7 +427,7 @@ BOOL LLInvFVBridge::isClipboardPasteable() const // 1. folders should be pastable // 2. when pasting, we should paste what is authorized and let the rest not pasted LLDynamicArray objects; - LLClipboard::getInstance()->retrieve(objects); + LLClipboard::getInstance()->pasteFromClipboard(objects); S32 count = objects.count(); for(S32 i = 0; i < count; i++) { @@ -451,7 +465,7 @@ BOOL LLInvFVBridge::isClipboardPasteableAsLink() const } LLDynamicArray objects; - LLClipboard::getInstance()->retrieve(objects); + LLClipboard::getInstance()->pasteFromClipboard(objects); S32 count = objects.count(); for(S32 i = 0; i < count; i++) { @@ -1673,16 +1687,6 @@ BOOL LLItemBridge::isItemCopyable() const return FALSE; } -BOOL LLItemBridge::copyToClipboard() const -{ - if(isItemCopyable()) - { - LLClipboard::getInstance()->add(mUUID); - return TRUE; - } - return FALSE; -} - LLViewerInventoryItem* LLItemBridge::getItem() const { LLViewerInventoryItem* item = NULL; @@ -1785,16 +1789,6 @@ BOOL LLFolderBridge::isItemCopyable() const return gSavedSettings.getBOOL("InventoryLinking"); } -BOOL LLFolderBridge::copyToClipboard() const -{ - if(isItemCopyable()) - { - LLClipboard::getInstance()->add(mUUID); - return TRUE; - } - return FALSE; -} - BOOL LLFolderBridge::isClipboardPasteable() const { if ( ! LLInvFVBridge::isClipboardPasteable() ) @@ -1810,7 +1804,7 @@ BOOL LLFolderBridge::isClipboardPasteable() const } LLDynamicArray objects; - LLClipboard::getInstance()->retrieve(objects); + LLClipboard::getInstance()->pasteFromClipboard(objects); const LLViewerInventoryCategory *current_cat = getCategory(); // Search for the direct descendent of current Friends subfolder among all pasted items, @@ -1848,7 +1842,7 @@ BOOL LLFolderBridge::isClipboardPasteableAsLink() const const BOOL is_in_friend_folder = LLFriendCardsManager::instance().isCategoryInFriendFolder( current_cat ); const LLUUID ¤t_cat_id = current_cat->getUUID(); LLDynamicArray objects; - LLClipboard::getInstance()->retrieve(objects); + LLClipboard::getInstance()->pasteFromClipboard(objects); S32 count = objects.count(); for(S32 i = 0; i < count; i++) { @@ -2844,7 +2838,7 @@ void LLFolderBridge::pasteFromClipboard() const LLUUID parent_id(mUUID); LLDynamicArray objects; - LLClipboard::getInstance()->retrieve(objects); + LLClipboard::getInstance()->pasteFromClipboard(objects); for (LLDynamicArray::const_iterator iter = objects.begin(); iter != objects.end(); ++iter) @@ -2900,7 +2894,7 @@ void LLFolderBridge::pasteLinkFromClipboard() const LLUUID parent_id(mUUID); LLDynamicArray objects; - LLClipboard::getInstance()->retrieve(objects); + LLClipboard::getInstance()->pasteFromClipboard(objects); for (LLDynamicArray::const_iterator iter = objects.begin(); iter != objects.end(); ++iter) diff --git a/indra/newview/llinventorybridge.h b/indra/newview/llinventorybridge.h index 3bcd71557c..f13ff15bc5 100644 --- a/indra/newview/llinventorybridge.h +++ b/indra/newview/llinventorybridge.h @@ -105,8 +105,8 @@ public: virtual void removeBatch(LLDynamicArray& batch); virtual void move(LLFolderViewEventListener* new_parent_bridge) {} virtual BOOL isItemCopyable() const { return FALSE; } - virtual BOOL copyToClipboard() const { return FALSE; } - virtual void cutToClipboard(); + virtual BOOL copyToClipboard() const; + virtual BOOL cutToClipboard() const; virtual BOOL isClipboardPasteable() const; virtual BOOL isClipboardPasteableAsLink() const; virtual void pasteFromClipboard() {} @@ -211,7 +211,6 @@ public: virtual BOOL renameItem(const std::string& new_name); virtual BOOL removeItem(); virtual BOOL isItemCopyable() const; - virtual BOOL copyToClipboard() const; virtual BOOL hasChildren() const { return FALSE; } virtual BOOL isUpToDate() const { return TRUE; } @@ -274,7 +273,6 @@ public: virtual BOOL isItemCopyable() const; virtual BOOL isClipboardPasteable() const; virtual BOOL isClipboardPasteableAsLink() const; - virtual BOOL copyToClipboard() const; static void createWearable(LLFolderBridge* bridge, LLWearableType::EType type); diff --git a/indra/newview/llpanelobjectinventory.cpp b/indra/newview/llpanelobjectinventory.cpp index 98ea680504..eb0a257def 100644 --- a/indra/newview/llpanelobjectinventory.cpp +++ b/indra/newview/llpanelobjectinventory.cpp @@ -124,7 +124,7 @@ public: virtual void move(LLFolderViewEventListener* parent_listener); virtual BOOL isItemCopyable() const; virtual BOOL copyToClipboard() const; - virtual void cutToClipboard(); + virtual BOOL cutToClipboard() const; virtual BOOL isClipboardPasteable() const; virtual void pasteFromClipboard(); virtual void pasteLinkFromClipboard(); @@ -524,8 +524,9 @@ BOOL LLTaskInvFVBridge::copyToClipboard() const return FALSE; } -void LLTaskInvFVBridge::cutToClipboard() +BOOL LLTaskInvFVBridge::cutToClipboard() const { + return FALSE; } BOOL LLTaskInvFVBridge::isClipboardPasteable() const -- cgit v1.2.3 From 91f77318db63d4b2560390551306056c4a6cc2d5 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Wed, 8 Feb 2012 15:44:02 -0800 Subject: EXP-1873 : Implement the hiding of cut items on the clipboard --- indra/llui/llclipboard.cpp | 6 +++++- indra/llui/llclipboard.h | 14 +++++++++----- indra/newview/llfolderviewitem.cpp | 6 ------ indra/newview/llinventoryfilter.cpp | 19 ++++++++++++++++++- indra/newview/llinventoryfilter.h | 4 +++- indra/newview/llinventorypanel.cpp | 13 +++++++++++++ indra/newview/llinventorypanel.h | 1 + 7 files changed, 49 insertions(+), 14 deletions(-) diff --git a/indra/llui/llclipboard.cpp b/indra/llui/llclipboard.cpp index 7794a0537f..ee1f1aa816 100644 --- a/indra/llui/llclipboard.cpp +++ b/indra/llui/llclipboard.cpp @@ -34,7 +34,8 @@ #include "llview.h" #include "llwindow.h" -LLClipboard::LLClipboard() +LLClipboard::LLClipboard() : + mState(0) { reset(); } @@ -46,6 +47,7 @@ LLClipboard::~LLClipboard() void LLClipboard::reset() { + mState++; mObjects.reset(); mCutMode = false; mString = LLWString(); @@ -74,6 +76,7 @@ bool LLClipboard::addToClipboard(const LLUUID& src, const LLAssetType::EType typ if (res) { mObjects.put(src); + mState++; } } return res; @@ -126,6 +129,7 @@ bool LLClipboard::addToClipboard(const LLWString &src, S32 pos, S32 len, bool us { mString = mString + sep + src.substr(pos, len); } + mState++; return (use_primary ? LLView::getWindow()->copyTextToPrimary(mString) : LLView::getWindow()->copyTextToClipboard(mString)); } diff --git a/indra/llui/llclipboard.h b/indra/llui/llclipboard.h index 608ea246a7..0231169748 100644 --- a/indra/llui/llclipboard.h +++ b/indra/llui/llclipboard.h @@ -47,6 +47,11 @@ class LLClipboard : public LLSingleton public: LLClipboard(); ~LLClipboard(); + + // Clears the clipboard + void reset(); + // Returns the state of the clipboard so client can know if it has been modified (comparing with tracked state) + int getState() const { return mState; } // Text strings management: // ------------------------ @@ -61,8 +66,6 @@ public: // Object list management: // ----------------------- - // Clears the clipboard - void reset(); // Clears and adds one single object to the clipboard bool copyToClipboard(const LLUUID& src, const LLAssetType::EType type = LLAssetType::AT_NONE); // Adds one object to the current list of objects on the clipboard @@ -74,12 +77,13 @@ public: bool isOnClipboard(const LLUUID& object) const; // True if the input object uuid is on the clipboard bool isCutMode() const { return mCutMode; } - void setCutMode(bool mode) { mCutMode = mode; } + void setCutMode(bool mode) { mCutMode = mode; mState++; } private: - LLDynamicArray mObjects; - LLWString mString; + LLDynamicArray mObjects; // Objects on the clipboard. Can be empty while mString contains something licit (e.g. text from chat) + LLWString mString; // The text string. If mObjects is not empty, this string is reflecting them (UUIDs for the moment). bool mCutMode; // This is a convenience flag for the viewer. It has no influence on the cliboard management. + int mState; // Incremented when the clipboard change so that interested parties can check its state. }; #endif // LL_LLCLIPBOARD_H diff --git a/indra/newview/llfolderviewitem.cpp b/indra/newview/llfolderviewitem.cpp index 37ef27a5d7..884cddfe7f 100644 --- a/indra/newview/llfolderviewitem.cpp +++ b/indra/newview/llfolderviewitem.cpp @@ -1004,12 +1004,6 @@ void LLFolderViewItem::draw() if (highlight_link) color = sLinkColor; if (in_library) color = sLibraryColor; - // Cut state rendering tweak (experimental) - if (LLClipboard::getInstance()->isCutMode() && LLClipboard::getInstance()->isOnClipboard(getListener()->getUUID())) - { - color.setAlpha(0.5); - } - 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); diff --git a/indra/newview/llinventoryfilter.cpp b/indra/newview/llinventoryfilter.cpp index 796251cae5..9d12478019 100644 --- a/indra/newview/llinventoryfilter.cpp +++ b/indra/newview/llinventoryfilter.cpp @@ -39,6 +39,7 @@ #include "llviewerfoldertype.h" // linden library includes +#include "llclipboard.h" #include "lltrans.h" LLInventoryFilter::FilterOps::FilterOps() : @@ -236,7 +237,18 @@ BOOL LLInventoryFilter::checkAgainstFilterType(const LLFolderViewItem* item) con } } } - + + //////////////////////////////////////////////////////////////////////////////// + // FILTERTYPE_CLIPBOARD + // Pass if this item is not on the clipboard + if (filterTypes & FILTERTYPE_CLIPBOARD) + { + if (LLClipboard::getInstance()->isCutMode() && LLClipboard::getInstance()->isOnClipboard(object_id)) + { + return FALSE; + } + } + return TRUE; } @@ -450,6 +462,11 @@ void LLInventoryFilter::setFilterEmptySystemFolders() mFilterOps.mFilterTypes |= FILTERTYPE_EMPTYFOLDERS; } +void LLInventoryFilter::setFilterClipboard() +{ + mFilterOps.mFilterTypes |= FILTERTYPE_CLIPBOARD; +} + void LLInventoryFilter::setFilterUUID(const LLUUID& object_id) { if (mFilterOps.mFilterUUID == LLUUID::null) diff --git a/indra/newview/llinventoryfilter.h b/indra/newview/llinventoryfilter.h index 343306ae8e..fb4f84b139 100644 --- a/indra/newview/llinventoryfilter.h +++ b/indra/newview/llinventoryfilter.h @@ -59,7 +59,8 @@ public: FILTERTYPE_UUID = 0x1 << 2, // find the object with UUID and any links to it FILTERTYPE_DATE = 0x1 << 3, // search by date range FILTERTYPE_WEARABLE = 0x1 << 4, // search by wearable type - FILTERTYPE_EMPTYFOLDERS = 0x1 << 5 // pass if folder is not a system folder to be hidden if empty + FILTERTYPE_EMPTYFOLDERS = 0x1 << 5, // pass if folder is not a system folder to be hidden if empty + FILTERTYPE_CLIPBOARD = 0x1 << 6 // pass if item is not on the clipboard }; enum EFilterLink @@ -91,6 +92,7 @@ public: void setFilterUUID(const LLUUID &object_id); void setFilterWearableTypes(U64 types); void setFilterEmptySystemFolders(); + void setFilterClipboard(); void updateFilterTypes(U64 types, U64& current_types); void setFilterSubString(const std::string& string); diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp index 382569fa3a..27f97ad26f 100644 --- a/indra/newview/llinventorypanel.cpp +++ b/indra/newview/llinventorypanel.cpp @@ -33,6 +33,7 @@ #include "llagentwearables.h" #include "llappearancemgr.h" #include "llavataractions.h" +#include "llclipboard.h" #include "llfloaterinventory.h" #include "llfloaterreg.h" #include "llfloatersidepanelcontainer.h" @@ -247,6 +248,10 @@ void LLInventoryPanel::initFromParams(const LLInventoryPanel::Params& params) getFilter()->setFilterEmptySystemFolders(); } + // hide items that are on the clipboard + getFilter()->setFilterClipboard(); + mClipboardState = LLClipboard::getInstance()->getState(); + // Initialize base class params. LLPanel::initFromParams(params); } @@ -277,6 +282,14 @@ void LLInventoryPanel::draw() { // Select the desired item (in case it wasn't loaded when the selection was requested) mFolderRoot->updateSelection(); + + // Nudge the filter if the clipboard state changed + if (mClipboardState != LLClipboard::getInstance()->getState()) + { + mClipboardState = LLClipboard::getInstance()->getState(); + getFilter()->setModified(LLInventoryFilter::FILTER_RESTART); + } + LLPanel::draw(); } diff --git a/indra/newview/llinventorypanel.h b/indra/newview/llinventorypanel.h index 7d805f6862..6db59afb9b 100644 --- a/indra/newview/llinventorypanel.h +++ b/indra/newview/llinventorypanel.h @@ -222,6 +222,7 @@ public: private: std::string mSortOrderSetting; + int mClipboardState; //-------------------------------------------------------------------- // Hidden folders -- cgit v1.2.3 From 10dadc6b0dd646faa251c0935e75d07c97b3052d Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Wed, 8 Feb 2012 17:22:04 -0800 Subject: EXP-1873 : Move cut items to trash in cut/copy over cut situations. --- indra/newview/llfolderview.cpp | 25 ++++++++++++++++++++++++- indra/newview/llfolderview.h | 1 + indra/newview/llinventoryfunctions.cpp | 25 +++++++++++++++++++++++++ indra/newview/llinventoryfunctions.h | 2 ++ 4 files changed, 52 insertions(+), 1 deletion(-) diff --git a/indra/newview/llfolderview.cpp b/indra/newview/llfolderview.cpp index 1d318ca221..51a5839b75 100644 --- a/indra/newview/llfolderview.cpp +++ b/indra/newview/llfolderview.cpp @@ -1014,6 +1014,24 @@ bool isDescendantOfASelectedItem(LLFolderViewItem* item, const std::vector exit + if (!LLClipboard::getInstance()->isCutMode()) + return; + + // Get the list of clipboard item uuids and iterate through them + LLDynamicArray objects; + LLClipboard::getInstance()->pasteFromClipboard(objects); + for (LLDynamicArray::const_iterator iter = objects.begin(); + iter != objects.end(); + ++iter) + { + const LLUUID& item_id = (*iter); + remove_item(&gInventory, item_id); + } +} + void LLFolderView::onItemsRemovalConfirmation(const LLSD& notification, const LLSD& response) { S32 option = LLNotificationsUtil::getSelectedOption(notification, response); @@ -2109,7 +2127,12 @@ bool LLFolderView::doToSelected(LLInventoryModel* model, const LLSD& userdata) return true; } if (("copy" == action) || ("cut" == action)) - { + { + // If there are things on the clipboard that have not been pasted but + // already disappeared from view, we need to move them to the trash + removeCutItems(); + + // Clear the clipboard before we start adding things on it LLClipboard::getInstance()->reset(); } diff --git a/indra/newview/llfolderview.h b/indra/newview/llfolderview.h index 1d018b5e6a..2f148d4e25 100644 --- a/indra/newview/llfolderview.h +++ b/indra/newview/llfolderview.h @@ -159,6 +159,7 @@ public: // deletion functionality void removeSelectedItems(); + void removeCutItems(); // open the selected item. void openSelectedItems( void ); diff --git a/indra/newview/llinventoryfunctions.cpp b/indra/newview/llinventoryfunctions.cpp index ea00474b2a..8313b23f44 100644 --- a/indra/newview/llinventoryfunctions.cpp +++ b/indra/newview/llinventoryfunctions.cpp @@ -160,6 +160,31 @@ void change_category_parent(LLInventoryModel* model, model->notifyObservers(); } +// Move the item to the trash. Works for folders and objects. +// Caution: This method assumes that the item is removable! +void remove_item(LLInventoryModel* model, const LLUUID& id) +{ + LLViewerInventoryItem* item = model->getItem(id); + if (!item) + return; + + if (item->getType() == LLAssetType::AT_CATEGORY) + { + // Call the general helper function to delete a folder + remove_category(model, id); + } + else + { + // Get the trash UUID + LLUUID trash_id = model->findCategoryUUIDForType(LLFolderType::FT_TRASH, false); + if (trash_id.notNull()) + { + // Finally, move the item to the trash + change_item_parent(model, item, trash_id, true); + } + } +} + void remove_category(LLInventoryModel* model, const LLUUID& cat_id) { if (!model || !get_is_category_removable(model, cat_id)) diff --git a/indra/newview/llinventoryfunctions.h b/indra/newview/llinventoryfunctions.h index ce2b89b22e..f8ecca22b6 100644 --- a/indra/newview/llinventoryfunctions.h +++ b/indra/newview/llinventoryfunctions.h @@ -62,6 +62,8 @@ void change_item_parent(LLInventoryModel* model, const LLUUID& new_parent_id, BOOL restamp); +void remove_item(LLInventoryModel* model, const LLUUID& id); + void change_category_parent(LLInventoryModel* model, LLViewerInventoryCategory* cat, const LLUUID& new_parent_id, -- cgit v1.2.3 From 2a4aa438f5798c34f1eef3ef75dc3289492138e1 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Thu, 9 Feb 2012 23:37:24 -0800 Subject: EXP-1863 : Implemented cut, copy, paste for folders. Issues with folder filtering though. --- indra/newview/llinventorybridge.cpp | 82 +++++++++++++++++++++------------- indra/newview/llinventoryfilter.cpp | 45 +++++++++++++++++-- indra/newview/llinventoryfunctions.cpp | 36 +++++++++++++++ indra/newview/llinventoryfunctions.h | 2 + 4 files changed, 131 insertions(+), 34 deletions(-) diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index 9775e54d6a..1fa6820d2d 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -210,21 +210,21 @@ BOOL LLInvFVBridge::isLink() const */ BOOL LLInvFVBridge::cutToClipboard() const { - LLViewerInventoryItem* inv_item = gInventory.getItem(mUUID); - if (inv_item && isItemMovable() && isItemRemovable()) + const LLInventoryObject* obj = gInventory.getObject(mUUID); + if (obj && isItemMovable() && isItemRemovable()) { LLClipboard::getInstance()->setCutMode(true); - return LLClipboard::getInstance()->addToClipboard(mUUID,inv_item->getType()); + return LLClipboard::getInstance()->addToClipboard(mUUID,obj->getType()); } return FALSE; } BOOL LLInvFVBridge::copyToClipboard() const { - LLViewerInventoryItem* inv_item = gInventory.getItem(mUUID); - if (inv_item && isItemCopyable()) + const LLInventoryObject* obj = gInventory.getObject(mUUID); + if (obj && isItemCopyable()) { - return LLClipboard::getInstance()->addToClipboard(mUUID,inv_item->getType()); + return LLClipboard::getInstance()->addToClipboard(mUUID,obj->getType()); } return FALSE; } @@ -423,9 +423,6 @@ BOOL LLInvFVBridge::isClipboardPasteable() const const LLUUID &agent_id = gAgent.getID(); - // Merov : This should be suppressed for 2 reasons: - // 1. folders should be pastable - // 2. when pasting, we should paste what is authorized and let the rest not pasted LLDynamicArray objects; LLClipboard::getInstance()->pasteFromClipboard(objects); S32 count = objects.count(); @@ -433,12 +430,9 @@ BOOL LLInvFVBridge::isClipboardPasteable() const { const LLUUID &item_id = objects.get(i); - // Can't paste folders + // Always paste folders const LLInventoryCategory *cat = model->getCategory(item_id); - if (cat) - { - return FALSE; - } + if (cat) continue; const LLInventoryItem *item = model->getItem(item_id); if (item) @@ -1313,7 +1307,6 @@ void LLItemBridge::performAction(LLInventoryModel* model, std::string action) } else if ("paste" == action) { - // Single item only LLInventoryItem* itemp = model->getItem(mUUID); if (!itemp) return; @@ -1785,8 +1778,9 @@ BOOL LLFolderBridge::isUpToDate() const BOOL LLFolderBridge::isItemCopyable() const { + return TRUE; // Can copy folders to paste-as-link, but not for straight paste. - return gSavedSettings.getBOOL("InventoryLinking"); + //return gSavedSettings.getBOOL("InventoryLinking"); } BOOL LLFolderBridge::isClipboardPasteable() const @@ -2829,7 +2823,7 @@ bool LLFolderBridge::removeItemResponse(const LLSD& notification, const LLSD& re void LLFolderBridge::pasteFromClipboard() { LLInventoryModel* model = getInventoryModel(); - if(model && isClipboardPasteable()) + if (model && isClipboardPasteable()) { const LLUUID ¤t_outfit_id = model->findCategoryUUIDForType(LLFolderType::FT_CURRENT_OUTFIT, false); const BOOL move_is_into_current_outfit = (mUUID == current_outfit_id); @@ -2845,7 +2839,8 @@ void LLFolderBridge::pasteFromClipboard() { const LLUUID& item_id = (*iter); LLInventoryItem *item = model->getItem(item_id); - if (item) + LLInventoryObject *obj = model->getObject(item_id); + if (obj) { if (move_is_into_current_outfit || move_is_into_outfit) { @@ -2856,24 +2851,49 @@ void LLFolderBridge::pasteFromClipboard() } else if (LLClipboard::getInstance()->isCutMode()) { - // move_inventory_item() is not enough, - //we have to update inventory locally too - LLViewerInventoryItem* viitem = dynamic_cast(item); - llassert(viitem); - if (viitem) + // Do a move to "paste" a "cut" + // move_inventory_item() is not enough, as we have to update inventory locally too + if (LLAssetType::AT_CATEGORY == obj->getType()) { - changeItemParent(model, viitem, parent_id, FALSE); + LLViewerInventoryCategory* vicat = (LLViewerInventoryCategory *) model->getCategory(item_id); + llassert(vicat); + if (vicat) + { + changeCategoryParent(model, vicat, parent_id, FALSE); + } + } + else + { + LLViewerInventoryItem* viitem = dynamic_cast(item); + llassert(viitem); + if (viitem) + { + changeItemParent(model, viitem, parent_id, FALSE); + } } } else { - copy_inventory_item( - gAgent.getID(), - item->getPermissions().getOwner(), - item->getUUID(), - parent_id, - std::string(), - LLPointer(NULL)); + // Do a "copy" to "paste" a regular copy clipboard + if (LLAssetType::AT_CATEGORY == obj->getType()) + { + LLViewerInventoryCategory* vicat = (LLViewerInventoryCategory *) model->getCategory(item_id); + llassert(vicat); + if (vicat) + { + copy_inventory_category(model, vicat, parent_id); + } + } + else + { + copy_inventory_item( + gAgent.getID(), + item->getPermissions().getOwner(), + item->getUUID(), + parent_id, + std::string(), + LLPointer(NULL)); + } } } } diff --git a/indra/newview/llinventoryfilter.cpp b/indra/newview/llinventoryfilter.cpp index 9d12478019..808b7619eb 100644 --- a/indra/newview/llinventoryfilter.cpp +++ b/indra/newview/llinventoryfilter.cpp @@ -240,12 +240,26 @@ BOOL LLInventoryFilter::checkAgainstFilterType(const LLFolderViewItem* item) con //////////////////////////////////////////////////////////////////////////////// // FILTERTYPE_CLIPBOARD - // Pass if this item is not on the clipboard + // Pass if this item is not on the clipboard or is not a descendant of a folder + // which is on the clipboard if (filterTypes & FILTERTYPE_CLIPBOARD) { - if (LLClipboard::getInstance()->isCutMode() && LLClipboard::getInstance()->isOnClipboard(object_id)) + if (LLClipboard::getInstance()->isCutMode()) { - return FALSE; + LLUUID current_id = object_id; + LLInventoryObject *current_object = gInventory.getObject(object_id); + while (current_id.notNull()) + { + if (LLClipboard::getInstance()->isOnClipboard(current_id)) + { + return FALSE; + } + current_id = current_object->getParentUUID(); + if (current_id.notNull()) + { + current_object = gInventory.getObject(current_id); + } + } } } @@ -309,6 +323,31 @@ bool LLInventoryFilter::checkAgainstFilterType(const LLInventoryItem* item) cons return false; } + //////////////////////////////////////////////////////////////////////////////// + // FILTERTYPE_CLIPBOARD + // Pass if this item is not on the clipboard or is not a descendant of a folder + // which is on the clipboard + if (filterTypes & FILTERTYPE_CLIPBOARD) + { + if (LLClipboard::getInstance()->isCutMode()) + { + LLUUID current_id = object_id; + LLInventoryObject *current_object = gInventory.getObject(object_id); + while (current_id.notNull()) + { + if (LLClipboard::getInstance()->isOnClipboard(current_id)) + { + return false; + } + current_id = current_object->getParentUUID(); + if (current_id.notNull()) + { + current_object = gInventory.getObject(current_id); + } + } + } + } + return true; } diff --git a/indra/newview/llinventoryfunctions.cpp b/indra/newview/llinventoryfunctions.cpp index 8313b23f44..4fb06f82c1 100644 --- a/indra/newview/llinventoryfunctions.cpp +++ b/indra/newview/llinventoryfunctions.cpp @@ -238,6 +238,42 @@ void rename_category(LLInventoryModel* model, const LLUUID& cat_id, const std::s model->notifyObservers(); } +void copy_inventory_category(LLInventoryModel* model, + LLViewerInventoryCategory* cat, + const LLUUID& parent_id) +{ + // Create the initial folder + LLUUID new_cat_uuid = gInventory.createNewCategory(parent_id, LLFolderType::FT_NONE, cat->getName()); + model->notifyObservers(); + + // Get the content of the folder + LLInventoryModel::cat_array_t* cat_array; + LLInventoryModel::item_array_t* item_array; + gInventory.getDirectDescendentsOf(cat->getUUID(),cat_array,item_array); + + // Copy all the items + LLInventoryModel::item_array_t item_array_copy = *item_array; + for (LLInventoryModel::item_array_t::iterator iter = item_array_copy.begin(); iter != item_array_copy.end(); iter++) + { + LLInventoryItem* item = *iter; + copy_inventory_item( + gAgent.getID(), + item->getPermissions().getOwner(), + item->getUUID(), + new_cat_uuid, + std::string(), + LLPointer(NULL)); + } + + // Copy all the folders + LLInventoryModel::cat_array_t cat_array_copy = *cat_array; + for (LLInventoryModel::cat_array_t::iterator iter = cat_array_copy.begin(); iter != cat_array_copy.end(); iter++) + { + LLViewerInventoryCategory* category = *iter; + copy_inventory_category(model, category, new_cat_uuid); + } +} + class LLInventoryCollectAllItems : public LLInventoryCollectFunctor { public: diff --git a/indra/newview/llinventoryfunctions.h b/indra/newview/llinventoryfunctions.h index f8ecca22b6..72c48c64f2 100644 --- a/indra/newview/llinventoryfunctions.h +++ b/indra/newview/llinventoryfunctions.h @@ -73,6 +73,8 @@ void remove_category(LLInventoryModel* model, const LLUUID& cat_id); void rename_category(LLInventoryModel* model, const LLUUID& cat_id, const std::string& new_name); +void copy_inventory_category(LLInventoryModel* model, LLViewerInventoryCategory* cat, const LLUUID& parent_id); + // Generates a string containing the path to the item specified by item_id. void append_path(const LLUUID& id, std::string& path); -- cgit v1.2.3 From d245dad7ddbac36b013c70326ad25eb9247784f6 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Fri, 10 Feb 2012 18:05:07 -0800 Subject: EXP-1863 : Fix the filtering of cut folders, also fix the move to trash of folders in double cut scenarios --- indra/newview/llfolderview.cpp | 13 ++++++- indra/newview/llinventoryfilter.cpp | 77 +++++++++++++------------------------ indra/newview/llinventoryfilter.h | 5 +-- indra/newview/llinventorypanel.cpp | 3 +- 4 files changed, 42 insertions(+), 56 deletions(-) diff --git a/indra/newview/llfolderview.cpp b/indra/newview/llfolderview.cpp index 51a5839b75..0abfa9db8e 100644 --- a/indra/newview/llfolderview.cpp +++ b/indra/newview/llfolderview.cpp @@ -1028,7 +1028,18 @@ void LLFolderView::removeCutItems() ++iter) { const LLUUID& item_id = (*iter); - remove_item(&gInventory, item_id); + LLInventoryObject *obj = gInventory.getObject(item_id); + if (obj) + { + if (LLAssetType::AT_CATEGORY == obj->getType()) + { + remove_category(&gInventory, item_id); + } + else + { + remove_item(&gInventory, item_id); + } + } } } diff --git a/indra/newview/llinventoryfilter.cpp b/indra/newview/llinventoryfilter.cpp index 808b7619eb..f3d4667034 100644 --- a/indra/newview/llinventoryfilter.cpp +++ b/indra/newview/llinventoryfilter.cpp @@ -97,13 +97,16 @@ BOOL LLInventoryFilter::check(const LLFolderViewItem* item) } mSubStringMatchOffset = mFilterSubString.size() ? item->getSearchableLabel().find(mFilterSubString) : std::string::npos; + const LLFolderViewEventListener* listener = item->getListener(); const BOOL passed_filtertype = checkAgainstFilterType(item); const BOOL passed_permissions = checkAgainstPermissions(item); const BOOL passed_filterlink = checkAgainstFilterLinks(item); + const BOOL passed_clipboard = (listener ? checkAgainstClipboard(listener->getUUID()) : TRUE); const BOOL passed = (passed_filtertype && passed_permissions && passed_filterlink && + passed_clipboard && (mFilterSubString.size() == 0 || mSubStringMatchOffset != std::string::npos)); return passed; @@ -115,8 +118,10 @@ bool LLInventoryFilter::check(const LLInventoryItem* item) const bool passed_filtertype = checkAgainstFilterType(item); const bool passed_permissions = checkAgainstPermissions(item); + const BOOL passed_clipboard = checkAgainstClipboard(item->getUUID()); const bool passed = (passed_filtertype && passed_permissions && + passed_clipboard && (mFilterSubString.size() == 0 || mSubStringMatchOffset != std::string::npos)); return passed; @@ -145,7 +150,10 @@ bool LLInventoryFilter::checkFolder(const LLFolderViewFolder* folder) return false; } - return true; + // Always check against the clipboard + const BOOL passed_clipboard = checkAgainstClipboard(folder_id); + + return passed_clipboard; } BOOL LLInventoryFilter::checkAgainstFilterType(const LLFolderViewItem* item) const @@ -238,31 +246,6 @@ BOOL LLInventoryFilter::checkAgainstFilterType(const LLFolderViewItem* item) con } } - //////////////////////////////////////////////////////////////////////////////// - // FILTERTYPE_CLIPBOARD - // Pass if this item is not on the clipboard or is not a descendant of a folder - // which is on the clipboard - if (filterTypes & FILTERTYPE_CLIPBOARD) - { - if (LLClipboard::getInstance()->isCutMode()) - { - LLUUID current_id = object_id; - LLInventoryObject *current_object = gInventory.getObject(object_id); - while (current_id.notNull()) - { - if (LLClipboard::getInstance()->isOnClipboard(current_id)) - { - return FALSE; - } - current_id = current_object->getParentUUID(); - if (current_id.notNull()) - { - current_object = gInventory.getObject(current_id); - } - } - } - } - return TRUE; } @@ -323,31 +306,30 @@ bool LLInventoryFilter::checkAgainstFilterType(const LLInventoryItem* item) cons return false; } - //////////////////////////////////////////////////////////////////////////////// - // FILTERTYPE_CLIPBOARD - // Pass if this item is not on the clipboard or is not a descendant of a folder - // which is on the clipboard - if (filterTypes & FILTERTYPE_CLIPBOARD) + return true; +} + +// Items and folders that are on the clipboard or, recursively, in a folder which +// is on the clipboard must be filtered out if the clipboard is in the "cut" mode. +bool LLInventoryFilter::checkAgainstClipboard(const LLUUID& object_id) const +{ + if (LLClipboard::getInstance()->isCutMode()) { - if (LLClipboard::getInstance()->isCutMode()) + LLUUID current_id = object_id; + LLInventoryObject *current_object = gInventory.getObject(object_id); + while (current_id.notNull()) { - LLUUID current_id = object_id; - LLInventoryObject *current_object = gInventory.getObject(object_id); - while (current_id.notNull()) + if (LLClipboard::getInstance()->isOnClipboard(current_id)) { - if (LLClipboard::getInstance()->isOnClipboard(current_id)) - { - return false; - } - current_id = current_object->getParentUUID(); - if (current_id.notNull()) - { - current_object = gInventory.getObject(current_id); - } + return false; + } + current_id = current_object->getParentUUID(); + if (current_id.notNull()) + { + current_object = gInventory.getObject(current_id); } } } - return true; } @@ -501,11 +483,6 @@ void LLInventoryFilter::setFilterEmptySystemFolders() mFilterOps.mFilterTypes |= FILTERTYPE_EMPTYFOLDERS; } -void LLInventoryFilter::setFilterClipboard() -{ - mFilterOps.mFilterTypes |= FILTERTYPE_CLIPBOARD; -} - void LLInventoryFilter::setFilterUUID(const LLUUID& object_id) { if (mFilterOps.mFilterUUID == LLUUID::null) diff --git a/indra/newview/llinventoryfilter.h b/indra/newview/llinventoryfilter.h index fb4f84b139..1ac90788b2 100644 --- a/indra/newview/llinventoryfilter.h +++ b/indra/newview/llinventoryfilter.h @@ -59,8 +59,7 @@ public: FILTERTYPE_UUID = 0x1 << 2, // find the object with UUID and any links to it FILTERTYPE_DATE = 0x1 << 3, // search by date range FILTERTYPE_WEARABLE = 0x1 << 4, // search by wearable type - FILTERTYPE_EMPTYFOLDERS = 0x1 << 5, // pass if folder is not a system folder to be hidden if empty - FILTERTYPE_CLIPBOARD = 0x1 << 6 // pass if item is not on the clipboard + FILTERTYPE_EMPTYFOLDERS = 0x1 << 5 // pass if folder is not a system folder to be hidden if empty }; enum EFilterLink @@ -92,7 +91,6 @@ public: void setFilterUUID(const LLUUID &object_id); void setFilterWearableTypes(U64 types); void setFilterEmptySystemFolders(); - void setFilterClipboard(); void updateFilterTypes(U64 types, U64& current_types); void setFilterSubString(const std::string& string); @@ -125,6 +123,7 @@ public: BOOL checkAgainstPermissions(const LLFolderViewItem* item) const; bool checkAgainstPermissions(const LLInventoryItem* item) const; BOOL checkAgainstFilterLinks(const LLFolderViewItem* item) const; + bool checkAgainstClipboard(const LLUUID& object_id) const; std::string::size_type getStringMatchOffset() const; diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp index 27f97ad26f..4508e7e083 100644 --- a/indra/newview/llinventorypanel.cpp +++ b/indra/newview/llinventorypanel.cpp @@ -248,8 +248,7 @@ void LLInventoryPanel::initFromParams(const LLInventoryPanel::Params& params) getFilter()->setFilterEmptySystemFolders(); } - // hide items that are on the clipboard - getFilter()->setFilterClipboard(); + // keep track of the clipboard state so that we avoid filtering too much mClipboardState = LLClipboard::getInstance()->getState(); // Initialize base class params. -- cgit v1.2.3 From 632c8c138c94fae24729ef75ac29967cd4758eb3 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Mon, 13 Feb 2012 10:09:33 -0800 Subject: EXP-1863 : Add comment and dead code cleanup --- indra/newview/llinventorybridge.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index 1fa6820d2d..eb0f9803b0 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -1778,9 +1778,9 @@ BOOL LLFolderBridge::isUpToDate() const BOOL LLFolderBridge::isItemCopyable() const { + // Folders are always copyable as they have no permissions attached to them as items. + // The story is different of course for items within folders. return TRUE; - // Can copy folders to paste-as-link, but not for straight paste. - //return gSavedSettings.getBOOL("InventoryLinking"); } BOOL LLFolderBridge::isClipboardPasteable() const -- cgit v1.2.3 From 155a171180be2df4500e7c6d03df3f99bf4231e7 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Thu, 16 Feb 2012 14:57:30 -0800 Subject: EXP-1896 : Prevent recursively copying of folders onto themselves --- indra/newview/llinventoryfunctions.cpp | 11 +++++++++-- indra/newview/llinventoryfunctions.h | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/indra/newview/llinventoryfunctions.cpp b/indra/newview/llinventoryfunctions.cpp index 4fb06f82c1..236c997ef6 100644 --- a/indra/newview/llinventoryfunctions.cpp +++ b/indra/newview/llinventoryfunctions.cpp @@ -240,11 +240,15 @@ void rename_category(LLInventoryModel* model, const LLUUID& cat_id, const std::s void copy_inventory_category(LLInventoryModel* model, LLViewerInventoryCategory* cat, - const LLUUID& parent_id) + const LLUUID& parent_id, + const LLUUID& root_copy_id) { // Create the initial folder LLUUID new_cat_uuid = gInventory.createNewCategory(parent_id, LLFolderType::FT_NONE, cat->getName()); model->notifyObservers(); + + // We need to exclude the initial root of the copy to avoid recursively copying the copy, etc... + LLUUID root_id = (root_copy_id.isNull() ? new_cat_uuid : root_copy_id); // Get the content of the folder LLInventoryModel::cat_array_t* cat_array; @@ -270,7 +274,10 @@ void copy_inventory_category(LLInventoryModel* model, for (LLInventoryModel::cat_array_t::iterator iter = cat_array_copy.begin(); iter != cat_array_copy.end(); iter++) { LLViewerInventoryCategory* category = *iter; - copy_inventory_category(model, category, new_cat_uuid); + if (category->getUUID() != root_id) + { + copy_inventory_category(model, category, new_cat_uuid, root_id); + } } } diff --git a/indra/newview/llinventoryfunctions.h b/indra/newview/llinventoryfunctions.h index 72c48c64f2..b3d9f4b966 100644 --- a/indra/newview/llinventoryfunctions.h +++ b/indra/newview/llinventoryfunctions.h @@ -73,7 +73,7 @@ void remove_category(LLInventoryModel* model, const LLUUID& cat_id); void rename_category(LLInventoryModel* model, const LLUUID& cat_id, const std::string& new_name); -void copy_inventory_category(LLInventoryModel* model, LLViewerInventoryCategory* cat, const LLUUID& parent_id); +void copy_inventory_category(LLInventoryModel* model, LLViewerInventoryCategory* cat, const LLUUID& parent_id, const LLUUID& root_copy_id = LLUUID::null); // Generates a string containing the path to the item specified by item_id. void append_path(const LLUUID& id, std::string& path); -- cgit v1.2.3 From 6363145f4556f3213f943637866445fae407593a Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Thu, 16 Feb 2012 17:19:53 -0800 Subject: EXP-1900 : Fix crash in filtering --- indra/newview/llinventoryfilter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/newview/llinventoryfilter.cpp b/indra/newview/llinventoryfilter.cpp index f3d4667034..7b803888e2 100644 --- a/indra/newview/llinventoryfilter.cpp +++ b/indra/newview/llinventoryfilter.cpp @@ -317,7 +317,7 @@ bool LLInventoryFilter::checkAgainstClipboard(const LLUUID& object_id) const { LLUUID current_id = object_id; LLInventoryObject *current_object = gInventory.getObject(object_id); - while (current_id.notNull()) + while (current_id.notNull() && current_object) { if (LLClipboard::getInstance()->isOnClipboard(current_id)) { -- cgit v1.2.3 From bb6ace0672fa5e1c47c534ba74396ef04daa408b Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Fri, 17 Feb 2012 14:42:12 -0800 Subject: EXP-1902, EXP-1903 : Move items cut to the trash when clipboard reset. --- indra/llui/llclipboard.cpp | 8 ++++++++ indra/llui/llclipboard.h | 9 +++++++-- indra/newview/llfolderview.cpp | 5 +---- indra/newview/llfolderview.h | 2 +- indra/newview/llinventorybridge.cpp | 2 +- 5 files changed, 18 insertions(+), 8 deletions(-) diff --git a/indra/llui/llclipboard.cpp b/indra/llui/llclipboard.cpp index ee1f1aa816..e0729366cc 100644 --- a/indra/llui/llclipboard.cpp +++ b/indra/llui/llclipboard.cpp @@ -47,9 +47,17 @@ LLClipboard::~LLClipboard() void LLClipboard::reset() { + // Increment the clipboard state mState++; + // Call the cleanup function (if any) before releasing the object list + if (mCutMode && mCleanupCallback) + { + mCleanupCallback(); + } + // Clear the clipboard mObjects.reset(); mCutMode = false; + mCleanupCallback = NULL; mString = LLWString(); } diff --git a/indra/llui/llclipboard.h b/indra/llui/llclipboard.h index 0231169748..3947fa0229 100644 --- a/indra/llui/llclipboard.h +++ b/indra/llui/llclipboard.h @@ -27,6 +27,7 @@ #ifndef LL_LLCLIPBOARD_H #define LL_LLCLIPBOARD_H +#include #include "llstring.h" #include "lluuid.h" @@ -35,6 +36,8 @@ #include "llassettype.h" #include "llinventory.h" +typedef boost::function cleanup_callback_t; + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Class LLClipboard // @@ -77,13 +80,15 @@ public: bool isOnClipboard(const LLUUID& object) const; // True if the input object uuid is on the clipboard bool isCutMode() const { return mCutMode; } - void setCutMode(bool mode) { mCutMode = mode; mState++; } + void setCutMode(bool mode, cleanup_callback_t cb = NULL) { mCutMode = mode; mCleanupCallback = cb; mState++; } private: LLDynamicArray mObjects; // Objects on the clipboard. Can be empty while mString contains something licit (e.g. text from chat) LLWString mString; // The text string. If mObjects is not empty, this string is reflecting them (UUIDs for the moment). - bool mCutMode; // This is a convenience flag for the viewer. It has no influence on the cliboard management. + bool mCutMode; // This is a convenience flag for the viewer. Will determine if mCleanupCallback() needs to be called. + cleanup_callback_t mCleanupCallback;// Function to call when the cut clipboard is being wiped out. Can be set to NULL (nothing done then). int mState; // Incremented when the clipboard change so that interested parties can check its state. + }; #endif // LL_LLCLIPBOARD_H diff --git a/indra/newview/llfolderview.cpp b/indra/newview/llfolderview.cpp index 0abfa9db8e..52cc70aee7 100644 --- a/indra/newview/llfolderview.cpp +++ b/indra/newview/llfolderview.cpp @@ -1014,6 +1014,7 @@ bool isDescendantOfASelectedItem(LLFolderViewItem* item, const std::vector exit @@ -2139,10 +2140,6 @@ bool LLFolderView::doToSelected(LLInventoryModel* model, const LLSD& userdata) } if (("copy" == action) || ("cut" == action)) { - // If there are things on the clipboard that have not been pasted but - // already disappeared from view, we need to move them to the trash - removeCutItems(); - // Clear the clipboard before we start adding things on it LLClipboard::getInstance()->reset(); } diff --git a/indra/newview/llfolderview.h b/indra/newview/llfolderview.h index 2f148d4e25..9a1df5a142 100644 --- a/indra/newview/llfolderview.h +++ b/indra/newview/llfolderview.h @@ -159,7 +159,7 @@ public: // deletion functionality void removeSelectedItems(); - void removeCutItems(); + static void removeCutItems(); // open the selected item. void openSelectedItems( void ); diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index eb0f9803b0..54d195a2e6 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -213,7 +213,7 @@ BOOL LLInvFVBridge::cutToClipboard() const const LLInventoryObject* obj = gInventory.getObject(mUUID); if (obj && isItemMovable() && isItemRemovable()) { - LLClipboard::getInstance()->setCutMode(true); + LLClipboard::getInstance()->setCutMode(true, boost::bind(LLFolderView::removeCutItems)); return LLClipboard::getInstance()->addToClipboard(mUUID,obj->getType()); } return FALSE; -- cgit v1.2.3 From 39e9a17c11d84d65645f2664b077438e9be1d449 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Fri, 17 Feb 2012 16:57:29 -0800 Subject: EXP-1894 : Fix the handling of no-copy items on the clipboard (can cut, can paste once but not twice and cannot copy). Also work on folders with no-copy items. --- indra/newview/llinventorybridge.cpp | 54 +++++++++++++++++++++++++++---------- 1 file changed, 40 insertions(+), 14 deletions(-) diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index 54d195a2e6..9fcad8093c 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -421,8 +421,6 @@ BOOL LLInvFVBridge::isClipboardPasteable() const return FALSE; } - const LLUUID &agent_id = gAgent.getID(); - LLDynamicArray objects; LLClipboard::getInstance()->pasteFromClipboard(objects); S32 count = objects.count(); @@ -430,18 +428,21 @@ BOOL LLInvFVBridge::isClipboardPasteable() const { const LLUUID &item_id = objects.get(i); - // Always paste folders + // Folders are pastable if all items in there are copyable const LLInventoryCategory *cat = model->getCategory(item_id); - if (cat) continue; - - const LLInventoryItem *item = model->getItem(item_id); - if (item) + if (cat) { - if (!item->getPermissions().allowCopyBy(agent_id)) - { + LLFolderBridge cat_br(mInventoryPanel.get(), mRoot, item_id); + if (!cat_br.isItemCopyable()) return FALSE; - } + // Skip to the next item in the clipboard + continue; } + + // Each item must be copyable to be pastable + LLItemBridge item_br(mInventoryPanel.get(), mRoot, item_id); + if (!item_br.isItemCopyable()) + return FALSE; } return TRUE; } @@ -634,7 +635,7 @@ void LLInvFVBridge::getClipboardEntries(bool show_asset_id, { items.push_back(std::string("Paste")); } - if (!isClipboardPasteable() || ((flags & FIRST_SELECTED_ITEM) == 0)) + if ((!LLClipboard::getInstance()->isCutMode() && !isClipboardPasteable()) || ((flags & FIRST_SELECTED_ITEM) == 0)) { disabled_items.push_back(std::string("Paste")); } @@ -1778,8 +1779,33 @@ BOOL LLFolderBridge::isUpToDate() const BOOL LLFolderBridge::isItemCopyable() const { - // Folders are always copyable as they have no permissions attached to them as items. - // The story is different of course for items within folders. + // Folders are copyable if items in them are, recursively, copyable. + + // Get the content of the folder + LLInventoryModel::cat_array_t* cat_array; + LLInventoryModel::item_array_t* item_array; + gInventory.getDirectDescendentsOf(mUUID,cat_array,item_array); + + // Check the items + LLInventoryModel::item_array_t item_array_copy = *item_array; + for (LLInventoryModel::item_array_t::iterator iter = item_array_copy.begin(); iter != item_array_copy.end(); iter++) + { + LLInventoryItem* item = *iter; + LLItemBridge item_br(mInventoryPanel.get(), mRoot, item->getUUID()); + if (!item_br.isItemCopyable()) + return FALSE; + } + + // Check the folders + LLInventoryModel::cat_array_t cat_array_copy = *cat_array; + for (LLInventoryModel::cat_array_t::iterator iter = cat_array_copy.begin(); iter != cat_array_copy.end(); iter++) + { + LLViewerInventoryCategory* category = *iter; + LLFolderBridge cat_br(mInventoryPanel.get(), mRoot, category->getUUID()); + if (!cat_br.isItemCopyable()) + return FALSE; + } + return TRUE; } @@ -2823,7 +2849,7 @@ bool LLFolderBridge::removeItemResponse(const LLSD& notification, const LLSD& re void LLFolderBridge::pasteFromClipboard() { LLInventoryModel* model = getInventoryModel(); - if (model && isClipboardPasteable()) + if (model && (isClipboardPasteable() || LLClipboard::getInstance()->isCutMode())) { const LLUUID ¤t_outfit_id = model->findCategoryUUIDForType(LLFolderType::FT_CURRENT_OUTFIT, false); const BOOL move_is_into_current_outfit = (mUUID == current_outfit_id); -- cgit v1.2.3 From 2fdb18971b01bb9026e2918b79993f0a2629994b Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Fri, 17 Feb 2012 17:43:54 -0800 Subject: EXP-1897 : Suppress the copy of UUID on text clipboard when copy/cut items (back to old behavior). --- indra/newview/llinventorybridge.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index 9fcad8093c..cac1dbfe4a 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -214,7 +214,7 @@ BOOL LLInvFVBridge::cutToClipboard() const if (obj && isItemMovable() && isItemRemovable()) { LLClipboard::getInstance()->setCutMode(true, boost::bind(LLFolderView::removeCutItems)); - return LLClipboard::getInstance()->addToClipboard(mUUID,obj->getType()); + return LLClipboard::getInstance()->addToClipboard(mUUID); } return FALSE; } @@ -224,7 +224,7 @@ BOOL LLInvFVBridge::copyToClipboard() const const LLInventoryObject* obj = gInventory.getObject(mUUID); if (obj && isItemCopyable()) { - return LLClipboard::getInstance()->addToClipboard(mUUID,obj->getType()); + return LLClipboard::getInstance()->addToClipboard(mUUID); } return FALSE; } -- cgit v1.2.3 From b14e34444b1f08c4a3df5abbe2ebd5880cc41ce7 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Fri, 17 Feb 2012 18:45:38 -0800 Subject: EXP-1906 : Allow cut of folders in place panel. --- indra/newview/llpanellandmarks.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/indra/newview/llpanellandmarks.cpp b/indra/newview/llpanellandmarks.cpp index c7454e85a9..68a3b6d1cd 100644 --- a/indra/newview/llpanellandmarks.cpp +++ b/indra/newview/llpanellandmarks.cpp @@ -1149,7 +1149,7 @@ Rules: - cut/rename/delete in any other accordions - paste - only in Favorites, Landmarks accordions 3. For Folders we can: perform any action in Landmarks accordion, except Received folder - 4. We can not paste folders from Clipboard (processed by LLFolderView::canPaste()) + 4. We can paste folders from Clipboard (processed by LLFolderView::canPaste()) 5. Check LLFolderView/Inventory Bridges rules */ bool LLLandmarksPanel::canItemBeModified(const std::string& command_name, LLFolderViewItem* item) const @@ -1206,8 +1206,7 @@ bool LLLandmarksPanel::canItemBeModified(const std::string& command_name, LLFold if ("cut" == command_name) { - // "Cut" disabled for folders. See EXT-8697. - can_be_modified = root_folder->canCut() && listenerp->getInventoryType() != LLInventoryType::IT_CATEGORY; + can_be_modified = root_folder->canCut(); } else if ("rename" == command_name) { -- cgit v1.2.3 From c2922a402d2e45284e2cd829175b958e081b264d Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Wed, 22 Feb 2012 16:55:46 -0800 Subject: EXP-1905, EXP-1911: Be a bit less forcefull when updating the filter after a change on the clipboard --- indra/newview/llinventorypanel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp index 4508e7e083..d569d819dd 100644 --- a/indra/newview/llinventorypanel.cpp +++ b/indra/newview/llinventorypanel.cpp @@ -286,7 +286,7 @@ void LLInventoryPanel::draw() if (mClipboardState != LLClipboard::getInstance()->getState()) { mClipboardState = LLClipboard::getInstance()->getState(); - getFilter()->setModified(LLInventoryFilter::FILTER_RESTART); + getFilter()->setModified(LLClipboard::getInstance()->isCutMode() ? LLInventoryFilter::FILTER_MORE_RESTRICTIVE : LLInventoryFilter::FILTER_LESS_RESTRICTIVE); } LLPanel::draw(); -- cgit v1.2.3 From a7499dc4abfa5fa7582dc7ebb535a07ed94d0c4f Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Thu, 23 Feb 2012 09:57:05 -0800 Subject: EXP-1895 : Fix the evaluation of visible children in folders --- indra/newview/llfolderviewitem.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/indra/newview/llfolderviewitem.cpp b/indra/newview/llfolderviewitem.cpp index 884cddfe7f..0b4baf52f9 100644 --- a/indra/newview/llfolderviewitem.cpp +++ b/indra/newview/llfolderviewitem.cpp @@ -1159,7 +1159,36 @@ S32 LLFolderViewFolder::arrange( S32* width, S32* height, S32 filter_generation) mNeedsSort = false; } + // evaluate mHasVisibleChildren mHasVisibleChildren = hasFilteredDescendants(filter_generation); + if (mHasVisibleChildren) + { + // We have to verify that there's at least one child that's not filtered out + bool found = false; + // Try the items first + for (items_t::iterator iit = mItems.begin(); iit != mItems.end(); ++iit) + { + LLFolderViewItem* itemp = (*iit); + found = (itemp->getFiltered(filter_generation)); + if (found) + break; + } + if (!found) + { + // If no item found, try the folders + for (folders_t::iterator fit = mFolders.begin(); fit != mFolders.end(); ++fit) + { + LLFolderViewFolder* folderp = (*fit); + found = ( folderp->getListener() + && (folderp->getFiltered(filter_generation) + || (folderp->getFilteredFolder(filter_generation) + && folderp->hasFilteredDescendants(filter_generation)))); + if (found) + break; + } + } + mHasVisibleChildren = found; + } // calculate height as a single item (without any children), and reshapes rectangle to match LLFolderViewItem::arrange( width, height, filter_generation ); -- cgit v1.2.3 From f0a1b43f2270cb8424409babf5ae88233cdd8f6c Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Thu, 1 Mar 2012 21:35:05 -0800 Subject: EXP-1841 : Use instance instead of getInstance on LLClipboard singleton. --- indra/llui/llclipboard.h | 2 +- indra/llui/lllineeditor.cpp | 12 ++++++------ indra/llui/llscrolllistctrl.cpp | 2 +- indra/llui/lltexteditor.cpp | 12 ++++++------ indra/newview/llfavoritesbar.cpp | 10 +++++----- indra/newview/llfloatergesture.cpp | 14 +++++++------- indra/newview/llfolderview.cpp | 10 +++++----- indra/newview/llinventorybridge.cpp | 32 ++++++++++++++++---------------- indra/newview/llinventoryfilter.cpp | 4 ++-- indra/newview/llinventorypanel.cpp | 8 ++++---- indra/newview/llpanelteleporthistory.cpp | 2 +- indra/newview/llpaneltopinfobar.cpp | 2 +- indra/newview/llpanelwearing.cpp | 2 +- indra/newview/llurllineeditorctrl.cpp | 2 +- 14 files changed, 57 insertions(+), 57 deletions(-) diff --git a/indra/llui/llclipboard.h b/indra/llui/llclipboard.h index 3947fa0229..e8a4f64035 100644 --- a/indra/llui/llclipboard.h +++ b/indra/llui/llclipboard.h @@ -42,7 +42,7 @@ typedef boost::function cleanup_callback_t; // Class LLClipboard // // This class is used to cut/copy/paste text strings and inventory items around -// the world. Use LLClipboard::getInstance()->method() to use its methods. +// the world. Use LLClipboard::instance().method() to use its methods. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ class LLClipboard : public LLSingleton diff --git a/indra/llui/lllineeditor.cpp b/indra/llui/lllineeditor.cpp index ff85afdf25..d0fbf4b913 100644 --- a/indra/llui/lllineeditor.cpp +++ b/indra/llui/lllineeditor.cpp @@ -1047,7 +1047,7 @@ void LLLineEditor::cut() // Prepare for possible rollback LLLineEditorRollback rollback( this ); - LLClipboard::getInstance()->copyToClipboard( mText.getWString(), left_pos, length ); + LLClipboard::instance().copyToClipboard( mText.getWString(), left_pos, length ); deleteSelection(); // Validate new string and rollback the if needed. @@ -1078,13 +1078,13 @@ void LLLineEditor::copy() { S32 left_pos = llmin( mSelectionStart, mSelectionEnd ); S32 length = llabs( mSelectionStart - mSelectionEnd ); - LLClipboard::getInstance()->copyToClipboard( mText.getWString(), left_pos, length ); + LLClipboard::instance().copyToClipboard( mText.getWString(), left_pos, length ); } } BOOL LLLineEditor::canPaste() const { - return !mReadOnly && LLClipboard::getInstance()->isTextAvailable(); + return !mReadOnly && LLClipboard::instance().isTextAvailable(); } void LLLineEditor::paste() @@ -1115,7 +1115,7 @@ void LLLineEditor::pasteHelper(bool is_primary) if (can_paste_it) { LLWString paste; - LLClipboard::getInstance()->pasteFromClipboard(paste, is_primary); + LLClipboard::instance().pasteFromClipboard(paste, is_primary); if (!paste.empty()) { @@ -1202,13 +1202,13 @@ void LLLineEditor::copyPrimary() { S32 left_pos = llmin( mSelectionStart, mSelectionEnd ); S32 length = llabs( mSelectionStart - mSelectionEnd ); - LLClipboard::getInstance()->copyToClipboard( mText.getWString(), left_pos, length, true); + LLClipboard::instance().copyToClipboard( mText.getWString(), left_pos, length, true); } } BOOL LLLineEditor::canPastePrimary() const { - return !mReadOnly && LLClipboard::getInstance()->isTextAvailable(true); + return !mReadOnly && LLClipboard::instance().isTextAvailable(true); } void LLLineEditor::updatePrimary() diff --git a/indra/llui/llscrolllistctrl.cpp b/indra/llui/llscrolllistctrl.cpp index 0a9d862b66..b3e1b63db5 100644 --- a/indra/llui/llscrolllistctrl.cpp +++ b/indra/llui/llscrolllistctrl.cpp @@ -2504,7 +2504,7 @@ void LLScrollListCtrl::copy() { buffer += (*itor)->getContentsCSV() + "\n"; } - LLClipboard::getInstance()->copyToClipboard(utf8str_to_wstring(buffer), 0, buffer.length()); + LLClipboard::instance().copyToClipboard(utf8str_to_wstring(buffer), 0, buffer.length()); } // virtual diff --git a/indra/llui/lltexteditor.cpp b/indra/llui/lltexteditor.cpp index 141602ad2e..9720dded6c 100644 --- a/indra/llui/lltexteditor.cpp +++ b/indra/llui/lltexteditor.cpp @@ -1332,7 +1332,7 @@ void LLTextEditor::cut() } S32 left_pos = llmin( mSelectionStart, mSelectionEnd ); S32 length = llabs( mSelectionStart - mSelectionEnd ); - LLClipboard::getInstance()->copyToClipboard( getWText(), left_pos, length); + LLClipboard::instance().copyToClipboard( getWText(), left_pos, length); deleteSelection( FALSE ); onKeyStroke(); @@ -1352,12 +1352,12 @@ void LLTextEditor::copy() } S32 left_pos = llmin( mSelectionStart, mSelectionEnd ); S32 length = llabs( mSelectionStart - mSelectionEnd ); - LLClipboard::getInstance()->copyToClipboard(getWText(), left_pos, length); + LLClipboard::instance().copyToClipboard(getWText(), left_pos, length); } BOOL LLTextEditor::canPaste() const { - return !mReadOnly && LLClipboard::getInstance()->isTextAvailable(); + return !mReadOnly && LLClipboard::instance().isTextAvailable(); } // paste from clipboard @@ -1394,7 +1394,7 @@ void LLTextEditor::pasteHelper(bool is_primary) } LLWString paste; - LLClipboard::getInstance()->pasteFromClipboard(paste, is_primary); + LLClipboard::instance().pasteFromClipboard(paste, is_primary); if (paste.empty()) { @@ -1467,12 +1467,12 @@ void LLTextEditor::copyPrimary() } S32 left_pos = llmin( mSelectionStart, mSelectionEnd ); S32 length = llabs( mSelectionStart - mSelectionEnd ); - LLClipboard::getInstance()->copyToClipboard(getWText(), left_pos, length, true); + LLClipboard::instance().copyToClipboard(getWText(), left_pos, length, true); } BOOL LLTextEditor::canPastePrimary() const { - return !mReadOnly && LLClipboard::getInstance()->isTextAvailable(true); + return !mReadOnly && LLClipboard::instance().isTextAvailable(true); } void LLTextEditor::updatePrimary() diff --git a/indra/newview/llfavoritesbar.cpp b/indra/newview/llfavoritesbar.cpp index d4bce1e3a1..575b613ccf 100644 --- a/indra/newview/llfavoritesbar.cpp +++ b/indra/newview/llfavoritesbar.cpp @@ -1118,7 +1118,7 @@ BOOL LLFavoritesBarCtrl::handleRightMouseDown(S32 x, S32 y, MASK mask) } void copy_slurl_to_clipboard_cb(std::string& slurl) { - LLClipboard::getInstance()->copyToClipboard(utf8str_to_wstring(slurl),0,slurl.size()); + LLClipboard::instance().copyToClipboard(utf8str_to_wstring(slurl),0,slurl.size()); LLSD args; args["SLURL"] = slurl; @@ -1187,7 +1187,7 @@ void LLFavoritesBarCtrl::doToSelected(const LLSD& userdata) } else if (action == "copy") { - LLClipboard::getInstance()->copyToClipboard(mSelectedItemID, LLAssetType::AT_LANDMARK); + LLClipboard::instance().copyToClipboard(mSelectedItemID, LLAssetType::AT_LANDMARK); } else if (action == "paste") { @@ -1211,13 +1211,13 @@ void LLFavoritesBarCtrl::doToSelected(const LLSD& userdata) BOOL LLFavoritesBarCtrl::isClipboardPasteable() const { - if (!LLClipboard::getInstance()->hasContents()) + if (!LLClipboard::instance().hasContents()) { return FALSE; } LLDynamicArray objects; - LLClipboard::getInstance()->pasteFromClipboard(objects); + LLClipboard::instance().pasteFromClipboard(objects); S32 count = objects.count(); for(S32 i = 0; i < count; i++) { @@ -1246,7 +1246,7 @@ void LLFavoritesBarCtrl::pastFromClipboard() const { LLInventoryItem* item = NULL; LLDynamicArray objects; - LLClipboard::getInstance()->pasteFromClipboard(objects); + LLClipboard::instance().pasteFromClipboard(objects); S32 count = objects.count(); LLUUID parent_id(mFavoriteFolderId); for(S32 i = 0; i < count; i++) diff --git a/indra/newview/llfloatergesture.cpp b/indra/newview/llfloatergesture.cpp index 7791d4688b..56051ff684 100644 --- a/indra/newview/llfloatergesture.cpp +++ b/indra/newview/llfloatergesture.cpp @@ -397,11 +397,11 @@ bool LLFloaterGesture::isActionEnabled(const LLSD& command) std::string command_name = command.asString(); if("paste" == command_name) { - if(!LLClipboard::getInstance()->hasContents()) + if(!LLClipboard::instance().hasContents()) return false; LLDynamicArray ids; - LLClipboard::getInstance()->pasteFromClipboard(ids); + LLClipboard::instance().pasteFromClipboard(ids); for(LLDynamicArray::iterator it = ids.begin(); it != ids.end(); it++) { LLInventoryItem* item = gInventory.getItem(*it); @@ -502,20 +502,20 @@ void LLFloaterGesture::onCopyPasteAction(const LLSD& command) uuid_vec_t ids; getSelectedIds(ids); // Make sure the clipboard is empty - LLClipboard::getInstance()->reset(); + LLClipboard::instance().reset(); for(uuid_vec_t::iterator it = ids.begin(); it != ids.end(); it++) { LLInventoryItem* item = gInventory.getItem(*it); if(item && item->getInventoryType() == LLInventoryType::IT_GESTURE) { - LLClipboard::getInstance()->addToClipboard(item->getUUID(),LLAssetType::AT_GESTURE); + LLClipboard::instance().addToClipboard(item->getUUID(),LLAssetType::AT_GESTURE); } } } else if ("paste" == command_name) { LLDynamicArray ids; - LLClipboard::getInstance()->pasteFromClipboard(ids); + LLClipboard::instance().pasteFromClipboard(ids); if(ids.empty() || !gInventory.isCategoryComplete(mGestureFolderID)) return; LLInventoryCategory* gesture_dir = gInventory.getCategory(mGestureFolderID); @@ -535,11 +535,11 @@ void LLFloaterGesture::onCopyPasteAction(const LLSD& command) gesture_dir->getUUID(), getString("copy_name", string_args), cb); } } - LLClipboard::getInstance()->reset(); + LLClipboard::instance().reset(); } else if ("copy_uuid" == command_name) { - LLClipboard::getInstance()->copyToClipboard(mGestureList->getCurrentID(),LLAssetType::AT_GESTURE); + LLClipboard::instance().copyToClipboard(mGestureList->getCurrentID(),LLAssetType::AT_GESTURE); } } diff --git a/indra/newview/llfolderview.cpp b/indra/newview/llfolderview.cpp index c0db2e366c..d9c6f4d9ce 100644 --- a/indra/newview/llfolderview.cpp +++ b/indra/newview/llfolderview.cpp @@ -1018,12 +1018,12 @@ bool isDescendantOfASelectedItem(LLFolderViewItem* item, const std::vector exit - if (!LLClipboard::getInstance()->isCutMode()) + if (!LLClipboard::instance().isCutMode()) return; // Get the list of clipboard item uuids and iterate through them LLDynamicArray objects; - LLClipboard::getInstance()->pasteFromClipboard(objects); + LLClipboard::instance().pasteFromClipboard(objects); for (LLDynamicArray::const_iterator iter = objects.begin(); iter != objects.end(); ++iter) @@ -1323,7 +1323,7 @@ BOOL LLFolderView::canCopy() const void LLFolderView::copy() { // *NOTE: total hack to clear the inventory clipboard - LLClipboard::getInstance()->reset(); + LLClipboard::instance().reset(); S32 count = mSelectedItems.size(); if(getVisible() && getEnabled() && (count > 0)) { @@ -1364,7 +1364,7 @@ BOOL LLFolderView::canCut() const void LLFolderView::cut() { // clear the inventory clipboard - LLClipboard::getInstance()->reset(); + LLClipboard::instance().reset(); S32 count = mSelectedItems.size(); if(getVisible() && getEnabled() && (count > 0)) { @@ -2141,7 +2141,7 @@ bool LLFolderView::doToSelected(LLInventoryModel* model, const LLSD& userdata) if (("copy" == action) || ("cut" == action)) { // Clear the clipboard before we start adding things on it - LLClipboard::getInstance()->reset(); + LLClipboard::instance().reset(); } static const std::string change_folder_string = "change_folder_type_"; diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index d55fb6a089..3001a998aa 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -220,8 +220,8 @@ BOOL LLInvFVBridge::cutToClipboard() const const LLInventoryObject* obj = gInventory.getObject(mUUID); if (obj && isItemMovable() && isItemRemovable()) { - LLClipboard::getInstance()->setCutMode(true, boost::bind(LLFolderView::removeCutItems)); - return LLClipboard::getInstance()->addToClipboard(mUUID); + LLClipboard::instance().setCutMode(true, boost::bind(LLFolderView::removeCutItems)); + return LLClipboard::instance().addToClipboard(mUUID); } return FALSE; } @@ -231,7 +231,7 @@ BOOL LLInvFVBridge::copyToClipboard() const const LLInventoryObject* obj = gInventory.getObject(mUUID); if (obj && isItemCopyable()) { - return LLClipboard::getInstance()->addToClipboard(mUUID); + return LLClipboard::instance().addToClipboard(mUUID); } return FALSE; } @@ -419,7 +419,7 @@ void LLInvFVBridge::removeBatchNoCheck(LLDynamicArrayhasContents() || !isAgentInventory()) + if (!LLClipboard::instance().hasContents() || !isAgentInventory()) { return FALSE; } @@ -430,7 +430,7 @@ BOOL LLInvFVBridge::isClipboardPasteable() const } LLDynamicArray objects; - LLClipboard::getInstance()->pasteFromClipboard(objects); + LLClipboard::instance().pasteFromClipboard(objects); S32 count = objects.count(); for(S32 i = 0; i < count; i++) { @@ -457,7 +457,7 @@ BOOL LLInvFVBridge::isClipboardPasteable() const BOOL LLInvFVBridge::isClipboardPasteableAsLink() const { - if (!LLClipboard::getInstance()->hasContents() || !isAgentInventory()) + if (!LLClipboard::instance().hasContents() || !isAgentInventory()) { return FALSE; } @@ -468,7 +468,7 @@ BOOL LLInvFVBridge::isClipboardPasteableAsLink() const } LLDynamicArray objects; - LLClipboard::getInstance()->pasteFromClipboard(objects); + LLClipboard::instance().pasteFromClipboard(objects); S32 count = objects.count(); for(S32 i = 0; i < count; i++) { @@ -643,7 +643,7 @@ void LLInvFVBridge::getClipboardEntries(bool show_asset_id, { items.push_back(std::string("Paste")); } - if ((!LLClipboard::getInstance()->isCutMode() && !isClipboardPasteable()) || ((flags & FIRST_SELECTED_ITEM) == 0)) + if ((!LLClipboard::instance().isCutMode() && !isClipboardPasteable()) || ((flags & FIRST_SELECTED_ITEM) == 0)) { disabled_items.push_back(std::string("Paste")); } @@ -1833,7 +1833,7 @@ BOOL LLFolderBridge::isClipboardPasteable() const } LLDynamicArray objects; - LLClipboard::getInstance()->pasteFromClipboard(objects); + LLClipboard::instance().pasteFromClipboard(objects); const LLViewerInventoryCategory *current_cat = getCategory(); // Search for the direct descendent of current Friends subfolder among all pasted items, @@ -1871,7 +1871,7 @@ BOOL LLFolderBridge::isClipboardPasteableAsLink() const const BOOL is_in_friend_folder = LLFriendCardsManager::instance().isCategoryInFriendFolder( current_cat ); const LLUUID ¤t_cat_id = current_cat->getUUID(); LLDynamicArray objects; - LLClipboard::getInstance()->pasteFromClipboard(objects); + LLClipboard::instance().pasteFromClipboard(objects); S32 count = objects.count(); for(S32 i = 0; i < count; i++) { @@ -2910,7 +2910,7 @@ bool LLFolderBridge::removeItemResponse(const LLSD& notification, const LLSD& re void LLFolderBridge::pasteFromClipboard() { LLInventoryModel* model = getInventoryModel(); - if (model && (isClipboardPasteable() || LLClipboard::getInstance()->isCutMode())) + if (model && (isClipboardPasteable() || LLClipboard::instance().isCutMode())) { const LLUUID ¤t_outfit_id = model->findCategoryUUIDForType(LLFolderType::FT_CURRENT_OUTFIT, false); const LLUUID &outbox_id = model->findCategoryUUIDForType(LLFolderType::FT_OUTBOX, false); @@ -2920,7 +2920,7 @@ void LLFolderBridge::pasteFromClipboard() const BOOL move_is_into_outbox = model->isObjectDescendentOf(mUUID, outbox_id); LLDynamicArray objects; - LLClipboard::getInstance()->pasteFromClipboard(objects); + LLClipboard::instance().pasteFromClipboard(objects); if (move_is_into_outbox) { @@ -2980,7 +2980,7 @@ void LLFolderBridge::pasteFromClipboard() dropToOutfit(item, move_is_into_current_outfit); } } - else if (LLClipboard::getInstance()->isCutMode()) + else if (LLClipboard::instance().isCutMode()) { // Do a move to "paste" a "cut" // move_inventory_item() is not enough, as we have to update inventory locally too @@ -3029,7 +3029,7 @@ void LLFolderBridge::pasteFromClipboard() } } // Change mode to paste for next paste - LLClipboard::getInstance()->setCutMode(false); + LLClipboard::instance().setCutMode(false); } } @@ -3054,7 +3054,7 @@ void LLFolderBridge::pasteLinkFromClipboard() const LLUUID parent_id(mUUID); LLDynamicArray objects; - LLClipboard::getInstance()->pasteFromClipboard(objects); + LLClipboard::instance().pasteFromClipboard(objects); for (LLDynamicArray::const_iterator iter = objects.begin(); iter != objects.end(); ++iter) @@ -3093,7 +3093,7 @@ void LLFolderBridge::pasteLinkFromClipboard() } } // Change mode to paste for next paste - LLClipboard::getInstance()->setCutMode(false); + LLClipboard::instance().setCutMode(false); } } diff --git a/indra/newview/llinventoryfilter.cpp b/indra/newview/llinventoryfilter.cpp index c127d7ac88..ccb9e74a8e 100644 --- a/indra/newview/llinventoryfilter.cpp +++ b/indra/newview/llinventoryfilter.cpp @@ -322,13 +322,13 @@ bool LLInventoryFilter::checkAgainstFilterType(const LLInventoryItem* item) cons // is on the clipboard must be filtered out if the clipboard is in the "cut" mode. bool LLInventoryFilter::checkAgainstClipboard(const LLUUID& object_id) const { - if (LLClipboard::getInstance()->isCutMode()) + if (LLClipboard::instance().isCutMode()) { LLUUID current_id = object_id; LLInventoryObject *current_object = gInventory.getObject(object_id); while (current_id.notNull() && current_object) { - if (LLClipboard::getInstance()->isOnClipboard(current_id)) + if (LLClipboard::instance().isOnClipboard(current_id)) { return false; } diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp index a1e17ffbf2..b7e2e8c67c 100644 --- a/indra/newview/llinventorypanel.cpp +++ b/indra/newview/llinventorypanel.cpp @@ -249,7 +249,7 @@ void LLInventoryPanel::initFromParams(const LLInventoryPanel::Params& params) } // keep track of the clipboard state so that we avoid filtering too much - mClipboardState = LLClipboard::getInstance()->getState(); + mClipboardState = LLClipboard::instance().getState(); // Initialize base class params. LLPanel::initFromParams(params); @@ -283,10 +283,10 @@ void LLInventoryPanel::draw() mFolderRoot->updateSelection(); // Nudge the filter if the clipboard state changed - if (mClipboardState != LLClipboard::getInstance()->getState()) + if (mClipboardState != LLClipboard::instance().getState()) { - mClipboardState = LLClipboard::getInstance()->getState(); - getFilter()->setModified(LLClipboard::getInstance()->isCutMode() ? LLInventoryFilter::FILTER_MORE_RESTRICTIVE : LLInventoryFilter::FILTER_LESS_RESTRICTIVE); + mClipboardState = LLClipboard::instance().getState(); + getFilter()->setModified(LLClipboard::instance().isCutMode() ? LLInventoryFilter::FILTER_MORE_RESTRICTIVE : LLInventoryFilter::FILTER_LESS_RESTRICTIVE); } LLPanel::draw(); diff --git a/indra/newview/llpanelteleporthistory.cpp b/indra/newview/llpanelteleporthistory.cpp index f92fbf3220..c63d89fc98 100644 --- a/indra/newview/llpanelteleporthistory.cpp +++ b/indra/newview/llpanelteleporthistory.cpp @@ -358,7 +358,7 @@ void LLTeleportHistoryPanel::ContextMenu::onInfo() //static void LLTeleportHistoryPanel::ContextMenu::gotSLURLCallback(const std::string& slurl) { - LLClipboard::getInstance()->copyToClipboard(utf8str_to_wstring(slurl),0,slurl.size()); + LLClipboard::instance().copyToClipboard(utf8str_to_wstring(slurl),0,slurl.size()); } void LLTeleportHistoryPanel::ContextMenu::onCopyToClipboard() diff --git a/indra/newview/llpaneltopinfobar.cpp b/indra/newview/llpaneltopinfobar.cpp index 0ad207ef00..280cc11179 100644 --- a/indra/newview/llpaneltopinfobar.cpp +++ b/indra/newview/llpaneltopinfobar.cpp @@ -467,7 +467,7 @@ void LLPanelTopInfoBar::onContextMenuItemClicked(const LLSD::String& item) LLAgentUI::buildSLURL(slurl, false); LLUIString location_str(slurl.getSLURLString()); - LLClipboard::getInstance()->copyToClipboard(location_str,0,location_str.length()); + LLClipboard::instance().copyToClipboard(location_str,0,location_str.length()); } } diff --git a/indra/newview/llpanelwearing.cpp b/indra/newview/llpanelwearing.cpp index 5199bcb6b1..3b9934d4be 100644 --- a/indra/newview/llpanelwearing.cpp +++ b/indra/newview/llpanelwearing.cpp @@ -302,6 +302,6 @@ void LLPanelWearing::copyToClipboard() } } - LLClipboard::getInstance()->copyToClipboard(utf8str_to_wstring(text),0,text.size()); + LLClipboard::instance().copyToClipboard(utf8str_to_wstring(text),0,text.size()); } // EOF diff --git a/indra/newview/llurllineeditorctrl.cpp b/indra/newview/llurllineeditorctrl.cpp index 3efebcade9..cad5769042 100644 --- a/indra/newview/llurllineeditorctrl.cpp +++ b/indra/newview/llurllineeditorctrl.cpp @@ -89,5 +89,5 @@ void LLURLLineEditor::copyEscapedURLToClipboard() else // human-readable location text_to_copy = utf8str_to_wstring(unescaped_text); - LLClipboard::getInstance()->copyToClipboard(text_to_copy, 0, text_to_copy.size()); + LLClipboard::instance().copyToClipboard(text_to_copy, 0, text_to_copy.size()); } -- cgit v1.2.3 From 44c66e11ccee4f8370dc9cf2a87c44e323c9c68d Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Thu, 1 Mar 2012 21:57:16 -0800 Subject: EXP-1841 : Use std::vector instead of LLDynamicArray in LLClipboard. --- indra/llui/llclipboard.cpp | 17 +++++++++-------- indra/llui/llclipboard.h | 4 ++-- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/indra/llui/llclipboard.cpp b/indra/llui/llclipboard.cpp index e0729366cc..037b9cb254 100644 --- a/indra/llui/llclipboard.cpp +++ b/indra/llui/llclipboard.cpp @@ -55,7 +55,7 @@ void LLClipboard::reset() mCleanupCallback(); } // Clear the clipboard - mObjects.reset(); + mObjects.clear(); mCutMode = false; mCleanupCallback = NULL; mString = LLWString(); @@ -83,24 +83,24 @@ bool LLClipboard::addToClipboard(const LLUUID& src, const LLAssetType::EType typ } if (res) { - mObjects.put(src); + mObjects.push_back(src); mState++; } } return res; } -bool LLClipboard::pasteFromClipboard(LLDynamicArray& inv_objects) const +bool LLClipboard::pasteFromClipboard(std::vector& inv_objects) const { bool res = false; - S32 count = mObjects.count(); + S32 count = mObjects.size(); if (count > 0) { res = true; - inv_objects.reset(); + inv_objects.clear(); for (S32 i = 0; i < count; i++) { - inv_objects.put(mObjects[i]); + inv_objects.push_back(mObjects[i]); } } return res; @@ -109,13 +109,14 @@ bool LLClipboard::pasteFromClipboard(LLDynamicArray& inv_objects) const // Returns true if the LL Clipboard has pasteable items in it bool LLClipboard::hasContents() const { - return (mObjects.count() > 0); + return (mObjects.size() > 0); } // Returns true if the input uuid is in the list of clipboard objects bool LLClipboard::isOnClipboard(const LLUUID& object) const { - return (mObjects.find(object) != LLDynamicArray::FAIL); + std::vector::const_iterator iter = std::find(mObjects.begin(), mObjects.end(), object); + return (iter != mObjects.end()); } // Copy the input string to the LL and the system clipboard diff --git a/indra/llui/llclipboard.h b/indra/llui/llclipboard.h index e8a4f64035..50b4c7cd77 100644 --- a/indra/llui/llclipboard.h +++ b/indra/llui/llclipboard.h @@ -74,7 +74,7 @@ public: // Adds one object to the current list of objects on the clipboard bool addToClipboard(const LLUUID& src, const LLAssetType::EType type = LLAssetType::AT_NONE); // Gets a copy of the objects on the clipboard - bool pasteFromClipboard(LLDynamicArray& inventory_objects) const; + bool pasteFromClipboard(std::vector& inventory_objects) const; bool hasContents() const; // True if the clipboard has pasteable objects bool isOnClipboard(const LLUUID& object) const; // True if the input object uuid is on the clipboard @@ -83,7 +83,7 @@ public: void setCutMode(bool mode, cleanup_callback_t cb = NULL) { mCutMode = mode; mCleanupCallback = cb; mState++; } private: - LLDynamicArray mObjects; // Objects on the clipboard. Can be empty while mString contains something licit (e.g. text from chat) + std::vector mObjects; // Objects on the clipboard. Can be empty while mString contains something licit (e.g. text from chat) LLWString mString; // The text string. If mObjects is not empty, this string is reflecting them (UUIDs for the moment). bool mCutMode; // This is a convenience flag for the viewer. Will determine if mCleanupCallback() needs to be called. cleanup_callback_t mCleanupCallback;// Function to call when the cut clipboard is being wiped out. Can be set to NULL (nothing done then). -- cgit v1.2.3 From a41507eef0a79731d1894ccf3179da6165f310ab Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Thu, 1 Mar 2012 23:10:06 -0800 Subject: EXP-1841 : change mState to mGeneration in LLClipboard. --- indra/llui/llclipboard.cpp | 10 +++++----- indra/llui/llclipboard.h | 9 ++++----- indra/newview/llinventorypanel.cpp | 6 +++--- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/indra/llui/llclipboard.cpp b/indra/llui/llclipboard.cpp index 037b9cb254..75c197463c 100644 --- a/indra/llui/llclipboard.cpp +++ b/indra/llui/llclipboard.cpp @@ -35,7 +35,7 @@ #include "llwindow.h" LLClipboard::LLClipboard() : - mState(0) + mGeneration(0) { reset(); } @@ -47,8 +47,8 @@ LLClipboard::~LLClipboard() void LLClipboard::reset() { - // Increment the clipboard state - mState++; + // Increment the clipboard count + mGeneration++; // Call the cleanup function (if any) before releasing the object list if (mCutMode && mCleanupCallback) { @@ -84,7 +84,7 @@ bool LLClipboard::addToClipboard(const LLUUID& src, const LLAssetType::EType typ if (res) { mObjects.push_back(src); - mState++; + mGeneration++; } } return res; @@ -138,7 +138,7 @@ bool LLClipboard::addToClipboard(const LLWString &src, S32 pos, S32 len, bool us { mString = mString + sep + src.substr(pos, len); } - mState++; + mGeneration++; return (use_primary ? LLView::getWindow()->copyTextToPrimary(mString) : LLView::getWindow()->copyTextToClipboard(mString)); } diff --git a/indra/llui/llclipboard.h b/indra/llui/llclipboard.h index 50b4c7cd77..8b5a2260ae 100644 --- a/indra/llui/llclipboard.h +++ b/indra/llui/llclipboard.h @@ -54,7 +54,7 @@ public: // Clears the clipboard void reset(); // Returns the state of the clipboard so client can know if it has been modified (comparing with tracked state) - int getState() const { return mState; } + int getGeneration() const { return mGeneration; } // Text strings management: // ------------------------ @@ -80,15 +80,14 @@ public: bool isOnClipboard(const LLUUID& object) const; // True if the input object uuid is on the clipboard bool isCutMode() const { return mCutMode; } - void setCutMode(bool mode, cleanup_callback_t cb = NULL) { mCutMode = mode; mCleanupCallback = cb; mState++; } + void setCutMode(bool mode, cleanup_callback_t cb = NULL) { mCutMode = mode; mCleanupCallback = cb; mGeneration++; } private: - std::vector mObjects; // Objects on the clipboard. Can be empty while mString contains something licit (e.g. text from chat) + std::vector mObjects; // Objects on the clipboard. Can be empty while mString contains something licit (e.g. text from chat) LLWString mString; // The text string. If mObjects is not empty, this string is reflecting them (UUIDs for the moment). bool mCutMode; // This is a convenience flag for the viewer. Will determine if mCleanupCallback() needs to be called. cleanup_callback_t mCleanupCallback;// Function to call when the cut clipboard is being wiped out. Can be set to NULL (nothing done then). - int mState; // Incremented when the clipboard change so that interested parties can check its state. - + int mGeneration; // Incremented when the clipboard changes so that interested parties can check for changes on the clipboard. }; #endif // LL_LLCLIPBOARD_H diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp index b7e2e8c67c..b417689858 100644 --- a/indra/newview/llinventorypanel.cpp +++ b/indra/newview/llinventorypanel.cpp @@ -249,7 +249,7 @@ void LLInventoryPanel::initFromParams(const LLInventoryPanel::Params& params) } // keep track of the clipboard state so that we avoid filtering too much - mClipboardState = LLClipboard::instance().getState(); + mClipboardState = LLClipboard::instance().getGeneration(); // Initialize base class params. LLPanel::initFromParams(params); @@ -283,9 +283,9 @@ void LLInventoryPanel::draw() mFolderRoot->updateSelection(); // Nudge the filter if the clipboard state changed - if (mClipboardState != LLClipboard::instance().getState()) + if (mClipboardState != LLClipboard::instance().getGeneration()) { - mClipboardState = LLClipboard::instance().getState(); + mClipboardState = LLClipboard::instance().getGeneration(); getFilter()->setModified(LLClipboard::instance().isCutMode() ? LLInventoryFilter::FILTER_MORE_RESTRICTIVE : LLInventoryFilter::FILTER_LESS_RESTRICTIVE); } -- cgit v1.2.3 From 652c67c2bcf077e580d734f68f5d9c374ed91b5d Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Fri, 2 Mar 2012 17:36:59 -0800 Subject: EXP-1911 : Fix the filter resetting, using U64 values where needed. --- indra/newview/llinventoryfilter.cpp | 7 +++++-- indra/newview/llpanelmaininventory.cpp | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/indra/newview/llinventoryfilter.cpp b/indra/newview/llinventoryfilter.cpp index ccb9e74a8e..b5062e65b5 100644 --- a/indra/newview/llinventoryfilter.cpp +++ b/indra/newview/llinventoryfilter.cpp @@ -42,6 +42,8 @@ #include "llclipboard.h" #include "lltrans.h" +LLFastTimer::DeclareTimer FT_FILTER_CLIPBOARD("Filter Clipboard"); + LLInventoryFilter::FilterOps::FilterOps() : mFilterObjectTypes(0xffffffffffffffffULL), mFilterCategoryTypes(0xffffffffffffffffULL), @@ -324,6 +326,7 @@ bool LLInventoryFilter::checkAgainstClipboard(const LLUUID& object_id) const { if (LLClipboard::instance().isCutMode()) { + LLFastTimer ft(FT_FILTER_CLIPBOARD); LLUUID current_id = object_id; LLInventoryObject *current_object = gInventory.getObject(object_id); while (current_id.notNull() && current_object) @@ -412,7 +415,7 @@ BOOL LLInventoryFilter::isNotDefault() const not_default |= (mFilterOps.mMinDate != mDefaultFilterOps.mMinDate); not_default |= (mFilterOps.mMaxDate != mDefaultFilterOps.mMaxDate); not_default |= (mFilterOps.mHoursAgo != mDefaultFilterOps.mHoursAgo); - + return not_default; } @@ -998,7 +1001,7 @@ void LLInventoryFilter::fromLLSD(LLSD& data) { if(data.has("filter_types")) { - setFilterObjectTypes((U32)data["filter_types"].asInteger()); + setFilterObjectTypes((U64)data["filter_types"].asInteger()); } if(data.has("min_date") && data.has("max_date")) diff --git a/indra/newview/llpanelmaininventory.cpp b/indra/newview/llpanelmaininventory.cpp index c3c62920d3..c11597f532 100644 --- a/indra/newview/llpanelmaininventory.cpp +++ b/indra/newview/llpanelmaininventory.cpp @@ -375,7 +375,7 @@ void LLPanelMainInventory::onClearSearch() if (mActivePanel) { mActivePanel->setFilterSubString(LLStringUtil::null); - mActivePanel->setFilterTypes(0xffffffff); + mActivePanel->setFilterTypes(0xffffffffffffffffULL); mActivePanel->setFilterLinks(LLInventoryFilter::FILTERLINK_INCLUDE_LINKS); } @@ -726,7 +726,7 @@ void LLFloaterInventoryFinder::updateElementsFromFilter() void LLFloaterInventoryFinder::draw() { LLMemType mt(LLMemType::MTYPE_INVENTORY_DRAW); - U32 filter = 0xffffffff; + U64 filter = 0xffffffffffffffffULL; BOOL filtered_by_all_types = TRUE; if (!getChild("check_animation")->getValue()) -- cgit v1.2.3 From a56290f408cbae4c947a0e2f6ec1ad0e6baff60a Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Mon, 5 Mar 2012 17:32:20 -0800 Subject: EXP-1912 : Fix filtering of folders when those are being cut. --- indra/newview/llfolderview.cpp | 9 +++++++-- indra/newview/llinventoryfilter.cpp | 18 ++++++++++-------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/indra/newview/llfolderview.cpp b/indra/newview/llfolderview.cpp index d9c6f4d9ce..ec954ac881 100644 --- a/indra/newview/llfolderview.cpp +++ b/indra/newview/llfolderview.cpp @@ -429,8 +429,13 @@ S32 LLFolderView::arrange( S32* unused_width, S32* unused_height, S32 filter_gen } else { - folderp->setVisible(show_folder_state == LLInventoryFilter::SHOW_ALL_FOLDERS || // always show folders? - (folderp->getFiltered(filter_generation) || folderp->hasFilteredDescendants(filter_generation))); // passed filter or has descendants that passed filter + bool visible = (show_folder_state == LLInventoryFilter::SHOW_ALL_FOLDERS || // always show folders? + (folderp->getFiltered(filter_generation) || folderp->hasFilteredDescendants(filter_generation))); + if (getFilter()) + { + visible &= getFilter()->check(folderp); + } + folderp->setVisible(visible); } if (folderp->getVisible()) diff --git a/indra/newview/llinventoryfilter.cpp b/indra/newview/llinventoryfilter.cpp index b5062e65b5..e859535d18 100644 --- a/indra/newview/llinventoryfilter.cpp +++ b/indra/newview/llinventoryfilter.cpp @@ -91,20 +91,22 @@ LLInventoryFilter::~LLInventoryFilter() BOOL LLInventoryFilter::check(const LLFolderViewItem* item) { - // If it's a folder and we're showing all folders, return TRUE automatically. + // Clipboard cut items are *always* filtered so we need this value upfront + const LLFolderViewEventListener* listener = item->getListener(); + const BOOL passed_clipboard = (listener ? checkAgainstClipboard(listener->getUUID()) : TRUE); + + // If it's a folder and we're showing all folders, return automatically. const BOOL is_folder = (dynamic_cast(item) != NULL); if (is_folder && (mFilterOps.mShowFolderState == LLInventoryFilter::SHOW_ALL_FOLDERS)) { - return TRUE; + return passed_clipboard; } mSubStringMatchOffset = mFilterSubString.size() ? item->getSearchableLabel().find(mFilterSubString) : std::string::npos; - const LLFolderViewEventListener* listener = item->getListener(); const BOOL passed_filtertype = checkAgainstFilterType(item); const BOOL passed_permissions = checkAgainstPermissions(item); const BOOL passed_filterlink = checkAgainstFilterLinks(item); - const BOOL passed_clipboard = (listener ? checkAgainstClipboard(listener->getUUID()) : TRUE); const BOOL passed = (passed_filtertype && passed_permissions && passed_filterlink && @@ -153,10 +155,13 @@ bool LLInventoryFilter::checkFolder(const LLFolderViewFolder* folder) const bool LLInventoryFilter::checkFolder(const LLUUID& folder_id) const { + // Always check against the clipboard + const BOOL passed_clipboard = checkAgainstClipboard(folder_id); + // we're showing all folders, overriding filter if (mFilterOps.mShowFolderState == LLInventoryFilter::SHOW_ALL_FOLDERS) { - return true; + return passed_clipboard; } if (mFilterOps.mFilterTypes & FILTERTYPE_CATEGORY) @@ -171,9 +176,6 @@ bool LLInventoryFilter::checkFolder(const LLUUID& folder_id) const return false; } - // Always check against the clipboard - const BOOL passed_clipboard = checkAgainstClipboard(folder_id); - return passed_clipboard; } -- cgit v1.2.3 From 85d380b210ebb609f6fc273918e06007c9da1950 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Mon, 5 Mar 2012 20:03:21 -0800 Subject: EXP-1917 : Fix items coming back in folders when quit after cut. --- indra/newview/llfolderview.cpp | 1 + indra/newview/llinventorybridge.cpp | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/indra/newview/llfolderview.cpp b/indra/newview/llfolderview.cpp index ec954ac881..99a3d65c6f 100644 --- a/indra/newview/llfolderview.cpp +++ b/indra/newview/llfolderview.cpp @@ -1383,6 +1383,7 @@ void LLFolderView::cut() listener->cutToClipboard(); } } + LLFolderView::removeCutItems(); } mSearchString.clear(); } diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index 3001a998aa..49eb8db5be 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -220,7 +220,7 @@ BOOL LLInvFVBridge::cutToClipboard() const const LLInventoryObject* obj = gInventory.getObject(mUUID); if (obj && isItemMovable() && isItemRemovable()) { - LLClipboard::instance().setCutMode(true, boost::bind(LLFolderView::removeCutItems)); + LLClipboard::instance().setCutMode(true); return LLClipboard::instance().addToClipboard(mUUID); } return FALSE; @@ -1307,6 +1307,7 @@ void LLItemBridge::performAction(LLInventoryModel* model, std::string action) else if ("cut" == action) { cutToClipboard(); + LLFolderView::removeCutItems(); return; } else if ("copy" == action) @@ -2697,6 +2698,7 @@ void LLFolderBridge::performAction(LLInventoryModel* model, std::string action) else if ("cut" == action) { cutToClipboard(); + LLFolderView::removeCutItems(); return; } else if ("copy" == action) -- cgit v1.2.3 From 45f5a027f64ca1e16059757353d9d206160ed66f Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Wed, 7 Mar 2012 15:37:52 -0800 Subject: EXP-1912 : Fix the substring filtering I broke while trying to fix 1912 the first time around. --- indra/newview/llfolderview.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/indra/newview/llfolderview.cpp b/indra/newview/llfolderview.cpp index 99a3d65c6f..3103267b35 100644 --- a/indra/newview/llfolderview.cpp +++ b/indra/newview/llfolderview.cpp @@ -429,13 +429,8 @@ S32 LLFolderView::arrange( S32* unused_width, S32* unused_height, S32 filter_gen } else { - bool visible = (show_folder_state == LLInventoryFilter::SHOW_ALL_FOLDERS || // always show folders? - (folderp->getFiltered(filter_generation) || folderp->hasFilteredDescendants(filter_generation))); - if (getFilter()) - { - visible &= getFilter()->check(folderp); - } - folderp->setVisible(visible); + folderp->setVisible((show_folder_state == LLInventoryFilter::SHOW_ALL_FOLDERS || // always show folders? + (folderp->getFiltered(filter_generation) || folderp->hasFilteredDescendants(filter_generation)))); } if (folderp->getVisible()) -- cgit v1.2.3 From 5170f18d3cecc757cae2779d9e271272e24d160b Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Thu, 8 Mar 2012 21:06:00 -0800 Subject: EXP-1917 : Suppress clean up callback now that we move things to the trash immediately --- indra/llui/llclipboard.cpp | 6 ------ indra/llui/llclipboard.h | 7 ++----- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/indra/llui/llclipboard.cpp b/indra/llui/llclipboard.cpp index 75c197463c..cc5b219e6f 100644 --- a/indra/llui/llclipboard.cpp +++ b/indra/llui/llclipboard.cpp @@ -49,15 +49,9 @@ void LLClipboard::reset() { // Increment the clipboard count mGeneration++; - // Call the cleanup function (if any) before releasing the object list - if (mCutMode && mCleanupCallback) - { - mCleanupCallback(); - } // Clear the clipboard mObjects.clear(); mCutMode = false; - mCleanupCallback = NULL; mString = LLWString(); } diff --git a/indra/llui/llclipboard.h b/indra/llui/llclipboard.h index 8b5a2260ae..7f31f66bbe 100644 --- a/indra/llui/llclipboard.h +++ b/indra/llui/llclipboard.h @@ -36,8 +36,6 @@ #include "llassettype.h" #include "llinventory.h" -typedef boost::function cleanup_callback_t; - //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Class LLClipboard // @@ -80,13 +78,12 @@ public: bool isOnClipboard(const LLUUID& object) const; // True if the input object uuid is on the clipboard bool isCutMode() const { return mCutMode; } - void setCutMode(bool mode, cleanup_callback_t cb = NULL) { mCutMode = mode; mCleanupCallback = cb; mGeneration++; } + void setCutMode(bool mode) { mCutMode = mode; mGeneration++; } private: std::vector mObjects; // Objects on the clipboard. Can be empty while mString contains something licit (e.g. text from chat) LLWString mString; // The text string. If mObjects is not empty, this string is reflecting them (UUIDs for the moment). - bool mCutMode; // This is a convenience flag for the viewer. Will determine if mCleanupCallback() needs to be called. - cleanup_callback_t mCleanupCallback;// Function to call when the cut clipboard is being wiped out. Can be set to NULL (nothing done then). + bool mCutMode; // This is a convenience flag for the viewer. int mGeneration; // Incremented when the clipboard changes so that interested parties can check for changes on the clipboard. }; -- cgit v1.2.3 From 5cf3f8e3c813d978f318fd59ad422c75b3e171cd Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Fri, 9 Mar 2012 14:20:31 -0800 Subject: EXP-1913 : Prevent text clipboard to zap inventory clipboard --- indra/llui/llclipboard.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/indra/llui/llclipboard.cpp b/indra/llui/llclipboard.cpp index cc5b219e6f..53b1b855de 100644 --- a/indra/llui/llclipboard.cpp +++ b/indra/llui/llclipboard.cpp @@ -116,7 +116,6 @@ bool LLClipboard::isOnClipboard(const LLUUID& object) const // Copy the input string to the LL and the system clipboard bool LLClipboard::copyToClipboard(const LLWString &src, S32 pos, S32 len, bool use_primary) { - reset(); return addToClipboard(src, pos, len, use_primary); } @@ -132,7 +131,6 @@ bool LLClipboard::addToClipboard(const LLWString &src, S32 pos, S32 len, bool us { mString = mString + sep + src.substr(pos, len); } - mGeneration++; return (use_primary ? LLView::getWindow()->copyTextToPrimary(mString) : LLView::getWindow()->copyTextToClipboard(mString)); } -- cgit v1.2.3 From 4ffad9495cdf6f5d6577c4829628fc78bb32b817 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Fri, 9 Mar 2012 17:15:48 -0800 Subject: EXP-1915 : Disable copy/cut options for folders as long as all items in them are not present. --- indra/newview/llinventorybridge.cpp | 51 ++++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 18 deletions(-) diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index 49eb8db5be..96785eb312 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -143,6 +143,21 @@ bool isMarketplaceSendAction(const std::string& action) return ("send_to_marketplace" == action); } +//Used by LLFolderBridge as callback for directory recursion. +class LLRightClickInventoryFetchDescendentsObserver : public LLInventoryFetchDescendentsObserver +{ +public: + LLRightClickInventoryFetchDescendentsObserver(const uuid_vec_t& ids, + bool copy_items) : + LLInventoryFetchDescendentsObserver(ids), + mCopyItems(copy_items) + {} + ~LLRightClickInventoryFetchDescendentsObserver() {} + virtual void done(); +protected: + bool mCopyItems; +}; + // +=================================================+ // | LLInvFVBridge | // +=================================================+ @@ -1722,9 +1737,15 @@ LLHandle LLFolderBridge::sSelf; BOOL LLFolderBridge::isItemMovable() const { LLInventoryObject* obj = getInventoryObject(); - if(obj) + if (obj) { - return (!LLFolderType::lookupIsProtectedType(((LLInventoryCategory*)obj)->getPreferredType())); + // If it's a protected type folder, we can't move it + if (LLFolderType::lookupIsProtectedType(((LLInventoryCategory*)obj)->getPreferredType())) + return FALSE; + // If the folder is not there yet, it's too early to decide if it's movable + if (!isUpToDate()) + return FALSE; + return TRUE; } return FALSE; } @@ -1759,6 +1780,10 @@ BOOL LLFolderBridge::isItemRemovable() const return FALSE; } + // If the folder is not there yet, we shouldn't try to remove it yet + if (!isUpToDate()) + return FALSE; + LLInventoryPanel* panel = mInventoryPanel.get(); LLFolderViewFolder* folderp = dynamic_cast(panel ? panel->getRootFolder()->getItemByID(mUUID) : NULL); if (folderp) @@ -1790,7 +1815,11 @@ BOOL LLFolderBridge::isUpToDate() const BOOL LLFolderBridge::isItemCopyable() const { // Folders are copyable if items in them are, recursively, copyable. - + + // If the folder is not there yet, it's not copyable + if (!isUpToDate()) + return FALSE; + // Get the content of the folder LLInventoryModel::cat_array_t* cat_array; LLInventoryModel::item_array_t* item_array; @@ -2492,21 +2521,6 @@ protected: }; -//Used by LLFolderBridge as callback for directory recursion. -class LLRightClickInventoryFetchDescendentsObserver : public LLInventoryFetchDescendentsObserver -{ -public: - LLRightClickInventoryFetchDescendentsObserver(const uuid_vec_t& ids, - bool copy_items) : - LLInventoryFetchDescendentsObserver(ids), - mCopyItems(copy_items) - {} - ~LLRightClickInventoryFetchDescendentsObserver() {} - virtual void done(); -protected: - bool mCopyItems; -}; - void LLRightClickInventoryFetchDescendentsObserver::done() { // Avoid passing a NULL-ref as mCompleteFolders.front() down to @@ -3358,6 +3372,7 @@ void LLFolderBridge::buildContextMenu(LLMenuGL& menu, U32 flags) inc_busy_count(); if (fetch->isFinished()) { + delete fetch; buildContextMenuFolderOptions(flags); } else -- cgit v1.2.3 From 8a792a86fad7c610651b964d164b8f099c790562 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Fri, 9 Mar 2012 17:34:30 -0800 Subject: EXP-1913 : Suppress the text concatenation on clipboard, unused and confusing. --- indra/llui/llclipboard.cpp | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/indra/llui/llclipboard.cpp b/indra/llui/llclipboard.cpp index 53b1b855de..7bf62b5bfc 100644 --- a/indra/llui/llclipboard.cpp +++ b/indra/llui/llclipboard.cpp @@ -122,15 +122,7 @@ bool LLClipboard::copyToClipboard(const LLWString &src, S32 pos, S32 len, bool u // Concatenate the input string to the LL and the system clipboard bool LLClipboard::addToClipboard(const LLWString &src, S32 pos, S32 len, bool use_primary) { - const LLWString sep(utf8str_to_wstring(std::string(", "))); - if (mString.length() == 0) - { - mString = src.substr(pos, len); - } - else - { - mString = mString + sep + src.substr(pos, len); - } + mString = src.substr(pos, len); return (use_primary ? LLView::getWindow()->copyTextToPrimary(mString) : LLView::getWindow()->copyTextToClipboard(mString)); } -- cgit v1.2.3 From 7b866448dbeeeb04b074df493369927afcf9971a Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Mon, 12 Mar 2012 13:59:25 -0700 Subject: EXP-1922 : Skip the clipboard elements when purging the trash when in cut mode --- indra/newview/llinventorymodel.cpp | 114 ++++++++++++++++++++++++------------- 1 file changed, 73 insertions(+), 41 deletions(-) diff --git a/indra/newview/llinventorymodel.cpp b/indra/newview/llinventorymodel.cpp index a71b699fdd..06e780508b 100644 --- a/indra/newview/llinventorymodel.cpp +++ b/indra/newview/llinventorymodel.cpp @@ -30,6 +30,7 @@ #include "llagent.h" #include "llagentwearables.h" #include "llappearancemgr.h" +#include "llclipboard.h" #include "llinventorypanel.h" #include "llinventorybridge.h" #include "llinventoryfunctions.h" @@ -1110,50 +1111,81 @@ void LLInventoryModel::purgeDescendentsOf(const LLUUID& id) return; } LLPointer cat = getCategory(id); - if(cat.notNull()) - { - // do the cache accounting - llinfos << "LLInventoryModel::purgeDescendentsOf " << cat->getName() - << llendl; - S32 descendents = cat->getDescendentCount(); - if(descendents > 0) - { - LLCategoryUpdate up(id, -descendents); - accountForUpdate(up); + if (cat.notNull()) + { + if (LLClipboard::instance().hasContents() && LLClipboard::instance().isCutMode()) + { + // Something on the clipboard is in "cut mode" and needs to be preserved + llinfos << "Merov debug : purging through iteration" << llendl; + cat_array_t* categories; + item_array_t* items; + // Get the list of direct descendants in tha categoy passed as argument + getDirectDescendentsOf(id, categories, items); + std::vector list_uuids; + // Make a unique list with all the UUIDs of the direct descendants (items and categories are not treated differently) + // Note: we need to do that shallow copy as purging things will invalidate the categories or items lists + for (cat_array_t::const_iterator it = categories->begin(); it != categories->end(); ++it) + { + list_uuids.push_back((*it)->getUUID()); + } + for (item_array_t::const_iterator it = items->begin(); it != items->end(); ++it) + { + list_uuids.push_back((*it)->getUUID()); + } + // Iterate through the list and only purge the UUIDs that are not on the clipboard + for (std::vector::const_iterator it = list_uuids.begin(); it != list_uuids.end(); ++it) + { + if (!LLClipboard::instance().isOnClipboard(*it)) + { + purgeObject(*it); + } + } } + else + { + // Fast purge + // do the cache accounting + llinfos << "LLInventoryModel::purgeDescendentsOf " << cat->getName() + << llendl; + S32 descendents = cat->getDescendentCount(); + if(descendents > 0) + { + LLCategoryUpdate up(id, -descendents); + accountForUpdate(up); + } - // we know that descendent count is 0, aide since the - // accounting may actually not do an update, we should force - // it here. - cat->setDescendentCount(0); + // we know that descendent count is 0, however since the + // accounting may actually not do an update, we should force + // it here. + cat->setDescendentCount(0); + + // send it upstream + LLMessageSystem* msg = gMessageSystem; + msg->newMessage("PurgeInventoryDescendents"); + msg->nextBlock("AgentData"); + msg->addUUID("AgentID", gAgent.getID()); + msg->addUUID("SessionID", gAgent.getSessionID()); + msg->nextBlock("InventoryData"); + msg->addUUID("FolderID", id); + gAgent.sendReliableMessage(); - // send it upstream - LLMessageSystem* msg = gMessageSystem; - msg->newMessage("PurgeInventoryDescendents"); - msg->nextBlock("AgentData"); - msg->addUUID("AgentID", gAgent.getID()); - msg->addUUID("SessionID", gAgent.getSessionID()); - msg->nextBlock("InventoryData"); - msg->addUUID("FolderID", id); - gAgent.sendReliableMessage(); - - // unceremoniously remove anything we have locally stored. - cat_array_t categories; - item_array_t items; - collectDescendents(id, - categories, - items, - INCLUDE_TRASH); - S32 count = items.count(); - S32 i; - for(i = 0; i < count; ++i) - { - deleteObject(items.get(i)->getUUID()); - } - count = categories.count(); - for(i = 0; i < count; ++i) - { - deleteObject(categories.get(i)->getUUID()); + // unceremoniously remove anything we have locally stored. + cat_array_t categories; + item_array_t items; + collectDescendents(id, + categories, + items, + INCLUDE_TRASH); + S32 count = items.count(); + for(S32 i = 0; i < count; ++i) + { + deleteObject(items.get(i)->getUUID()); + } + count = categories.count(); + for(S32 i = 0; i < count; ++i) + { + deleteObject(categories.get(i)->getUUID()); + } } } } -- cgit v1.2.3 From 0df0218329ce894afe3a27980a2862ac4a584be7 Mon Sep 17 00:00:00 2001 From: merov Date: Mon, 12 Mar 2012 17:21:32 -0700 Subject: EXP-1914 : Fix the evaluation of isClipboardPasteable() when the clipboard is in cut mode. --- indra/newview/llinventorybridge.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index 96785eb312..060250cc07 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -434,6 +434,7 @@ void LLInvFVBridge::removeBatchNoCheck(LLDynamicArray objects; LLClipboard::instance().pasteFromClipboard(objects); S32 count = objects.count(); @@ -658,7 +666,7 @@ void LLInvFVBridge::getClipboardEntries(bool show_asset_id, { items.push_back(std::string("Paste")); } - if ((!LLClipboard::instance().isCutMode() && !isClipboardPasteable()) || ((flags & FIRST_SELECTED_ITEM) == 0)) + if (!isClipboardPasteable() || ((flags & FIRST_SELECTED_ITEM) == 0)) { disabled_items.push_back(std::string("Paste")); } @@ -2926,7 +2934,7 @@ bool LLFolderBridge::removeItemResponse(const LLSD& notification, const LLSD& re void LLFolderBridge::pasteFromClipboard() { LLInventoryModel* model = getInventoryModel(); - if (model && (isClipboardPasteable() || LLClipboard::instance().isCutMode())) + if (model && isClipboardPasteable()) { const LLUUID ¤t_outfit_id = model->findCategoryUUIDForType(LLFolderType::FT_CURRENT_OUTFIT, false); const LLUUID &outbox_id = model->findCategoryUUIDForType(LLFolderType::FT_OUTBOX, false); -- cgit v1.2.3 From 82700548058527001657758888cf79df099064b3 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Tue, 13 Mar 2012 21:08:10 -0700 Subject: EXP-1915 : Rewrote the fetching mechanism for folders making it truly recursive. --- indra/newview/llinventorybridge.cpp | 221 ++++++++++++++++++++---------------- indra/newview/llinventorymodel.cpp | 3 +- 2 files changed, 128 insertions(+), 96 deletions(-) diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index 060250cc07..03f6a31c6d 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -143,19 +143,40 @@ bool isMarketplaceSendAction(const std::string& action) return ("send_to_marketplace" == action); } -//Used by LLFolderBridge as callback for directory recursion. +// Used by LLFolderBridge as callback for directory fetching recursion class LLRightClickInventoryFetchDescendentsObserver : public LLInventoryFetchDescendentsObserver { public: - LLRightClickInventoryFetchDescendentsObserver(const uuid_vec_t& ids, - bool copy_items) : - LLInventoryFetchDescendentsObserver(ids), - mCopyItems(copy_items) - {} + LLRightClickInventoryFetchDescendentsObserver(const uuid_vec_t& ids) : LLInventoryFetchDescendentsObserver(ids) {} ~LLRightClickInventoryFetchDescendentsObserver() {} - virtual void done(); -protected: - bool mCopyItems; + virtual void execute(bool clear_observer = false); + virtual void done() + { + execute(true); + } +}; + +// Used by LLFolderBridge as callback for directory content items fetching +class LLRightClickInventoryFetchObserver : public LLInventoryFetchItemsObserver +{ +public: + LLRightClickInventoryFetchObserver(const uuid_vec_t& ids) : LLInventoryFetchItemsObserver(ids) { }; + ~LLRightClickInventoryFetchObserver() {} + void execute(bool clear_observer = false) + { + if (clear_observer) + { + dec_busy_count(); + gInventory.removeObserver(this); + delete this; + } + // we've downloaded all the items, so repaint the dialog + LLFolderBridge::staticFolderOptionsMenu(); + } + virtual void done() + { + execute(true); + } }; // +=================================================+ @@ -2499,106 +2520,114 @@ BOOL move_inv_category_world_to_agent(const LLUUID& object_id, return accept; } -//Used by LLFolderBridge as callback for directory recursion. -class LLRightClickInventoryFetchObserver : public LLInventoryFetchItemsObserver +void LLRightClickInventoryFetchDescendentsObserver::execute(bool clear_observer) { -public: - LLRightClickInventoryFetchObserver(const uuid_vec_t& ids) : - LLInventoryFetchItemsObserver(ids), - mCopyItems(false) - { }; - LLRightClickInventoryFetchObserver(const uuid_vec_t& ids, - const LLUUID& cat_id, - bool copy_items) : - LLInventoryFetchItemsObserver(ids), - mCatID(cat_id), - mCopyItems(copy_items) - { }; - virtual void done() - { - // we've downloaded all the items, so repaint the dialog - LLFolderBridge::staticFolderOptionsMenu(); - - gInventory.removeObserver(this); - delete this; - } - -protected: - LLUUID mCatID; - bool mCopyItems; - -}; - -void LLRightClickInventoryFetchDescendentsObserver::done() -{ - // Avoid passing a NULL-ref as mCompleteFolders.front() down to - // gInventory.collectDescendents() + // Bail out immediately if no descendents if( mComplete.empty() ) { llwarns << "LLRightClickInventoryFetchDescendentsObserver::done with empty mCompleteFolders" << llendl; - dec_busy_count(); - gInventory.removeObserver(this); - delete this; + if (clear_observer) + { + dec_busy_count(); + gInventory.removeObserver(this); + delete this; + } return; } - - // What we do here is get the complete information on the items in - // the library, and set up an observer that will wait for that to - // happen. - LLInventoryModel::cat_array_t cat_array; - LLInventoryModel::item_array_t item_array; - gInventory.collectDescendents(mComplete.front(), - cat_array, - item_array, - LLInventoryModel::EXCLUDE_TRASH); - S32 count = item_array.count(); -#if 0 // HACK/TODO: Why? - // This early causes a giant menu to get produced, and doesn't seem to be needed. - if(!count) - { - llwarns << "Nothing fetched in category " << mCompleteFolders.front() - << llendl; + + // Copy the list of complete fetched folders while "this" is still valid + uuid_vec_t completed_folder = mComplete; + + // Clean up, and remove this as an observer now since recursive calls + // could notify observers and throw us into an infinite loop. + if (clear_observer) + { dec_busy_count(); gInventory.removeObserver(this); delete this; - return; } -#endif - - uuid_vec_t ids; - for(S32 i = 0; i < count; ++i) + + for (uuid_vec_t::iterator current_folder = completed_folder.begin(); current_folder != completed_folder.end(); ++current_folder) { - ids.push_back(item_array.get(i)->getUUID()); - } + // Get the information on the fetched folder items and subfolders and fetch those + LLInventoryModel::cat_array_t* cat_array; + LLInventoryModel::item_array_t* item_array; + gInventory.getDirectDescendentsOf(*current_folder, cat_array, item_array); - LLRightClickInventoryFetchObserver* outfit = new LLRightClickInventoryFetchObserver(ids, mComplete.front(), mCopyItems); + S32 item_count = item_array->count(); + S32 cat_count = cat_array->count(); + + // Move to next if current folder empty + if ((item_count == 0) && (cat_count == 0)) + { + continue; + } - // clean up, and remove this as an observer since the call to the - // outfit could notify observers and throw us into an infinite - // loop. - dec_busy_count(); - gInventory.removeObserver(this); - delete this; + uuid_vec_t ids; + LLRightClickInventoryFetchObserver* outfit = NULL; + LLRightClickInventoryFetchDescendentsObserver* categories = NULL; - // increment busy count and either tell the inventory to check & - // call done, or add this object to the inventory for observation. - inc_busy_count(); + // Fetch the items + if (item_count) + { + for (S32 i = 0; i < item_count; ++i) + { + ids.push_back(item_array->get(i)->getUUID()); + } + outfit = new LLRightClickInventoryFetchObserver(ids); + } + // Fetch the subfolders + if (cat_count) + { + for (S32 i = 0; i < cat_count; ++i) + { + ids.push_back(cat_array->get(i)->getUUID()); + } + categories = new LLRightClickInventoryFetchDescendentsObserver(ids); + } - // do the fetch - outfit->startFetch(); - outfit->done(); //Not interested in waiting and this will be right 99% of the time. -//Uncomment the following code for laggy Inventory UI. -/* if(outfit->isFinished()) - { - // everything is already here - call done. - outfit->done(); + // Perform the item fetch + if (outfit) + { + outfit->startFetch(); + outfit->execute(); // Not interested in waiting and this will be right 99% of the time. + delete outfit; + // Uncomment the following code for laggy Inventory UI. + /* + if (outfit->isFinished()) + { + // everything is already here - call done. + outfit->execute(); + delete outfit; + } + else + { + // it's all on its way - add an observer, and the inventory + // will call done for us when everything is here. + inc_busy_count(); + gInventory.addObserver(outfit); + } + */ + } + // Perform the subfolders fetch : this is where we truly recurse down the folder hierarchy + if (categories) + { + categories->startFetch(); + if (categories->isFinished()) + { + // everything is already here - call done. + categories->execute(); + delete categories; + } + else + { + // it's all on its way - add an observer, and the inventory + // will call done for us when everything is here. + inc_busy_count(); + gInventory.addObserver(categories); + } + } } - else - { - // it's all on it's way - add an observer, and the inventory - // will call done for us when everything is here. - gInventory.addObserver(outfit); - }*/ } @@ -3375,17 +3404,19 @@ void LLFolderBridge::buildContextMenu(LLMenuGL& menu, U32 flags) folders.push_back(category->getUUID()); sSelf = getHandle(); - LLRightClickInventoryFetchDescendentsObserver* fetch = new LLRightClickInventoryFetchDescendentsObserver(folders, FALSE); + LLRightClickInventoryFetchDescendentsObserver* fetch = new LLRightClickInventoryFetchDescendentsObserver(folders); fetch->startFetch(); - inc_busy_count(); if (fetch->isFinished()) { + // Do not call execute() or done() here as if the folder is here, there's likely no point drilling down + // This saves lots of time as buildContextMenu() is called a lot delete fetch; buildContextMenuFolderOptions(flags); } else { // it's all on its way - add an observer, and the inventory will call done for us when everything is here. + inc_busy_count(); gInventory.addObserver(fetch); } } diff --git a/indra/newview/llinventorymodel.cpp b/indra/newview/llinventorymodel.cpp index 06e780508b..0eba8bd0f1 100644 --- a/indra/newview/llinventorymodel.cpp +++ b/indra/newview/llinventorymodel.cpp @@ -1116,7 +1116,8 @@ void LLInventoryModel::purgeDescendentsOf(const LLUUID& id) if (LLClipboard::instance().hasContents() && LLClipboard::instance().isCutMode()) { // Something on the clipboard is in "cut mode" and needs to be preserved - llinfos << "Merov debug : purging through iteration" << llendl; + llinfos << "LLInventoryModel::purgeDescendentsOf " << cat->getName() + << " iterate and purge non hidden items" << llendl; cat_array_t* categories; item_array_t* items; // Get the list of direct descendants in tha categoy passed as argument -- cgit v1.2.3 From 9dfb6284df315588b0a387725965e3626d63784c Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Tue, 13 Mar 2012 21:37:54 -0700 Subject: EXP-1924 : Relax the cconsistency policy between text and UUID on the clipboard. --- indra/llui/llclipboard.cpp | 5 ----- indra/llui/llclipboard.h | 6 +++++- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/indra/llui/llclipboard.cpp b/indra/llui/llclipboard.cpp index 7bf62b5bfc..14173fdbb0 100644 --- a/indra/llui/llclipboard.cpp +++ b/indra/llui/llclipboard.cpp @@ -133,11 +133,6 @@ bool LLClipboard::pasteFromClipboard(LLWString &dst, bool use_primary) bool res = (use_primary ? LLView::getWindow()->pasteTextFromPrimary(dst) : LLView::getWindow()->pasteTextFromClipboard(dst)); if (res) { - if (dst != mString) - { - // Invalidate the LL clipboard if the System had a different string in it (i.e. some copy/cut was done in some other app) - reset(); - } mString = dst; } return res; diff --git a/indra/llui/llclipboard.h b/indra/llui/llclipboard.h index 7f31f66bbe..fd2e7610df 100644 --- a/indra/llui/llclipboard.h +++ b/indra/llui/llclipboard.h @@ -41,6 +41,10 @@ // // This class is used to cut/copy/paste text strings and inventory items around // the world. Use LLClipboard::instance().method() to use its methods. +// Note that the text and UUIDs are loosely coupled only. There are few cases +// where the viewer does offer a serialized version of the UUID on the clipboard. +// In those case, the text is overridden when copying/cutting the item. +// In all other cases, the text and the UUIDs are very much independent. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ class LLClipboard : public LLSingleton @@ -82,7 +86,7 @@ public: private: std::vector mObjects; // Objects on the clipboard. Can be empty while mString contains something licit (e.g. text from chat) - LLWString mString; // The text string. If mObjects is not empty, this string is reflecting them (UUIDs for the moment). + LLWString mString; // The text string. If mObjects is not empty, this string is reflecting them (UUIDs for the moment) if the asset type is knowable. bool mCutMode; // This is a convenience flag for the viewer. int mGeneration; // Incremented when the clipboard changes so that interested parties can check for changes on the clipboard. }; -- cgit v1.2.3 From f4722686d4bd125ebbecac5da511390252a7084e Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Wed, 14 Mar 2012 15:36:23 -0700 Subject: EXP-1841 : Comments clean up --- indra/newview/llfolderview.h | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/indra/newview/llfolderview.h b/indra/newview/llfolderview.h index 9a1df5a142..5705846c0e 100644 --- a/indra/newview/llfolderview.h +++ b/indra/newview/llfolderview.h @@ -61,8 +61,8 @@ class LLTextBox; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Class LLFolderView // -// Th LLFolderView represents the root level folder view object. It -// manages the screen region of the folder view. +// The LLFolderView represents the root level folder view object. +// It manages the screen region of the folder view. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ class LLFolderView : public LLFolderViewFolder, public LLEditMenuHandler @@ -88,7 +88,7 @@ public: virtual LLFolderView* getRoot() { return this; } - // FolderViews default to sort by name. This will change that, + // FolderViews default to sort by name. This will change that, // and resort the items if necessary. void setSortOrder(U32 order); void setFilterPermMask(PermissionMask filter_perm_mask); @@ -117,20 +117,20 @@ public: virtual void setOpenArrangeRecursively(BOOL openitem, ERecurseType recurse); virtual BOOL addFolder( LLFolderViewFolder* folder); - // Finds width and height of this object and it's children. Also - // makes sure that this view and it's children are the right size. + // Find width and height of this object and its children. Also + // makes sure that this view and its children are the right size. virtual S32 arrange( S32* width, S32* height, S32 filter_generation ); void arrangeAll() { mArrangeGeneration++; } S32 getArrangeGeneration() { return mArrangeGeneration; } - // applies filters to control visibility of inventory items + // Apply filters to control visibility of inventory items virtual void filter( LLInventoryFilter& filter); - // get the last selected item + // Get the last selected item virtual LLFolderViewItem* getCurSelectedItem( void ); - // Record the selected item and pass it down the hierachy. + // Record the selected item and pass it down the hierarchy. virtual BOOL setSelection(LLFolderViewItem* selection, BOOL openitem, BOOL take_keyboard_focus); @@ -140,13 +140,13 @@ public: // Called once a frame to update the selection if mSelectThisID has been set void updateSelection(); - // This method is used to toggle the selection of an item. Walks - // children, and keeps track of selected objects. + // This method is used to toggle the selection of an item. + // Walks children and keeps track of selected objects. virtual BOOL changeSelection(LLFolderViewItem* selection, BOOL selected); virtual std::set getSelectionList() const; - // make sure if ancestor is selected, descendents are not + // Make sure if ancestor is selected, descendents are not void sanitizeSelection(); void clearSelection(); void addToSelectionList(LLFolderViewItem* item); @@ -157,22 +157,22 @@ public: void setDraggingOverItem(LLFolderViewItem* item) { mDraggingOverItem = item; } LLFolderViewItem* getDraggingOverItem() { return mDraggingOverItem; } - // deletion functionality + // Deletion functionality void removeSelectedItems(); static void removeCutItems(); - // open the selected item. + // Open the selected item void openSelectedItems( void ); void propertiesSelectedItems( void ); - // change the folder type + // Change the folder type void changeType(LLInventoryModel *model, LLFolderType::EType new_folder_type); void autoOpenItem(LLFolderViewFolder* item); void closeAutoOpenedFolders(); BOOL autoOpenTest(LLFolderViewFolder* item); - // copy & paste + // Copy & paste virtual void copy(); virtual BOOL canCopy() const; @@ -185,7 +185,7 @@ public: virtual void doDelete(); virtual BOOL canDoDelete() const; - // public rename functionality - can only start the process + // Public rename functionality - can only start the process void startRenamingSelectedItem( void ); // These functions were used when there was only one folderview, @@ -326,7 +326,7 @@ protected: /** * Is used to determine if we need to cut text In LLFolderViewItem to avoid horizontal scroll. - * NOTE: For now it uses only to cut LLFolderViewItem::mLabel text to be used for Landmarks in Places Panel. + * NOTE: For now it's used only to cut LLFolderViewItem::mLabel text for Landmarks in Places Panel. */ bool mUseEllipses; // See EXT-719 -- cgit v1.2.3 From 86c572ad63f0cf222050e807899e80ea5802e1d7 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Fri, 16 Mar 2012 15:58:05 -0700 Subject: EXP-1915 : Fetch recursively folders when selected --- indra/newview/llinventorybridge.cpp | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index 9b8c311d16..8d3ac3e723 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -1775,9 +1775,6 @@ BOOL LLFolderBridge::isItemMovable() const // If it's a protected type folder, we can't move it if (LLFolderType::lookupIsProtectedType(((LLInventoryCategory*)obj)->getPreferredType())) return FALSE; - // If the folder is not there yet, it's too early to decide if it's movable - if (!isUpToDate()) - return FALSE; return TRUE; } return FALSE; @@ -1785,9 +1782,10 @@ BOOL LLFolderBridge::isItemMovable() const void LLFolderBridge::selectItem() { + // Have no fear: the first thing start() does is to test if everything for that folder has been fetched... + LLInventoryModelBackgroundFetch::instance().start(getUUID(), true); } - // Iterate through a folder's children to determine if // all the children are removable. class LLIsItemRemovable : public LLFolderViewFunctor @@ -1813,10 +1811,6 @@ BOOL LLFolderBridge::isItemRemovable() const return FALSE; } - // If the folder is not there yet, we shouldn't try to remove it yet - if (!isUpToDate()) - return FALSE; - LLInventoryPanel* panel = mInventoryPanel.get(); LLFolderViewFolder* folderp = dynamic_cast(panel ? panel->getRootFolder()->getItemByID(mUUID) : NULL); if (folderp) @@ -1849,10 +1843,6 @@ BOOL LLFolderBridge::isItemCopyable() const { // Folders are copyable if items in them are, recursively, copyable. - // If the folder is not there yet, it's not copyable - if (!isUpToDate()) - return FALSE; - // Get the content of the folder LLInventoryModel::cat_array_t* cat_array; LLInventoryModel::item_array_t* item_array; -- cgit v1.2.3