diff options
author | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
commit | 38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch) | |
tree | adca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/newview/llinventoryactions.cpp | |
parent | README.txt (diff) | |
download | meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2 meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz |
Second Life viewer sources 1.13.2.12
Diffstat (limited to 'linden/indra/newview/llinventoryactions.cpp')
-rw-r--r-- | linden/indra/newview/llinventoryactions.cpp | 640 |
1 files changed, 640 insertions, 0 deletions
diff --git a/linden/indra/newview/llinventoryactions.cpp b/linden/indra/newview/llinventoryactions.cpp new file mode 100644 index 0000000..a10ccdf --- /dev/null +++ b/linden/indra/newview/llinventoryactions.cpp | |||
@@ -0,0 +1,640 @@ | |||
1 | /** | ||
2 | * @file llinventoryactions.cpp | ||
3 | * @brief Implementation of the actions associated with menu items. | ||
4 | * | ||
5 | * Copyright (c) 2001-2007, Linden Research, Inc. | ||
6 | * | ||
7 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
8 | * to you under the terms of the GNU General Public License, version 2.0 | ||
9 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
10 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
11 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
12 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
13 | * | ||
14 | * There are special exceptions to the terms and conditions of the GPL as | ||
15 | * it is applied to this Source Code. View the full text of the exception | ||
16 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
17 | * online at http://secondlife.com/developers/opensource/flossexception | ||
18 | * | ||
19 | * By copying, modifying or distributing this software, you acknowledge | ||
20 | * that you have read and understood your obligations described above, | ||
21 | * and agree to abide by those obligations. | ||
22 | * | ||
23 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
24 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
25 | * COMPLETENESS OR PERFORMANCE. | ||
26 | */ | ||
27 | |||
28 | #include "llviewerprecompiledheaders.h" | ||
29 | |||
30 | #include <utility> // for std::pair<> | ||
31 | |||
32 | #include "llinventoryview.h" | ||
33 | #include "llpanelinventory.h" | ||
34 | #include "llinventorybridge.h" | ||
35 | |||
36 | #include "message.h" | ||
37 | |||
38 | #include "llagent.h" | ||
39 | #include "llcallingcard.h" | ||
40 | #include "llcheckboxctrl.h" // for radio buttons | ||
41 | #include "llradiogroup.h" | ||
42 | #include "llspinctrl.h" | ||
43 | #include "lltextbox.h" | ||
44 | #include "llui.h" | ||
45 | |||
46 | #include "llviewercontrol.h" | ||
47 | #include "llfirstuse.h" | ||
48 | #include "llfloateravatarinfo.h" | ||
49 | #include "llfloaterchat.h" | ||
50 | #include "llfloatercustomize.h" | ||
51 | #include "llfloaterproperties.h" | ||
52 | #include "llfocusmgr.h" | ||
53 | #include "llfolderview.h" | ||
54 | #include "llgesturemgr.h" | ||
55 | #include "lliconctrl.h" | ||
56 | #include "llinventorymodel.h" | ||
57 | #include "llinventoryclipboard.h" | ||
58 | #include "lllineeditor.h" | ||
59 | #include "llmenugl.h" | ||
60 | #include "llpreviewanim.h" | ||
61 | #include "llpreviewgesture.h" | ||
62 | #include "llpreviewlandmark.h" | ||
63 | #include "llpreviewnotecard.h" | ||
64 | #include "llpreviewscript.h" | ||
65 | #include "llpreviewsound.h" | ||
66 | #include "llpreviewtexture.h" | ||
67 | #include "llresmgr.h" | ||
68 | #include "llscrollcontainer.h" | ||
69 | #include "llimview.h" | ||
70 | #include "lltooldraganddrop.h" | ||
71 | #include "llviewerimagelist.h" | ||
72 | #include "llviewerinventory.h" | ||
73 | #include "llviewerobjectlist.h" | ||
74 | #include "llviewerwindow.h" | ||
75 | #include "llwearable.h" | ||
76 | #include "llwearablelist.h" | ||
77 | #include "viewer.h" | ||
78 | #include "llviewermessage.h" | ||
79 | #include "llviewerregion.h" | ||
80 | #include "lltabcontainer.h" | ||
81 | #include "llvieweruictrlfactory.h" | ||
82 | #include "llselectmgr.h" | ||
83 | |||
84 | typedef LLMemberListener<LLPanelInventory> object_inventory_listener_t; | ||
85 | typedef LLMemberListener<LLInventoryView> inventory_listener_t; | ||
86 | typedef LLMemberListener<LLInventoryPanel> inventory_panel_listener_t; | ||
87 | |||
88 | bool doToSelected(LLFolderView* folder, LLString action) | ||
89 | { | ||
90 | LLInventoryModel* model = &gInventory; | ||
91 | if ("rename" == action) | ||
92 | { | ||
93 | folder->startRenamingSelectedItem(); | ||
94 | return true; | ||
95 | } | ||
96 | if ("delete" == action) | ||
97 | { | ||
98 | folder->removeSelectedItems(); | ||
99 | return true; | ||
100 | } | ||
101 | |||
102 | if ("copy" == action) | ||
103 | { | ||
104 | LLInventoryClipboard::instance().reset(); | ||
105 | } | ||
106 | |||
107 | std::set<LLUUID> selected_items; | ||
108 | folder->getSelectionList(selected_items); | ||
109 | |||
110 | LLMultiPreview* multi_previewp = NULL; | ||
111 | LLMultiProperties* multi_propertiesp = NULL; | ||
112 | |||
113 | if ("open" == action && selected_items.size() > 1) | ||
114 | { | ||
115 | S32 left, top; | ||
116 | gFloaterView->getNewFloaterPosition(&left, &top); | ||
117 | |||
118 | multi_previewp = new LLMultiPreview(LLRect(left, top, left + 300, top - 100)); | ||
119 | gFloaterView->addChild(multi_previewp); | ||
120 | |||
121 | LLFloater::setFloaterHost(multi_previewp); | ||
122 | |||
123 | } | ||
124 | else if ("properties" == action && selected_items.size() > 1) | ||
125 | { | ||
126 | S32 left, top; | ||
127 | gFloaterView->getNewFloaterPosition(&left, &top); | ||
128 | |||
129 | multi_propertiesp = new LLMultiProperties(LLRect(left, top, left + 100, top - 100)); | ||
130 | gFloaterView->addChild(multi_propertiesp); | ||
131 | |||
132 | LLFloater::setFloaterHost(multi_propertiesp); | ||
133 | } | ||
134 | |||
135 | std::set<LLUUID>::iterator set_iter; | ||
136 | |||
137 | for (set_iter = selected_items.begin(); set_iter != selected_items.end(); ++set_iter) | ||
138 | { | ||
139 | LLFolderViewItem* folder_item = folder->getItemByID(*set_iter); | ||
140 | if(!folder_item) continue; | ||
141 | LLInvFVBridge* bridge = (LLInvFVBridge*)folder_item->getListener(); | ||
142 | if(!bridge) continue; | ||
143 | |||
144 | bridge->performAction(folder, model, action); | ||
145 | } | ||
146 | |||
147 | LLFloater::setFloaterHost(NULL); | ||
148 | if ("open" == action && selected_items.size() > 1) | ||
149 | { | ||
150 | multi_previewp->open(); | ||
151 | } | ||
152 | else if ("properties" == action && selected_items.size() > 1) | ||
153 | { | ||
154 | multi_propertiesp->open(); | ||
155 | } | ||
156 | |||
157 | return true; | ||
158 | } | ||
159 | |||
160 | class LLDoToSelectedPanel : public object_inventory_listener_t | ||
161 | { | ||
162 | bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) | ||
163 | { | ||
164 | LLString action = userdata.asString(); | ||
165 | LLPanelInventory *panel = mPtr; | ||
166 | LLFolderView* folder = panel->getRootFolder(); | ||
167 | if(!folder) return true; | ||
168 | |||
169 | return doToSelected(folder, action); | ||
170 | } | ||
171 | }; | ||
172 | |||
173 | class LLDoToSelectedFloater : public inventory_listener_t | ||
174 | { | ||
175 | bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) | ||
176 | { | ||
177 | LLString action = userdata.asString(); | ||
178 | LLInventoryPanel *panel = mPtr->getPanel(); | ||
179 | LLFolderView* folder = panel->getRootFolder(); | ||
180 | if(!folder) return true; | ||
181 | |||
182 | return doToSelected(folder, action); | ||
183 | } | ||
184 | }; | ||
185 | |||
186 | class LLDoToSelected : public inventory_panel_listener_t | ||
187 | { | ||
188 | bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) | ||
189 | { | ||
190 | LLString action = userdata.asString(); | ||
191 | LLInventoryPanel *panel = mPtr; | ||
192 | LLFolderView* folder = panel->getRootFolder(); | ||
193 | if(!folder) return true; | ||
194 | |||
195 | return doToSelected(folder, action); | ||
196 | } | ||
197 | }; | ||
198 | |||
199 | class LLNewWindow : public inventory_listener_t | ||
200 | { | ||
201 | bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) | ||
202 | { | ||
203 | LLRect rect(gSavedSettings.getRect("FloaterInventoryRect")); | ||
204 | S32 left = 0 , top = 0; | ||
205 | gFloaterView->getNewFloaterPosition(&left, &top); | ||
206 | rect.setLeftTopAndSize(left, top, rect.getWidth(), rect.getHeight()); | ||
207 | LLInventoryView* iv = new LLInventoryView("Inventory", | ||
208 | rect, | ||
209 | mPtr->getActivePanel()->getModel()); | ||
210 | iv->getActivePanel()->setFilterTypes(mPtr->getActivePanel()->getFilterTypes()); | ||
211 | iv->getActivePanel()->setFilterSubString(mPtr->getActivePanel()->getFilterSubString()); | ||
212 | iv->open(); | ||
213 | |||
214 | // force onscreen | ||
215 | gFloaterView->adjustToFitScreen(iv, FALSE); | ||
216 | return true; | ||
217 | } | ||
218 | }; | ||
219 | |||
220 | class LLShowFilters : public inventory_listener_t | ||
221 | { | ||
222 | bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) | ||
223 | { | ||
224 | mPtr->toggleFindOptions(); | ||
225 | return true; | ||
226 | } | ||
227 | }; | ||
228 | |||
229 | class LLResetFilter : public inventory_listener_t | ||
230 | { | ||
231 | bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) | ||
232 | { | ||
233 | LLInventoryViewFinder *finder = mPtr->getFinder(); | ||
234 | mPtr->getActivePanel()->getFilter()->resetDefault(); | ||
235 | if (finder) | ||
236 | { | ||
237 | finder->updateElementsFromFilter(); | ||
238 | } | ||
239 | |||
240 | mPtr->setFilterTextFromFilter(); | ||
241 | return true; | ||
242 | } | ||
243 | }; | ||
244 | |||
245 | class LLCloseAllFolders : public inventory_panel_listener_t | ||
246 | { | ||
247 | bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) | ||
248 | { | ||
249 | mPtr->closeAllFolders(); | ||
250 | return true; | ||
251 | } | ||
252 | }; | ||
253 | |||
254 | class LLCloseAllFoldersFloater : public inventory_listener_t | ||
255 | { | ||
256 | bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) | ||
257 | { | ||
258 | mPtr->getPanel()->closeAllFolders(); | ||
259 | return true; | ||
260 | } | ||
261 | }; | ||
262 | |||
263 | class LLEmptyTrash : public inventory_panel_listener_t | ||
264 | { | ||
265 | bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) | ||
266 | { | ||
267 | LLInventoryModel* model = mPtr->getModel(); | ||
268 | if(!model) return false; | ||
269 | gViewerWindow->alertXml("ConfirmEmptyTrash", callback_empty_trash, this); | ||
270 | return true; | ||
271 | } | ||
272 | |||
273 | static void callback_empty_trash(S32 option, void* userdata) | ||
274 | { | ||
275 | LLEmptyTrash* empty_trash = (LLEmptyTrash*)userdata; | ||
276 | if (option == 0) // YES | ||
277 | { | ||
278 | LLInventoryModel* model = empty_trash->mPtr->getModel(); | ||
279 | LLUUID trash_id = model->findCategoryUUIDForType(LLAssetType::AT_TRASH); | ||
280 | model->purgeDescendentsOf(trash_id); | ||
281 | model->notifyObservers(); | ||
282 | } | ||
283 | } | ||
284 | }; | ||
285 | |||
286 | class LLEmptyTrashFloater : public inventory_listener_t | ||
287 | { | ||
288 | bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) | ||
289 | { | ||
290 | LLInventoryModel* model = mPtr->getPanel()->getModel(); | ||
291 | if(!model) return false; | ||
292 | LLUUID trash_id = model->findCategoryUUIDForType(LLAssetType::AT_TRASH); | ||
293 | model->purgeDescendentsOf(trash_id); | ||
294 | model->notifyObservers(); | ||
295 | return true; | ||
296 | } | ||
297 | }; | ||
298 | |||
299 | void do_create(LLInventoryModel *model, LLInventoryPanel *ptr, LLString type, LLFolderBridge *self = NULL) | ||
300 | { | ||
301 | if ("category" == type) | ||
302 | { | ||
303 | if (self) | ||
304 | { | ||
305 | model->createNewCategory(self->getUUID(), LLAssetType::AT_NONE, NULL); | ||
306 | } | ||
307 | else | ||
308 | { | ||
309 | model->createNewCategory(gAgent.getInventoryRootID(), | ||
310 | LLAssetType::AT_NONE, NULL); | ||
311 | } | ||
312 | model->notifyObservers(); | ||
313 | } | ||
314 | else if ("lsl" == type) | ||
315 | { | ||
316 | LLUUID parent_id = self ? self->getUUID() : model->findCategoryUUIDForType(LLAssetType::AT_LSL_TEXT); | ||
317 | ptr->createNewItem(NEW_LSL_NAME, | ||
318 | parent_id, | ||
319 | LLAssetType::AT_LSL_TEXT, | ||
320 | LLInventoryType::IT_LSL, | ||
321 | PERM_MOVE | PERM_TRANSFER); | ||
322 | } | ||
323 | else if ("notecard" == type) | ||
324 | { | ||
325 | LLUUID parent_id = self ? self->getUUID() : model->findCategoryUUIDForType(LLAssetType::AT_NOTECARD); | ||
326 | ptr->createNewItem(NEW_NOTECARD_NAME, | ||
327 | parent_id, | ||
328 | LLAssetType::AT_NOTECARD, | ||
329 | LLInventoryType::IT_NOTECARD, | ||
330 | PERM_ALL); | ||
331 | } | ||
332 | else if ("gesture" == type) | ||
333 | { | ||
334 | LLUUID parent_id = self ? self->getUUID() : model->findCategoryUUIDForType(LLAssetType::AT_GESTURE); | ||
335 | ptr->createNewItem(NEW_GESTURE_NAME, | ||
336 | parent_id, | ||
337 | LLAssetType::AT_GESTURE, | ||
338 | LLInventoryType::IT_GESTURE, | ||
339 | PERM_ALL); | ||
340 | } | ||
341 | else if ("shirt" == type) | ||
342 | { | ||
343 | LLUUID parent_id = self ? self->getUUID() : gInventory.findCategoryUUIDForType(LLAssetType::AT_CLOTHING); | ||
344 | LLFolderBridge::createWearable(parent_id, WT_SHIRT); | ||
345 | } | ||
346 | else if ("pants" == type) | ||
347 | { | ||
348 | LLUUID parent_id = self ? self->getUUID() : gInventory.findCategoryUUIDForType(LLAssetType::AT_CLOTHING); | ||
349 | LLFolderBridge::createWearable(parent_id, WT_PANTS); | ||
350 | } | ||
351 | else if ("shoes" == type) | ||
352 | { | ||
353 | LLUUID parent_id = self ? self->getUUID() : gInventory.findCategoryUUIDForType(LLAssetType::AT_CLOTHING); | ||
354 | LLFolderBridge::createWearable(parent_id, WT_SHOES); | ||
355 | } | ||
356 | else if ("socks" == type) | ||
357 | { | ||
358 | LLUUID parent_id = self ? self->getUUID() : gInventory.findCategoryUUIDForType(LLAssetType::AT_CLOTHING); | ||
359 | LLFolderBridge::createWearable(parent_id, WT_SOCKS); | ||
360 | } | ||
361 | else if ("jacket" == type) | ||
362 | { | ||
363 | LLUUID parent_id = self ? self->getUUID() : gInventory.findCategoryUUIDForType(LLAssetType::AT_CLOTHING); | ||
364 | LLFolderBridge::createWearable(parent_id, WT_JACKET); | ||
365 | } | ||
366 | else if ("skirt" == type) | ||
367 | { | ||
368 | LLUUID parent_id = self ? self->getUUID() : gInventory.findCategoryUUIDForType(LLAssetType::AT_CLOTHING); | ||
369 | LLFolderBridge::createWearable(parent_id, WT_SKIRT); | ||
370 | } | ||
371 | else if ("gloves" == type) | ||
372 | { | ||
373 | LLUUID parent_id = self ? self->getUUID() : gInventory.findCategoryUUIDForType(LLAssetType::AT_CLOTHING); | ||
374 | LLFolderBridge::createWearable(parent_id, WT_GLOVES); | ||
375 | } | ||
376 | else if ("undershirt" == type) | ||
377 | { | ||
378 | LLUUID parent_id = self ? self->getUUID() : gInventory.findCategoryUUIDForType(LLAssetType::AT_CLOTHING); | ||
379 | LLFolderBridge::createWearable(parent_id, WT_UNDERSHIRT); | ||
380 | } | ||
381 | else if ("underpants" == type) | ||
382 | { | ||
383 | LLUUID parent_id = self ? self->getUUID() : gInventory.findCategoryUUIDForType(LLAssetType::AT_CLOTHING); | ||
384 | LLFolderBridge::createWearable(parent_id, WT_UNDERPANTS); | ||
385 | } | ||
386 | else if ("shape" == type) | ||
387 | { | ||
388 | LLUUID parent_id = self ? self->getUUID() : gInventory.findCategoryUUIDForType(LLAssetType::AT_BODYPART); | ||
389 | LLFolderBridge::createWearable(parent_id, WT_SHAPE); | ||
390 | } | ||
391 | else if ("skin" == type) | ||
392 | { | ||
393 | LLUUID parent_id = self ? self->getUUID() : gInventory.findCategoryUUIDForType(LLAssetType::AT_BODYPART); | ||
394 | LLFolderBridge::createWearable(parent_id, WT_SKIN); | ||
395 | } | ||
396 | else if ("hair" == type) | ||
397 | { | ||
398 | LLUUID parent_id = self ? self->getUUID() : gInventory.findCategoryUUIDForType(LLAssetType::AT_BODYPART); | ||
399 | LLFolderBridge::createWearable(parent_id, WT_HAIR); | ||
400 | } | ||
401 | else if ("eyes" == type) | ||
402 | { | ||
403 | LLUUID parent_id = self ? self->getUUID() : gInventory.findCategoryUUIDForType(LLAssetType::AT_BODYPART); | ||
404 | LLFolderBridge::createWearable(parent_id, WT_EYES); | ||
405 | } | ||
406 | } | ||
407 | |||
408 | class LLDoCreate : public inventory_panel_listener_t | ||
409 | { | ||
410 | bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) | ||
411 | { | ||
412 | LLInventoryModel* model = mPtr->getModel(); | ||
413 | if(!model) return false; | ||
414 | LLString type = userdata.asString(); | ||
415 | do_create(model, mPtr, type, LLFolderBridge::sSelf); | ||
416 | return true; | ||
417 | } | ||
418 | }; | ||
419 | |||
420 | class LLDoCreateFloater : public inventory_listener_t | ||
421 | { | ||
422 | bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) | ||
423 | { | ||
424 | LLInventoryModel* model = mPtr->getPanel()->getModel(); | ||
425 | if(!model) return false; | ||
426 | LLString type = userdata.asString(); | ||
427 | do_create(model, mPtr->getPanel(), type); | ||
428 | return true; | ||
429 | } | ||
430 | }; | ||
431 | |||
432 | class LLSetSortBy : public inventory_listener_t | ||
433 | { | ||
434 | bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) | ||
435 | { | ||
436 | LLString sort_field = userdata.asString(); | ||
437 | if (sort_field == "name") | ||
438 | { | ||
439 | U32 order = mPtr->getActivePanel()->getSortOrder(); | ||
440 | mPtr->getActivePanel()->setSortOrder( order & ~LLInventoryFilter::SO_DATE ); | ||
441 | |||
442 | mPtr->getControl("Inventory.SortByName")->setValue( TRUE ); | ||
443 | mPtr->getControl("Inventory.SortByDate")->setValue( FALSE ); | ||
444 | } | ||
445 | else if (sort_field == "date") | ||
446 | { | ||
447 | U32 order = mPtr->getActivePanel()->getSortOrder(); | ||
448 | mPtr->getActivePanel()->setSortOrder( order | LLInventoryFilter::SO_DATE ); | ||
449 | |||
450 | mPtr->getControl("Inventory.SortByName")->setValue( FALSE ); | ||
451 | mPtr->getControl("Inventory.SortByDate")->setValue( TRUE ); | ||
452 | } | ||
453 | else if (sort_field == "foldersalwaysbyname") | ||
454 | { | ||
455 | U32 order = mPtr->getActivePanel()->getSortOrder(); | ||
456 | if ( order & LLInventoryFilter::SO_FOLDERS_BY_NAME ) | ||
457 | { | ||
458 | order &= ~LLInventoryFilter::SO_FOLDERS_BY_NAME; | ||
459 | |||
460 | mPtr->getControl("Inventory.FoldersAlwaysByName")->setValue( FALSE ); | ||
461 | } | ||
462 | else | ||
463 | { | ||
464 | order |= LLInventoryFilter::SO_FOLDERS_BY_NAME; | ||
465 | |||
466 | mPtr->getControl("Inventory.FoldersAlwaysByName")->setValue( TRUE ); | ||
467 | } | ||
468 | mPtr->getActivePanel()->setSortOrder( order ); | ||
469 | } | ||
470 | |||
471 | return true; | ||
472 | } | ||
473 | }; | ||
474 | |||
475 | class LLBeginIMSession : public inventory_panel_listener_t | ||
476 | { | ||
477 | bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) | ||
478 | { | ||
479 | LLString who = userdata.asString(); | ||
480 | bool only_online = false; | ||
481 | if ("everyone" == who) | ||
482 | { | ||
483 | only_online = false; | ||
484 | } | ||
485 | else // "online" | ||
486 | { | ||
487 | only_online = true; | ||
488 | } | ||
489 | LLInventoryPanel *panel = mPtr; | ||
490 | LLInventoryModel* model = panel->getModel(); | ||
491 | if(!model) return true; | ||
492 | std::set<LLUUID> selected_items; | ||
493 | panel->getRootFolder()->getSelectionList(selected_items); | ||
494 | LLUUID item = *selected_items.begin(); | ||
495 | LLFolderViewItem* folder_item = panel->getRootFolder()->getItemByID(item); | ||
496 | if(!folder_item) return true; | ||
497 | LLFolderBridge* bridge = (LLFolderBridge*)folder_item->getListener(); | ||
498 | if(!bridge) return true; | ||
499 | LLViewerInventoryCategory* cat = bridge->getCategory(); | ||
500 | if(!cat) return true; | ||
501 | LLUniqueBuddyCollector is_buddy; | ||
502 | LLInventoryModel::cat_array_t cat_array; | ||
503 | LLInventoryModel::item_array_t item_array; | ||
504 | model->collectDescendentsIf(bridge->getUUID(), | ||
505 | cat_array, | ||
506 | item_array, | ||
507 | LLInventoryModel::EXCLUDE_TRASH, | ||
508 | is_buddy); | ||
509 | S32 count = item_array.count(); | ||
510 | if(count > 0) | ||
511 | { | ||
512 | // create the session | ||
513 | gIMView->setFloaterOpen(TRUE); | ||
514 | LLDynamicArray<LLUUID> members; | ||
515 | //members.put(gAgent.getID()); | ||
516 | S32 i; | ||
517 | EInstantMessage type = IM_SESSION_ADD; | ||
518 | if(only_online) | ||
519 | { | ||
520 | LLAvatarTracker& at = LLAvatarTracker::instance(); | ||
521 | LLUUID id; | ||
522 | for(i = 0; i < count; ++i) | ||
523 | { | ||
524 | id = item_array.get(i)->getCreatorUUID(); | ||
525 | if(at.isBuddyOnline(id)) | ||
526 | { | ||
527 | members.put(id); | ||
528 | } | ||
529 | } | ||
530 | } | ||
531 | else | ||
532 | { | ||
533 | type = IM_SESSION_OFFLINE_ADD; | ||
534 | for(i = 0; i < count; ++i) | ||
535 | { | ||
536 | members.put(item_array.get(i)->getCreatorUUID()); | ||
537 | } | ||
538 | } | ||
539 | // the session_id is always the item_id of the inventory folder | ||
540 | gIMView->addSession(cat->getName(), | ||
541 | type, | ||
542 | bridge->getUUID(), | ||
543 | members); | ||
544 | } | ||
545 | return true; | ||
546 | } | ||
547 | }; | ||
548 | |||
549 | void rez_attachment(LLViewerInventoryItem* item, LLViewerJointAttachment* attachment); | ||
550 | |||
551 | class LLAttachObject : public inventory_panel_listener_t | ||
552 | { | ||
553 | bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) | ||
554 | { | ||
555 | LLInventoryPanel *panel = mPtr; | ||
556 | LLFolderView* folder = panel->getRootFolder(); | ||
557 | if(!folder) return true; | ||
558 | |||
559 | std::set<LLUUID> selected_items; | ||
560 | folder->getSelectionList(selected_items); | ||
561 | LLUUID id = *selected_items.begin(); | ||
562 | |||
563 | LLString joint_name = userdata.asString(); | ||
564 | LLVOAvatar *avatarp = gAgent.getAvatarObject(); | ||
565 | LLViewerJointAttachment* attachmentp = NULL; | ||
566 | for (LLViewerJointAttachment* attachment = avatarp->mAttachmentPoints.getFirstData(); | ||
567 | attachment; | ||
568 | attachment = gAgent.getAvatarObject()->mAttachmentPoints.getNextData()) | ||
569 | { | ||
570 | if (attachment->getName() == joint_name) | ||
571 | { | ||
572 | attachmentp = attachment; | ||
573 | break; | ||
574 | } | ||
575 | } | ||
576 | if (attachmentp == NULL) | ||
577 | { | ||
578 | return true; | ||
579 | } | ||
580 | LLViewerInventoryItem* item = (LLViewerInventoryItem*)gInventory.getItem(id); | ||
581 | |||
582 | if(item && gInventory.isObjectDescendentOf(id, gAgent.getInventoryRootID())) | ||
583 | { | ||
584 | rez_attachment(item, attachmentp); | ||
585 | } | ||
586 | else if(item && item->isComplete()) | ||
587 | { | ||
588 | // must be in library. copy it to our inventory and put it on. | ||
589 | LLPointer<LLInventoryCallback> cb = new RezAttachmentCallback(attachmentp); | ||
590 | copy_inventory_item( | ||
591 | gAgent.getID(), | ||
592 | item->getPermissions().getOwner(), | ||
593 | item->getUUID(), | ||
594 | LLUUID::null, | ||
595 | std::string(), | ||
596 | cb); | ||
597 | } | ||
598 | gFocusMgr.setKeyboardFocus(NULL, NULL); | ||
599 | |||
600 | return true; | ||
601 | } | ||
602 | }; | ||
603 | |||
604 | /* | ||
605 | class LL : public listener_t | ||
606 | { | ||
607 | bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) | ||
608 | { | ||
609 | return true; | ||
610 | } | ||
611 | }; | ||
612 | */ | ||
613 | |||
614 | void init_object_inventory_panel_actions(LLPanelInventory *panel) | ||
615 | { | ||
616 | (new LLDoToSelectedPanel())->registerListener(panel, "Inventory.DoToSelected"); | ||
617 | } | ||
618 | |||
619 | void init_inventory_actions(LLInventoryView *floater) | ||
620 | { | ||
621 | (new LLDoToSelectedFloater())->registerListener(floater, "Inventory.DoToSelected"); | ||
622 | (new LLCloseAllFoldersFloater())->registerListener(floater, "Inventory.CloseAllFolders"); | ||
623 | (new LLEmptyTrashFloater())->registerListener(floater, "Inventory.EmptyTrash"); | ||
624 | (new LLDoCreateFloater())->registerListener(floater, "Inventory.DoCreate"); | ||
625 | |||
626 | (new LLNewWindow())->registerListener(floater, "Inventory.NewWindow"); | ||
627 | (new LLShowFilters())->registerListener(floater, "Inventory.ShowFilters"); | ||
628 | (new LLResetFilter())->registerListener(floater, "Inventory.ResetFilter"); | ||
629 | (new LLSetSortBy())->registerListener(floater, "Inventory.SetSortBy"); | ||
630 | } | ||
631 | |||
632 | void init_inventory_panel_actions(LLInventoryPanel *panel) | ||
633 | { | ||
634 | (new LLDoToSelected())->registerListener(panel, "Inventory.DoToSelected"); | ||
635 | (new LLAttachObject())->registerListener(panel, "Inventory.AttachObject"); | ||
636 | (new LLCloseAllFolders())->registerListener(panel, "Inventory.CloseAllFolders"); | ||
637 | (new LLEmptyTrash())->registerListener(panel, "Inventory.EmptyTrash"); | ||
638 | (new LLDoCreate())->registerListener(panel, "Inventory.DoCreate"); | ||
639 | (new LLBeginIMSession())->registerListener(panel, "Inventory.BeginIMSession"); | ||
640 | } | ||