viewer#1300 'Star' favorites in inventory #4

master
Andrey Kleshchev 2024-04-29 22:07:12 +03:00
parent 2add3b4953
commit 1e7dc04644
6 changed files with 46 additions and 17 deletions

View File

@ -198,7 +198,7 @@ BOOL LLFolderViewItem::postBuild()
// getDisplayName() is expensive (due to internal getLabelSuffix() and name building)
// it also sets search strings so it requires a filter reset
mLabel = vmi->getDisplayName();
mIsFavorite = vmi->isFavorite();
mIsFavorite = vmi->isFavorite() && !vmi->isItemInTrash();
setToolTip(vmi->getName());
// Dirty the filter flag of the model from the view (CHUI-849)
@ -312,7 +312,7 @@ void LLFolderViewItem::refresh()
LLFolderViewModelItem& vmi = *getViewModelItem();
mLabel = vmi.getDisplayName();
mIsFavorite = vmi.isFavorite();
mIsFavorite = vmi.isFavorite() && !vmi.isItemInTrash();
setToolTip(vmi.getName());
// icons are slightly expensive to get, can be optimized
// see LLInventoryIcon::getIcon()
@ -345,7 +345,7 @@ void LLFolderViewItem::refreshSuffix()
mIconOpen = vmi->getIconOpen();
mIconOverlay = vmi->getIconOverlay();
mIsFavorite = vmi->isFavorite();
mIsFavorite = vmi->isFavorite() && !vmi->isItemInTrash();
if (mRoot->useLabelSuffix())
{
@ -1808,7 +1808,7 @@ void LLFolderViewFolder::onIdleUpdateFavorites(void* data)
if (self->mFavoritesDirtyFlags == 0)
{
LL_WARNS() << "Called onIdleUpdateFavorites without dirty flags set" << LL_ENDL;
gIdleCallbacks.addFunction(&LLFolderViewFolder::onIdleUpdateFavorites, self);
gIdleCallbacks.deleteFunction(&LLFolderViewFolder::onIdleUpdateFavorites, self);
return;
}
@ -1816,20 +1816,26 @@ void LLFolderViewFolder::onIdleUpdateFavorites(void* data)
{
// do not display favorite-stars in trash
self->mFavoritesDirtyFlags = 0;
gIdleCallbacks.addFunction(&LLFolderViewFolder::onIdleUpdateFavorites, self);
gIdleCallbacks.deleteFunction(&LLFolderViewFolder::onIdleUpdateFavorites, self);
return;
}
LLFolderViewFolder* root_folder = self->getRoot();
if (self->mFavoritesDirtyFlags == FAVORITE_ADDED)
{
if (!self->mHasFavorites)
{
// propagate up, exclude root
LLFolderViewFolder* parent = self;
while (parent && !parent->hasFavorites() && root_folder != parent)
while (parent
&& (!parent->hasFavorites() || parent->mFavoritesDirtyFlags)
&& !parent->getViewModelItem()->isAgentInventoryRoot())
{
parent->setHasFavorites(true);
if (parent->mFavoritesDirtyFlags)
{
gIdleCallbacks.deleteFunction(&LLFolderViewFolder::onIdleUpdateFavorites, parent);
parent->mFavoritesDirtyFlags = 0;
}
parent = parent->getParentFolder();
}
}
@ -1838,7 +1844,7 @@ void LLFolderViewFolder::onIdleUpdateFavorites(void* data)
{
// full check
LLFolderViewFolder* parent = self;
while (parent && root_folder != parent)
while (parent && !parent->getViewModelItem()->isAgentInventoryRoot())
{
bool has_favorites = false;
for (items_t::iterator iter = parent->mItems.begin();
@ -1878,19 +1884,28 @@ void LLFolderViewFolder::onIdleUpdateFavorites(void* data)
else
{
// propagate up, exclude root
while (parent && !parent->hasFavorites() && root_folder != parent)
while (parent
&& (!parent->hasFavorites() || parent->mFavoritesDirtyFlags)
&& !parent->getViewModelItem()->isAgentInventoryRoot())
{
parent->setHasFavorites(true);
if (parent->mFavoritesDirtyFlags)
{
gIdleCallbacks.deleteFunction(&LLFolderViewFolder::onIdleUpdateFavorites, parent);
parent->mFavoritesDirtyFlags = 0;
}
parent = parent->getParentFolder();
}
break;
}
if (parent->mFavoritesDirtyFlags)
{
parent->mFavoritesDirtyFlags = 0;
gIdleCallbacks.deleteFunction(&LLFolderViewFolder::onIdleUpdateFavorites, parent);
}
parent = parent->getParentFolder();
}
}
self->mFavoritesDirtyFlags = 0;
gIdleCallbacks.addFunction(&LLFolderViewFolder::onIdleUpdateFavorites, self);
}

View File

@ -185,6 +185,9 @@ public:
virtual void pasteFromClipboard() = 0;
virtual void pasteLinkFromClipboard() = 0;
virtual bool isAgentInventory() const = 0;
virtual bool isAgentInventoryRoot() const = 0;
virtual void buildContextMenu(LLMenuGL& menu, U32 flags) = 0;
virtual bool potentiallyVisible() = 0; // is the item definitely visible or we haven't made up our minds yet?

View File

@ -80,6 +80,8 @@ public:
virtual LLFontGL::StyleFlags getLabelStyle() const { return LLFontGL::NORMAL; }
virtual std::string getLabelSuffix() const { return LLStringUtil::null; }
virtual bool isFavorite() const { return false; }
virtual bool isAgentInventory() const { return false; }
virtual bool isAgentInventoryRoot() const { return false; }
virtual BOOL isItemRenameable() const { return TRUE; }
virtual BOOL renameItem(const std::string& new_name) { mName = new_name; mNeedsRefresh = true; return TRUE; }
virtual BOOL isItemMovable( void ) const { return FALSE; }

View File

@ -47,7 +47,8 @@ public:
virtual void showProperties(void) = 0;
virtual BOOL isItemInTrash( void) const { return FALSE; } // TODO: make into pure virtual.
virtual bool isItemInOutfits() const { return false; }
virtual BOOL isAgentInventory() const { return FALSE; }
virtual bool isAgentInventory() const { return false; }
virtual bool isAgentInventoryRoot() const { return false; }
virtual BOOL isUpToDate() const = 0;
virtual void addChild(LLFolderViewModelItem* child);
virtual bool hasChildren() const = 0;

View File

@ -1335,7 +1335,7 @@ BOOL LLInvFVBridge::isLinkedObjectMissing() const
return FALSE;
}
BOOL LLInvFVBridge::isAgentInventory() const
bool LLInvFVBridge::isAgentInventory() const
{
const LLInventoryModel* model = getInventoryModel();
if(!model) return FALSE;
@ -1343,6 +1343,13 @@ BOOL LLInvFVBridge::isAgentInventory() const
return model->isObjectDescendentOf(mUUID, gInventory.getRootFolderID());
}
bool LLInvFVBridge::isAgentInventoryRoot() const
{
const LLInventoryModel* model = getInventoryModel();
if(!model) return false;
return gInventory.getRootFolderID() == mUUID;
}
BOOL LLInvFVBridge::isCOFFolder() const
{
return LLAppearanceMgr::instance().getIsInCOF(mUUID);
@ -7868,7 +7875,7 @@ protected:
BOOL isItemInTrash() const;
// return true if the item is in agent inventory. if false, it
// must be lost or in the inventory library.
BOOL isAgentInventory() const;
bool isAgentInventory() const;
void wearOnAvatar();
};
@ -7879,7 +7886,7 @@ BOOL LLWearableBridgeAction::isItemInTrash() const
return mModel->isObjectDescendentOf(mUUID, trash_id);
}
BOOL LLWearableBridgeAction::isAgentInventory() const
bool LLWearableBridgeAction::isAgentInventory() const
{
if(!mModel) return FALSE;
if(gInventory.getRootFolderID() == mUUID) return TRUE;

View File

@ -172,7 +172,8 @@ protected:
BOOL isLinkedObjectInTrash() const; // Is this obj or its baseobj in the trash?
BOOL isLinkedObjectMissing() const; // Is this a linked obj whose baseobj is not in inventory?
BOOL isAgentInventory() const; // false if lost or in the inventory library
bool isAgentInventory() const; // false if lost or in the inventory library
bool isAgentInventoryRoot() const; // true if worn by agent
BOOL isCOFFolder() const; // true if COF or descendant of
BOOL isInboxFolder() const; // true if COF or descendant of marketplace inbox