Forgot changes to the guiTreeViewCtrl to enable advanced filtering behavior.

This commit is contained in:
Areloch 2019-05-18 02:37:28 -05:00
parent af14de2bb7
commit 8c05e33e7e
2 changed files with 51 additions and 6 deletions

View file

@ -832,6 +832,8 @@ GuiTreeViewCtrl::GuiTreeViewCtrl()
mTexSelected = NULL; mTexSelected = NULL;
mRenderTooltipDelegate.bind( this, &GuiTreeViewCtrl::renderTooltip ); mRenderTooltipDelegate.bind( this, &GuiTreeViewCtrl::renderTooltip );
mDoFilterChildren = true;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -1122,7 +1124,7 @@ void GuiTreeViewCtrl::_expandObjectHierarchy( SimGroup* group )
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void GuiTreeViewCtrl::_buildItem( Item* item, U32 tabLevel, bool bForceFullUpdate ) void GuiTreeViewCtrl::_buildItem( Item* item, U32 tabLevel, bool bForceFullUpdate, bool skipFlter )
{ {
if (!item || !mActive || !isVisible() || !mProfile ) if (!item || !mActive || !isVisible() || !mProfile )
return; return;
@ -1145,7 +1147,7 @@ void GuiTreeViewCtrl::_buildItem( Item* item, U32 tabLevel, bool bForceFullUpdat
// If we have a filter pattern, sync the item's filtering status to it. // If we have a filter pattern, sync the item's filtering status to it.
if( !getFilterText().isEmpty() ) if( !getFilterText().isEmpty() && !skipFlter)
{ {
// Determine the filtering status by looking for the filter // Determine the filtering status by looking for the filter
// text in the item's display text. // text in the item's display text.
@ -1154,7 +1156,11 @@ void GuiTreeViewCtrl::_buildItem( Item* item, U32 tabLevel, bool bForceFullUpdat
item->getDisplayText( sizeof( displayText ), displayText ); item->getDisplayText( sizeof( displayText ), displayText );
if( !dStristr( displayText, mFilterText ) ) if( !dStristr( displayText, mFilterText ) )
{ {
item->mState.set( Item::Filtered ); //Last check, see if we special-exception this item
if (!mItemFilterExceptionList.contains(item->mId))
item->mState.set(Item::Filtered);
else
item->mState.clear(Item::Filtered);
// If it's not a parent, we're done. Otherwise, there may be children // If it's not a parent, we're done. Otherwise, there may be children
// that are not filtered so we need to process them first. // that are not filtered so we need to process them first.
@ -1163,7 +1169,9 @@ void GuiTreeViewCtrl::_buildItem( Item* item, U32 tabLevel, bool bForceFullUpdat
return; return;
} }
else else
item->mState.clear( Item::Filtered ); {
item->mState.clear(Item::Filtered);
}
} }
else else
item->mState.clear( Item::Filtered ); item->mState.clear( Item::Filtered );
@ -1217,7 +1225,10 @@ void GuiTreeViewCtrl::_buildItem( Item* item, U32 tabLevel, bool bForceFullUpdat
Item *pChildTemp = child; Item *pChildTemp = child;
child = child->mNext; child = child->mNext;
_buildItem( pChildTemp, tabLevel + 1, bForceFullUpdate ); if (!mItemFilterExceptionList.contains(item->mId) && !mDoFilterChildren && !item->isFiltered())
_buildItem( pChildTemp, tabLevel + 1, bForceFullUpdate, true );
else
_buildItem(pChildTemp, tabLevel + 1, bForceFullUpdate, false);
} }
} }
} }
@ -4775,6 +4786,18 @@ void GuiTreeViewCtrl::setFilterText( const String& text )
mFlags.set( RebuildVisible ); mFlags.set( RebuildVisible );
} }
void GuiTreeViewCtrl::setItemFilterException(U32 item, bool isExempted)
{
if (isExempted)
{
mItemFilterExceptionList.push_back(item);
}
else
{
mItemFilterExceptionList.remove(item);
}
}
//============================================================================= //=============================================================================
// Console Methods. // Console Methods.
//============================================================================= //=============================================================================
@ -5574,6 +5597,20 @@ DefineEngineMethod( GuiTreeViewCtrl, setFilterText, void, ( const char* pattern
object->setFilterText( pattern ); object->setFilterText( pattern );
} }
DefineEngineMethod(GuiTreeViewCtrl, setFilterChildren, void, (bool doFilterChildren), (true),
"Sets if the filter will also apply to any children of items that manage to pass being filtered.\n\n"
"@param doFilterChildren If true, items that pass the filter do not have their children filtered. If false, all items are filtered.\n\n")
{
object->setFilterChildren(doFilterChildren);
}
DefineEngineMethod(GuiTreeViewCtrl, setItemFilterException, void, (U32 item, bool isExempt), (0, true),
"Set a given item to be excluded from being filtered.\n\n"
"@param item Item ID of the item that is to be exempt from the filter.\n\n"
"@param isExempt If the item is exempt from the filter.\n\n")
{
object->setItemFilterException(item, isExempt);
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
DefineEngineMethod( GuiTreeViewCtrl, clearFilterText, void, (),, DefineEngineMethod( GuiTreeViewCtrl, clearFilterText, void, (),,

View file

@ -356,6 +356,11 @@ class GuiTreeViewCtrl : public GuiArrayCtrl
/// Current filter that determines which items in the tree are displayed and which are hidden. /// Current filter that determines which items in the tree are displayed and which are hidden.
String mFilterText; String mFilterText;
/// If true, all items are filtered. If false, then children of items that successfully pass filter are not filtered
bool mDoFilterChildren;
Vector<U32> mItemFilterExceptionList;
/// If true, a trace of actions taken by the control is logged to the console. Can /// If true, a trace of actions taken by the control is logged to the console. Can
/// be turned on with the setDebug() script method. /// be turned on with the setDebug() script method.
bool mDebug; bool mDebug;
@ -431,7 +436,7 @@ class GuiTreeViewCtrl : public GuiArrayCtrl
void _deleteItem(Item* item); void _deleteItem(Item* item);
void _buildItem(Item* item, U32 tabLevel, bool bForceFullUpdate = false); void _buildItem(Item* item, U32 tabLevel, bool bForceFullUpdate = false, bool skipFlter = false);
Item* _findItemByAmbiguousId( S32 itemOrObjectId, bool buildVirtual = true ); Item* _findItemByAmbiguousId( S32 itemOrObjectId, bool buildVirtual = true );
@ -569,6 +574,9 @@ class GuiTreeViewCtrl : public GuiArrayCtrl
/// matches this pattern are displayed. /// matches this pattern are displayed.
void setFilterText( const String& text ); void setFilterText( const String& text );
void setFilterChildren(bool doFilter) { mDoFilterChildren = doFilter; }
void setItemFilterException(U32 item, bool isExempt);
/// Clear the current item filtering pattern. /// Clear the current item filtering pattern.
void clearFilterText() { setFilterText( String::EmptyString ); } void clearFilterText() { setFilterText( String::EmptyString ); }