aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llfolderview.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/llfolderview.h883
1 files changed, 883 insertions, 0 deletions
diff --git a/linden/indra/newview/llfolderview.h b/linden/indra/newview/llfolderview.h
new file mode 100644
index 0000000..a63ae26
--- /dev/null
+++ b/linden/indra/newview/llfolderview.h
@@ -0,0 +1,883 @@
1/**
2 * @file llfolderview.h
3 * @brief Definition of the folder view collection of classes.
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/**
29 *
30 * The folder view collection of classes provides an interface for
31 * making a 'folder view' similar to the way the a single pane file
32 * folder interface works.
33 *
34 */
35
36#ifndef LL_LLFOLDERVIEW_H
37#define LL_LLFOLDERVIEW_H
38
39#include <vector>
40#include <map>
41#include <deque>
42
43#include "lluictrl.h"
44#include "v4color.h"
45#include "lldarray.h"
46//#include "llviewermenu.h"
47#include "stdenums.h"
48#include "llfontgl.h"
49#include "lleditmenuhandler.h"
50#include "llviewerimage.h"
51#include "lldepthstack.h"
52#include "lltooldraganddrop.h"
53
54class LLMenuGL;
55
56//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
57// Class LLFolderViewEventListener
58//
59// This is an abstract base class that users of the folderview classes
60// would use to catch the useful events emitted from the folder
61// views.
62//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
63
64
65class LLFolderViewItem;
66class LLFolderView;
67class LLInventoryModel;
68class LLScrollableContainerView;
69typedef BOOL (*LLFolderSearchFunction)(LLFolderViewItem* first_item, const char *find_text, BOOL backward);
70
71class LLFolderViewEventListener
72{
73public:
74 virtual ~LLFolderViewEventListener( void ) {}
75 virtual const LLString& getName() const = 0;
76 virtual const LLString& getDisplayName() const = 0;
77 virtual const LLUUID& getUUID() const = 0;
78 virtual U32 getCreationDate() const = 0; // UTC seconds
79 virtual PermissionMask getPermissionMask() const = 0;
80 virtual LLViewerImage* getIcon() const = 0;
81 virtual LLFontGL::StyleFlags getLabelStyle() const = 0;
82 virtual LLString getLabelSuffix() const = 0;
83 virtual void openItem( void ) = 0;
84 virtual void previewItem( void ) = 0;
85 virtual void selectItem(void) = 0;
86 virtual void showProperties(void) = 0;
87 virtual BOOL isItemRenameable() const = 0;
88 virtual BOOL renameItem(const LLString& new_name) = 0;
89 virtual BOOL isItemMovable( void ) = 0; // Can be moved to another folder
90 virtual BOOL isItemRemovable( void ) = 0; // Can be destroyed
91 virtual BOOL removeItem() = 0;
92 virtual void removeBatch(LLDynamicArray<LLFolderViewEventListener*>& batch) = 0;
93 virtual void move( LLFolderViewEventListener* parent_listener ) = 0;
94 virtual BOOL isItemCopyable() const = 0;
95 virtual BOOL copyToClipboard() const = 0;
96 virtual void cutToClipboard() = 0;
97 virtual BOOL isClipboardPasteable() const = 0;
98 virtual void pasteFromClipboard() = 0;
99 virtual void buildContextMenu(LLMenuGL& menu, U32 flags) = 0;
100 virtual BOOL isUpToDate() const = 0;
101 virtual BOOL hasChildren() const = 0;
102 virtual LLInventoryType::EType getInventoryType() const = 0;
103 virtual void performAction(LLFolderView* folder, LLInventoryModel* model, LLString action) {}
104
105 // This method should be called when a drag begins. returns TRUE
106 // if the drag can begin, otherwise FALSE.
107 virtual BOOL startDrag(EDragAndDropType* type, LLUUID* id) = 0;
108
109 // This method will be called to determine if a drop can be
110 // performed, and will set drop to TRUE if a drop is
111 // requested. Returns TRUE if a drop is possible/happened,
112 // otherwise FALSE.
113 virtual BOOL dragOrDrop(MASK mask, BOOL drop,
114 EDragAndDropType cargo_type,
115 void* cargo_data) = 0;
116
117 // This method is called when the object being referenced by the
118 // bridge is actually dropped. This allows for cleanup of the old
119 // view, reference counting, etc.
120// virtual void dropped() = 0;
121
122 // this method accesses the parent and arranges and sets it as
123 // specified.
124 void arrangeAndSet(LLFolderViewItem* focus, BOOL set_selection,
125 BOOL take_keyboard_focus = TRUE);
126};
127
128
129//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
130// Class LLFolderViewListenerFunctor
131//
132// This simple abstract base class can be used to applied to all
133// listeners in a hierarchy.
134//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
135
136class LLFolderViewListenerFunctor
137{
138public:
139 virtual ~LLFolderViewListenerFunctor() {}
140 virtual void operator()(LLFolderViewEventListener* listener) = 0;
141};
142
143//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
144// Class LLFolderViewFunctor
145//
146// Simple abstract base class for applying a functor to folders and
147// items in a folder view hierarchy. This is suboptimal for algorithms
148// that only work folders or only work on items, but I'll worry about
149// that later when it's determined to be too slow.
150//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
151
152class LLFolderViewItem;
153class LLFolderViewFolder;
154
155class LLFolderViewFunctor
156{
157public:
158 virtual ~LLFolderViewFunctor() {}
159 virtual void doFolder(LLFolderViewFolder* folder) = 0;
160 virtual void doItem(LLFolderViewItem* item) = 0;
161};
162
163class LLInventoryFilter
164{
165public:
166 typedef enum e_folder_show
167 {
168 SHOW_ALL_FOLDERS,
169 SHOW_NON_EMPTY_FOLDERS,
170 SHOW_NO_FOLDERS
171 } EFolderShow;
172
173 typedef enum e_filter_behavior
174 {
175 FILTER_NONE, // nothing to do, already filtered
176 FILTER_RESTART, // restart filtering from scratch
177 FILTER_LESS_RESTRICTIVE, // existing filtered items will certainly pass this filter
178 FILTER_MORE_RESTRICTIVE // if you didn't pass the previous filter, you definitely won't pass this one
179 } EFilterBehavior;
180
181 static const U32 SO_DATE = 1;
182 static const U32 SO_FOLDERS_BY_NAME = 2;
183
184 LLInventoryFilter(const LLString& name);
185 virtual ~LLInventoryFilter();
186
187 void setFilterTypes(U32 types);
188 U32 getFilterTypes() const { return mFilterOps.mFilterTypes; }
189
190 void setFilterSubString(const LLString& string);
191 const LLString getFilterSubString(BOOL trim = FALSE);
192
193 void setFilterPermissions(PermissionMask perms);
194 PermissionMask getFilterPermissions() const { return mFilterOps.mPermissions; }
195
196 void setDateRange(U32 min_date, U32 max_date);
197 void setDateRangeLastLogoff(BOOL sl);
198 U32 getMinDate() const { return mFilterOps.mMinDate; }
199 U32 getMaxDate() const { return mFilterOps.mMaxDate; }
200
201 void setHoursAgo(U32 hours);
202 U32 getHoursAgo() const { return mFilterOps.mHoursAgo; }
203
204 void setShowFolderState( EFolderShow state);
205 EFolderShow getShowFolderState() { return mFilterOps.mShowFolderState; }
206
207 void setSortOrder(U32 order);
208 U32 getSortOrder() { return mOrder; }
209
210 BOOL check(LLFolderViewItem* item);
211 std::string::size_type getStringMatchOffset() const;
212 BOOL isActive();
213 BOOL isModified();
214 BOOL isModifiedAndClear();
215 BOOL isSinceLogoff();
216 void clearModified() { mModified = FALSE; mFilterBehavior = FILTER_NONE; }
217 const LLString getName() const { return mName; }
218 LLString getFilterText();
219
220 void setFilterCount(S32 count) { mFilterCount = count; }
221 S32 getFilterCount() { return mFilterCount; }
222 void decrementFilterCount() { mFilterCount--; }
223
224 void markDefault();
225 void resetDefault();
226
227 BOOL isFilterWith(LLInventoryType::EType t);
228
229 S32 getCurrentGeneration() const { return mFilterGeneration; }
230 S32 getMinRequiredGeneration() const { return mMinRequiredGeneration; }
231 S32 getMustPassGeneration() const { return mMustPassGeneration; }
232
233 //RN: this is public to allow system to externally force a global refilter
234 void setModified(EFilterBehavior behavior = FILTER_RESTART);
235
236protected:
237 struct filter_ops
238 {
239 U32 mFilterTypes;
240 U32 mMinDate;
241 U32 mMaxDate;
242 U32 mHoursAgo;
243 EFolderShow mShowFolderState;
244 PermissionMask mPermissions;
245 };
246 filter_ops mFilterOps;
247 filter_ops mDefaultFilterOps;
248 std::string::size_type mSubStringMatchOffset;
249 LLString mFilterSubString;
250 U32 mOrder;
251 const LLString mName;
252 S32 mFilterGeneration;
253 S32 mMustPassGeneration;
254 S32 mMinRequiredGeneration;
255 S32 mFilterCount;
256 S32 mNextFilterGeneration;
257 EFilterBehavior mFilterBehavior;
258
259private:
260 U32 mLastLogoff;
261 BOOL mModified;
262 BOOL mNeedTextRebuild;
263 LLString mFilterText;
264};
265
266//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
267// Class LLFolderViewItem
268//
269// An instance of this class represents a single item in a folder view
270// such as an inventory item or a file.
271//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
272
273class LLFontGL;
274class LLFolderViewFolder;
275class LLFolderView;
276
277class LLFolderViewItem : public LLUICtrl
278{
279protected:
280 friend class LLFolderViewEventListener;
281
282 static const LLFontGL* sFont;
283 static const LLFontGL* sSmallFont;
284 static LLColor4 sFgColor;
285 static LLColor4 sHighlightBgColor;
286 static LLColor4 sHighlightFgColor;
287 static LLColor4 sFilterBGColor;
288 static LLColor4 sFilterTextColor;
289
290 LLString mLabel;
291 LLString mSearchableLabel;
292 LLString mType;
293 S32 mLabelWidth;
294 U32 mCreationDate;
295 LLFolderViewFolder* mParentFolder;
296 LLFolderViewEventListener* mListener;
297 BOOL mIsSelected;
298 BOOL mIsCurSelection;
299 BOOL mSelectPending;
300 LLFontGL::StyleFlags mLabelStyle;
301 LLString mLabelSuffix;
302 LLPointer<LLViewerImage> mIcon;
303 LLString mStatusText;
304 BOOL mHasVisibleChildren;
305 S32 mIndentation;
306 S32 mNumDescendantsSelected;
307 BOOL mFiltered;
308 S32 mLastFilterGeneration;
309 std::string::size_type mStringMatchOffset;
310 F32 mControlLabelRotation;
311 LLFolderView* mRoot;
312 BOOL mDragAndDropTarget;
313 LLPointer<LLViewerImage> mArrowImage;
314 LLPointer<LLViewerImage> mBoxImage;
315
316 // This function clears the currently selected item, and records
317 // the specified selected item appropriately for display and use
318 // in the UI. If open is TRUE, then folders are opened up along
319 // the way to the selection.
320 void setSelectionFromRoot(LLFolderViewItem* selection, BOOL open,
321 BOOL take_keyboard_focus = TRUE);
322
323 // helper function to change the selection from the root.
324 void changeSelectionFromRoot(LLFolderViewItem* selection, BOOL selected);
325
326 // helper function to change the selection from the root.
327 void extendSelectionFromRoot(LLFolderViewItem* selection);
328
329 // this is an internal method used for adding items to folders. A
330 // no-op at this leve, but reimplemented in derived classes.
331 virtual BOOL addItem(LLFolderViewItem*) { return FALSE; }
332 virtual BOOL addFolder(LLFolderViewFolder*) { return FALSE; }
333
334public:
335 // This function is called when the folder view is dirty. It's
336 // implemented here but called by derived classes when folding the
337 // views.
338 void arrangeFromRoot();
339 void filterFromRoot( void );
340
341 // creation_date is in UTC seconds
342 LLFolderViewItem( const LLString& name, LLViewerImage* icon, S32 creation_date, LLFolderView* root, LLFolderViewEventListener* listener );
343 virtual ~LLFolderViewItem( void );
344
345 virtual EWidgetType getWidgetType() const;
346 virtual LLString getWidgetTag() const;
347
348 // addToFolder() returns TRUE if it succeeds. FALSE otherwise
349 enum { ARRANGE = TRUE, DO_NOT_ARRANGE = FALSE };
350 virtual BOOL addToFolder(LLFolderViewFolder* folder, LLFolderView* root);
351
352 // Finds width and height of this object and it's children. Also
353 // makes sure that this view and it's children are the right size.
354 virtual S32 arrange( S32* width, S32* height, S32 filter_generation );
355 virtual S32 getItemHeight();
356
357 // applies filters to control visibility of inventory items
358 virtual void filter( LLInventoryFilter& filter);
359
360 // updates filter serial number and optionally propagated value up to root
361 S32 getLastFilterGeneration() { return mLastFilterGeneration; }
362
363 virtual void dirtyFilter();
364
365 // If the selection is 'this' then note that otherwise
366 // ignore. Returns TRUE if this object was affected. If open is
367 // TRUE, then folders are opened up along the way to the
368 // selection.
369 virtual BOOL setSelection(LLFolderViewItem* selection, BOOL open,
370 BOOL take_keyboard_focus);
371
372 // This method is used to toggle the selection of an item. If
373 // selection is 'this', then note selection, and return TRUE.
374 virtual BOOL changeSelection(LLFolderViewItem* selection, BOOL selected);
375
376 // this method is used to group select items
377 virtual S32 extendSelection(LLFolderViewItem* selection, LLFolderViewItem* last_selected, LLDynamicArray<LLFolderViewItem*>& items){ return FALSE; }
378
379 // this method is used to group select items
380 virtual void recursiveDeselect(BOOL deselect_self);
381
382 // gets multiple-element selection
383 virtual BOOL getSelectionList(std::set<LLUUID> &selection){return TRUE;}
384
385 // Returns true is this object and all of its children can be removed (deleted by user)
386 virtual BOOL isRemovable();
387
388 // Returns true is this object and all of its children can be moved
389 virtual BOOL isMovable();
390
391 // destroys this item recursively
392 virtual void destroyView();
393
394 S32 getNumSelectedDescendants() { return mNumDescendantsSelected; }
395
396 BOOL isSelected() { return mIsSelected; }
397
398 void setIsCurSelection(BOOL select) { mIsCurSelection = select; }
399
400 BOOL getIsCurSelection() { return mIsCurSelection; }
401
402 BOOL hasVisibleChildren() { return mHasVisibleChildren; }
403
404 // Call through to the viewed object and return true if it can be
405 // removed. Returns true if it's removed.
406 //virtual BOOL removeRecursively(BOOL single_item);
407 BOOL remove();
408
409 // Build an appropriate context menu for the item. Flags unused.
410 void buildContextMenu(LLMenuGL& menu, U32 flags);
411
412 // This method returns the actual name of the thing being
413 // viewed. This method will ask the viewed object itself.
414 const LLString& getName( void ) const;
415
416 const LLString& getSearchableLabel( void ) const;
417
418 // This method returns the label displayed on the view. This
419 // method was primarily added to allow sorting on the folder
420 // contents possible before the entire view has been constructed.
421 const char* getLabel() const { return mLabel.c_str(); }
422
423 // Used for sorting, like getLabel() above.
424 virtual U32 getCreationDate() const { return mCreationDate; }
425
426 LLFolderViewFolder* getParentFolder( void );
427 LLFolderViewItem* getNextOpenNode( BOOL include_children = TRUE );
428 LLFolderViewItem* getPreviousOpenNode( BOOL include_children = TRUE );
429
430 LLFolderViewEventListener* getListener( void );
431
432 // just rename the object.
433 void rename(const LLString& new_name);
434
435 // open
436 virtual void open( void );
437 virtual void preview(void);
438
439 // Show children (unfortunate that this is called "open")
440 virtual void setOpen(BOOL open = TRUE) {};
441
442 virtual BOOL isOpen() { return FALSE; }
443
444 LLFolderView* getRoot();
445 BOOL isDescendantOf( const LLFolderViewFolder* potential_ancestor );
446 S32 getIndentation() { return mIndentation; }
447
448 virtual void setStatusText(const LLString& text) { mStatusText = text; }
449
450 BOOL getFiltered();
451 BOOL getFiltered(S32 filter_generation);
452 virtual void setFiltered(BOOL filtered, S32 filter_generation);
453
454 // change the icon
455 void setIcon(LLViewerImage* icon);
456
457 // refresh information from the object being viewed.
458 virtual void refresh();
459
460 virtual void applyListenerFunctorRecursively(LLFolderViewListenerFunctor& functor);
461
462 // LLView functionality
463 virtual BOOL handleRightMouseDown( S32 x, S32 y, MASK mask );
464 virtual BOOL handleMouseDown( S32 x, S32 y, MASK mask );
465 virtual BOOL handleHover( S32 x, S32 y, MASK mask );
466 virtual BOOL handleMouseUp( S32 x, S32 y, MASK mask );
467 virtual BOOL handleDoubleClick( S32 x, S32 y, MASK mask );
468 virtual BOOL handleScrollWheel(S32 x, S32 y, S32 clicks);
469
470 // virtual void handleDropped();
471 virtual void draw();
472 virtual BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
473 EDragAndDropType cargo_type,
474 void* cargo_data,
475 EAcceptance* accept,
476 LLString& tooltip_msg);
477};
478
479
480// function used for sorting.
481typedef bool (*sort_order_f)(LLFolderViewItem* a, LLFolderViewItem* b);
482
483
484//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
485// Class LLFolderViewFolder
486//
487// An instance of an LLFolderViewFolder represents a collection of
488// more folders and items. This is used to build the hierarchy of
489// items found in the folder view. :)
490//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
491
492class LLFolderViewFolder : public LLFolderViewItem
493{
494public:
495 typedef enum e_trash
496 {
497 UNKNOWN, TRASH, NOT_TRASH
498 } ETrash;
499
500protected:
501 typedef std::vector<LLFolderViewItem*> items_t;
502 typedef std::vector<LLFolderViewFolder*> folders_t;
503 items_t mItems;
504 folders_t mFolders;
505 sort_order_f mSortFunction;
506
507 BOOL mIsOpen;
508 BOOL mExpanderHighlighted;
509 F32 mCurHeight;
510 F32 mTargetHeight;
511 F32 mAutoOpenCountdown;
512 U32 mSubtreeCreationDate;
513 ETrash mAmTrash;
514 S32 mLastArrangeGeneration;
515 S32 mLastCalculatedWidth;
516 S32 mCompletedFilterGeneration;
517 S32 mMostFilteredDescendantGeneration;
518public:
519 typedef enum e_recurse_type
520 {
521 RECURSE_NO,
522 RECURSE_UP,
523 RECURSE_DOWN,
524 RECURSE_UP_DOWN
525 } ERecurseType;
526
527 LLFolderViewFolder( const LLString& name, LLViewerImage* icon,
528 LLFolderView* root,
529 LLFolderViewEventListener* listener );
530 virtual ~LLFolderViewFolder( void );
531
532 virtual EWidgetType getWidgetType() const;
533 virtual LLString getWidgetTag() const;
534
535 LLFolderViewItem* getNextFromChild( LLFolderViewItem*, BOOL include_children = TRUE );
536 LLFolderViewItem* getPreviousFromChild( LLFolderViewItem*, BOOL include_children = TRUE );
537
538 // addToFolder() returns TRUE if it succeeds. FALSE otherwise
539 virtual BOOL addToFolder(LLFolderViewFolder* folder, LLFolderView* root);
540
541 // Finds width and height of this object and it's children. Also
542 // makes sure that this view and it's children are the right size.
543 virtual S32 arrange( S32* width, S32* height, S32 filter_generation );
544
545 BOOL needsArrange();
546
547 virtual void setCompletedFilterGeneration(S32 generation, BOOL recurse_up);
548 virtual S32 getCompletedFilterGeneration() { return mCompletedFilterGeneration; }
549
550 BOOL hasFilteredDescendants(S32 filter_generation) { return mMostFilteredDescendantGeneration >= filter_generation; }
551 BOOL hasFilteredDescendants();
552
553 // applies filters to control visibility of inventory items
554 virtual void filter( LLInventoryFilter& filter);
555 virtual void setFiltered(BOOL filtered, S32 filter_generation);
556 virtual void dirtyFilter();
557
558 // Passes selection information on to children and record
559 // selection information if necessary. Returns TRUE if this object
560 // (or a child) was affected.
561 virtual BOOL setSelection(LLFolderViewItem* selection, BOOL open,
562 BOOL take_keyboard_focus);
563
564 // This method is used to change the selection of an item. If
565 // selection is 'this', then note selection as true. Returns TRUE
566 // if this or a child is now selected.
567 virtual BOOL changeSelection(LLFolderViewItem* selection, BOOL selected);
568
569 // this method is used to group select items
570 virtual S32 extendSelection(LLFolderViewItem* selection, LLFolderViewItem* last_selected, LLDynamicArray<LLFolderViewItem*>& items);
571
572 virtual void recursiveDeselect(BOOL deselect_self);
573
574 // Returns true is this object and all of its children can be removed.
575 virtual BOOL isRemovable();
576
577 // Returns true is this object and all of its children can be moved
578 virtual BOOL isMovable();
579
580 // destroys this folder, and all children
581 virtual void destroyView();
582
583 // If this folder can be removed, remove all children that can be
584 // removed, return TRUE if this is empty after the operation and
585 // it's viewed folder object can be removed.
586 //virtual BOOL removeRecursively(BOOL single_item);
587 //virtual BOOL remove();
588
589 // remove the specified item (and any children) if
590 // possible. Return TRUE if the item was deleted.
591 BOOL removeItem(LLFolderViewItem* item);
592
593 // simply remove the view (and any children) Don't bother telling
594 // the listeners.
595 void removeView(LLFolderViewItem* item);
596
597 // extractItem() removes the specified item from the folder, but
598 // doesn't delete it.
599 void extractItem( LLFolderViewItem* item );
600
601 // This function is called by a child that needs to be resorted.
602 void resort(LLFolderViewItem* item);
603
604 void setItemSortFunction(sort_order_f ordering);
605 void sortBy(U32);
606 //BOOL (*func)(LLFolderViewItem* a, LLFolderViewItem* b));
607
608 void setAutoOpenCountdown(F32 countdown) { mAutoOpenCountdown = countdown; }
609
610 // folders can be opened. This will usually be called by internal
611 // methods.
612 virtual void toggleOpen();
613
614 // Force a folder open or closed
615 virtual void setOpen(BOOL open = TRUE);
616
617 // Called when a child is refreshed.
618 virtual void requestArrange();
619
620 // internal method which doesn't update the entire view. This
621 // method was written because the list iterators destroy the state
622 // of other iterations, thus, we can't arrange while iterating
623 // through the children (such as when setting which is selected.
624 virtual void setOpenArrangeRecursively(BOOL open, ERecurseType recurse = RECURSE_NO);
625
626 // Get the current state of the folder.
627 virtual BOOL isOpen() { return mIsOpen; }
628
629 // special case if an object is dropped on the child.
630 BOOL handleDragAndDropFromChild(MASK mask,
631 BOOL drop,
632 EDragAndDropType cargo_type,
633 void* cargo_data,
634 EAcceptance* accept,
635 LLString& tooltip_msg);
636
637 void applyFunctorRecursively(LLFolderViewFunctor& functor);
638 virtual void applyListenerFunctorRecursively(LLFolderViewListenerFunctor& functor);
639
640 virtual void open( void );
641 virtual BOOL addItem(LLFolderViewItem* item);
642 virtual BOOL addFolder( LLFolderViewFolder* folder);
643
644 // LLView functionality
645 virtual BOOL handleHover(S32 x, S32 y, MASK mask);
646 virtual BOOL handleRightMouseDown( S32 x, S32 y, MASK mask );
647 virtual BOOL handleMouseDown( S32 x, S32 y, MASK mask );
648 virtual BOOL handleDoubleClick( S32 x, S32 y, MASK mask );
649 virtual BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
650 EDragAndDropType cargo_type,
651 void* cargo_data,
652 EAcceptance* accept,
653 LLString& tooltip_msg);
654 virtual void draw();
655
656 U32 getCreationDate() const;
657 bool isTrash();
658};
659
660
661//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
662// Class LLFolderView
663//
664// Th LLFolderView represents the root level folder view object. It
665// manages the screen region of the folder view.
666//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
667
668class LLUICtrl;
669class LLLineEditor;
670
671class LLFolderView : public LLFolderViewFolder, LLEditMenuHandler
672{
673public:
674 typedef void (*SelectCallback)(const std::deque<LLFolderViewItem*> &items, BOOL user_action, void* data);
675
676 static F32 sAutoOpenTime;
677
678 LLFolderView( const LLString& name, LLViewerImage* root_folder_icon, const LLRect& rect,
679 const LLUUID& source_id, LLView *parent_view );
680 virtual ~LLFolderView( void );
681
682 virtual EWidgetType getWidgetType() const;
683 virtual LLString getWidgetTag() const;
684 virtual BOOL canFocusChildren() const;
685
686 // FolderViews default to sort by name. This will change that,
687 // and resort the items if necessary.
688 void setSortOrder(U32 order);
689 void checkTreeResortForModelChanged();
690 void setFilterPermMask(PermissionMask filter_perm_mask) { mFilter.setFilterPermissions(filter_perm_mask); }
691 void setSelectCallback(SelectCallback callback, void* user_data) { mSelectCallback = callback, mUserData = user_data; }
692 void setAllowMultiSelect(BOOL allow) { mAllowMultiSelect = allow; }
693
694 LLInventoryFilter* getFilter() { return &mFilter; }
695 const LLString getFilterSubString(BOOL trim = FALSE);
696 U32 getFilterTypes() const { return mFilter.getFilterTypes(); }
697 PermissionMask getFilterPermissions() const { return mFilter.getFilterPermissions(); }
698 LLInventoryFilter::EFolderShow getShowFolderState() { return mFilter.getShowFolderState(); }
699 U32 getSortOrder() const;
700 BOOL isFilterActive() { return mFilter.isActive(); }
701 BOOL getAllowMultiSelect() { return mAllowMultiSelect; }
702
703 // Close all folders in the view
704 void closeAllFolders();
705 void openFolder(const LLString& foldername);
706
707 virtual void toggleOpen() {};
708 virtual void setOpenArrangeRecursively(BOOL open, ERecurseType recurse);
709 virtual BOOL addFolder( LLFolderViewFolder* folder);
710
711 // Finds width and height of this object and it's children. Also
712 // makes sure that this view and it's children are the right size.
713 virtual S32 arrange( S32* width, S32* height, S32 filter_generation );
714
715 void arrangeAll() { mArrangeGeneration++; }
716 S32 getArrangeGeneration() { return mArrangeGeneration; }
717
718 // applies filters to control visibility of inventory items
719 virtual void filter( LLInventoryFilter& filter);
720
721 // get the last selected item
722 virtual LLFolderViewItem* getCurSelectedItem( void );
723
724 // Record the selected item and pass it down the hierachy.
725 virtual BOOL setSelection(LLFolderViewItem* selection, BOOL open,
726 BOOL take_keyboard_focus);
727
728 // This method is used to toggle the selection of an item. Walks
729 // children, and keeps track of selected objects.
730 virtual BOOL changeSelection(LLFolderViewItem* selection, BOOL selected);
731
732 virtual S32 extendSelection(LLFolderViewItem* selection, LLFolderViewItem* last_selected, LLDynamicArray<LLFolderViewItem*>& items);
733
734 virtual BOOL getSelectionList(std::set<LLUUID> &selection);
735
736 // make sure if ancestor is selected, descendents are not
737 void sanitizeSelection();
738 void clearSelection();
739 void addToSelectionList(LLFolderViewItem* item);
740 void removeFromSelectionList(LLFolderViewItem* item);
741
742 BOOL startDrag(LLToolDragAndDrop::ESource source);
743 void setDragAndDropThisFrame() { mDragAndDropThisFrame = TRUE; }
744
745 // deletion functionality
746 void removeSelectedItems();
747
748 // open the selected item.
749 void openSelectedItems( void );
750 void propertiesSelectedItems( void );
751
752 void autoOpenItem(LLFolderViewFolder* item);
753 void closeAutoOpenedFolders();
754 BOOL autoOpenTest(LLFolderViewFolder* item);
755
756 // copy & paste
757 virtual void copy();
758 virtual BOOL canCopy();
759
760 virtual void cut();
761 virtual BOOL canCut();
762
763 virtual void paste();
764 virtual BOOL canPaste();
765
766 virtual void doDelete();
767 virtual BOOL canDoDelete();
768
769 // public rename functionality - can only start the process
770 void startRenamingSelectedItem( void );
771
772 // These functions were used when there was only one folderview,
773 // and relied on that concept. This functionality is now handled
774 // by the listeners and the lldraganddroptool.
775 //LLFolderViewItem* getMovingItem() { return mMovingItem; }
776 //void setMovingItem( LLFolderViewItem* item ) { mMovingItem = item; }
777 //void dragItemIntoFolder( LLFolderViewItem* moving_item, LLFolderViewFolder* dst_folder, BOOL drop, BOOL* accept );
778 //void dragFolderIntoFolder( LLFolderViewFolder* moving_folder, LLFolderViewFolder* dst_folder, BOOL drop, BOOL* accept );
779
780 // LLUICtrl Functionality
781 /*virtual*/ void setFocus(BOOL focus);
782
783 // LLView functionality
784 ///*virtual*/ BOOL handleKey( KEY key, MASK mask, BOOL called_from_parent );
785 /*virtual*/ BOOL handleKeyHere( KEY key, MASK mask, BOOL called_from_parent );
786 /*virtual*/ BOOL handleUnicodeCharHere(llwchar uni_char, BOOL called_from_parent);
787 /*virtual*/ BOOL handleMouseDown( S32 x, S32 y, MASK mask );
788 /*virtual*/ BOOL handleDoubleClick( S32 x, S32 y, MASK mask );
789 /*virtual*/ BOOL handleRightMouseDown( S32 x, S32 y, MASK mask );
790 /*virtual*/ BOOL handleHover( S32 x, S32 y, MASK mask );
791 /*virtual*/ BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
792 EDragAndDropType cargo_type,
793 void* cargo_data,
794 EAcceptance* accept,
795 LLString& tooltip_msg);
796 /*virtual*/ void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE);
797 /*virtual*/ void onFocusLost();
798 virtual BOOL handleScrollWheel(S32 x, S32 y, S32 clicks);
799 virtual void draw();
800 virtual void deleteAllChildren();
801
802 void scrollToShowSelection();
803 void scrollToShowItem(LLFolderViewItem* item);
804 void setScrollContainer( LLScrollableContainerView* parent ) { mScrollContainer = parent; }
805 LLRect getVisibleRect();
806
807 BOOL search(LLFolderViewItem* first_item, const LLString &search_string, BOOL backward);
808 void setShowSelectionContext(BOOL show) { mShowSelectionContext = show; }
809 BOOL getShowSelectionContext();
810 void setShowSingleSelection(BOOL show);
811 BOOL getShowSingleSelection() { return mShowSingleSelection; }
812 F32 getSelectionFadeElapsedTime() { return mMultiSelectionFadeTimer.getElapsedTimeF32(); }
813
814 void addItemID(const LLUUID& id, LLFolderViewItem* itemp);
815 void removeItemID(const LLUUID& id);
816 LLFolderViewItem* getItemByID(const LLUUID& id);
817
818 static void idle(void* user_data);
819
820 void setAutoSelectOverride(bool override) { mAutoSelectOverride = override; }
821 BOOL needsAutoSelect() { return mNeedsAutoSelect && !mAutoSelectOverride; }
822 BOOL getDebugFilters() { return mDebugFilters; }
823
824 // DEBUG only
825 void dumpSelectionInformation();
826
827protected:
828 LLScrollableContainerView* mScrollContainer; // NULL if this is not a child of a scroll container.
829
830 static void commitRename( LLUICtrl* renamer, void* user_data );
831 void finishRenamingItem( void );
832 void revertRenamingItem( void );
833
834protected:
835 LLViewHandle mPopupMenuHandle;
836
837 typedef std::deque<LLFolderViewItem*> selected_items_t;
838 selected_items_t mSelectedItems;
839 BOOL mKeyboardSelection;
840 BOOL mAllowMultiSelect;
841 BOOL mShowFolderHierarchy;
842 LLUUID mSourceID;
843
844 // Renaming variables and methods
845 LLFolderViewItem* mRenameItem; // The item currently being renamed
846 LLLineEditor* mRenamer;
847
848 BOOL mNeedsScroll;
849 LLFolderViewItem* mLastScrollItem;
850 LLCoordGL mLastScrollOffset;
851 BOOL mNeedsAutoSelect;
852 BOOL mAutoSelectOverride;
853
854 BOOL mDebugFilters;
855 U32 mSortOrder;
856 LLDepthStack<LLFolderViewFolder> mAutoOpenItems;
857 LLFolderViewFolder* mAutoOpenCandidate;
858 LLFrameTimer mAutoOpenTimer;
859 LLFrameTimer mSearchTimer;
860 LLString mSearchString;
861 LLInventoryFilter mFilter;
862 BOOL mShowSelectionContext;
863 BOOL mShowSingleSelection;
864 LLFrameTimer mMultiSelectionFadeTimer;
865 S32 mArrangeGeneration;
866
867 void* mUserData;
868 SelectCallback mSelectCallback;
869 BOOL mSelectionChanged;
870 S32 mMinWidth;
871 std::map<LLUUID, LLFolderViewItem*> mItemMap;
872 BOOL mDragAndDropThisFrame;
873
874};
875
876bool sort_item_name(LLFolderViewItem* a, LLFolderViewItem* b);
877bool sort_item_date(LLFolderViewItem* a, LLFolderViewItem* b);
878
879// Flags for buildContextMenu()
880const U32 SUPPRESS_OPEN_ITEM = 0x1;
881const U32 FIRST_SELECTED_ITEM = 0x2;
882
883#endif // LL_LLFOLDERVIEW_H