summaryrefslogtreecommitdiff
path: root/indra/newview/llblocklist.h
blob: 0f7fa41c3206efd93356a7db8d79ede41d9bd6cd (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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
/**
 * @file llblocklist.h
 * @brief List of the blocked avatars and objects.
 *
 * $LicenseInfo:firstyear=2012&license=viewerlgpl$
 * Second Life Viewer Source Code
 * Copyright (C) 2012, 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 LLBLOCKLIST_H_
#define LLBLOCKLIST_H_

#include "llflatlistview.h"
#include "lllistcontextmenu.h"
#include "llmutelist.h"
#include "lltoggleablemenu.h"

class LLBlockedListItem;
class LLMute;

enum BlockListActionType {NONE, ADD, REMOVE};

/**
 * List of blocked avatars and objects.
 * This list represents contents of the LLMuteList.
 * Each change in LLMuteList leads to rebuilding this list, so
 * it's always in actual state.
 */
class LLBlockList: public LLFlatListViewEx, public LLMuteListObserver
{
	LOG_CLASS(LLBlockList);
public:
	struct Params : public LLInitParam::Block<Params, LLFlatListViewEx::Params>
	{
		Params(){};
	};

	LLBlockList(const Params& p);
	virtual ~LLBlockList();

	virtual BOOL 		handleRightMouseDown(S32 x, S32 y, MASK mask);
	LLToggleableMenu*	getContextMenu() const { return mContextMenu.get(); }
	LLBlockedListItem*	getBlockedItem() const;

	virtual void onChange() { }
	virtual void onChangeDetailed(const LLMute& );
	virtual void draw();

	void setNameFilter(const std::string& filter);
	void sortByName();
	void sortByType();
	void refresh();

private:

	void addNewItem(const LLMute* mute);
	void removeListItem(const LLMute* mute);
	void hideListItem(LLBlockedListItem* item, bool show);
	void setDirty(bool dirty = true) { mDirty = dirty; }
	bool findInsensitive(std::string haystack, const std::string& needle_upper);

	bool isActionEnabled(const LLSD& userdata);
	void onCustomAction (const LLSD& userdata);
	void createList();

	BlockListActionType getCurrentMuteListActionType();

	LLHandle<LLToggleableMenu>	mContextMenu;

	std::string 				mNameFilter;
	bool 						mDirty;
	bool						mShouldAddAll;
	BlockListActionType			mActionType;
	U32							mMuteListSize;

	// This data is used to save information about item that currently changed(added or removed) 
	LLUUID						mCurItemId;
	std::string					mCurItemName;
	LLMute::EType 				mCurItemType;
	U32							mCurItemFlags;
	std::string					mPrevNameFilter;

};


/*
 * Abstract comparator for blocked items
 */
class LLBlockListItemComparator : public LLFlatListView::ItemComparator
{
	LOG_CLASS(LLBlockListItemComparator);

public:
	LLBlockListItemComparator() {};
	virtual ~LLBlockListItemComparator() {};

	virtual bool compare(const LLPanel* item1, const LLPanel* item2) const;

protected:

	virtual bool doCompare(const LLBlockedListItem* blocked_item1, const LLBlockedListItem* blocked_item2) const = 0;
};


/*
 * Compares items by name
 */
class LLBlockListNameComparator : public LLBlockListItemComparator
{
	LOG_CLASS(LLBlockListNameComparator);

public:
	LLBlockListNameComparator() {};
	virtual ~LLBlockListNameComparator() {};

protected:

	virtual bool doCompare(const LLBlockedListItem* blocked_item1, const LLBlockedListItem* blocked_item2) const;
};

/*
 * Compares items by type and then by name within type
 * Objects come first then avatars
 */
class LLBlockListNameTypeComparator : public LLBlockListItemComparator
{
	LOG_CLASS(LLBlockListNameTypeComparator);

public:
	LLBlockListNameTypeComparator() {};
	virtual ~LLBlockListNameTypeComparator() {};

protected:

	virtual bool doCompare(const LLBlockedListItem* blocked_item1, const LLBlockedListItem* blocked_item2) const;
};

#endif /* LLBLOCKLIST_H_ */