summaryrefslogtreecommitdiff
path: root/indra/newview/llfolderviewitem.h
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llfolderviewitem.h')
-rw-r--r--indra/newview/llfolderviewitem.h178
1 files changed, 57 insertions, 121 deletions
diff --git a/indra/newview/llfolderviewitem.h b/indra/newview/llfolderviewitem.h
index 3c7592046a..b7588223da 100644
--- a/indra/newview/llfolderviewitem.h
+++ b/indra/newview/llfolderviewitem.h
@@ -30,52 +30,13 @@
#include "lldarray.h" // *TODO: Eliminate, forward declare
#include "lluiimage.h"
-class LLFontGL;
class LLFolderView;
-class LLFolderViewEventListener;
+class LLFolderViewModelItemInventory;
class LLFolderViewFolder;
class LLFolderViewFunctor;
-class LLFolderViewItem;
-class LLFolderViewListenerFunctor;
class LLInventoryFilter;
-class LLMenuGL;
-class LLUIImage;
class LLViewerInventoryItem;
-// These are grouping of inventory types.
-// Order matters when sorting system folders to the top.
-enum EInventorySortGroup
-{
- SG_SYSTEM_FOLDER,
- SG_TRASH_FOLDER,
- SG_NORMAL_FOLDER,
- SG_ITEM
-};
-
-// *TODO: do we really need one sort object per folder?
-// can we just have one of these per LLFolderView ?
-class LLInventorySort
-{
-public:
- LLInventorySort()
- : mSortOrder(0),
- mByDate(false),
- mSystemToTop(false),
- mFoldersByName(false) { }
-
- // Returns true if order has changed
- bool updateSort(U32 order);
- U32 getSort() { return mSortOrder; }
- bool isByDate() { return mByDate; }
-
- bool operator()(const LLFolderViewItem* const& a, const LLFolderViewItem* const& b);
-private:
- U32 mSortOrder;
- bool mByDate;
- bool mSystemToTop;
- bool mFoldersByName;
-};
-
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Class LLFolderViewItem
//
@@ -91,19 +52,19 @@ public:
struct Params : public LLInitParam::Block<Params, LLView::Params>
{
- Optional<LLUIImage*> icon;
- Optional<LLUIImage*> icon_open; // used for folders
- Optional<LLUIImage*> icon_overlay; // for links
+ Optional<LLUIImage*> icon,
+ icon_open, // used for folders
+ icon_overlay, // for links
+ folder_arrow_image,
+ selection_image;
Optional<LLFolderView*> root;
- Mandatory<LLFolderViewEventListener*> listener;
+ Mandatory<LLFolderViewModelItemInventory*> listener;
- Optional<LLUIImage*> folder_arrow_image;
- Optional<S32> folder_indentation; // pixels
- Optional<LLUIImage*> selection_image;
- Optional<S32> item_height; // pixels
- Optional<S32> item_top_pad; // pixels
+ Optional<S32> folder_indentation, // pixels
+ item_height,
+ item_top_pad;
- Optional<S32> creation_date; //UTC seconds
+ Optional<time_t> creation_date;
Params();
};
@@ -121,17 +82,14 @@ public:
static const F32 FOLDER_CLOSE_TIME_CONSTANT;
static const F32 FOLDER_OPEN_TIME_CONSTANT;
- // Mostly for debugging printout purposes.
const std::string& getSearchableLabel() { return mSearchableLabel; }
- BOOL isLoading() const { return mIsLoading; }
-
private:
BOOL mIsSelected;
protected:
friend class LLUICtrlFactory;
- friend class LLFolderViewEventListener;
+ friend class LLFolderViewModelItem;
LLFolderViewItem(const Params& p);
@@ -139,9 +97,8 @@ protected:
std::string mSearchableLabel;
S32 mLabelWidth;
bool mLabelWidthDirty;
- time_t mCreationDate;
LLFolderViewFolder* mParentFolder;
- LLFolderViewEventListener* mListener;
+ LLFolderViewModelItemInventory* mListener;
BOOL mIsCurSelection;
BOOL mSelectPending;
LLFontGL::StyleFlags mLabelStyle;
@@ -159,9 +116,6 @@ protected:
F32 mControlLabelRotation;
LLFolderView* mRoot;
BOOL mDragAndDropTarget;
- BOOL mIsLoading;
- LLTimer mTimeSinceRequestStart;
- bool mShowLoadStatus;
bool mIsMouseOverTitle;
// helper function to change the selection from the root.
@@ -174,11 +128,11 @@ protected:
static LLFontGL* getLabelFontForStyle(U8 style);
- virtual void setCreationDate(time_t creation_date_utc) { mCreationDate = creation_date_utc; }
-
public:
BOOL postBuild();
+ virtual void openItem( void );
+
// This function clears the currently selected item, and records
// the specified selected item appropriately for display and use
// in the UI. If open is TRUE, then folders are opened up along
@@ -198,9 +152,7 @@ public:
// addToFolder() returns TRUE if it succeeds. FALSE otherwise
enum { ARRANGE = TRUE, DO_NOT_ARRANGE = FALSE };
- virtual BOOL addToFolder(LLFolderViewFolder* folder, LLFolderView* root);
-
- virtual EInventorySortGroup getSortGroup() const;
+ virtual BOOL addToFolder(LLFolderViewFolder* folder);
// Finds width and height of this object and it's children. Also
// makes sure that this view and it's children are the right size.
@@ -231,7 +183,7 @@ public:
virtual void selectItem();
// gets multiple-element selection
- virtual std::set<LLUUID> getSelectionList() const;
+ virtual std::set<LLFolderViewItem*> getSelectionList() const;
// Returns true is this object and all of its children can be removed (deleted by user)
virtual BOOL isRemovable();
@@ -252,15 +204,13 @@ public:
BOOL hasVisibleChildren() { return mHasVisibleChildren; }
- void setShowLoadStatus(bool status) { mShowLoadStatus = status; }
-
// Call through to the viewed object and return true if it can be
// removed. Returns true if it's removed.
//virtual BOOL removeRecursively(BOOL single_item);
BOOL remove();
// Build an appropriate context menu for the item. Flags unused.
- void buildContextMenu(LLMenuGL& menu, U32 flags);
+ void buildContextMenu(class LLMenuGL& menu, U32 flags);
// This method returns the actual name of the thing being
// viewed. This method will ask the viewed object itself.
@@ -273,8 +223,6 @@ public:
// contents possible before the entire view has been constructed.
const std::string& getLabel() const { return mLabel; }
- // Used for sorting, like getLabel() above.
- virtual time_t getCreationDate() const { return mCreationDate; }
LLFolderViewFolder* getParentFolder( void ) { return mParentFolder; }
const LLFolderViewFolder* getParentFolder( void ) const { return mParentFolder; }
@@ -282,22 +230,15 @@ public:
LLFolderViewItem* getNextOpenNode( BOOL include_children = TRUE );
LLFolderViewItem* getPreviousOpenNode( BOOL include_children = TRUE );
- const LLFolderViewEventListener* getListener( void ) const { return mListener; }
- LLFolderViewEventListener* getListener( void ) { return mListener; }
-
- // Gets the inventory item if it exists (null otherwise)
- LLViewerInventoryItem * getInventoryItem(void);
+ const LLFolderViewModelItemInventory* getListener( void ) const { return mListener; }
+ LLFolderViewModelItemInventory* getListener( void ) { return mListener; }
// just rename the object.
void rename(const std::string& new_name);
- // open
- virtual void openItem( void );
- virtual void preview(void);
// Show children (unfortunate that this is called "open")
virtual void setOpen(BOOL open = TRUE) {};
-
virtual BOOL isOpen() const { return FALSE; }
virtual LLFolderView* getRoot();
@@ -315,11 +256,8 @@ public:
void setIcon(LLUIImagePtr icon);
// refresh information from the object being viewed.
- void refreshFromListener();
virtual void refresh();
- virtual void applyListenerFunctorRecursively(LLFolderViewListenerFunctor& functor);
-
// LLView functionality
virtual BOOL handleRightMouseDown( S32 x, S32 y, MASK mask );
virtual BOOL handleMouseDown( S32 x, S32 y, MASK mask );
@@ -339,14 +277,40 @@ public:
EAcceptance* accept,
std::string& tooltip_msg);
+ // Gets the inventory item if it exists (null otherwise)
+ LLViewerInventoryItem * getInventoryItem(void);
+ // open
+ virtual void preview(void);
+
private:
static std::map<U8, LLFontGL*> sFonts; // map of styles to fonts
};
+class LLInventorySort
+{
+public:
+ LLInventorySort(U32 order)
+ : mSortOrder(0),
+ mByDate(false),
+ mSystemToTop(false),
+ mFoldersByName(false)
+ {
+ mSortOrder = order;
+ mByDate = (order & LLInventoryFilter::SO_DATE);
+ mSystemToTop = (order & LLInventoryFilter::SO_SYSTEM_FOLDERS_TO_TOP);
+ mFoldersByName = (order & LLInventoryFilter::SO_FOLDERS_BY_NAME);
+ }
-// function used for sorting.
-typedef bool (*sort_order_f)(LLFolderViewItem* a, LLFolderViewItem* b);
+ bool isByDate() { return mByDate; }
+ U32 getSortOrder() { return mSortOrder; }
+ bool operator()(const LLFolderViewModelItemInventory* const& a, const LLFolderViewModelItemInventory* const& b);
+private:
+ U32 mSortOrder;
+ bool mByDate;
+ bool mSystemToTop;
+ bool mFoldersByName;
+};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Class LLFolderViewFolder
@@ -363,10 +327,6 @@ protected:
friend class LLUICtrlFactory;
public:
- typedef enum e_trash
- {
- UNKNOWN, TRASH, NOT_TRASH
- } ETrash;
typedef std::list<LLFolderViewItem*> items_t;
typedef std::list<LLFolderViewFolder*> folders_t;
@@ -374,15 +334,12 @@ public:
protected:
items_t mItems;
folders_t mFolders;
- LLInventorySort mSortFunction;
BOOL mIsOpen;
BOOL mExpanderHighlighted;
F32 mCurHeight;
F32 mTargetHeight;
F32 mAutoOpenCountdown;
- time_t mSubtreeCreationDate;
- mutable ETrash mAmTrash;
S32 mLastArrangeGeneration;
S32 mLastCalculatedWidth;
S32 mCompletedFilterGeneration;
@@ -408,17 +365,13 @@ public:
LLFolderViewItem* getPreviousFromChild( LLFolderViewItem*, BOOL include_children = TRUE );
// addToFolder() returns TRUE if it succeeds. FALSE otherwise
- virtual BOOL addToFolder(LLFolderViewFolder* folder, LLFolderView* root);
+ virtual BOOL addToFolder(LLFolderViewFolder* folder);
// Finds width and height of this object and it's children. Also
// makes sure that this view and it's children are the right size.
virtual S32 arrange( S32* width, S32* height, S32 filter_generation );
BOOL needsArrange();
- void requestSort();
-
- // Returns the sort group (system, trash, folder) for this folder.
- virtual EInventorySortGroup getSortGroup() const;
virtual void setCompletedFilterGeneration(S32 generation, BOOL recurse_up);
virtual S32 getCompletedFilterGeneration() { return mCompletedFilterGeneration; }
@@ -479,15 +432,11 @@ public:
// extractItem() removes the specified item from the folder, but
// doesn't delete it.
- void extractItem( LLFolderViewItem* item );
+ virtual void extractItem( LLFolderViewItem* item );
// This function is called by a child that needs to be resorted.
void resort(LLFolderViewItem* item);
- void setItemSortOrder(U32 ordering);
- void sortBy(U32);
- //BOOL (*func)(LLFolderViewItem* a, LLFolderViewItem* b));
-
void setAutoOpenCountdown(F32 countdown) { mAutoOpenCountdown = countdown; }
// folders can be opened. This will usually be called by internal
@@ -501,6 +450,8 @@ public:
// don't rearrange child folder contents unless explicitly requested
virtual void requestArrange(BOOL include_descendants = FALSE);
+ virtual void requestSort();
+
// internal method which doesn't update the entire view. This
// method was written because the list iterators destroy the state
// of other iterations, thus, we can't arrange while iterating
@@ -519,7 +470,6 @@ public:
std::string& tooltip_msg);
void applyFunctorRecursively(LLFolderViewFunctor& functor);
- virtual void applyListenerFunctorRecursively(LLFolderViewListenerFunctor& functor);
// Just apply this functor to the folder's immediate children.
void applyFunctorToChildren(LLFolderViewFunctor& functor);
@@ -545,32 +495,18 @@ public:
std::string& tooltip_msg);
virtual void draw();
- time_t getCreationDate() const;
- bool isTrash() const;
- folders_t::const_iterator getFoldersBegin() const { return mFolders.begin(); }
- folders_t::const_iterator getFoldersEnd() const { return mFolders.end(); }
+ folders_t::iterator getFoldersBegin() const { return mFolders.begin(); }
+ folders_t::iterator getFoldersEnd() const { return mFolders.end(); }
folders_t::size_type getFoldersCount() const { return mFolders.size(); }
- items_t::const_iterator getItemsBegin() const { return mItems.begin(); }
- items_t::const_iterator getItemsEnd() const { return mItems.end(); }
+ items_t::iterator getItemsBegin() const { return mItems.begin(); }
+ items_t::iterator getItemsEnd() const { return mItems.end(); }
items_t::size_type getItemsCount() const { return mItems.size(); }
+
LLFolderViewFolder* getCommonAncestor(LLFolderViewItem* item_a, LLFolderViewItem* item_b, bool& reverse);
void gatherChildRangeExclusive(LLFolderViewItem* start, LLFolderViewItem* end, bool reverse, std::vector<LLFolderViewItem*>& items);
};
-//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-// Class LLFolderViewListenerFunctor
-//
-// This simple abstract base class can be used to applied to all
-// listeners in a hierarchy.
-//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-class LLFolderViewListenerFunctor
-{
-public:
- virtual ~LLFolderViewListenerFunctor() {}
- virtual void operator()(LLFolderViewEventListener* listener) = 0;
-};
#endif // LLFOLDERVIEWITEM_H