llfolderview.h

Go to the documentation of this file.
00001 
00040 #ifndef LL_LLFOLDERVIEW_H
00041 #define LL_LLFOLDERVIEW_H
00042 
00043 #include <vector>
00044 #include <map>
00045 #include <deque>
00046 
00047 #include "lluictrl.h"
00048 #include "v4color.h"
00049 #include "lldarray.h"
00050 //#include "llviewermenu.h"
00051 #include "stdenums.h"
00052 #include "llfontgl.h"
00053 #include "lleditmenuhandler.h"
00054 #include "llviewerimage.h"
00055 #include "lldepthstack.h"
00056 #include "lltooldraganddrop.h"
00057 
00058 class LLMenuGL;
00059 
00060 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00061 // Class LLFolderViewEventListener
00062 //
00063 // This is an abstract base class that users of the folderview classes
00064 // would use to catch the useful events emitted from the folder
00065 // views.
00066 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00067 
00068 
00069 class LLFolderViewItem;
00070 class LLFolderView;
00071 class LLInventoryModel;
00072 class LLScrollableContainerView;
00073 typedef BOOL (*LLFolderSearchFunction)(LLFolderViewItem* first_item, const char *find_text, BOOL backward);
00074 
00075 class LLFolderViewEventListener
00076 {
00077 public:
00078         virtual ~LLFolderViewEventListener( void ) {}
00079         virtual const LLString& getName() const = 0;
00080         virtual const LLString& getDisplayName() const = 0;
00081         virtual const LLUUID& getUUID() const = 0;
00082         virtual U32 getCreationDate() const = 0;        // UTC seconds
00083         virtual PermissionMask getPermissionMask() const = 0;
00084         virtual LLUIImagePtr getIcon() const = 0;
00085         virtual LLFontGL::StyleFlags getLabelStyle() const = 0;
00086         virtual LLString getLabelSuffix() const = 0;
00087         virtual void openItem( void ) = 0;
00088         virtual void previewItem( void ) = 0;
00089         virtual void selectItem(void) = 0;
00090         virtual void showProperties(void) = 0;
00091         virtual BOOL isItemRenameable() const = 0;
00092         virtual BOOL renameItem(const LLString& new_name) = 0;
00093         virtual BOOL isItemMovable( void ) = 0;         // Can be moved to another folder
00094         virtual BOOL isItemRemovable( void ) = 0;       // Can be destroyed
00095         virtual BOOL removeItem() = 0;
00096         virtual void removeBatch(LLDynamicArray<LLFolderViewEventListener*>& batch) = 0;
00097         virtual void move( LLFolderViewEventListener* parent_listener ) = 0;
00098         virtual BOOL isItemCopyable() const = 0;
00099         virtual BOOL copyToClipboard() const = 0;
00100         virtual void cutToClipboard() = 0;
00101         virtual BOOL isClipboardPasteable() const = 0;
00102         virtual void pasteFromClipboard() = 0;
00103         virtual void buildContextMenu(LLMenuGL& menu, U32 flags) = 0;
00104         virtual BOOL isUpToDate() const = 0;
00105         virtual BOOL hasChildren() const = 0;
00106         virtual LLInventoryType::EType getInventoryType() const = 0;
00107         virtual void performAction(LLFolderView* folder, LLInventoryModel* model, LLString action) {}
00108 
00109         // This method should be called when a drag begins. returns TRUE
00110         // if the drag can begin, otherwise FALSE.
00111         virtual BOOL startDrag(EDragAndDropType* type, LLUUID* id) const = 0;
00112 
00113         // This method will be called to determine if a drop can be
00114         // performed, and will set drop to TRUE if a drop is
00115         // requested. Returns TRUE if a drop is possible/happened,
00116         // otherwise FALSE.
00117         virtual BOOL dragOrDrop(MASK mask, BOOL drop,
00118                                                         EDragAndDropType cargo_type,
00119                                                         void* cargo_data) = 0;
00120 
00121         // This method is called when the object being referenced by the
00122         // bridge is actually dropped. This allows for cleanup of the old
00123         // view, reference counting, etc.
00124 //      virtual void dropped() = 0;
00125 
00126         // this method accesses the parent and arranges and sets it as
00127         // specified.
00128         void arrangeAndSet(LLFolderViewItem* focus, BOOL set_selection,
00129                 BOOL take_keyboard_focus = TRUE);
00130 };
00131 
00132 
00133 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00134 // Class LLFolderViewListenerFunctor
00135 //
00136 // This simple abstract base class can be used to applied to all
00137 // listeners in a hierarchy.
00138 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00139 
00140 class LLFolderViewListenerFunctor
00141 {
00142 public:
00143         virtual ~LLFolderViewListenerFunctor() {}
00144         virtual void operator()(LLFolderViewEventListener* listener) = 0;
00145 };
00146 
00147 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00148 // Class LLFolderViewFunctor
00149 //
00150 // Simple abstract base class for applying a functor to folders and
00151 // items in a folder view hierarchy. This is suboptimal for algorithms
00152 // that only work folders or only work on items, but I'll worry about
00153 // that later when it's determined to be too slow.
00154 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00155 
00156 class LLFolderViewItem;
00157 class LLFolderViewFolder;
00158 
00159 class LLFolderViewFunctor
00160 {
00161 public:
00162         virtual ~LLFolderViewFunctor() {}
00163         virtual void doFolder(LLFolderViewFolder* folder) = 0;
00164         virtual void doItem(LLFolderViewItem* item) = 0;
00165 };
00166 
00167 class LLInventoryFilter
00168 {
00169 public:
00170         typedef enum e_folder_show
00171         {
00172                 SHOW_ALL_FOLDERS,
00173                 SHOW_NON_EMPTY_FOLDERS,
00174                 SHOW_NO_FOLDERS
00175         } EFolderShow;
00176 
00177         typedef enum e_filter_behavior
00178         {
00179                 FILTER_NONE,                            // nothing to do, already filtered
00180                 FILTER_RESTART,                         // restart filtering from scratch
00181                 FILTER_LESS_RESTRICTIVE,        // existing filtered items will certainly pass this filter
00182                 FILTER_MORE_RESTRICTIVE         // if you didn't pass the previous filter, you definitely won't pass this one
00183         } EFilterBehavior;
00184 
00185         static const U32 SO_DATE = 1;
00186         static const U32 SO_FOLDERS_BY_NAME = 2;
00187         static const U32 SO_SYSTEM_FOLDERS_TO_TOP = 4;
00188 
00189         LLInventoryFilter(const LLString& name);
00190         virtual ~LLInventoryFilter();
00191 
00192         void setFilterTypes(U32 types);
00193         U32 getFilterTypes() const { return mFilterOps.mFilterTypes; }
00194         
00195         void setFilterSubString(const LLString& string);
00196         const LLString getFilterSubString(BOOL trim = FALSE);
00197 
00198         void setFilterPermissions(PermissionMask perms);
00199         PermissionMask getFilterPermissions() const { return mFilterOps.mPermissions; }
00200 
00201         void setDateRange(U32 min_date, U32 max_date);
00202         void setDateRangeLastLogoff(BOOL sl);
00203         U32 getMinDate() const { return mFilterOps.mMinDate; }
00204         U32 getMaxDate() const { return mFilterOps.mMaxDate; }
00205 
00206         void setHoursAgo(U32 hours);
00207         U32 getHoursAgo() const { return mFilterOps.mHoursAgo; }
00208 
00209         void setShowFolderState( EFolderShow state);
00210         EFolderShow getShowFolderState() { return mFilterOps.mShowFolderState; }
00211 
00212         void setSortOrder(U32 order);
00213         U32 getSortOrder() { return mOrder; }
00214 
00215         BOOL check(LLFolderViewItem* item);
00216         std::string::size_type getStringMatchOffset() const;
00217         BOOL isActive();
00218         BOOL isNotDefault();
00219         BOOL isModified();
00220         BOOL isModifiedAndClear();
00221         BOOL isSinceLogoff();
00222         void clearModified() { mModified = FALSE; mFilterBehavior = FILTER_NONE; }
00223         const LLString getName() const { return mName; }
00224         LLString getFilterText();
00225 
00226         void setFilterCount(S32 count) { mFilterCount = count; }
00227         S32 getFilterCount() { return mFilterCount; }
00228         void decrementFilterCount() { mFilterCount--; }
00229         
00230         void markDefault();
00231         void resetDefault();
00232 
00233         BOOL isFilterWith(LLInventoryType::EType t);
00234 
00235         S32 getCurrentGeneration() const { return mFilterGeneration; }
00236         S32 getMinRequiredGeneration() const { return mMinRequiredGeneration; }
00237         S32 getMustPassGeneration() const { return mMustPassGeneration; }
00238 
00239         //RN: this is public to allow system to externally force a global refilter
00240         void setModified(EFilterBehavior behavior = FILTER_RESTART);
00241 
00242         void toLLSD(LLSD& data);
00243         void fromLLSD(LLSD& data);
00244 
00245 protected:
00246         struct filter_ops
00247         {
00248                 U32                     mFilterTypes;
00249                 U32                     mMinDate;
00250                 U32                     mMaxDate;
00251                 U32                     mHoursAgo;
00252                 EFolderShow     mShowFolderState;
00253                 PermissionMask  mPermissions;
00254         };
00255         filter_ops              mFilterOps;
00256         filter_ops              mDefaultFilterOps;
00257         std::string::size_type  mSubStringMatchOffset;
00258         LLString                mFilterSubString;
00259         U32                             mOrder;
00260         const LLString  mName;
00261         S32                             mFilterGeneration;
00262         S32                             mMustPassGeneration;
00263         S32                             mMinRequiredGeneration;
00264         S32                             mFilterCount;
00265         S32                             mNextFilterGeneration;
00266         EFilterBehavior mFilterBehavior;
00267 
00268 private:
00269         U32 mLastLogoff;
00270         BOOL mModified;
00271         BOOL mNeedTextRebuild;
00272         LLString mFilterText;
00273 };
00274 
00275 // These are grouping of inventory types.
00276 // Order matters when sorting system folders to the top.
00277 enum EInventorySortGroup
00278 { 
00279         SG_SYSTEM_FOLDER, 
00280         SG_TRASH_FOLDER, 
00281         SG_NORMAL_FOLDER, 
00282         SG_ITEM 
00283 };
00284 
00285 class LLInventorySort
00286 {
00287 public:
00288         LLInventorySort() 
00289                 : mSortOrder(0),
00290                   mByDate(false),
00291                   mSystemToTop(false),
00292                   mFoldersByName(false) { }
00293         
00294         // Returns true if order has changed
00295         bool updateSort(U32 order);
00296         U32 getSort() { return mSortOrder; }
00297 
00298         bool operator()(LLFolderViewItem* a, LLFolderViewItem* b);
00299 private:
00300         U32  mSortOrder;
00301         bool mByDate;
00302         bool mSystemToTop;
00303         bool mFoldersByName;
00304 };
00305 
00306 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00307 // Class LLFolderViewItem
00308 //
00309 // An instance of this class represents a single item in a folder view
00310 // such as an inventory item or a file.
00311 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00312 
00313 class LLFontGL;
00314 class LLFolderViewFolder;
00315 class LLFolderView;
00316 
00317 class LLFolderViewItem : public LLUICtrl
00318 {
00319 protected:
00320         friend class LLFolderViewEventListener;
00321 
00322         static const LLFontGL*          sFont;
00323         static const LLFontGL*          sSmallFont;
00324         static LLColor4                         sFgColor;
00325         static LLColor4                         sHighlightBgColor;
00326         static LLColor4                         sHighlightFgColor;
00327         static LLColor4                         sFilterBGColor;
00328         static LLColor4                         sFilterTextColor;
00329         static LLColor4                         sSuffixColor;
00330         static LLColor4                         sSearchStatusColor;
00331 
00332         LLString                                        mLabel;
00333         LLString                                        mSearchableLabel;
00334         LLString                                        mType;
00335         S32                                                     mLabelWidth;
00336         U32                                                     mCreationDate;
00337         LLFolderViewFolder*                     mParentFolder;
00338         LLFolderViewEventListener*      mListener;
00339         BOOL                                            mIsSelected;
00340         BOOL                                            mIsCurSelection;
00341         BOOL                                            mSelectPending;
00342         LLFontGL::StyleFlags            mLabelStyle;
00343         LLString                                        mLabelSuffix;
00344         LLUIImagePtr                            mIcon;
00345         LLString                                        mStatusText;
00346         BOOL                                            mHasVisibleChildren;
00347         S32                                                     mIndentation;
00348         S32                                                     mNumDescendantsSelected;
00349         BOOL                                            mFiltered;
00350         S32                                                     mLastFilterGeneration;
00351         std::string::size_type          mStringMatchOffset;
00352         F32                                                     mControlLabelRotation;
00353         LLFolderView*                           mRoot;
00354         BOOL                                            mDragAndDropTarget;
00355         LLUIImagePtr                            mArrowImage;
00356         LLUIImagePtr                            mBoxImage;
00357         BOOL                            mIsLoading;
00358         LLTimer                         mTimeSinceRequestStart;
00359         
00360         // This function clears the currently selected item, and records
00361         // the specified selected item appropriately for display and use
00362         // in the UI. If open is TRUE, then folders are opened up along
00363         // the way to the selection.
00364         void setSelectionFromRoot(LLFolderViewItem* selection, BOOL open,               /* Flawfinder: ignore */
00365                 BOOL take_keyboard_focus = TRUE);
00366 
00367         // helper function to change the selection from the root.
00368         void changeSelectionFromRoot(LLFolderViewItem* selection, BOOL selected);
00369 
00370         // helper function to change the selection from the root.
00371         void extendSelectionFromRoot(LLFolderViewItem* selection);
00372 
00373         // this is an internal method used for adding items to folders. A
00374         // no-op at this leve, but reimplemented in derived classes.
00375         virtual BOOL addItem(LLFolderViewItem*) { return FALSE; }
00376         virtual BOOL addFolder(LLFolderViewFolder*) { return FALSE; }
00377 
00378 public:
00379         // This function is called when the folder view is dirty. It's
00380         // implemented here but called by derived classes when folding the
00381         // views.
00382         void arrangeFromRoot();
00383         void filterFromRoot( void );
00384 
00385         // creation_date is in UTC seconds
00386         LLFolderViewItem( const LLString& name, LLUIImagePtr icon, S32 creation_date, LLFolderView* root, LLFolderViewEventListener* listener );
00387         virtual ~LLFolderViewItem( void );
00388 
00389         // addToFolder() returns TRUE if it succeeds. FALSE otherwise
00390         enum { ARRANGE = TRUE, DO_NOT_ARRANGE = FALSE };
00391         virtual BOOL addToFolder(LLFolderViewFolder* folder, LLFolderView* root);
00392 
00393         virtual EInventorySortGroup getSortGroup();
00394 
00395         // Finds width and height of this object and it's children.  Also
00396         // makes sure that this view and it's children are the right size.
00397         virtual S32 arrange( S32* width, S32* height, S32 filter_generation );
00398         virtual S32 getItemHeight();
00399 
00400         // applies filters to control visibility of inventory items
00401         virtual void filter( LLInventoryFilter& filter);
00402 
00403         // updates filter serial number and optionally propagated value up to root
00404         S32             getLastFilterGeneration() { return mLastFilterGeneration; }
00405 
00406         virtual void    dirtyFilter();
00407 
00408         // If the selection is 'this' then note that otherwise
00409         // ignore. Returns TRUE if this object was affected. If open is
00410         // TRUE, then folders are opened up along the way to the
00411         // selection.
00412         virtual BOOL setSelection(LLFolderViewItem* selection, BOOL open,               /* Flawfinder: ignore */
00413                 BOOL take_keyboard_focus);
00414 
00415         // This method is used to toggle the selection of an item. If
00416         // selection is 'this', then note selection, and return TRUE.
00417         virtual BOOL changeSelection(LLFolderViewItem* selection, BOOL selected);
00418 
00419         // this method is used to group select items
00420         virtual S32 extendSelection(LLFolderViewItem* selection, LLFolderViewItem* last_selected, LLDynamicArray<LLFolderViewItem*>& items){ return FALSE; }
00421 
00422         // this method is used to group select items
00423         virtual void recursiveDeselect(BOOL deselect_self);
00424 
00425         // gets multiple-element selection
00426         virtual BOOL getSelectionList(std::set<LLUUID> &selection){return TRUE;}
00427 
00428         // Returns true is this object and all of its children can be removed (deleted by user)
00429         virtual BOOL isRemovable();
00430 
00431         // Returns true is this object and all of its children can be moved
00432         virtual BOOL isMovable();
00433 
00434         // destroys this item recursively
00435         virtual void destroyView();
00436 
00437         S32 getNumSelectedDescendants() { return mNumDescendantsSelected; }
00438 
00439         BOOL isSelected() { return mIsSelected; }
00440 
00441         void setIsCurSelection(BOOL select) { mIsCurSelection = select; }
00442 
00443         BOOL getIsCurSelection() { return mIsCurSelection; }
00444 
00445         BOOL hasVisibleChildren() { return mHasVisibleChildren; }
00446 
00447         // Call through to the viewed object and return true if it can be
00448         // removed. Returns true if it's removed.
00449         //virtual BOOL removeRecursively(BOOL single_item);
00450         BOOL remove();
00451 
00452         // Build an appropriate context menu for the item.      Flags unused.
00453         void buildContextMenu(LLMenuGL& menu, U32 flags);
00454 
00455         // This method returns the actual name of the thing being
00456         // viewed. This method will ask the viewed object itself.
00457         const LLString& getName( void ) const;
00458 
00459         const LLString& getSearchableLabel( void ) const;
00460 
00461         // This method returns the label displayed on the view. This
00462         // method was primarily added to allow sorting on the folder
00463         // contents possible before the entire view has been constructed.
00464         const char* getLabel() const { return mLabel.c_str(); }
00465 
00466         // Used for sorting, like getLabel() above.
00467         virtual U32 getCreationDate() const { return mCreationDate; }
00468         
00469         LLFolderViewFolder* getParentFolder( void ) { return mParentFolder; }
00470         const LLFolderViewFolder* getParentFolder( void ) const { return mParentFolder; }
00471         
00472         LLFolderViewItem* getNextOpenNode( BOOL include_children = TRUE );
00473         LLFolderViewItem* getPreviousOpenNode( BOOL include_children = TRUE );
00474 
00475         const LLFolderViewEventListener* getListener( void ) const { return mListener; }
00476         LLFolderViewEventListener* getListener( void ) { return mListener; }
00477 
00478         // just rename the object.
00479         void rename(const LLString& new_name);
00480 
00481         // open
00482         virtual void open( void );              /* Flawfinder: ignore */
00483         virtual void preview(void);
00484 
00485         // Show children (unfortunate that this is called "open")
00486         virtual void setOpen(BOOL open = TRUE) {};
00487 
00488         virtual BOOL isOpen() { return FALSE; }
00489 
00490         LLFolderView*   getRoot();
00491         BOOL                    isDescendantOf( const LLFolderViewFolder* potential_ancestor );
00492         S32                             getIndentation() { return mIndentation; }
00493 
00494         virtual BOOL    potentiallyVisible(); // do we know for a fact that this item has been filtered out?
00495 
00496         virtual BOOL    getFiltered();
00497         virtual BOOL    getFiltered(S32 filter_generation);
00498         virtual void    setFiltered(BOOL filtered, S32 filter_generation);
00499 
00500         // change the icon
00501         void setIcon(LLUIImagePtr icon);
00502 
00503         // refresh information from the object being viewed.
00504         virtual void refresh();
00505 
00506         virtual void applyListenerFunctorRecursively(LLFolderViewListenerFunctor& functor);
00507 
00508         // LLView functionality
00509         virtual BOOL handleRightMouseDown( S32 x, S32 y, MASK mask );
00510         virtual BOOL handleMouseDown( S32 x, S32 y, MASK mask );
00511         virtual BOOL handleHover( S32 x, S32 y, MASK mask );
00512         virtual BOOL handleMouseUp( S32 x, S32 y, MASK mask );
00513         virtual BOOL handleDoubleClick( S32 x, S32 y, MASK mask );
00514         virtual BOOL handleScrollWheel(S32 x, S32 y, S32 clicks);
00515 
00516         //      virtual void handleDropped();
00517         virtual void draw();
00518         virtual BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
00519                                                                    EDragAndDropType cargo_type,
00520                                                                    void* cargo_data,
00521                                                                    EAcceptance* accept,
00522                                                                    LLString& tooltip_msg);
00523 };
00524 
00525 
00526 // function used for sorting.
00527 typedef bool (*sort_order_f)(LLFolderViewItem* a, LLFolderViewItem* b);
00528 
00529 
00530 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00531 // Class LLFolderViewFolder
00532 //
00533 // An instance of an LLFolderViewFolder represents a collection of
00534 // more folders and items. This is used to build the hierarchy of
00535 // items found in the folder view. :)
00536 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00537 
00538 class LLFolderViewFolder : public LLFolderViewItem
00539 {
00540 public:
00541         typedef enum e_trash
00542         {
00543                 UNKNOWN, TRASH, NOT_TRASH
00544         } ETrash;
00545 
00546 protected:
00547         typedef std::vector<LLFolderViewItem*> items_t;
00548         typedef std::vector<LLFolderViewFolder*> folders_t;
00549         items_t mItems;
00550         folders_t mFolders;
00551         LLInventorySort mSortFunction;
00552 
00553         BOOL            mIsOpen;
00554         BOOL            mExpanderHighlighted;
00555         F32                     mCurHeight;
00556         F32                     mTargetHeight;
00557         F32                     mAutoOpenCountdown;
00558         U32                     mSubtreeCreationDate;
00559         ETrash          mAmTrash;
00560         S32                     mLastArrangeGeneration;
00561         S32                     mLastCalculatedWidth;
00562         S32                     mCompletedFilterGeneration;
00563         S32                     mMostFilteredDescendantGeneration;
00564 public:
00565         typedef enum e_recurse_type
00566         {
00567                 RECURSE_NO,
00568                 RECURSE_UP,
00569                 RECURSE_DOWN,
00570                 RECURSE_UP_DOWN
00571         } ERecurseType;
00572 
00573         LLFolderViewFolder( const LLString& name, LLUIImagePtr icon,
00574                                                 LLFolderView* root,
00575                                                 LLFolderViewEventListener* listener );
00576         virtual ~LLFolderViewFolder( void );
00577 
00578         virtual BOOL    potentiallyVisible();
00579 
00580         LLFolderViewItem* getNextFromChild( LLFolderViewItem*, BOOL include_children = TRUE );
00581         LLFolderViewItem* getPreviousFromChild( LLFolderViewItem*, BOOL include_children = TRUE  );
00582 
00583         // addToFolder() returns TRUE if it succeeds. FALSE otherwise
00584         virtual BOOL addToFolder(LLFolderViewFolder* folder, LLFolderView* root);
00585 
00586         // Finds width and height of this object and it's children.  Also
00587         // makes sure that this view and it's children are the right size.
00588         virtual S32 arrange( S32* width, S32* height, S32 filter_generation );
00589 
00590         BOOL needsArrange();
00591 
00592         // Returns the sort group (system, trash, folder) for this folder.
00593         virtual EInventorySortGroup getSortGroup();
00594 
00595         virtual void    setCompletedFilterGeneration(S32 generation, BOOL recurse_up);
00596         virtual S32             getCompletedFilterGeneration() { return mCompletedFilterGeneration; }
00597 
00598         BOOL hasFilteredDescendants(S32 filter_generation) { return mMostFilteredDescendantGeneration >= filter_generation; }
00599         BOOL hasFilteredDescendants();
00600 
00601         // applies filters to control visibility of inventory items
00602         virtual void filter( LLInventoryFilter& filter);
00603         virtual void setFiltered(BOOL filtered, S32 filter_generation);
00604         virtual void dirtyFilter();
00605 
00606         // Passes selection information on to children and record
00607         // selection information if necessary. Returns TRUE if this object
00608         // (or a child) was affected.
00609         virtual BOOL setSelection(LLFolderViewItem* selection, BOOL open,               /* Flawfinder: ignore */
00610                 BOOL take_keyboard_focus);
00611 
00612         // This method is used to change the selection of an item. If
00613         // selection is 'this', then note selection as true. Returns TRUE
00614         // if this or a child is now selected.
00615         virtual BOOL changeSelection(LLFolderViewItem* selection, BOOL selected);
00616 
00617         // this method is used to group select items
00618         virtual S32 extendSelection(LLFolderViewItem* selection, LLFolderViewItem* last_selected, LLDynamicArray<LLFolderViewItem*>& items);
00619 
00620         virtual void recursiveDeselect(BOOL deselect_self);
00621 
00622         // Returns true is this object and all of its children can be removed.
00623         virtual BOOL isRemovable();
00624 
00625         // Returns true is this object and all of its children can be moved
00626         virtual BOOL isMovable();
00627 
00628         // destroys this folder, and all children
00629         virtual void destroyView();
00630 
00631         // If this folder can be removed, remove all children that can be
00632         // removed, return TRUE if this is empty after the operation and
00633         // it's viewed folder object can be removed.
00634         //virtual BOOL removeRecursively(BOOL single_item);
00635         //virtual BOOL remove();
00636 
00637         // remove the specified item (and any children) if
00638         // possible. Return TRUE if the item was deleted.
00639         BOOL removeItem(LLFolderViewItem* item);
00640 
00641         // simply remove the view (and any children) Don't bother telling
00642         // the listeners.
00643         void removeView(LLFolderViewItem* item);
00644 
00645         // extractItem() removes the specified item from the folder, but
00646         // doesn't delete it.
00647         void extractItem( LLFolderViewItem* item );
00648 
00649         // This function is called by a child that needs to be resorted.
00650         void resort(LLFolderViewItem* item);
00651 
00652         void setItemSortOrder(U32 ordering);
00653         void sortBy(U32);
00654         //BOOL (*func)(LLFolderViewItem* a, LLFolderViewItem* b));
00655 
00656         void setAutoOpenCountdown(F32 countdown) { mAutoOpenCountdown = countdown; }
00657 
00658         // folders can be opened. This will usually be called by internal
00659         // methods.
00660         virtual void toggleOpen();
00661 
00662         // Force a folder open or closed
00663         virtual void setOpen(BOOL open = TRUE);         /* Flawfinder: ignore */
00664 
00665         // Called when a child is refreshed.
00666         // don't rearrange child folder contents unless explicitly requested
00667         virtual void requestArrange(BOOL include_descendants = FALSE);
00668 
00669         // internal method which doesn't update the entire view. This
00670         // method was written because the list iterators destroy the state
00671         // of other iterations, thus, we can't arrange while iterating
00672         // through the children (such as when setting which is selected.
00673         virtual void setOpenArrangeRecursively(BOOL open, ERecurseType recurse = RECURSE_NO);           /* Flawfinder: ignore */
00674 
00675         // Get the current state of the folder.
00676         virtual BOOL isOpen() { return mIsOpen; }
00677 
00678         // special case if an object is dropped on the child.
00679         BOOL handleDragAndDropFromChild(MASK mask,
00680                                                                         BOOL drop,
00681                                                                         EDragAndDropType cargo_type,
00682                                                                         void* cargo_data,
00683                                                                         EAcceptance* accept,
00684                                                                         LLString& tooltip_msg);
00685 
00686         void applyFunctorRecursively(LLFolderViewFunctor& functor);
00687         virtual void applyListenerFunctorRecursively(LLFolderViewListenerFunctor& functor);
00688 
00689         virtual void open( void );              /* Flawfinder: ignore */
00690         virtual BOOL addItem(LLFolderViewItem* item); 
00691         virtual BOOL addFolder( LLFolderViewFolder* folder);
00692 
00693         // LLView functionality
00694         virtual BOOL handleHover(S32 x, S32 y, MASK mask);
00695         virtual BOOL handleRightMouseDown( S32 x, S32 y, MASK mask );
00696         virtual BOOL handleMouseDown( S32 x, S32 y, MASK mask );
00697         virtual BOOL handleDoubleClick( S32 x, S32 y, MASK mask );
00698         virtual BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
00699                                                                    EDragAndDropType cargo_type,
00700                                                                    void* cargo_data,
00701                                                                    EAcceptance* accept,
00702                                                                    LLString& tooltip_msg);
00703         virtual void draw();
00704 
00705         U32 getCreationDate() const;
00706         bool isTrash();
00707 };
00708 
00709 
00710 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00711 // Class LLFolderView
00712 //
00713 // Th LLFolderView represents the root level folder view object. It
00714 // manages the screen region of the folder view.
00715 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00716 
00717 class LLUICtrl;
00718 class LLLineEditor;
00719 
00720 class LLFolderView : public LLFolderViewFolder, LLEditMenuHandler
00721 {
00722 public:
00723         typedef void (*SelectCallback)(const std::deque<LLFolderViewItem*> &items, BOOL user_action, void* data);
00724 
00725         static F32 sAutoOpenTime;
00726 
00727         LLFolderView( const LLString& name, LLUIImagePtr root_folder_icon, const LLRect& rect, 
00728                                         const LLUUID& source_id, LLView *parent_view );
00729         virtual ~LLFolderView( void );
00730 
00731         virtual BOOL canFocusChildren() const;
00732 
00733         // FolderViews default to sort by name.  This will change that,
00734         // and resort the items if necessary.
00735         void setSortOrder(U32 order);
00736         void checkTreeResortForModelChanged();
00737         void setFilterPermMask(PermissionMask filter_perm_mask) { mFilter.setFilterPermissions(filter_perm_mask); }
00738         void setSelectCallback(SelectCallback callback, void* user_data) { mSelectCallback = callback, mUserData = user_data; }
00739         void setAllowMultiSelect(BOOL allow) { mAllowMultiSelect = allow; }
00740 
00741         LLInventoryFilter* getFilter() { return &mFilter; }
00742         const LLString getFilterSubString(BOOL trim = FALSE);
00743         U32 getFilterTypes() const { return mFilter.getFilterTypes(); }
00744         PermissionMask getFilterPermissions() const { return mFilter.getFilterPermissions(); }
00745         LLInventoryFilter::EFolderShow getShowFolderState() { return mFilter.getShowFolderState(); }
00746         U32 getSortOrder() const;
00747         BOOL isFilterModified() { return mFilter.isNotDefault(); }
00748         BOOL getAllowMultiSelect() { return mAllowMultiSelect; }
00749 
00750         // Close all folders in the view
00751         void closeAllFolders();
00752         void openFolder(const LLString& foldername);
00753 
00754         virtual void toggleOpen() {};
00755         virtual void setOpenArrangeRecursively(BOOL open, ERecurseType recurse);                /* Flawfinder: ignore */
00756         virtual BOOL addFolder( LLFolderViewFolder* folder);
00757 
00758         // Finds width and height of this object and it's children.  Also
00759         // makes sure that this view and it's children are the right size.
00760         virtual S32 arrange( S32* width, S32* height, S32 filter_generation );
00761 
00762         void arrangeAll() { mArrangeGeneration++; }
00763         S32 getArrangeGeneration() { return mArrangeGeneration; }
00764 
00765         // applies filters to control visibility of inventory items
00766         virtual void filter( LLInventoryFilter& filter);
00767 
00768         // get the last selected item
00769         virtual LLFolderViewItem* getCurSelectedItem( void );
00770 
00771         // Record the selected item and pass it down the hierachy.
00772         virtual BOOL setSelection(LLFolderViewItem* selection, BOOL open,               /* Flawfinder: ignore */
00773                 BOOL take_keyboard_focus);
00774 
00775         // This method is used to toggle the selection of an item. Walks
00776         // children, and keeps track of selected objects.
00777         virtual BOOL changeSelection(LLFolderViewItem* selection, BOOL selected);
00778 
00779         virtual S32 extendSelection(LLFolderViewItem* selection, LLFolderViewItem* last_selected, LLDynamicArray<LLFolderViewItem*>& items);
00780 
00781         virtual BOOL getSelectionList(std::set<LLUUID> &selection);
00782 
00783         // make sure if ancestor is selected, descendents are not
00784         void sanitizeSelection();
00785         void clearSelection();
00786         void addToSelectionList(LLFolderViewItem* item);
00787         void removeFromSelectionList(LLFolderViewItem* item);
00788 
00789         BOOL startDrag(LLToolDragAndDrop::ESource source);
00790         void setDragAndDropThisFrame() { mDragAndDropThisFrame = TRUE; }
00791 
00792         // deletion functionality
00793         void removeSelectedItems();
00794 
00795         // open the selected item.
00796         void openSelectedItems( void );
00797         void propertiesSelectedItems( void );
00798 
00799         void autoOpenItem(LLFolderViewFolder* item);
00800         void closeAutoOpenedFolders();
00801         BOOL autoOpenTest(LLFolderViewFolder* item);
00802 
00803         // copy & paste
00804         virtual void    copy();
00805         virtual BOOL    canCopy() const;
00806 
00807         virtual void    cut();
00808         virtual BOOL    canCut() const;
00809 
00810         virtual void    paste();
00811         virtual BOOL    canPaste() const;
00812 
00813         virtual void    doDelete();
00814         virtual BOOL    canDoDelete() const;
00815 
00816         // public rename functionality - can only start the process
00817         void startRenamingSelectedItem( void );
00818 
00819         // These functions were used when there was only one folderview,
00820         // and relied on that concept. This functionality is now handled
00821         // by the listeners and the lldraganddroptool.
00822         //LLFolderViewItem*     getMovingItem() { return mMovingItem; }
00823         //void setMovingItem( LLFolderViewItem* item ) { mMovingItem = item; }
00824         //void                          dragItemIntoFolder( LLFolderViewItem* moving_item, LLFolderViewFolder* dst_folder, BOOL drop, BOOL* accept );
00825         //void                          dragFolderIntoFolder( LLFolderViewFolder* moving_folder, LLFolderViewFolder* dst_folder, BOOL drop, BOOL* accept );
00826 
00827         // LLUICtrl Functionality
00828         /*virtual*/ void setFocus(BOOL focus);
00829 
00830         // LLView functionality
00832         /*virtual*/ BOOL handleKeyHere( KEY key, MASK mask );
00833         /*virtual*/ BOOL handleUnicodeCharHere(llwchar uni_char);
00834         /*virtual*/ BOOL handleMouseDown( S32 x, S32 y, MASK mask );
00835         /*virtual*/ BOOL handleDoubleClick( S32 x, S32 y, MASK mask );
00836         /*virtual*/ BOOL handleRightMouseDown( S32 x, S32 y, MASK mask );
00837         /*virtual*/ BOOL handleHover( S32 x, S32 y, MASK mask );
00838         /*virtual*/ BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
00839                                                                    EDragAndDropType cargo_type,
00840                                                                    void* cargo_data,
00841                                                                    EAcceptance* accept,
00842                                                                    LLString& tooltip_msg);
00843         /*virtual*/ void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE);
00844         /*virtual*/ void onFocusLost();
00845         virtual BOOL handleScrollWheel(S32 x, S32 y, S32 clicks);
00846         virtual void draw();
00847         virtual void deleteAllChildren();
00848 
00849         void scrollToShowSelection();
00850         void scrollToShowItem(LLFolderViewItem* item);
00851         void setScrollContainer( LLScrollableContainerView* parent ) { mScrollContainer = parent; }
00852         LLRect getVisibleRect();
00853 
00854         BOOL search(LLFolderViewItem* first_item, const LLString &search_string, BOOL backward);
00855         void setShowSelectionContext(BOOL show) { mShowSelectionContext = show; }
00856         BOOL getShowSelectionContext();
00857         void setShowSingleSelection(BOOL show);
00858         BOOL getShowSingleSelection() { return mShowSingleSelection; }
00859         F32  getSelectionFadeElapsedTime() { return mMultiSelectionFadeTimer.getElapsedTimeF32(); }
00860 
00861         void addItemID(const LLUUID& id, LLFolderViewItem* itemp);
00862         void removeItemID(const LLUUID& id);
00863         LLFolderViewItem* getItemByID(const LLUUID& id);
00864 
00865         void    doIdle();                                               // Real idle routine
00866         static void idle(void* user_data);              // static glue to doIdle()
00867 
00868         BOOL needsAutoSelect() { return mNeedsAutoSelect && !mAutoSelectOverride; }
00869         BOOL needsAutoRename() { return mNeedsAutoRename; }
00870         void setNeedsAutoRename(BOOL val) { mNeedsAutoRename = val; }
00871 
00872         BOOL getDebugFilters() { return mDebugFilters; }
00873 
00874         // DEBUG only
00875         void dumpSelectionInformation();
00876 
00877 protected:
00878         LLScrollableContainerView* mScrollContainer;  // NULL if this is not a child of a scroll container.
00879 
00880         static void commitRename( LLUICtrl* renamer, void* user_data );
00881         static void onRenamerLost( LLUICtrl* renamer, void* user_data);
00882 
00883         void finishRenamingItem( void );
00884         void revertRenamingItem( void );
00885 
00886 protected:
00887         LLHandle<LLView>                                        mPopupMenuHandle;
00888         
00889         typedef std::deque<LLFolderViewItem*> selected_items_t;
00890         selected_items_t                                mSelectedItems;
00891         BOOL                                                    mKeyboardSelection;
00892         BOOL                                                    mAllowMultiSelect;
00893         BOOL                                                    mShowFolderHierarchy;
00894         LLUUID                                                  mSourceID;
00895 
00896         // Renaming variables and methods
00897         LLFolderViewItem*                               mRenameItem;  // The item currently being renamed
00898         LLLineEditor*                                   mRenamer;
00899 
00900         BOOL                                                    mNeedsScroll;
00901         LLFolderViewItem*                               mLastScrollItem;
00902         LLCoordGL                                               mLastScrollOffset;
00903         BOOL                                                    mNeedsAutoSelect;
00904         BOOL                                                    mAutoSelectOverride;
00905         BOOL                                                    mNeedsAutoRename;
00906         
00907         BOOL                                                    mDebugFilters;
00908         U32                                                             mSortOrder;
00909         LLDepthStack<LLFolderViewFolder>        mAutoOpenItems;
00910         LLFolderViewFolder*                             mAutoOpenCandidate;
00911         LLFrameTimer                                    mAutoOpenTimer;
00912         LLFrameTimer                                    mSearchTimer;
00913         LLString                                                mSearchString;
00914         LLInventoryFilter                               mFilter;
00915         BOOL                                                    mShowSelectionContext;
00916         BOOL                                                    mShowSingleSelection;
00917         LLFrameTimer                                    mMultiSelectionFadeTimer;
00918         S32                                                             mArrangeGeneration;
00919 
00920         void*                                                   mUserData;
00921         SelectCallback                                  mSelectCallback;
00922         S32                                                             mSignalSelectCallback;
00923         S32                                                             mMinWidth;
00924         std::map<LLUUID, LLFolderViewItem*> mItemMap;
00925         BOOL                                                    mDragAndDropThisFrame;
00926 
00927 };
00928 
00929 bool sort_item_name(LLFolderViewItem* a, LLFolderViewItem* b);
00930 bool sort_item_date(LLFolderViewItem* a, LLFolderViewItem* b);
00931 
00932 // Flags for buildContextMenu()
00933 const U32 SUPPRESS_OPEN_ITEM = 0x1;
00934 const U32 FIRST_SELECTED_ITEM = 0x2;
00935 
00936 #endif // LL_LLFOLDERVIEW_H

Generated on Fri May 16 08:33:36 2008 for SecondLife by  doxygen 1.5.5