Annotation of /trunk/indra/newview/llinventoryview.h
Parent Directory
|
Revision Log
Revision 137 - (view) (download)
| 1 : | mjm | 135 | /** |
| 2 : | * @file llinventoryview.h | ||
| 3 : | * @brief LLInventoryView, LLInventoryFolder, and LLInventoryItem | ||
| 4 : | * class definition | ||
| 5 : | * | ||
| 6 : | * $LicenseInfo:firstyear=2001&license=viewergpl$ | ||
| 7 : | * | ||
| 8 : | mjm | 137 | * Copyright (c) 2001-2010, Linden Research, Inc. |
| 9 : | mjm | 135 | * |
| 10 : | * Second Life Viewer Source Code | ||
| 11 : | * The source code in this file ("Source Code") is provided by Linden Lab | ||
| 12 : | * to you under the terms of the GNU General Public License, version 2.0 | ||
| 13 : | * ("GPL"), unless you have obtained a separate licensing agreement | ||
| 14 : | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
| 15 : | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
| 16 : | * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 | ||
| 17 : | * | ||
| 18 : | * There are special exceptions to the terms and conditions of the GPL as | ||
| 19 : | * it is applied to this Source Code. View the full text of the exception | ||
| 20 : | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
| 21 : | * online at | ||
| 22 : | * http://secondlifegrid.net/programs/open_source/licensing/flossexception | ||
| 23 : | * | ||
| 24 : | * By copying, modifying or distributing this software, you acknowledge | ||
| 25 : | * that you have read and understood your obligations described above, | ||
| 26 : | * and agree to abide by those obligations. | ||
| 27 : | * | ||
| 28 : | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
| 29 : | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
| 30 : | * COMPLETENESS OR PERFORMANCE. | ||
| 31 : | * $/LicenseInfo$ | ||
| 32 : | */ | ||
| 33 : | |||
| 34 : | #ifndef LL_LLINVENTORYVIEW_H | ||
| 35 : | #define LL_LLINVENTORYVIEW_H | ||
| 36 : | |||
| 37 : | #include "llassetstorage.h" | ||
| 38 : | #include "lldarray.h" | ||
| 39 : | #include "llfloater.h" | ||
| 40 : | #include "llinventory.h" | ||
| 41 : | #include "llfolderview.h" | ||
| 42 : | #include "llinventorymodel.h" | ||
| 43 : | #include "llmemberlistener.h" | ||
| 44 : | #include "lluictrlfactory.h" | ||
| 45 : | #include <set> | ||
| 46 : | |||
| 47 : | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| 48 : | // Class LLInventoryView | ||
| 49 : | // | ||
| 50 : | // This is the controller class specific for handling agent | ||
| 51 : | // inventory. It deals with the buttons and views used to navigate as | ||
| 52 : | // well as controls the behavior of the overall object. | ||
| 53 : | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| 54 : | |||
| 55 : | class LLInventoryModel; | ||
| 56 : | class LLInvFVBridge; | ||
| 57 : | class LLMenuBarGL; | ||
| 58 : | class LLCheckBoxCtrl; | ||
| 59 : | class LLSpinCtrl; | ||
| 60 : | class LLScrollableContainerView; | ||
| 61 : | class LLTextBox; | ||
| 62 : | class LLIconCtrl; | ||
| 63 : | class LLSaveFolderState; | ||
| 64 : | class LLSearchEditor; | ||
| 65 : | |||
| 66 : | |||
| 67 : | class LLInventoryPanel : public LLPanel | ||
| 68 : | { | ||
| 69 : | public: | ||
| 70 : | static const std::string DEFAULT_SORT_ORDER; | ||
| 71 : | static const std::string RECENTITEMS_SORT_ORDER; | ||
| 72 : | static const std::string INHERIT_SORT_ORDER; | ||
| 73 : | |||
| 74 : | LLInventoryPanel(const std::string& name, | ||
| 75 : | const std::string& sort_order_setting, | ||
| 76 : | const LLRect& rect, | ||
| 77 : | LLInventoryModel* inventory, | ||
| 78 : | BOOL allow_multi_select, | ||
| 79 : | LLView *parent_view = NULL); | ||
| 80 : | ~LLInventoryPanel(); | ||
| 81 : | |||
| 82 : | LLInventoryModel* getModel() { return mInventory; } | ||
| 83 : | |||
| 84 : | BOOL postBuild(); | ||
| 85 : | |||
| 86 : | virtual LLXMLNodePtr getXML(bool save_children = true) const; | ||
| 87 : | static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory); | ||
| 88 : | |||
| 89 : | // LLView methods | ||
| 90 : | void draw(); | ||
| 91 : | BOOL handleHover(S32 x, S32 y, MASK mask); | ||
| 92 : | BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, | ||
| 93 : | EDragAndDropType cargo_type, | ||
| 94 : | void* cargo_data, | ||
| 95 : | EAcceptance* accept, | ||
| 96 : | std::string& tooltip_msg); | ||
| 97 : | |||
| 98 : | // Call this method to set the selection. | ||
| 99 : | void openAllFolders(); | ||
| 100 : | void closeAllFolders(); | ||
| 101 : | void openDefaultFolderForType(LLAssetType::EType); | ||
| 102 : | void setSelection(const LLUUID& obj_id, BOOL take_keyboard_focus); | ||
| 103 : | void setSelectCallback(LLFolderView::SelectCallback callback, void* user_data) { if (mFolders) mFolders->setSelectCallback(callback, user_data); } | ||
| 104 : | void clearSelection(); | ||
| 105 : | LLInventoryFilter* getFilter() { return mFolders->getFilter(); } | ||
| 106 : | void setFilterTypes(U32 filter); | ||
| 107 : | U32 getFilterTypes() const { return mFolders->getFilterTypes(); } | ||
| 108 : | void setFilterPermMask(PermissionMask filter_perm_mask); | ||
| 109 : | U32 getFilterPermMask() const { return mFolders->getFilterPermissions(); } | ||
| 110 : | void setFilterSubString(const std::string& string); | ||
| 111 : | const std::string getFilterSubString() { return mFolders->getFilterSubString(); } | ||
| 112 : | void setFilterWorn(bool worn); | ||
| 113 : | bool getFilterWorn() const { return mFolders->getFilterWorn(); } | ||
| 114 : | |||
| 115 : | void setSortOrder(U32 order); | ||
| 116 : | U32 getSortOrder() { return mFolders->getSortOrder(); } | ||
| 117 : | void setSinceLogoff(BOOL sl); | ||
| 118 : | void setHoursAgo(U32 hours); | ||
| 119 : | BOOL getSinceLogoff() { return mFolders->getFilter()->isSinceLogoff(); } | ||
| 120 : | |||
| 121 : | void setShowFolderState(LLInventoryFilter::EFolderShow show); | ||
| 122 : | LLInventoryFilter::EFolderShow getShowFolderState(); | ||
| 123 : | void setAllowMultiSelect(BOOL allow) { mFolders->setAllowMultiSelect(allow); } | ||
| 124 : | // This method is called when something has changed about the inventory. | ||
| 125 : | void modelChanged(U32 mask); | ||
| 126 : | LLFolderView* getRootFolder() { return mFolders; } | ||
| 127 : | LLScrollableContainerView* getScrollableContainer() { return mScroller; } | ||
| 128 : | |||
| 129 : | // DEBUG ONLY: | ||
| 130 : | static void dumpSelectionInformation(void* user_data); | ||
| 131 : | |||
| 132 : | void openSelected(); | ||
| 133 : | |||
| 134 : | void unSelectAll() { mFolders->setSelection(NULL, FALSE, FALSE); } | ||
| 135 : | |||
| 136 : | protected: | ||
| 137 : | // Given the id and the parent, build all of the folder views. | ||
| 138 : | void rebuildViewsFor(const LLUUID& id, U32 mask); | ||
| 139 : | void buildNewViews(const LLUUID& id); | ||
| 140 : | |||
| 141 : | public: | ||
| 142 : | // TomY TODO: Move this elsewhere? | ||
| 143 : | // helper method which creates an item with a good description, | ||
| 144 : | // updates the inventory, updates the server, and pushes the | ||
| 145 : | // inventory update out to other observers. | ||
| 146 : | void createNewItem(const std::string& name, | ||
| 147 : | const LLUUID& parent_id, | ||
| 148 : | LLAssetType::EType asset_type, | ||
| 149 : | LLInventoryType::EType inv_type, | ||
| 150 : | U32 next_owner_perm = 0); | ||
| 151 : | |||
| 152 : | protected: | ||
| 153 : | LLInventoryModel* mInventory; | ||
| 154 : | LLInventoryObserver* mInventoryObserver; | ||
| 155 : | LLFolderView* mFolders; | ||
| 156 : | LLScrollableContainerView* mScroller; | ||
| 157 : | BOOL mAllowMultiSelect; | ||
| 158 : | const std::string mSortOrderSetting; | ||
| 159 : | LLUUID mSelectThisID; // if non null, select this item | ||
| 160 : | }; | ||
| 161 : | |||
| 162 : | class LLInventoryView; | ||
| 163 : | |||
| 164 : | class LLInventoryViewFinder : public LLFloater | ||
| 165 : | { | ||
| 166 : | public: | ||
| 167 : | LLInventoryViewFinder(const std::string& name, | ||
| 168 : | const LLRect& rect, | ||
| 169 : | LLInventoryView* inventory_view); | ||
| 170 : | virtual void draw(); | ||
| 171 : | virtual void onClose(bool app_quitting); | ||
| 172 : | void changeFilter(LLInventoryFilter* filter); | ||
| 173 : | void updateElementsFromFilter(); | ||
| 174 : | BOOL getCheckShowEmpty(); | ||
| 175 : | BOOL getCheckSinceLogoff(); | ||
| 176 : | |||
| 177 : | static void onTimeAgo(LLUICtrl*, void *); | ||
| 178 : | static void onCheckSinceLogoff(LLUICtrl*, void *); | ||
| 179 : | static void onCloseBtn(void* user_data); | ||
| 180 : | static void selectAllTypes(void* user_data); | ||
| 181 : | static void selectNoTypes(void* user_data); | ||
| 182 : | |||
| 183 : | protected: | ||
| 184 : | LLInventoryView* mInventoryView; | ||
| 185 : | LLSpinCtrl* mSpinSinceDays; | ||
| 186 : | LLSpinCtrl* mSpinSinceHours; | ||
| 187 : | LLInventoryFilter* mFilter; | ||
| 188 : | }; | ||
| 189 : | |||
| 190 : | class LLInventoryView : public LLFloater, LLInventoryObserver | ||
| 191 : | { | ||
| 192 : | friend class LLInventoryViewFinder; | ||
| 193 : | |||
| 194 : | public: | ||
| 195 : | LLInventoryView(const std::string& name, const std::string& rect, | ||
| 196 : | LLInventoryModel* inventory); | ||
| 197 : | LLInventoryView(const std::string& name, const LLRect& rect, | ||
| 198 : | LLInventoryModel* inventory); | ||
| 199 : | ~LLInventoryView(); | ||
| 200 : | |||
| 201 : | /*virtual*/ void changed(U32 mask); | ||
| 202 : | |||
| 203 : | BOOL postBuild(); | ||
| 204 : | |||
| 205 : | // | ||
| 206 : | // Misc functions | ||
| 207 : | // | ||
| 208 : | void setFilterTextFromFilter() { mFilterText = mActivePanel->getFilter()->getFilterText(); } | ||
| 209 : | void startSearch(); | ||
| 210 : | // This method makes sure that an inventory view exists, is | ||
| 211 : | // visible, and has focus. The view chosen is returned. | ||
| 212 : | static LLInventoryView* showAgentInventory(BOOL take_keyboard_focus = FALSE); | ||
| 213 : | |||
| 214 : | // Return the active inventory view if there is one. Active is | ||
| 215 : | // defined as the inventory that is the closest to the front, and | ||
| 216 : | // is visible. | ||
| 217 : | static LLInventoryView* getActiveInventory(); | ||
| 218 : | |||
| 219 : | // This method calls showAgentInventory() if no views are visible, | ||
| 220 : | // or hides/destroyes them all if any are visible. | ||
| 221 : | static void toggleVisibility(); | ||
| 222 : | static void toggleVisibility(void*) { toggleVisibility(); } | ||
| 223 : | |||
| 224 : | // Final cleanup, destroy all open inventory views. | ||
| 225 : | static void cleanup(); | ||
| 226 : | |||
| 227 : | // LLView & LLFloater functionality | ||
| 228 : | virtual void onClose(bool app_quitting); | ||
| 229 : | virtual void setVisible(BOOL visible); | ||
| 230 : | virtual void draw(); | ||
| 231 : | virtual BOOL handleKeyHere(KEY key, MASK mask); | ||
| 232 : | |||
| 233 : | BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, | ||
| 234 : | EDragAndDropType cargo_type, | ||
| 235 : | void* cargo_data, | ||
| 236 : | EAcceptance* accept, | ||
| 237 : | std::string& tooltip_msg); | ||
| 238 : | |||
| 239 : | |||
| 240 : | LLInventoryPanel* getPanel() { return mActivePanel; } | ||
| 241 : | LLInventoryPanel* getActivePanel() { return mActivePanel; } | ||
| 242 : | |||
| 243 : | static BOOL filtersVisible(void* user_data); | ||
| 244 : | static void onClearSearch(void* user_data); | ||
| 245 : | static void onFoldersByName(void *user_data); | ||
| 246 : | static BOOL checkFoldersByName(void *user_data); | ||
| 247 : | static void onSearchEdit(const std::string& search_string, void* user_data ); | ||
| 248 : | static void onFilterSelected(void* userdata, bool from_click); | ||
| 249 : | static void onSelectionChange(const std::deque<LLFolderViewItem*> &items, BOOL user_action, void* data); | ||
| 250 : | |||
| 251 : | const std::string getFilterSubString() { return mActivePanel->getFilterSubString(); } | ||
| 252 : | void setFilterSubString(const std::string& string) { mActivePanel->setFilterSubString(string); } | ||
| 253 : | |||
| 254 : | // HACK: Until we can route this info through the instant message hierarchy | ||
| 255 : | static BOOL sWearNewClothing; | ||
| 256 : | static LLUUID sWearNewClothingTransactionID; // wear all clothing in this transaction | ||
| 257 : | |||
| 258 : | void toggleFindOptions(); | ||
| 259 : | |||
| 260 : | LLInventoryViewFinder* getFinder() { return (LLInventoryViewFinder*)mFinderHandle.get(); } | ||
| 261 : | |||
| 262 : | protected: | ||
| 263 : | // internal initialization code | ||
| 264 : | void init(LLInventoryModel* inventory); | ||
| 265 : | |||
| 266 : | protected: | ||
| 267 : | LLSearchEditor* mSearchEditor; | ||
| 268 : | LLTabContainer* mFilterTabs; | ||
| 269 : | LLHandle<LLFloater> mFinderHandle; | ||
| 270 : | LLInventoryPanel* mActivePanel; | ||
| 271 : | LLSaveFolderState* mSavedFolderState; | ||
| 272 : | |||
| 273 : | std::string mFilterText; | ||
| 274 : | |||
| 275 : | |||
| 276 : | // This container is used to hold all active inventory views. This | ||
| 277 : | // is here to support the inventory toggle show button. | ||
| 278 : | //MK | ||
| 279 : | public: | ||
| 280 : | //mk | ||
| 281 : | static LLDynamicArray<LLInventoryView*> sActiveViews; | ||
| 282 : | }; | ||
| 283 : | |||
| 284 : | class LLSelectFirstFilteredItem : public LLFolderViewFunctor | ||
| 285 : | { | ||
| 286 : | public: | ||
| 287 : | LLSelectFirstFilteredItem() : mItemSelected(FALSE) {} | ||
| 288 : | virtual ~LLSelectFirstFilteredItem() {} | ||
| 289 : | virtual void doFolder(LLFolderViewFolder* folder); | ||
| 290 : | virtual void doItem(LLFolderViewItem* item); | ||
| 291 : | BOOL wasItemSelected() { return mItemSelected; } | ||
| 292 : | protected: | ||
| 293 : | BOOL mItemSelected; | ||
| 294 : | }; | ||
| 295 : | |||
| 296 : | class LLOpenFilteredFolders : public LLFolderViewFunctor | ||
| 297 : | { | ||
| 298 : | public: | ||
| 299 : | LLOpenFilteredFolders() {} | ||
| 300 : | virtual ~LLOpenFilteredFolders() {} | ||
| 301 : | virtual void doFolder(LLFolderViewFolder* folder); | ||
| 302 : | virtual void doItem(LLFolderViewItem* item); | ||
| 303 : | }; | ||
| 304 : | |||
| 305 : | class LLSaveFolderState : public LLFolderViewFunctor | ||
| 306 : | { | ||
| 307 : | public: | ||
| 308 : | LLSaveFolderState() : mApply(FALSE) {} | ||
| 309 : | virtual ~LLSaveFolderState() {} | ||
| 310 : | virtual void doFolder(LLFolderViewFolder* folder); | ||
| 311 : | virtual void doItem(LLFolderViewItem* item) {} | ||
| 312 : | void setApply(BOOL apply); | ||
| 313 : | void clearOpenFolders() { mOpenFolders.clear(); } | ||
| 314 : | protected: | ||
| 315 : | std::set<LLUUID> mOpenFolders; | ||
| 316 : | BOOL mApply; | ||
| 317 : | }; | ||
| 318 : | |||
| 319 : | class LLOpenFoldersWithSelection : public LLFolderViewFunctor | ||
| 320 : | { | ||
| 321 : | public: | ||
| 322 : | LLOpenFoldersWithSelection() {} | ||
| 323 : | virtual ~LLOpenFoldersWithSelection() {} | ||
| 324 : | virtual void doFolder(LLFolderViewFolder* folder); | ||
| 325 : | virtual void doItem(LLFolderViewItem* item); | ||
| 326 : | }; | ||
| 327 : | |||
| 328 : | ///---------------------------------------------------------------------------- | ||
| 329 : | /// Function declarations, constants, enums, and typedefs | ||
| 330 : | ///---------------------------------------------------------------------------- | ||
| 331 : | |||
| 332 : | // useful functions with the inventory view | ||
| 333 : | // *FIX: move these methods. | ||
| 334 : | |||
| 335 : | void init_inventory_actions(LLInventoryView *floater); | ||
| 336 : | void init_inventory_panel_actions(LLInventoryPanel *panel); | ||
| 337 : | |||
| 338 : | class LLInventoryCategory; | ||
| 339 : | class LLInventoryItem; | ||
| 340 : | //void wear_inventory_category_on_avatar(LLInventoryCategory* category); | ||
| 341 : | |||
| 342 : | void wear_inventory_item_on_avatar(LLInventoryItem* item); | ||
| 343 : | void wear_outfit_by_name(const std::string& name); | ||
| 344 : | void wear_inventory_category(LLInventoryCategory* category, bool copy, bool append); | ||
| 345 : | |||
| 346 : | // These methods can open items without the inventory being visible | ||
| 347 : | void open_notecard(LLViewerInventoryItem* inv_item, const std::string& title, const LLUUID& object_id, BOOL show_keep_discard, const LLUUID& source_id = LLUUID::null, BOOL take_focus = TRUE); | ||
| 348 : | void open_landmark(LLViewerInventoryItem* inv_item, const std::string& title, BOOL show_keep_discard, const LLUUID& source_id = LLUUID::null, BOOL take_focus = TRUE); | ||
| 349 : | void open_texture(const LLUUID& item_id, const std::string& title, BOOL show_keep_discard, const LLUUID& source_id = LLUUID::null, BOOL take_focus = TRUE); | ||
| 350 : | |||
| 351 : | std::string get_item_icon_name(LLAssetType::EType asset_type, | ||
| 352 : | LLInventoryType::EType inventory_type, | ||
| 353 : | U32 attachment_point, | ||
| 354 : | BOOL item_is_multi ); | ||
| 355 : | |||
| 356 : | LLUIImagePtr get_item_icon(LLAssetType::EType asset_type, | ||
| 357 : | LLInventoryType::EType inventory_type, | ||
| 358 : | U32 attachment_point, | ||
| 359 : | BOOL item_is_multi ); | ||
| 360 : | |||
| 361 : | // Move items from an in-world object's "Contents" folder to a specified | ||
| 362 : | // folder in agent inventory. | ||
| 363 : | BOOL move_inv_category_world_to_agent(const LLUUID& object_id, | ||
| 364 : | const LLUUID& category_id, | ||
| 365 : | BOOL drop, | ||
| 366 : | void (*callback)(S32, void*) = NULL, | ||
| 367 : | void* user_data = NULL); | ||
| 368 : | |||
| 369 : | const BOOL TAKE_FOCUS_YES = TRUE; | ||
| 370 : | const BOOL TAKE_FOCUS_NO = FALSE; | ||
| 371 : | |||
| 372 : | void rez_attachment(LLViewerInventoryItem* item, LLViewerJointAttachment* attachment); | ||
| 373 : | |||
| 374 : | #endif // LL_LLINVENTORYVIEW_H | ||
| 375 : | |||
| 376 : | |||
| 377 : |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |

