From 37e0f72711931894390cf660f521beff2fa08b10 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Thu, 6 Jun 2013 18:24:37 -0400 Subject: [PATCH] Slight tweak to filtered node expansion logic. When a filter is active, only expand parent nodes if either a) there is only one matching parent, or 2) the match actually hit a function contained in it. This allows the case where the intent of the filter is to find a particular set of files or subdirectories to be handled more efficiently. --- .../gui/team_window/ImageFunctionsView.cpp | 41 +++++++++++++++++-- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/src/apps/debugger/user_interface/gui/team_window/ImageFunctionsView.cpp b/src/apps/debugger/user_interface/gui/team_window/ImageFunctionsView.cpp index 2c39d2f35c..45d3b8b174 100644 --- a/src/apps/debugger/user_interface/gui/team_window/ImageFunctionsView.cpp +++ b/src/apps/debugger/user_interface/gui/team_window/ImageFunctionsView.cpp @@ -51,7 +51,8 @@ public: fComponentName(componentName), fSourceFile(sourceFile), fFunction(function), - fFilterMatch() + fFilterMatch(), + fHasMatchingChild(false) { if (fSourceFile != NULL) fSourceFile->AcquireReference(); @@ -148,6 +149,16 @@ public: fFilterMatch = match; } + bool HasMatchingChild() const + { + return fHasMatchingChild; + } + + void SetHasMatchingChild() + { + fHasMatchingChild = true; + } + private: friend class ImageFunctionsView::FunctionsTableModel; @@ -173,6 +184,7 @@ private: FunctionInstance* fFunction; ChildPathComponentList fChildPathComponents; RegExp::MatchResult fFilterMatch; + bool fHasMatchingChild; }; @@ -398,6 +410,16 @@ public: return true; } + bool HasMatchingChildAt(void* parent, int32 index) const + { + SourcePathComponentNode* node + = (SourcePathComponentNode*)ChildAt(parent, index); + if (node != NULL) + return node->HasMatchingChild(); + + return false; + } + bool GetFunctionPath(FunctionInstance* function, TreeTablePath& _path) { if (function == NULL) @@ -543,7 +565,12 @@ private: nodeReference.Detach(); } } + + if (functionMatch.HasMatched()) + currentNode->SetHasMatchingChild(); + parentNode = currentNode; + } return _AddFunctionNode(currentNode, function, file, @@ -806,9 +833,15 @@ ImageFunctionsView::_ExpandFilteredNodes() for (int32 i = 0; i < fFunctionsTableModel->CountChildren( fFunctionsTableModel); i++) { - TreeTablePath path; - path.AddComponent(i); - fFunctionsTable->SetNodeExpanded(path, true, true); + // only expand nodes if the match actually hit a function, + // and not just the containing path. + if (fFunctionsTableModel->CountChildren(fFunctionsTableModel) == 1 + || fFunctionsTableModel->HasMatchingChildAt(fFunctionsTableModel, + i)) { + TreeTablePath path; + path.AddComponent(i); + fFunctionsTable->SetNodeExpanded(path, true, true); + } } fFunctionsTable->ResizeAllColumnsToPreferred();