summaryrefslogtreecommitdiff
path: root/indra/newview/llfolderviewmodelinventory.h
blob: 890d03d1c9cf29e48c4a20fe2a4260f5545f1857 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/** 
 * @file llfolderviewmodelinventory.h
 * @brief view model implementation specific to inventory
 * class definition
 *
 * $LicenseInfo:firstyear=2001&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_LLFOLDERVIEWMODELINVENTORY_H
#define LL_LLFOLDERVIEWMODELINVENTORY_H

#include "llinventoryfilter.h"
#include "llinventory.h"
#include "llwearabletype.h"
#include "lltooldraganddrop.h"

class LLFolderViewModelItemInventory
	:	public LLFolderViewModelItemCommon
{
public:
	LLFolderViewModelItemInventory(class LLFolderViewModelInventory& root_view_model);
	virtual const LLUUID& getUUID() const = 0;
	virtual time_t getCreationDate() const = 0;	// UTC seconds
	virtual void setCreationDate(time_t creation_date_utc) = 0;
	virtual PermissionMask getPermissionMask() const = 0;
	virtual LLFolderType::EType getPreferredType() const = 0;
	virtual void showProperties(void) = 0;
	virtual BOOL isItemInTrash( void) const { return FALSE; } // TODO: make   into pure virtual.
	virtual BOOL isUpToDate() const = 0;
	virtual bool hasChildren() const = 0;
	virtual LLInventoryType::EType getInventoryType() const = 0;
	virtual void performAction(LLInventoryModel* model, std::string action)   = 0;
	virtual LLWearableType::EType getWearableType() const = 0;
	virtual EInventorySortGroup getSortGroup() const = 0;
	virtual LLInventoryObject* getInventoryObject() const = 0;
	virtual void requestSort();
	virtual void setPassedFilter(bool filtered, S32 filter_generation, std::string::size_type string_offset = std::string::npos, std::string::size_type string_size = 0);
	virtual bool filter( LLFolderViewFilter& filter);
	virtual bool filterChildItem( LLFolderViewModelItem* item, LLFolderViewFilter& filter);

	virtual BOOL startDrag(EDragAndDropType* type, LLUUID* id) const = 0;
	virtual LLToolDragAndDrop::ESource getDragSource() const = 0;

protected:
	bool								mPrevPassedAllFilters;
};

class LLInventorySort
{
public:
	struct Params : public LLInitParam::Block<Params>
	{
		Optional<S32> order;

		Params()
		:	order("order", 0)
		{}
	};

	LLInventorySort(S32 order = 0)
	{
		fromParams(Params().order(order));
	}

	bool isByDate() const { return mByDate; }
	U32 getSortOrder() const { return mSortOrder; }
	void toParams(Params& p) { p.order(mSortOrder);}
	void fromParams(Params& p) 
	{ 
		mSortOrder = p.order; 
		mByDate = (mSortOrder & LLInventoryFilter::SO_DATE);
		mSystemToTop = (mSortOrder & LLInventoryFilter::SO_SYSTEM_FOLDERS_TO_TOP);
		mFoldersByName = (mSortOrder & LLInventoryFilter::SO_FOLDERS_BY_NAME);
	}

	bool operator()(const LLFolderViewModelItemInventory* const& a, const LLFolderViewModelItemInventory* const& b) const;
private:
	U32  mSortOrder;
	bool mByDate;
	bool mSystemToTop;
	bool mFoldersByName;
};

class LLFolderViewModelInventory
	:	public LLFolderViewModel<LLInventorySort,   LLFolderViewModelItemInventory, LLFolderViewModelItemInventory,   LLInventoryFilter>
{
public:
	typedef LLFolderViewModel<LLInventorySort,   LLFolderViewModelItemInventory, LLFolderViewModelItemInventory,   LLInventoryFilter> base_t;

	void setTaskID(const LLUUID& id) {mTaskID = id;}

	void sort(LLFolderViewFolder* folder);
	bool contentsReady();
	bool startDrag(std::vector<LLFolderViewModelItem*>& items);

private:
	LLUUID mTaskID;
};
#endif // LL_LLFOLDERVIEWMODELINVENTORY_H