PageRenderTime 246ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/newview/llinventoryclipboard.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 110 lines | 56 code | 17 blank | 37 comment | 4 complexity | d6b8e2dae6ef76114851d87557ae27d1 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llinventoryclipboard.cpp
  3. * @brief LLInventoryClipboard class implementation
  4. *
  5. * $LicenseInfo:firstyear=2002&license=viewerlgpl$
  6. * Second Life Viewer Source Code
  7. * Copyright (C) 2010, Linden Research, Inc.
  8. *
  9. * This library is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation;
  12. * version 2.1 of the License only.
  13. *
  14. * This library is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this library; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. *
  23. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  24. * $/LicenseInfo$
  25. */
  26. #include "llviewerprecompiledheaders.h"
  27. #include "llinventoryclipboard.h"
  28. LLInventoryClipboard LLInventoryClipboard::sInstance;
  29. ///----------------------------------------------------------------------------
  30. /// Local function declarations, constants, enums, and typedefs
  31. ///----------------------------------------------------------------------------
  32. ///----------------------------------------------------------------------------
  33. /// Class LLInventoryClipboard
  34. ///----------------------------------------------------------------------------
  35. LLInventoryClipboard::LLInventoryClipboard()
  36. : mCutMode(false)
  37. {
  38. }
  39. LLInventoryClipboard::~LLInventoryClipboard()
  40. {
  41. reset();
  42. }
  43. void LLInventoryClipboard::add(const LLUUID& object)
  44. {
  45. mObjects.put(object);
  46. }
  47. // this stores a single inventory object
  48. void LLInventoryClipboard::store(const LLUUID& object)
  49. {
  50. reset();
  51. mObjects.put(object);
  52. }
  53. void LLInventoryClipboard::store(const LLDynamicArray<LLUUID>& inv_objects)
  54. {
  55. reset();
  56. S32 count = inv_objects.count();
  57. for(S32 i = 0; i < count; i++)
  58. {
  59. mObjects.put(inv_objects[i]);
  60. }
  61. }
  62. void LLInventoryClipboard::cut(const LLUUID& object)
  63. {
  64. if(!mCutMode && !mObjects.empty())
  65. {
  66. //looks like there are some stored items, reset clipboard state
  67. reset();
  68. }
  69. mCutMode = true;
  70. add(object);
  71. }
  72. void LLInventoryClipboard::retrieve(LLDynamicArray<LLUUID>& inv_objects) const
  73. {
  74. inv_objects.reset();
  75. S32 count = mObjects.count();
  76. for(S32 i = 0; i < count; i++)
  77. {
  78. inv_objects.put(mObjects[i]);
  79. }
  80. }
  81. void LLInventoryClipboard::reset()
  82. {
  83. mObjects.reset();
  84. mCutMode = false;
  85. }
  86. // returns true if the clipboard has something pasteable in it.
  87. BOOL LLInventoryClipboard::hasContents() const
  88. {
  89. return (mObjects.count() > 0);
  90. }
  91. ///----------------------------------------------------------------------------
  92. /// Local function definitions
  93. ///----------------------------------------------------------------------------