diff options
Diffstat (limited to '')
-rw-r--r-- | linden/indra/newview/llinventoryview.cpp | 113 |
1 files changed, 111 insertions, 2 deletions
diff --git a/linden/indra/newview/llinventoryview.cpp b/linden/indra/newview/llinventoryview.cpp index bb70ea4..8ac5f21 100644 --- a/linden/indra/newview/llinventoryview.cpp +++ b/linden/indra/newview/llinventoryview.cpp | |||
@@ -64,6 +64,7 @@ | |||
64 | #include "llpreviewtexture.h" | 64 | #include "llpreviewtexture.h" |
65 | #include "llresmgr.h" | 65 | #include "llresmgr.h" |
66 | #include "llscrollcontainer.h" | 66 | #include "llscrollcontainer.h" |
67 | #include "llscrollbar.h" | ||
67 | #include "llimview.h" | 68 | #include "llimview.h" |
68 | #include "lltooldraganddrop.h" | 69 | #include "lltooldraganddrop.h" |
69 | #include "llviewerimagelist.h" | 70 | #include "llviewerimagelist.h" |
@@ -78,6 +79,8 @@ | |||
78 | #include "llvieweruictrlfactory.h" | 79 | #include "llvieweruictrlfactory.h" |
79 | #include "llselectmgr.h" | 80 | #include "llselectmgr.h" |
80 | 81 | ||
82 | #include "llsdserialize.h" | ||
83 | |||
81 | LLDynamicArray<LLInventoryView*> LLInventoryView::sActiveViews; | 84 | LLDynamicArray<LLInventoryView*> LLInventoryView::sActiveViews; |
82 | 85 | ||
83 | //BOOL LLInventoryView::sOpenNextNewItem = FALSE; | 86 | //BOOL LLInventoryView::sOpenNextNewItem = FALSE; |
@@ -464,6 +467,9 @@ void LLInventoryView::init(LLInventoryModel* inventory) | |||
464 | 467 | ||
465 | gUICtrlFactory->buildFloater(this, "floater_inventory.xml", NULL); | 468 | gUICtrlFactory->buildFloater(this, "floater_inventory.xml", NULL); |
466 | 469 | ||
470 | mFilterTabs = (LLTabContainer*)LLUICtrlFactory::getTabContainerByName(this, "inventory filter tabs"); | ||
471 | |||
472 | // Set up the default inv. panel/filter settings. | ||
467 | mActivePanel = (LLInventoryPanel*)getCtrlByNameAndType("All Items", WIDGET_TYPE_INVENTORY_PANEL); | 473 | mActivePanel = (LLInventoryPanel*)getCtrlByNameAndType("All Items", WIDGET_TYPE_INVENTORY_PANEL); |
468 | if (mActivePanel) | 474 | if (mActivePanel) |
469 | { | 475 | { |
@@ -471,6 +477,7 @@ void LLInventoryView::init(LLInventoryModel* inventory) | |||
471 | mActivePanel->setSortOrder(gSavedSettings.getU32("InventorySortOrder")); | 477 | mActivePanel->setSortOrder(gSavedSettings.getU32("InventorySortOrder")); |
472 | mActivePanel->getFilter()->markDefault(); | 478 | mActivePanel->getFilter()->markDefault(); |
473 | mActivePanel->getRootFolder()->applyFunctorRecursively(*mSavedFolderState); | 479 | mActivePanel->getRootFolder()->applyFunctorRecursively(*mSavedFolderState); |
480 | mActivePanel->setSelectCallback(onSelectionChange, mActivePanel); | ||
474 | } | 481 | } |
475 | LLInventoryPanel* recent_items_panel = (LLInventoryPanel*)getCtrlByNameAndType("Recent Items", WIDGET_TYPE_INVENTORY_PANEL); | 482 | LLInventoryPanel* recent_items_panel = (LLInventoryPanel*)getCtrlByNameAndType("Recent Items", WIDGET_TYPE_INVENTORY_PANEL); |
476 | if (recent_items_panel) | 483 | if (recent_items_panel) |
@@ -479,7 +486,29 @@ void LLInventoryView::init(LLInventoryModel* inventory) | |||
479 | recent_items_panel->setSortOrder(LLInventoryFilter::SO_DATE); | 486 | recent_items_panel->setSortOrder(LLInventoryFilter::SO_DATE); |
480 | recent_items_panel->setShowFolderState(LLInventoryFilter::SHOW_NON_EMPTY_FOLDERS); | 487 | recent_items_panel->setShowFolderState(LLInventoryFilter::SHOW_NON_EMPTY_FOLDERS); |
481 | recent_items_panel->getFilter()->markDefault(); | 488 | recent_items_panel->getFilter()->markDefault(); |
482 | } | 489 | recent_items_panel->setSelectCallback(onSelectionChange, recent_items_panel); |
490 | } | ||
491 | |||
492 | // Now load the stored settings from disk, if available. | ||
493 | std::ostringstream filterSaveName; | ||
494 | filterSaveName << gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, "filters.xml"); | ||
495 | llinfos << "LLInventoryView::init: reading from " << filterSaveName << llendl; | ||
496 | llifstream file(filterSaveName.str().c_str()); | ||
497 | LLSD savedFilterState; | ||
498 | if (file.is_open()) | ||
499 | { | ||
500 | LLSDSerialize::fromXML(savedFilterState, file); | ||
501 | file.close(); | ||
502 | |||
503 | // Load the persistent "Recent Items" settings. | ||
504 | // Note that the "All Items" settings do not persist. | ||
505 | if(savedFilterState.has(recent_items_panel->getFilter()->getName())) | ||
506 | { | ||
507 | LLSD recent_items = savedFilterState.get(recent_items_panel->getFilter()->getName()); | ||
508 | recent_items_panel->getFilter()->fromLLSD(recent_items); | ||
509 | } | ||
510 | } | ||
511 | |||
483 | 512 | ||
484 | mSearchEditor = (LLSearchEditor*)getCtrlByNameAndType("inventory search editor", WIDGET_TYPE_SEARCH_EDITOR); | 513 | mSearchEditor = (LLSearchEditor*)getCtrlByNameAndType("inventory search editor", WIDGET_TYPE_SEARCH_EDITOR); |
485 | if (mSearchEditor) | 514 | if (mSearchEditor) |
@@ -504,6 +533,36 @@ BOOL LLInventoryView::postBuild() | |||
504 | // Destroys the object | 533 | // Destroys the object |
505 | LLInventoryView::~LLInventoryView( void ) | 534 | LLInventoryView::~LLInventoryView( void ) |
506 | { | 535 | { |
536 | // Save the filters state. | ||
537 | LLSD filterRoot; | ||
538 | LLInventoryPanel* all_items_panel = (LLInventoryPanel*)getCtrlByNameAndType("All Items", WIDGET_TYPE_INVENTORY_PANEL); | ||
539 | if (all_items_panel) | ||
540 | { | ||
541 | LLInventoryFilter* filter = all_items_panel->getFilter(); | ||
542 | LLSD filterState; | ||
543 | filter->toLLSD(filterState); | ||
544 | filterRoot[filter->getName()] = filterState; | ||
545 | } | ||
546 | |||
547 | LLInventoryPanel* recent_items_panel = (LLInventoryPanel*)getCtrlByNameAndType("Recent Items", WIDGET_TYPE_INVENTORY_PANEL); | ||
548 | if (recent_items_panel) | ||
549 | { | ||
550 | LLInventoryFilter* filter = recent_items_panel->getFilter(); | ||
551 | LLSD filterState; | ||
552 | filter->toLLSD(filterState); | ||
553 | filterRoot[filter->getName()] = filterState; | ||
554 | } | ||
555 | |||
556 | std::ostringstream filterSaveName; | ||
557 | filterSaveName << gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, "filters.xml"); | ||
558 | llofstream filtersFile(filterSaveName.str().c_str()); | ||
559 | if(!LLSDSerialize::toPrettyXML(filterRoot, filtersFile)) | ||
560 | { | ||
561 | llwarns << "Could not write to filters save file " << filterSaveName << llendl; | ||
562 | } | ||
563 | else | ||
564 | filtersFile.close(); | ||
565 | |||
507 | sActiveViews.removeObj(this); | 566 | sActiveViews.removeObj(this); |
508 | gInventory.removeObserver(this); | 567 | gInventory.removeObserver(this); |
509 | delete mSavedFolderState; | 568 | delete mSavedFolderState; |
@@ -630,7 +689,9 @@ void LLInventoryView::onClose(bool app_quitting) | |||
630 | mSavedFolderState->setApply(FALSE); | 689 | mSavedFolderState->setApply(FALSE); |
631 | mActivePanel->getRootFolder()->applyFunctorRecursively(*mSavedFolderState); | 690 | mActivePanel->getRootFolder()->applyFunctorRecursively(*mSavedFolderState); |
632 | } | 691 | } |
633 | onClearSearch(this); | 692 | |
693 | // onClearSearch(this); | ||
694 | |||
634 | // pass up | 695 | // pass up |
635 | LLFloater::setVisible(FALSE); | 696 | LLFloater::setVisible(FALSE); |
636 | } | 697 | } |
@@ -930,6 +991,7 @@ void LLInventoryView::onFilterSelected(void* userdata, bool from_click) | |||
930 | LLInventoryViewFinder *finder = self->getFinder(); | 991 | LLInventoryViewFinder *finder = self->getFinder(); |
931 | // Find my index | 992 | // Find my index |
932 | self->mActivePanel = (LLInventoryPanel*)self->childGetVisibleTab("inventory filter tabs"); | 993 | self->mActivePanel = (LLInventoryPanel*)self->childGetVisibleTab("inventory filter tabs"); |
994 | |||
933 | if (!self->mActivePanel) | 995 | if (!self->mActivePanel) |
934 | { | 996 | { |
935 | return; | 997 | return; |
@@ -947,6 +1009,42 @@ void LLInventoryView::onFilterSelected(void* userdata, bool from_click) | |||
947 | self->setFilterTextFromFilter(); | 1009 | self->setFilterTextFromFilter(); |
948 | } | 1010 | } |
949 | 1011 | ||
1012 | // static | ||
1013 | void LLInventoryView::onSelectionChange(const std::deque<LLFolderViewItem*> &items, BOOL user_action, void* data) | ||
1014 | { | ||
1015 | LLInventoryPanel* panel = (LLInventoryPanel*)data; | ||
1016 | LLFolderView* fv = panel->getRootFolder(); | ||
1017 | if (fv->needsAutoRename()) // auto-selecting a new user-created asset and preparing to rename | ||
1018 | { | ||
1019 | fv->setNeedsAutoRename(FALSE); | ||
1020 | if (items.size()) // new asset is visible and selected | ||
1021 | { | ||
1022 | fv->startRenamingSelectedItem(); | ||
1023 | } | ||
1024 | } | ||
1025 | } | ||
1026 | |||
1027 | BOOL LLInventoryView::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, | ||
1028 | EDragAndDropType cargo_type, | ||
1029 | void* cargo_data, | ||
1030 | EAcceptance* accept, | ||
1031 | LLString& tooltip_msg) | ||
1032 | { | ||
1033 | // Check to see if we are auto scrolling from the last frame | ||
1034 | LLInventoryPanel* panel = (LLInventoryPanel*)this->getActivePanel(); | ||
1035 | BOOL needsToScroll = panel->getScrollableContainer()->needsToScroll(x, y, LLScrollableContainerView::VERTICAL); | ||
1036 | if(mFilterTabs) | ||
1037 | { | ||
1038 | if(needsToScroll) | ||
1039 | { | ||
1040 | mFilterTabs->setDragAndDropDelayTimer(); | ||
1041 | } | ||
1042 | } | ||
1043 | |||
1044 | BOOL handled = LLFloater::handleDragAndDrop(x, y, mask, drop, cargo_type, cargo_data, accept, tooltip_msg); | ||
1045 | |||
1046 | return handled; | ||
1047 | } | ||
950 | LLUUID get_item_icon_uuid(LLAssetType::EType asset_type, | 1048 | LLUUID get_item_icon_uuid(LLAssetType::EType asset_type, |
951 | LLInventoryType::EType inventory_type, | 1049 | LLInventoryType::EType inventory_type, |
952 | U32 attachment_point, | 1050 | U32 attachment_point, |
@@ -1142,6 +1240,7 @@ BOOL LLInventoryPanel::postBuild() | |||
1142 | } | 1240 | } |
1143 | mFolders->setSortOrder(mFolders->getFilter()->getSortOrder()); | 1241 | mFolders->setSortOrder(mFolders->getFilter()->getSortOrder()); |
1144 | 1242 | ||
1243 | |||
1145 | return TRUE; | 1244 | return TRUE; |
1146 | } | 1245 | } |
1147 | 1246 | ||
@@ -1302,6 +1401,14 @@ void LLInventoryPanel::modelChanged(U32 mask) | |||
1302 | llwarns << *id_it << " is in model but not in view, but ADD flag not set" << llendl; | 1401 | llwarns << *id_it << " is in model but not in view, but ADD flag not set" << llendl; |
1303 | } | 1402 | } |
1304 | buildNewViews(*id_it); | 1403 | buildNewViews(*id_it); |
1404 | |||
1405 | // select any newly created object | ||
1406 | // that has the auto rename at top of folder | ||
1407 | // root set | ||
1408 | if(mFolders->getRoot()->needsAutoRename()) | ||
1409 | { | ||
1410 | setSelection(*id_it, FALSE); | ||
1411 | } | ||
1305 | } | 1412 | } |
1306 | else | 1413 | else |
1307 | { | 1414 | { |
@@ -1526,6 +1633,7 @@ BOOL LLInventoryPanel::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, | |||
1526 | EAcceptance* accept, | 1633 | EAcceptance* accept, |
1527 | LLString& tooltip_msg) | 1634 | LLString& tooltip_msg) |
1528 | { | 1635 | { |
1636 | |||
1529 | BOOL handled = LLPanel::handleDragAndDrop(x, y, mask, drop, cargo_type, cargo_data, accept, tooltip_msg); | 1637 | BOOL handled = LLPanel::handleDragAndDrop(x, y, mask, drop, cargo_type, cargo_data, accept, tooltip_msg); |
1530 | 1638 | ||
1531 | if (handled) | 1639 | if (handled) |
@@ -1586,6 +1694,7 @@ void LLInventoryPanel::createNewItem(const char* name, | |||
1586 | create_inventory_item(gAgent.getID(), gAgent.getSessionID(), | 1694 | create_inventory_item(gAgent.getID(), gAgent.getSessionID(), |
1587 | parent_id, LLTransactionID::tnull, name, desc, asset_type, inv_type, | 1695 | parent_id, LLTransactionID::tnull, name, desc, asset_type, inv_type, |
1588 | NOT_WEARABLE, next_owner_perm, cb); | 1696 | NOT_WEARABLE, next_owner_perm, cb); |
1697 | |||
1589 | } | 1698 | } |
1590 | 1699 | ||
1591 | // static DEBUG ONLY: | 1700 | // static DEBUG ONLY: |