PageRenderTime 39ms CodeModel.GetById 17ms app.highlight 17ms 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
  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
 27#include "llviewerprecompiledheaders.h"
 28
 29#include "llinventoryclipboard.h"
 30
 31
 32LLInventoryClipboard LLInventoryClipboard::sInstance;
 33
 34///----------------------------------------------------------------------------
 35/// Local function declarations, constants, enums, and typedefs
 36///----------------------------------------------------------------------------
 37
 38
 39///----------------------------------------------------------------------------
 40/// Class LLInventoryClipboard
 41///----------------------------------------------------------------------------
 42
 43LLInventoryClipboard::LLInventoryClipboard()
 44: mCutMode(false)
 45{
 46}
 47
 48LLInventoryClipboard::~LLInventoryClipboard()
 49{
 50	reset();
 51}
 52
 53void LLInventoryClipboard::add(const LLUUID& object)
 54{
 55	mObjects.put(object);
 56}
 57
 58// this stores a single inventory object
 59void LLInventoryClipboard::store(const LLUUID& object)
 60{
 61	reset();
 62	mObjects.put(object);
 63}
 64
 65void LLInventoryClipboard::store(const LLDynamicArray<LLUUID>& inv_objects)
 66{
 67	reset();
 68	S32 count = inv_objects.count();
 69	for(S32 i = 0; i < count; i++)
 70	{
 71		mObjects.put(inv_objects[i]);
 72	}
 73}
 74
 75void LLInventoryClipboard::cut(const LLUUID& object)
 76{
 77	if(!mCutMode && !mObjects.empty())
 78	{
 79		//looks like there are some stored items, reset clipboard state
 80		reset();
 81	}
 82	mCutMode = true;
 83	add(object);
 84}
 85void LLInventoryClipboard::retrieve(LLDynamicArray<LLUUID>& inv_objects) const
 86{
 87	inv_objects.reset();
 88	S32 count = mObjects.count();
 89	for(S32 i = 0; i < count; i++)
 90	{
 91		inv_objects.put(mObjects[i]);
 92	}
 93}
 94
 95void LLInventoryClipboard::reset()
 96{
 97	mObjects.reset();
 98	mCutMode = false;
 99}
100
101// returns true if the clipboard has something pasteable in it.
102BOOL LLInventoryClipboard::hasContents() const
103{
104	return (mObjects.count() > 0);
105}
106
107
108///----------------------------------------------------------------------------
109/// Local function definitions
110///----------------------------------------------------------------------------