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 LLViewerImage* 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) = 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         typedef bool(*comparison_function_t)(LLInventorySort*self, LLFolderViewItem* a, LLFolderViewItem* b);
00289 
00290         LLInventorySort() 
00291                 : mSortOrder(0) { setComparisonFunction(compare); }
00292         
00293         // Returns true if order has changed
00294         bool updateSort(U32 order);
00295         U32 getSort() { return mSortOrder; }
00296 
00297         bool isByDate() const { return mByDate; }
00298         bool isSystemToTop() const { return mSystemToTop; }
00299         bool isFoldersByName() const { return mFoldersByName; }
00300 
00301 
00302         bool operator()(LLFolderViewItem* a, LLFolderViewItem* b);
00303 
00304         void setComparisonFunction(comparison_function_t func) { mComparisonFunction = func; }
00305         static bool compare(LLInventorySort*self, LLFolderViewItem* a, LLFolderViewItem* b);
00306 private:
00307         comparison_function_t mComparisonFunction;
00308 
00309         U32  mSortOrder;
00310         bool mByDate;
00311         bool mSystemToTop;
00312         bool mFoldersByName;
00313 };
00314 
00315 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00316 // Class LLFolderViewItem
00317 //
00318 // An instance of this class represents a single item in a folder view
00319 // such as an inventory item or a file.
00320 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00321 
00322 class LLFontGL;
00323 class LLFolderViewFolder;
00324 class LLFolderView;
00325 
00326 class LLFolderViewItem : public LLUICtrl
00327 {
00328 protected:
00329         friend class LLFolderViewEventListener;
00330 
00331         static const LLFontGL*          sFont;
00332         static const LLFontGL*          sSmallFont;
00333         static LLColor4                         sFgColor;
00334         static LLColor4                         sHighlightBgColor;
00335         static LLColor4                         sHighlightFgColor;
00336         static LLColor4                         sFilterBGColor;
00337         static LLColor4                         sFilterTextColor;
00338 
00339         LLString                                        mLabel;
00340         LLString                                        mSearchableLabel;
00341         LLString                                        mType;
00342         S32                                                     mLabelWidth;
00343         U32                                                     mCreationDate;
00344         LLFolderViewFolder*                     mParentFolder;
00345         LLFolderViewEventListener*      mListener;
00346         BOOL                                            mIsSelected;
00347         BOOL                                            mIsCurSelection;
00348         BOOL                                            mSelectPending;
00349         LLFontGL::StyleFlags            mLabelStyle;
00350         LLString                                        mLabelSuffix;
00351         LLPointer<LLViewerImage>        mIcon;
00352         LLString                                        mStatusText;
00353         BOOL                                            mHasVisibleChildren;
00354         S32                                                     mIndentation;
00355         S32                                                     mNumDescendantsSelected;
00356         BOOL                                            mFiltered;
00357         S32                                                     mLastFilterGeneration;
00358         std::string::size_type          mStringMatchOffset;
00359         F32                                                     mControlLabelRotation;
00360         LLFolderView*                           mRoot;
00361         BOOL                                            mDragAndDropTarget;
00362         LLPointer<LLViewerImage>        mArrowImage;
00363         LLPointer<LLViewerImage>        mBoxImage;
00364         
00365         // This function clears the currently selected item, and records
00366         // the specified selected item appropriately for display and use
00367         // in the UI. If open is TRUE, then folders are opened up along
00368         // the way to the selection.
00369         void setSelectionFromRoot(LLFolderViewItem* selection, BOOL open,               /* Flawfinder: ignore */
00370                 BOOL take_keyboard_focus = TRUE);
00371 
00372         // helper function to change the selection from the root.
00373         void changeSelectionFromRoot(LLFolderViewItem* selection, BOOL selected);
00374 
00375         // helper function to change the selection from the root.
00376         void extendSelectionFromRoot(LLFolderViewItem* selection);
00377 
00378         // this is an internal method used for adding items to folders. A
00379         // no-op at this leve, but reimplemented in derived classes.
00380         virtual BOOL addItem(LLFolderViewItem*) { return FALSE; }
00381         virtual BOOL addFolder(LLFolderViewFolder*) { return FALSE; }
00382 
00383 public:
00384         // This function is called when the folder view is dirty. It's
00385         // implemented here but called by derived classes when folding the
00386         // views.
00387         void arrangeFromRoot();
00388         void filterFromRoot( void );
00389 
00390         // creation_date is in UTC seconds
00391         LLFolderViewItem( const LLString& name, LLViewerImage* icon, S32 creation_date, LLFolderView* root, LLFolderViewEventListener* listener );
00392         virtual ~LLFolderViewItem( void );
00393 
00394         virtual EWidgetType getWidgetType() const;
00395         virtual LLString getWidgetTag() const;
00396 
00397         // addToFolder() returns TRUE if it succeeds. FALSE otherwise
00398         enum { ARRANGE = TRUE, DO_NOT_ARRANGE = FALSE };
00399         virtual BOOL addToFolder(LLFolderViewFolder* folder, LLFolderView* root);
00400 
00401         virtual EInventorySortGroup getSortGroup();
00402 
00403         // Finds width and height of this object and it's children.  Also
00404         // makes sure that this view and it's children are the right size.
00405         virtual S32 arrange( S32* width, S32* height, S32 filter_generation );
00406         virtual S32 getItemHeight();
00407 
00408         // applies filters to control visibility of inventory items
00409         virtual void filter( LLInventoryFilter& filter);
00410 
00411         // updates filter serial number and optionally propagated value up to root
00412         S32             getLastFilterGeneration() { return mLastFilterGeneration; }
00413 
00414         virtual void    dirtyFilter();
00415 
00416         // If the selection is 'this' then note that otherwise
00417         // ignore. Returns TRUE if this object was affected. If open is
00418         // TRUE, then folders are opened up along the way to the
00419         // selection.
00420         virtual BOOL setSelection(LLFolderViewItem* selection, BOOL open,               /* Flawfinder: ignore */
00421                 BOOL take_keyboard_focus);
00422 
00423         // This method is used to toggle the selection of an item. If
00424         // selection is 'this', then note selection, and return TRUE.
00425         virtual BOOL changeSelection(LLFolderViewItem* selection, BOOL selected);
00426 
00427         // this method is used to group select items
00428         virtual S32 extendSelection(LLFolderViewItem* selection, LLFolderViewItem* last_selected, LLDynamicArray<LLFolderViewItem*>& items){ return FALSE; }
00429 
00430         // this method is used to group select items
00431         virtual void recursiveDeselect(BOOL deselect_self);
00432 
00433         // gets multiple-element selection
00434         virtual BOOL getSelectionList(std::set<LLUUID> &selection){return TRUE;}
00435 
00436         // Returns true is this object and all of its children can be removed (deleted by user)
00437         virtual BOOL isRemovable();
00438 
00439         // Returns true is this object and all of its children can be moved
00440         virtual BOOL isMovable();
00441 
00442         // destroys this item recursively
00443         virtual void destroyView();
00444 
00445         S32 getNumSelectedDescendants() { return mNumDescendantsSelected; }
00446 
00447         BOOL isSelected() { return mIsSelected; }
00448 
00449         void setIsCurSelection(BOOL select) { mIsCurSelection = select; }
00450 
00451         BOOL getIsCurSelection() { return mIsCurSelection; }
00452 
00453         BOOL hasVisibleChildren() { return mHasVisibleChildren; }
00454 
00455         // Call through to the viewed object and return true if it can be
00456         // removed. Returns true if it's removed.
00457         //virtual BOOL removeRecursively(BOOL single_item);
00458         BOOL remove();
00459 
00460         // Build an appropriate context menu for the item.      Flags unused.
00461         void buildContextMenu(LLMenuGL& menu, U32 flags);
00462 
00463         // This method returns the actual name of the thing being
00464         // viewed. This method will ask the viewed object itself.
00465         const LLString& getName( void ) const;
00466 
00467         const LLString& getSearchableLabel( void ) const;
00468 
00469         // This method returns the label displayed on the view. This
00470         // method was primarily added to allow sorting on the folder
00471         // contents possible before the entire view has been constructed.
00472         const char* getLabel() const { return mLabel.c_str(); }
00473 
00474         // Used for sorting, like getLabel() above.
00475         virtual U32 getCreationDate() const { return mCreationDate; }
00476         
00477         LLFolderViewFolder* getParentFolder( void );
00478         LLFolderViewItem* getNextOpenNode( BOOL include_children = TRUE );
00479         LLFolderViewItem* getPreviousOpenNode( BOOL include_children = TRUE );
00480 
00481         LLFolderViewEventListener* getListener( void );
00482 
00483         // just rename the object.
00484         void rename(const LLString& new_name);
00485 
00486         // open
00487         virtual void open( void );              /* Flawfinder: ignore */
00488         virtual void preview(void);
00489 
00490         // Show children (unfortunate that this is called "open")
00491         virtual void setOpen(BOOL open = TRUE) {};
00492 
00493         virtual BOOL isOpen() { return FALSE; }
00494 
00495         LLFolderView*   getRoot();
00496         BOOL                    isDescendantOf( const LLFolderViewFolder* potential_ancestor );
00497         S32                             getIndentation() { return mIndentation; }
00498 
00499         virtual BOOL    potentiallyVisible(); // do we know for a fact that this item has been filtered out?
00500 
00501         virtual BOOL    getFiltered();
00502         virtual BOOL    getFiltered(S32 filter_generation);
00503         virtual void    setFiltered(BOOL filtered, S32 filter_generation);
00504 
00505         // change the icon
00506         void setIcon(LLViewerImage* icon);
00507 
00508         // refresh information from the object being viewed.
00509         virtual void refresh();
00510 
00511         virtual void applyListenerFunctorRecursively(LLFolderViewListenerFunctor& functor);
00512 
00513         // LLView functionality
00514         virtual BOOL handleRightMouseDown( S32 x, S32 y, MASK mask );
00515         virtual BOOL handleMouseDown( S32 x, S32 y, MASK mask );
00516         virtual BOOL handleHover( S32 x, S32 y, MASK mask );
00517         virtual BOOL handleMouseUp( S32 x, S32 y, MASK mask );
00518         virtual BOOL handleDoubleClick( S32 x, S32 y, MASK mask );
00519         virtual BOOL handleScrollWheel(S32 x, S32 y, S32 clicks);
00520 
00521         //      virtual void handleDropped();
00522         virtual void draw();
00523         virtual BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
00524                                                                    EDragAndDropType cargo_type,
00525                                                                    void* cargo_data,
00526                                                                    EAcceptance* accept,
00527                                                                    LLString& tooltip_msg);
00528 };
00529 
00530 
00531 // function used for sorting.
00532 typedef bool (*sort_order_f)(LLFolderViewItem* a, LLFolderViewItem* b);
00533 
00534 
00535 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00536 // Class LLFolderViewFolder
00537 //
00538 // An instance of an LLFolderViewFolder represents a collection of
00539 // more folders and items. This is used to build the hierarchy of
00540 // items found in the folder view. :)
00541 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00542 
00543 class LLFolderViewFolder : public LLFolderViewItem
00544 {
00545 public:
00546         typedef enum e_trash
00547         {
00548                 UNKNOWN, TRASH, NOT_TRASH
00549         } ETrash;
00550 
00551 protected:
00552         typedef std::vector<LLFolderViewItem*> items_t;
00553         typedef std::vector<LLFolderViewFolder*> folders_t;
00554         items_t mItems;
00555         folders_t mFolders;
00556         LLInventorySort mSortFunction;
00557 
00558         BOOL            mIsOpen;
00559         BOOL            mExpanderHighlighted;
00560         F32                     mCurHeight;
00561         F32                     mTargetHeight;
00562         F32                     mAutoOpenCountdown;
00563         U32                     mSubtreeCreationDate;
00564         ETrash          mAmTrash;
00565         S32                     mLastArrangeGeneration;
00566         S32                     mLastCalculatedWidth;
00567         S32                     mCompletedFilterGeneration;
00568         S32                     mMostFilteredDescendantGeneration;
00569 public:
00570         typedef enum e_recurse_type
00571         {
00572                 RECURSE_NO,
00573                 RECURSE_UP,
00574                 RECURSE_DOWN,
00575                 RECURSE_UP_DOWN
00576         } ERecurseType;
00577 
00578         LLFolderViewFolder( const LLString& name, LLViewerImage* icon,
00579                                                 LLFolderView* root,
00580                                                 LLFolderViewEventListener* listener );
00581         virtual ~LLFolderViewFolder( void );
00582 
00583         virtual EWidgetType getWidgetType() const;
00584         virtual LLString getWidgetTag() const;
00585 
00586         virtual BOOL    potentiallyVisible();
00587 
00588         LLFolderViewItem* getNextFromChild( LLFolderViewItem*, BOOL include_children = TRUE );
00589         LLFolderViewItem* getPreviousFromChild( LLFolderViewItem*, BOOL include_children = TRUE  );
00590 
00591         // addToFolder() returns TRUE if it succeeds. FALSE otherwise
00592         virtual BOOL addToFolder(LLFolderViewFolder* folder, LLFolderView* root);
00593 
00594         // Finds width and height of this object and it's children.  Also
00595         // makes sure that this view and it's children are the right size.
00596         virtual S32 arrange( S32* width, S32* height, S32 filter_generation );
00597 
00598         BOOL needsArrange();
00599 
00600         // Returns the sort group (system, trash, folder) for this folder.
00601         virtual EInventorySortGroup getSortGroup();
00602 
00603         virtual void    setCompletedFilterGeneration(S32 generation, BOOL recurse_up);
00604         virtual S32             getCompletedFilterGeneration() { return mCompletedFilterGeneration; }
00605 
00606         BOOL hasFilteredDescendants(S32 filter_generation) { return mMostFilteredDescendantGeneration >= filter_generation; }
00607         BOOL hasFilteredDescendants();
00608 
00609         // applies filters to control visibility of inventory items
00610         virtual void filter( LLInventoryFilter& filter);
00611         virtual void setFiltered(BOOL filtered, S32 filter_generation);
00612         virtual void dirtyFilter();
00613 
00614         // Passes selection information on to children and record
00615         // selection information if necessary. Returns TRUE if this object
00616         // (or a child) was affected.
00617         virtual BOOL setSelection(LLFolderViewItem* selection, BOOL open,               /* Flawfinder: ignore */
00618                 BOOL take_keyboard_focus);
00619 
00620         // This method is used to change the selection of an item. If
00621         // selection is 'this', then note selection as true. Returns TRUE
00622         // if this or a child is now selected.
00623         virtual BOOL changeSelection(LLFolderViewItem* selection, BOOL selected);
00624 
00625         // this method is used to group select items
00626         virtual S32 extendSelection(LLFolderViewItem* selection, LLFolderViewItem* last_selected, LLDynamicArray<LLFolderViewItem*>& items);
00627 
00628         virtual void recursiveDeselect(BOOL deselect_self);
00629 
00630         // Returns true is this object and all of its children can be removed.
00631         virtual BOOL isRemovable();
00632 
00633         // Returns true is this object and all of its children can be moved
00634         virtual BOOL isMovable();
00635 
00636         // destroys this folder, and all children
00637         virtual void destroyView();
00638 
00639         // If this folder can be removed, remove all children that can be
00640         // removed, return TRUE if this is empty after the operation and
00641         // it's viewed folder object can be removed.
00642         //virtual BOOL removeRecursively(BOOL single_item);
00643         //virtual BOOL remove();
00644 
00645         // remove the specified item (and any children) if
00646         // possible. Return TRUE if the item was deleted.
00647         BOOL removeItem(LLFolderViewItem* item);
00648 
00649         // simply remove the view (and any children) Don't bother telling
00650         // the listeners.
00651         void removeView(LLFolderViewItem* item);
00652 
00653         // extractItem() removes the specified item from the folder, but
00654         // doesn't delete it.
00655         void extractItem( LLFolderViewItem* item );
00656 
00657         // This function is called by a child that needs to be resorted.
00658         void resort(LLFolderViewItem* item);
00659 
00660         void setItemSortOrder(U32 ordering);
00661         void sortBy(U32);
00662         //BOOL (*func)(LLFolderViewItem* a, LLFolderViewItem* b));
00663 
00664         void setAutoOpenCountdown(F32 countdown) { mAutoOpenCountdown = countdown; }
00665 
00666         // folders can be opened. This will usually be called by internal
00667         // methods.
00668         virtual void toggleOpen();
00669 
00670         // Force a folder open or closed
00671         virtual void setOpen(BOOL open = TRUE);         /* Flawfinder: ignore */
00672 
00673         // Called when a child is refreshed.
00674         // don't rearrange child folder contents unless explicitly requested
00675         virtual void requestArrange(BOOL include_descendants = FALSE);
00676 
00677         // internal method which doesn't update the entire view. This
00678         // method was written because the list iterators destroy the state
00679         // of other iterations, thus, we can't arrange while iterating
00680         // through the children (such as when setting which is selected.
00681         virtual void setOpenArrangeRecursively(BOOL open, ERecurseType recurse = RECURSE_NO);           /* Flawfinder: ignore */
00682 
00683         // Get the current state of the folder.
00684         virtual BOOL isOpen() { return mIsOpen; }
00685 
00686         // special case if an object is dropped on the child.
00687         BOOL handleDragAndDropFromChild(MASK mask,
00688                                                                         BOOL drop,
00689                                                                         EDragAndDropType cargo_type,
00690                                                                         void* cargo_data,
00691                                                                         EAcceptance* accept,
00692                                                                         LLString& tooltip_msg);
00693 
00694         void applyFunctorRecursively(LLFolderViewFunctor& functor);
00695         virtual void applyListenerFunctorRecursively(LLFolderViewListenerFunctor& functor);
00696 
00697         virtual void open( void );              /* Flawfinder: ignore */
00698         virtual BOOL addItem(LLFolderViewItem* item); 
00699         virtual BOOL addFolder( LLFolderViewFolder* folder);
00700 
00701         // LLView functionality
00702         virtual BOOL handleHover(S32 x, S32 y, MASK mask);
00703         virtual BOOL handleRightMouseDown( S32 x, S32 y, MASK mask );
00704         virtual BOOL handleMouseDown( S32 x, S32 y, MASK mask );
00705         virtual BOOL handleDoubleClick( S32 x, S32 y, MASK mask );
00706         virtual BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
00707                                                                    EDragAndDropType cargo_type,
00708                                                                    void* cargo_data,
00709                                                                    EAcceptance* accept,
00710                                                                    LLString& tooltip_msg);
00711         virtual void draw();
00712 
00713         U32 getCreationDate() const;
00714         bool isTrash();
00715 
00716         LLInventorySort *getSortFunction() { return &mSortFunction; } // HACK
00717 };
00718 
00719 
00720 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00721 // Class LLFolderView
00722 //
00723 // Th LLFolderView represents the root level folder view object. It
00724 // manages the screen region of the folder view.
00725 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00726 
00727 class LLUICtrl;
00728 class LLLineEditor;
00729 
00730 class LLFolderView : public LLFolderViewFolder, LLEditMenuHandler
00731 {
00732 public:
00733         typedef void (*SelectCallback)(const std::deque<LLFolderViewItem*> &items, BOOL user_action, void* data);
00734 
00735         static F32 sAutoOpenTime;
00736 
00737         LLFolderView( const LLString& name, LLViewerImage* root_folder_icon, const LLRect& rect, 
00738                                         const LLUUID& source_id, LLView *parent_view );
00739         virtual ~LLFolderView( void );
00740 
00741         virtual EWidgetType getWidgetType() const;
00742         virtual LLString getWidgetTag() const;
00743         virtual BOOL canFocusChildren() const;
00744 
00745         // FolderViews default to sort by name.  This will change that,
00746         // and resort the items if necessary.
00747         void setSortOrder(U32 order);
00748         void checkTreeResortForModelChanged();
00749         void setFilterPermMask(PermissionMask filter_perm_mask) { mFilter.setFilterPermissions(filter_perm_mask); }
00750         void setSelectCallback(SelectCallback callback, void* user_data) { mSelectCallback = callback, mUserData = user_data; }
00751         void setAllowMultiSelect(BOOL allow) { mAllowMultiSelect = allow; }
00752 
00753         LLInventoryFilter* getFilter() { return &mFilter; }
00754         const LLString getFilterSubString(BOOL trim = FALSE);
00755         U32 getFilterTypes() const { return mFilter.getFilterTypes(); }
00756         PermissionMask getFilterPermissions() const { return mFilter.getFilterPermissions(); }
00757         LLInventoryFilter::EFolderShow getShowFolderState() { return mFilter.getShowFolderState(); }
00758         U32 getSortOrder() const;
00759         BOOL isFilterModified() { return mFilter.isNotDefault(); }
00760         BOOL getAllowMultiSelect() { return mAllowMultiSelect; }
00761 
00762         // Close all folders in the view
00763         void closeAllFolders();
00764         void openFolder(const LLString& foldername);
00765 
00766         virtual void toggleOpen() {};
00767         virtual void setOpenArrangeRecursively(BOOL open, ERecurseType recurse);                /* Flawfinder: ignore */
00768         virtual BOOL addFolder( LLFolderViewFolder* folder);
00769 
00770         // Finds width and height of this object and it's children.  Also
00771         // makes sure that this view and it's children are the right size.
00772         virtual S32 arrange( S32* width, S32* height, S32 filter_generation );
00773 
00774         void arrangeAll() { mArrangeGeneration++; }
00775         S32 getArrangeGeneration() { return mArrangeGeneration; }
00776 
00777         // applies filters to control visibility of inventory items
00778         virtual void filter( LLInventoryFilter& filter);
00779 
00780         // get the last selected item
00781         virtual LLFolderViewItem* getCurSelectedItem( void );
00782 
00783         // Record the selected item and pass it down the hierachy.
00784         virtual BOOL setSelection(LLFolderViewItem* selection, BOOL open,               /* Flawfinder: ignore */
00785                 BOOL take_keyboard_focus);
00786 
00787         // This method is used to toggle the selection of an item. Walks
00788         // children, and keeps track of selected objects.
00789         virtual BOOL changeSelection(LLFolderViewItem* selection, BOOL selected);
00790 
00791         virtual S32 extendSelection(LLFolderViewItem* selection, LLFolderViewItem* last_selected, LLDynamicArray<LLFolderViewItem*>& items);
00792 
00793         virtual BOOL getSelectionList(std::set<LLUUID> &selection);
00794 
00795         // make sure if ancestor is selected, descendents are not
00796         void sanitizeSelection();
00797         void clearSelection();
00798         void addToSelectionList(LLFolderViewItem* item);
00799         void removeFromSelectionList(LLFolderViewItem* item);
00800 
00801         BOOL startDrag(LLToolDragAndDrop::ESource source);
00802         void setDragAndDropThisFrame() { mDragAndDropThisFrame = TRUE; }
00803 
00804         // deletion functionality
00805         void removeSelectedItems();
00806 
00807         // open the selected item.
00808         void openSelectedItems( void );
00809         void propertiesSelectedItems( void );
00810 
00811         void autoOpenItem(LLFolderViewFolder* item);
00812         void closeAutoOpenedFolders();
00813         BOOL autoOpenTest(LLFolderViewFolder* item);
00814 
00815         // copy & paste
00816         virtual void    copy();
00817         virtual BOOL    canCopy();
00818 
00819         virtual void    cut();
00820         virtual BOOL    canCut();
00821 
00822         virtual void    paste();
00823         virtual BOOL    canPaste();
00824 
00825         virtual void    doDelete();
00826         virtual BOOL    canDoDelete();
00827 
00828         // public rename functionality - can only start the process
00829         void startRenamingSelectedItem( void );
00830 
00831         // These functions were used when there was only one folderview,
00832         // and relied on that concept. This functionality is now handled
00833         // by the listeners and the lldraganddroptool.
00834         //LLFolderViewItem*     getMovingItem() { return mMovingItem; }
00835         //void setMovingItem( LLFolderViewItem* item ) { mMovingItem = item; }
00836         //void                          dragItemIntoFolder( LLFolderViewItem* moving_item, LLFolderViewFolder* dst_folder, BOOL drop, BOOL* accept );
00837         //void                          dragFolderIntoFolder( LLFolderViewFolder* moving_folder, LLFolderViewFolder* dst_folder, BOOL drop, BOOL* accept );
00838 
00839         // LLUICtrl Functionality
00840         /*virtual*/ void setFocus(BOOL focus);
00841 
00842         // LLView functionality
00844         /*virtual*/ BOOL handleKeyHere( KEY key, MASK mask, BOOL called_from_parent );
00845         /*virtual*/ BOOL handleUnicodeCharHere(llwchar uni_char, BOOL called_from_parent);
00846         /*virtual*/ BOOL handleMouseDown( S32 x, S32 y, MASK mask );
00847         /*virtual*/ BOOL handleDoubleClick( S32 x, S32 y, MASK mask );
00848         /*virtual*/ BOOL handleRightMouseDown( S32 x, S32 y, MASK mask );
00849         /*virtual*/ BOOL handleHover( S32 x, S32 y, MASK mask );
00850         /*virtual*/ BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
00851                                                                    EDragAndDropType cargo_type,
00852                                                                    void* cargo_data,
00853                                                                    EAcceptance* accept,
00854                                                                    LLString& tooltip_msg);
00855         /*virtual*/ void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE);
00856         /*virtual*/ void onFocusLost();
00857         virtual BOOL handleScrollWheel(S32 x, S32 y, S32 clicks);
00858         virtual void draw();
00859         virtual void deleteAllChildren();
00860 
00861         void scrollToShowSelection();
00862         void scrollToShowItem(LLFolderViewItem* item);
00863         void setScrollContainer( LLScrollableContainerView* parent ) { mScrollContainer = parent; }
00864         LLRect getVisibleRect();
00865 
00866         BOOL search(LLFolderViewItem* first_item, const LLString &search_string, BOOL backward);
00867         void setShowSelectionContext(BOOL show) { mShowSelectionContext = show; }
00868         BOOL getShowSelectionContext();
00869         void setShowSingleSelection(BOOL show);
00870         BOOL getShowSingleSelection() { return mShowSingleSelection; }
00871         F32  getSelectionFadeElapsedTime() { return mMultiSelectionFadeTimer.getElapsedTimeF32(); }
00872 
00873         void addItemID(const LLUUID& id, LLFolderViewItem* itemp);
00874         void removeItemID(const LLUUID& id);
00875         LLFolderViewItem* getItemByID(const LLUUID& id);
00876 
00877         void    doIdle();                                               // Real idle routine
00878         static void idle(void* user_data);              // static glue to doIdle()
00879 
00880         BOOL needsAutoSelect() { return mNeedsAutoSelect && !mAutoSelectOverride; }
00881         BOOL needsAutoRename() { return mNeedsAutoRename; }
00882         void setNeedsAutoRename(BOOL val) { mNeedsAutoRename = val; }
00883 
00884         BOOL getDebugFilters() { return mDebugFilters; }
00885 
00886         // DEBUG only
00887         void dumpSelectionInformation();
00888 
00889 protected:
00890         LLScrollableContainerView* mScrollContainer;  // NULL if this is not a child of a scroll container.
00891 
00892         static void commitRename( LLUICtrl* renamer, void* user_data );
00893         void finishRenamingItem( void );
00894         void revertRenamingItem( void );
00895 
00896 protected:
00897         LLViewHandle                                    mPopupMenuHandle;
00898         
00899         typedef std::deque<LLFolderViewItem*> selected_items_t;
00900         selected_items_t                                mSelectedItems;
00901         BOOL                                                    mKeyboardSelection;
00902         BOOL                                                    mAllowMultiSelect;
00903         BOOL                                                    mShowFolderHierarchy;
00904         LLUUID                                                  mSourceID;
00905 
00906         // Renaming variables and methods
00907         LLFolderViewItem*                               mRenameItem;  // The item currently being renamed
00908         LLLineEditor*                                   mRenamer;
00909 
00910         BOOL                                                    mNeedsScroll;
00911         LLFolderViewItem*                               mLastScrollItem;
00912         LLCoordGL                                               mLastScrollOffset;
00913         BOOL                                                    mNeedsAutoSelect;
00914         BOOL                                                    mAutoSelectOverride;
00915         BOOL                                                    mNeedsAutoRename;
00916         
00917         BOOL                                                    mDebugFilters;
00918         U32                                                             mSortOrder;
00919         LLDepthStack<LLFolderViewFolder>        mAutoOpenItems;
00920         LLFolderViewFolder*                             mAutoOpenCandidate;
00921         LLFrameTimer                                    mAutoOpenTimer;
00922         LLFrameTimer                                    mSearchTimer;
00923         LLString                                                mSearchString;
00924         LLInventoryFilter                               mFilter;
00925         BOOL                                                    mShowSelectionContext;
00926         BOOL                                                    mShowSingleSelection;
00927         LLFrameTimer                                    mMultiSelectionFadeTimer;
00928         S32                                                             mArrangeGeneration;
00929 
00930         void*                                                   mUserData;
00931         SelectCallback                                  mSelectCallback;
00932         BOOL                                                    mSelectionChanged;
00933         S32                                                             mMinWidth;
00934         std::map<LLUUID, LLFolderViewItem*> mItemMap;
00935         BOOL                                                    mDragAndDropThisFrame;
00936 
00937 };
00938 
00939 bool sort_item_name(LLFolderViewItem* a, LLFolderViewItem* b);
00940 bool sort_item_date(LLFolderViewItem* a, LLFolderViewItem* b);
00941 
00942 // Flags for buildContextMenu()
00943 const U32 SUPPRESS_OPEN_ITEM = 0x1;
00944 const U32 FIRST_SELECTED_ITEM = 0x2;
00945 
00946 #endif // LL_LLFOLDERVIEW_H

Generated on Thu Jul 1 06:08:38 2010 for Second Life Viewer by  doxygen 1.4.7