From 6bb2b2cb99740a00498f5441b8a48b0bf5a04985 Mon Sep 17 00:00:00 2001 From: Leslie Linden <leslie@lindenlab.com> Date: Wed, 7 Sep 2011 12:45:50 -0700 Subject: [PATCH] EXP-1194 FIX -- Update New tag behavior to update Newness timestamp when Received Items panel is open and do not auto open Received Items panel * Updated inbox freshness time setting name to "LastInventoryInboxActivity" * New time stamp reflects time of last activity performed on the inbox by the user * Selection and opening items in the inbox both count as activity on the inbox * Focus going to the inbox panel counts as activity on the inbox * Creation date of folders now computed based on date of items being added to them * Creation date of folders no longer relies on queries for creation date, as is done during sorting * Folders are assumed to be "new" if no inbox freshness time setting is saved --- .../app_settings/settings_per_account.xml | 4 +- indra/newview/llfolderviewitem.cpp | 62 +++++++------------ indra/newview/llfolderviewitem.h | 4 +- indra/newview/llinventorypanel.cpp | 5 +- indra/newview/llinventorypanel.h | 2 + indra/newview/llpanelmarketplaceinbox.cpp | 6 +- .../llpanelmarketplaceinboxinventory.cpp | 44 ++++++++----- .../llpanelmarketplaceinboxinventory.h | 8 +-- .../llpanelmarketplaceoutboxinventory.cpp | 5 -- .../llpanelmarketplaceoutboxinventory.h | 2 - indra/newview/llsidepanelinventory.cpp | 4 +- 11 files changed, 71 insertions(+), 75 deletions(-) diff --git a/indra/newview/app_settings/settings_per_account.xml b/indra/newview/app_settings/settings_per_account.xml index 49f8a11e3e9..c7140283f19 100644 --- a/indra/newview/app_settings/settings_per_account.xml +++ b/indra/newview/app_settings/settings_per_account.xml @@ -33,10 +33,10 @@ <key>Value</key> <string /> </map> - <key>LastInventoryInboxExpansion</key> + <key>LastInventoryInboxActivity</key> <map> <key>Comment</key> - <string>The last time the received items inbox was expanded for view.</string> + <string>The last time the received items inbox was poked by the user.</string> <key>Persist</key> <integer>1</integer> <key>Type</key> diff --git a/indra/newview/llfolderviewitem.cpp b/indra/newview/llfolderviewitem.cpp index 72e2294196f..00bc63326b1 100644 --- a/indra/newview/llfolderviewitem.cpp +++ b/indra/newview/llfolderviewitem.cpp @@ -2057,23 +2057,42 @@ BOOL LLFolderViewFolder::isRemovable() BOOL LLFolderViewFolder::addItem(LLFolderViewItem* item) { mItems.push_back(item); + if (item->isSelected()) { recursiveIncrementNumDescendantsSelected(1); } + item->setRect(LLRect(0, 0, getRect().getWidth(), 0)); item->setVisible(FALSE); - addChild( item ); + + addChild(item); + item->dirtyFilter(); + + // Update the folder creation date if the child is newer than our current date + setCreationDate(llmax<time_t>(mCreationDate, item->getCreationDate())); + + // Handle sorting requestArrange(); requestSort(); + + // Traverse parent folders and update creation date and resort, if necessary LLFolderViewFolder* parentp = getParentFolder(); - while (parentp && parentp->mSortFunction.isByDate()) + while (parentp) { - // parent folder doesn't have a time stamp yet, so get it from us - parentp->requestSort(); + // Update the folder creation date if the child is newer than our current date + parentp->setCreationDate(llmax<time_t>(parentp->mCreationDate, item->getCreationDate())); + + if (parentp->mSortFunction.isByDate()) + { + // parent folder doesn't have a time stamp yet, so get it from us + parentp->requestSort(); + } + parentp = parentp->getParentFolder(); } + return TRUE; } @@ -2437,41 +2456,6 @@ void LLFolderViewFolder::draw() time_t LLFolderViewFolder::getCreationDate() const { - // folders have no creation date try to create one from an item somewhere in our folder hierarchy - if (!mCreationDate) - { - for (items_t::const_iterator iit = mItems.begin(); - iit != mItems.end(); ++iit) - { - LLFolderViewItem* itemp = (*iit); - - const time_t item_creation_date = itemp->getCreationDate(); - - if (item_creation_date) - { - setCreationDate(item_creation_date); - break; - } - } - - if (!mCreationDate) - { - for (folders_t::const_iterator fit = mFolders.begin(); - fit != mFolders.end(); ++fit) - { - LLFolderViewFolder* folderp = (*fit); - - const time_t folder_creation_date = folderp->getCreationDate(); - - if (folder_creation_date) - { - setCreationDate(folder_creation_date); - break; - } - } - } - } - return llmax<time_t>(mCreationDate, mSubtreeCreationDate); } diff --git a/indra/newview/llfolderviewitem.h b/indra/newview/llfolderviewitem.h index ce936b49918..676eaf825dc 100644 --- a/indra/newview/llfolderviewitem.h +++ b/indra/newview/llfolderviewitem.h @@ -136,7 +136,7 @@ class LLFolderViewItem : public LLView std::string mSearchableLabel; S32 mLabelWidth; bool mLabelWidthDirty; - mutable time_t mCreationDate; + time_t mCreationDate; LLFolderViewFolder* mParentFolder; LLFolderViewEventListener* mListener; BOOL mIsCurSelection; @@ -174,7 +174,7 @@ class LLFolderViewItem : public LLView static LLFontGL* getLabelFontForStyle(U8 style); - virtual void setCreationDate(time_t creation_date_utc) const { mCreationDate = creation_date_utc; } + virtual void setCreationDate(time_t creation_date_utc) { mCreationDate = creation_date_utc; } public: BOOL postBuild(); diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp index 5f033cf5175..173e5c6ae6a 100644 --- a/indra/newview/llinventorypanel.cpp +++ b/indra/newview/llinventorypanel.cpp @@ -234,7 +234,6 @@ void LLInventoryPanel::initFromParams(const LLInventoryPanel::Params& params) { setSortOrder(gSavedSettings.getU32(DEFAULT_SORT_ORDER)); } - mFolderRoot->setSortOrder(getFilter()->getSortOrder()); // hide inbox getFilter()->setFilterCategoryTypes(getFilter()->getFilterCategoryTypes() & ~(1ULL << LLFolderType::FT_INBOX)); @@ -347,6 +346,10 @@ U32 LLInventoryPanel::getSortOrder() const return mFolderRoot->getSortOrder(); } +void LLInventoryPanel::requestSort() +{ + mFolderRoot->requestSort(); +} void LLInventoryPanel::setSinceLogoff(BOOL sl) { diff --git a/indra/newview/llinventorypanel.h b/indra/newview/llinventorypanel.h index 7676bbb6d7e..cfb84bf4b7c 100644 --- a/indra/newview/llinventorypanel.h +++ b/indra/newview/llinventorypanel.h @@ -208,6 +208,8 @@ class LLInventoryPanel : public LLPanel void setSortOrder(U32 order); U32 getSortOrder() const; + void requestSort(); + private: std::string mSortOrderSetting; diff --git a/indra/newview/llpanelmarketplaceinbox.cpp b/indra/newview/llpanelmarketplaceinbox.cpp index 9f17c34dfb7..8d0712a328a 100644 --- a/indra/newview/llpanelmarketplaceinbox.cpp +++ b/indra/newview/llpanelmarketplaceinbox.cpp @@ -95,8 +95,10 @@ LLInventoryPanel * LLPanelMarketplaceInbox::setupInventoryPanel() LLRect inventory_placeholder_rect = inbox_inventory_placeholder->getRect(); mInventoryPanel->setShape(inventory_placeholder_rect); - // Set the sort order newest to oldest, and a selection change callback + // Set the sort order newest to oldest mInventoryPanel->setSortOrder(LLInventoryFilter::SO_DATE); + + // Set selection callback for proper update of inventory status buttons mInventoryPanel->setSelectCallback(boost::bind(&LLPanelMarketplaceInbox::onSelectionChange, this)); // Set up the note to display when the inbox is empty @@ -113,6 +115,8 @@ void LLPanelMarketplaceInbox::onFocusReceived() LLSidepanelInventory * sidepanel_inventory = LLSideTray::getInstance()->getPanel<LLSidepanelInventory>("sidepanel_inventory"); sidepanel_inventory->clearSelections(true, false, true); + + gSavedPerAccountSettings.setString("LastInventoryInboxActivity", LLDate::now().asString()); } BOOL LLPanelMarketplaceInbox::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDragAndDropType cargo_type, void *cargo_data, EAcceptance *accept, std::string& tooltip_msg) diff --git a/indra/newview/llpanelmarketplaceinboxinventory.cpp b/indra/newview/llpanelmarketplaceinboxinventory.cpp index e5b0db92f3a..47f34434db7 100644 --- a/indra/newview/llpanelmarketplaceinboxinventory.cpp +++ b/indra/newview/llpanelmarketplaceinboxinventory.cpp @@ -37,6 +37,8 @@ #include "llviewerfoldertype.h" +#define DEBUGGING_FRESHNESS 0 + // // statics // @@ -188,49 +190,57 @@ void LLInboxFolderViewFolder::draw() LLFolderViewFolder::draw(); } -BOOL LLInboxFolderViewFolder::addToFolder(LLFolderViewFolder* folder, LLFolderView* root) -{ - BOOL retval = LLFolderViewFolder::addToFolder(folder, root); - - // Only mark top-level inbox folders as fresh - mFresh = (mParentFolder == mRoot); - - return retval; -} - -void LLInboxFolderViewFolder::updateFlag() const +void LLInboxFolderViewFolder::computeFreshness() { - const std::string& last_expansion = gSavedPerAccountSettings.getString("LastInventoryInboxExpansion"); + const std::string& last_expansion = gSavedPerAccountSettings.getString("LastInventoryInboxActivity"); if (!last_expansion.empty()) { LLDate saved_freshness_date = LLDate(last_expansion); mFresh = (mCreationDate > saved_freshness_date.secondsSinceEpoch()); + +#if DEBUGGING_FRESHNESS + if (mFresh) + { + llinfos << "Item is fresh! -- creation " << mCreationDate << ", saved_freshness_date " << saved_freshness_date.secondsSinceEpoch() << llendl; + } +#endif + } + else + { + mFresh = true; } } +void LLInboxFolderViewFolder::deFreshify() +{ + mFresh = false; + + gSavedPerAccountSettings.setString("LastInventoryInboxActivity", LLDate::now().asString()); +} + void LLInboxFolderViewFolder::selectItem() { LLFolderViewFolder::selectItem(); - mFresh = false; + deFreshify(); } void LLInboxFolderViewFolder::toggleOpen() { LLFolderViewFolder::toggleOpen(); - mFresh = false; + deFreshify(); } -void LLInboxFolderViewFolder::setCreationDate(time_t creation_date_utc) const +void LLInboxFolderViewFolder::setCreationDate(time_t creation_date_utc) { mCreationDate = creation_date_utc; - if (mFresh) + if (mParentFolder == mRoot) { - updateFlag(); + computeFreshness(); } } diff --git a/indra/newview/llpanelmarketplaceinboxinventory.h b/indra/newview/llpanelmarketplaceinboxinventory.h index 06706539a05..089facf80cf 100644 --- a/indra/newview/llpanelmarketplaceinboxinventory.h +++ b/indra/newview/llpanelmarketplaceinboxinventory.h @@ -75,18 +75,18 @@ class LLInboxFolderViewFolder : public LLFolderViewFolder, public LLBadgeOwner void draw(); - BOOL addToFolder(LLFolderViewFolder* folder, LLFolderView* root); + void computeFreshness(); + void deFreshify(); - void updateFlag() const; void selectItem(); void toggleOpen(); bool isFresh() const { return mFresh; } protected: - void setCreationDate(time_t creation_date_utc) const; + void setCreationDate(time_t creation_date_utc); - mutable bool mFresh; + bool mFresh; }; diff --git a/indra/newview/llpanelmarketplaceoutboxinventory.cpp b/indra/newview/llpanelmarketplaceoutboxinventory.cpp index 14b6ee9e0ab..ed1206aec82 100644 --- a/indra/newview/llpanelmarketplaceoutboxinventory.cpp +++ b/indra/newview/llpanelmarketplaceoutboxinventory.cpp @@ -259,11 +259,6 @@ void LLOutboxFolderViewFolder::setError(S32 errorCode) } } -void LLOutboxFolderViewFolder::setCreationDate(time_t creation_date_utc) const -{ - mCreationDate = creation_date_utc; -} - // // LLOutboxFolderViewItem Implementation // diff --git a/indra/newview/llpanelmarketplaceoutboxinventory.h b/indra/newview/llpanelmarketplaceoutboxinventory.h index ec55b7eb2ed..346680a79d9 100644 --- a/indra/newview/llpanelmarketplaceoutboxinventory.h +++ b/indra/newview/llpanelmarketplaceoutboxinventory.h @@ -77,8 +77,6 @@ class LLOutboxFolderViewFolder : public LLFolderViewFolder, public LLBadgeOwner bool hasError() const { return (mError != 0); } protected: - void setCreationDate(time_t creation_date_utc) const; - S32 mError; }; diff --git a/indra/newview/llsidepanelinventory.cpp b/indra/newview/llsidepanelinventory.cpp index 522de30467a..858639215c2 100644 --- a/indra/newview/llsidepanelinventory.cpp +++ b/indra/newview/llsidepanelinventory.cpp @@ -539,7 +539,7 @@ void LLSidepanelInventory::onToggleInboxBtn() if (inbox_expanded && inboxPanel->isInVisibleChain()) { - gSavedPerAccountSettings.setString("LastInventoryInboxExpansion", LLDate::now().asString()); + gSavedPerAccountSettings.setString("LastInventoryInboxActivity", LLDate::now().asString()); } } @@ -568,7 +568,7 @@ void LLSidepanelInventory::onOpen(const LLSD& key) #else if (mInboxEnabled && getChild<LLButton>(INBOX_BUTTON_NAME)->getToggleState()) { - gSavedPerAccountSettings.setString("LastInventoryInboxExpansion", LLDate::now().asString()); + gSavedPerAccountSettings.setString("LastInventoryInboxActivity", LLDate::now().asString()); } #endif -- GitLab