llinventoryview.h

Go to the documentation of this file.
00001 
00033 #ifndef LL_LLINVENTORYVIEW_H
00034 #define LL_LLINVENTORYVIEW_H
00035 
00036 #include "llassetstorage.h"
00037 #include "lldarray.h"
00038 #include "llfloater.h"
00039 #include "llinventory.h"
00040 #include "llfolderview.h"
00041 #include "llinventorymodel.h"
00042 #include "llmemberlistener.h"
00043 #include "lluictrlfactory.h"
00044 #include <set>
00045 
00046 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00047 // Class LLInventoryView
00048 //
00049 // This is the controller class specific for handling agent
00050 // inventory. It deals with the buttons and views used to navigate as
00051 // well as controls the behavior of the overall object.
00052 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00053 
00054 class LLInventoryModel;
00055 class LLInvFVBridge;
00056 class LLMenuBarGL;
00057 class LLCheckBoxCtrl;
00058 class LLSpinCtrl;
00059 class LLScrollableContainerView;
00060 class LLTextBox;
00061 class LLIconCtrl;
00062 class LLSaveFolderState;
00063 class LLSearchEditor;
00064 
00065 
00066 class LLInventoryPanel : public LLPanel
00067 {
00068 public:
00069         static const LLString DEFAULT_SORT_ORDER;
00070         static const LLString RECENTITEMS_SORT_ORDER;
00071         static const LLString INHERIT_SORT_ORDER;
00072 
00073         LLInventoryPanel(const LLString& name,
00074                         const LLString& sort_order_setting,
00075                         const LLRect& rect,
00076                         LLInventoryModel* inventory,
00077                         LLFolderSearchFunction search,
00078                         BOOL allow_multi_select,
00079                         LLView *parent_view = NULL);
00080         ~LLInventoryPanel();
00081 
00082         LLInventoryModel* getModel() { return mInventory; }
00083 
00084         BOOL postBuild();
00085 
00086         virtual LLXMLNodePtr getXML(bool save_children = true) const;
00087         static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory);
00088 
00089         // LLView methods
00090         BOOL handleHover(S32 x, S32 y, MASK mask);
00091         BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
00092                                                                    EDragAndDropType cargo_type,
00093                                                                    void* cargo_data,
00094                                                                    EAcceptance* accept,
00095                                                                    LLString& tooltip_msg);
00096 
00097         // Call this method to set the selection.
00098         void openAllFolders();
00099         void closeAllFolders();
00100         void openDefaultFolderForType(LLAssetType::EType);
00101         void setSelection(const LLUUID& obj_id, BOOL take_keyboard_focus);
00102         void setSelectCallback(LLFolderView::SelectCallback callback, void* user_data) { if (mFolders) mFolders->setSelectCallback(callback, user_data); }
00103         void clearSelection();
00104         LLInventoryFilter* getFilter() { return mFolders->getFilter(); }
00105         void setFilterTypes(U32 filter);
00106         U32 getFilterTypes() const { return mFolders->getFilterTypes(); }
00107         void setFilterPermMask(PermissionMask filter_perm_mask);
00108         U32 getFilterPermMask() const { return mFolders->getFilterPermissions(); }
00109         void setFilterSubString(const LLString& string);
00110         const LLString getFilterSubString() { return mFolders->getFilterSubString(); }
00111         void setSortOrder(U32 order);
00112         U32 getSortOrder() { return mFolders->getSortOrder(); }
00113         void setSinceLogoff(BOOL sl);
00114         void setHoursAgo(U32 hours);
00115         BOOL getSinceLogoff() { return mFolders->getFilter()->isSinceLogoff(); }
00116         
00117         void setShowFolderState(LLInventoryFilter::EFolderShow show);
00118         LLInventoryFilter::EFolderShow getShowFolderState();
00119         void setAllowMultiSelect(BOOL allow) { mFolders->setAllowMultiSelect(allow); }
00120         // This method is called when something has changed about the inventory.
00121         void modelChanged(U32 mask);
00122         LLFolderView* getRootFolder() { return mFolders; }
00123         LLScrollableContainerView* getScrollableContainer() { return mScroller; }
00124 
00125         // DEBUG ONLY:
00126         static void dumpSelectionInformation(void* user_data);
00127 
00128         void openSelected();
00129 
00130         void unSelectAll()      { mFolders->setSelection(NULL, FALSE, FALSE); }
00131 
00132 protected:
00133         // Given the id and the parent, build all of the folder views.
00134         void rebuildViewsFor(const LLUUID& id, U32 mask);
00135         void buildNewViews(const LLUUID& id);
00136 
00137 public:
00138         // TomY TODO: Move this elsewhere?
00139         // helper method which creates an item with a good description,
00140         // updates the inventory, updates the server, and pushes the
00141         // inventory update out to other observers.
00142         void createNewItem(const char* name,
00143                                            const LLUUID& parent_id,
00144                                            LLAssetType::EType asset_type,
00145                                            LLInventoryType::EType inv_type,
00146                                            U32 next_owner_perm = 0);
00147 
00148 protected:
00149         LLInventoryModel*                       mInventory;
00150         LLInventoryObserver*            mInventoryObserver;
00151         LLFolderView*                           mFolders;
00152         LLScrollableContainerView*      mScroller;
00153         BOOL                                            mAllowMultiSelect;
00154         const LLString                          mSortOrderSetting;
00155         LLFolderSearchFunction          mSearchFunction;
00156 };
00157 
00158 class LLInventoryView;
00159 
00160 class LLInventoryViewFinder : public LLFloater
00161 {
00162 public:
00163         LLInventoryViewFinder(const LLString& name,
00164                                                 const LLRect& rect,
00165                                                 LLInventoryView* inventory_view);
00166         virtual void draw();
00167         virtual void onClose(bool app_quitting);
00168         void changeFilter(LLInventoryFilter* filter);
00169         void updateElementsFromFilter();
00170         BOOL getCheckShowEmpty();
00171         BOOL getCheckSinceLogoff();
00172 
00173         static void onTimeAgo(LLUICtrl*, void *);
00174         static void onCheckSinceLogoff(LLUICtrl*, void *);
00175         static void onCloseBtn(void* user_data);
00176         static void selectAllTypes(void* user_data);
00177         static void selectNoTypes(void* user_data);
00178 
00179 protected:
00180         LLInventoryView*        mInventoryView;
00181         LLSpinCtrl*                     mSpinSinceDays;
00182         LLSpinCtrl*                     mSpinSinceHours;
00183         LLInventoryFilter*      mFilter;
00184 };
00185 
00186 class LLInventoryView : public LLFloater, LLInventoryObserver
00187 {
00188 friend class LLInventoryViewFinder;
00189 
00190 public:
00191         LLInventoryView(const LLString& name, const LLString& rect,
00192                         LLInventoryModel* inventory);
00193         LLInventoryView(const LLString& name, const LLRect& rect,
00194                                         LLInventoryModel* inventory);
00195         ~LLInventoryView();
00196 
00197         /*virtual*/ void changed(U32 mask);
00198 
00199          BOOL postBuild();
00200 
00201         //
00202         // Misc functions
00203         //
00204         void setFilterTextFromFilter() { mFilterText = mActivePanel->getFilter()->getFilterText(); }
00205         void startSearch();
00206         // This method makes sure that an inventory view exists, is
00207         // visible, and has focus. The view chosen is returned.
00208         static LLInventoryView* showAgentInventory(BOOL take_keyboard_focus = FALSE);
00209 
00210         // Return the active inventory view if there is one. Active is
00211         // defined as the inventory that is the closest to the front, and
00212         // is visible.
00213         static LLInventoryView* getActiveInventory();
00214 
00215         // This method calls showAgentInventory() if no views are visible,
00216         // or hides/destroyes them all if any are visible.
00217         static void toggleVisibility();
00218         static void toggleVisibility(void*) { toggleVisibility(); }
00219 
00220         // Final cleanup, destroy all open inventory views.
00221         static void cleanup();
00222 
00223         // LLView & LLFloater functionality
00224         virtual void onClose(bool app_quitting);
00225         virtual void setVisible(BOOL visible);
00226         virtual void draw();
00227         virtual BOOL handleKeyHere(KEY key, MASK mask);
00228 
00229         BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
00230                 EDragAndDropType cargo_type,
00231                 void* cargo_data,
00232                 EAcceptance* accept,
00233                 LLString& tooltip_msg);
00234 
00235 
00236         LLInventoryPanel* getPanel() { return mActivePanel; }
00237         LLInventoryPanel* getActivePanel() { return mActivePanel; }
00238 
00239         static BOOL filtersVisible(void* user_data);
00240         static void onClearSearch(void* user_data);
00241         static void onFoldersByName(void *user_data);
00242         static BOOL checkFoldersByName(void *user_data);
00243         static void onSearchEdit(const LLString& search_string, void* user_data );
00244         //static void onSearchCommit(LLUICtrl* caller, void* user_data );
00245         static void onFilterSelected(void* userdata, bool from_click);
00246         static void onSelectionChange(const std::deque<LLFolderViewItem*> &items, BOOL user_action, void* data);
00247         static BOOL incrementalFind(LLFolderViewItem* first_item, const char* find_text, BOOL backward);
00248 
00249         const LLString getFilterSubString() { return mActivePanel->getFilterSubString(); }
00250         void setFilterSubString(const LLString& string) { mActivePanel->setFilterSubString(string); }
00251 
00252         // HACK: Until we can route this info through the instant message hierarchy
00253         //static BOOL sOpenNextNewItem;
00254         static BOOL sWearNewClothing;
00255         static LLUUID sWearNewClothingTransactionID;    // wear all clothing in this transaction
00256 
00257         void toggleFindOptions();
00258 
00259         LLInventoryViewFinder* getFinder() { return (LLInventoryViewFinder*)mFinderHandle.get(); }
00260 
00261 protected:
00262         // internal initialization code
00263         void init(LLInventoryModel* inventory);
00264 
00265 protected:
00266         LLSearchEditor*                         mSearchEditor;
00267         LLTabContainer*                         mFilterTabs;
00268         LLHandle<LLFloater>                             mFinderHandle;
00269         LLInventoryPanel*                       mActivePanel;
00270         LLSaveFolderState*                      mSavedFolderState;
00271 
00272         LLString                                        mFilterText;
00273 
00274 
00275         // This container is used to hold all active inventory views. This
00276         // is here to support the inventory toggle show button.
00277         static LLDynamicArray<LLInventoryView*> sActiveViews;
00278 };
00279 
00280 class LLSelectFirstFilteredItem : public LLFolderViewFunctor
00281 {
00282 public:
00283         LLSelectFirstFilteredItem() : mItemSelected(FALSE) {}
00284         virtual ~LLSelectFirstFilteredItem() {}
00285         virtual void doFolder(LLFolderViewFolder* folder);
00286         virtual void doItem(LLFolderViewItem* item);
00287         BOOL wasItemSelected() { return mItemSelected; }
00288 protected:
00289         BOOL    mItemSelected;
00290 };
00291 
00292 class LLOpenFilteredFolders : public LLFolderViewFunctor
00293 {
00294 public:
00295         LLOpenFilteredFolders()  {}
00296         virtual ~LLOpenFilteredFolders() {}
00297         virtual void doFolder(LLFolderViewFolder* folder);
00298         virtual void doItem(LLFolderViewItem* item);
00299 };
00300 
00301 class LLSaveFolderState : public LLFolderViewFunctor
00302 {
00303 public:
00304         LLSaveFolderState() : mApply(FALSE) {}
00305         virtual ~LLSaveFolderState() {}
00306         virtual void doFolder(LLFolderViewFolder* folder);
00307         virtual void doItem(LLFolderViewItem* item) {}
00308         void setApply(BOOL apply);
00309         void clearOpenFolders() { mOpenFolders.clear(); }
00310 protected:
00311         std::set<LLUUID> mOpenFolders;
00312         BOOL mApply;
00313 };
00314 
00315 class LLOpenFoldersWithSelection : public LLFolderViewFunctor
00316 {
00317 public:
00318         LLOpenFoldersWithSelection() {}
00319         virtual ~LLOpenFoldersWithSelection() {}
00320         virtual void doFolder(LLFolderViewFolder* folder);
00321         virtual void doItem(LLFolderViewItem* item);
00322 };
00323 
00327 
00328 // useful functions with the inventory view
00329 // *FIX: move these methods.
00330 
00331 void init_inventory_actions(LLInventoryView *floater);
00332 void init_inventory_panel_actions(LLInventoryPanel *panel);
00333 
00334 class LLInventoryCategory;
00335 class LLInventoryItem;
00336 //void wear_inventory_category_on_avatar(LLInventoryCategory* category);
00337 
00338 void wear_inventory_item_on_avatar(LLInventoryItem* item);
00339 void wear_outfit_by_name(const char* name);
00340 void wear_inventory_category(LLInventoryCategory* category, bool copy, bool append);
00341 
00342 // These methods can open items without the inventory being visible
00343 void open_notecard(LLViewerInventoryItem* inv_item, const LLString& title, const LLUUID& object_id, BOOL show_keep_discard, const LLUUID& source_id = LLUUID::null, BOOL take_focus = TRUE);
00344 void open_landmark(LLViewerInventoryItem* inv_item, const LLString& title,                          BOOL show_keep_discard, const LLUUID& source_id = LLUUID::null, BOOL take_focus = TRUE);
00345 void open_texture(const LLUUID& item_id, const LLString& title, BOOL show_keep_discard, const LLUUID& source_id = LLUUID::null, BOOL take_focus = TRUE);
00346 
00347 LLString get_item_icon_name(LLAssetType::EType asset_type,
00348                                                          LLInventoryType::EType inventory_type,
00349                                                          U32 attachment_point, 
00350                                                          BOOL item_is_multi );
00351 
00352 LLUIImagePtr get_item_icon(LLAssetType::EType asset_type,
00353                                                          LLInventoryType::EType inventory_type,
00354                                                          U32 attachment_point, 
00355                                                          BOOL item_is_multi );
00356 
00357 // Move items from an in-world object's "Contents" folder to a specified
00358 // folder in agent inventory.
00359 BOOL move_inv_category_world_to_agent(const LLUUID& object_id, 
00360                                                                           const LLUUID& category_id,
00361                                                                           BOOL drop,
00362                                                                           void (*callback)(S32, void*) = NULL,
00363                                                                           void* user_data = NULL);
00364 
00365 const BOOL TAKE_FOCUS_YES = TRUE;
00366 const BOOL TAKE_FOCUS_NO  = FALSE;
00367 
00368 void rez_attachment(LLViewerInventoryItem* item, LLViewerJointAttachment* attachment);
00369 
00370 #endif // LL_LLINVENTORYVIEW_H
00371 
00372 
00373 

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