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

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