From f0d8b55fe6f4f3d437434cb6334118af4c02ca47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Mon, 8 Sep 2008 11:25:57 +0000 Subject: [PATCH] Add method to remove all subitems of a result item, and optionally also the item itself. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27376 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/text_search/GrepListView.cpp | 28 +++++++++++++++++++++++++++ src/apps/text_search/GrepListView.h | 3 +++ 2 files changed, 31 insertions(+) diff --git a/src/apps/text_search/GrepListView.cpp b/src/apps/text_search/GrepListView.cpp index 6e139bdb89..787e4763ee 100644 --- a/src/apps/text_search/GrepListView.cpp +++ b/src/apps/text_search/GrepListView.cpp @@ -58,3 +58,31 @@ GrepListView::FindItem(const entry_ref& ref, int32* _index) const *_index = -1; return NULL; } + + +ResultItem* +GrepListView::RemoveResults(const entry_ref& ref, bool completeItem) +{ + int32 index; + ResultItem* item = FindItem(ref, &index); + if (item == NULL) + return NULL; + + // remove all the sub items + while (true) { + BListItem* subItem = FullListItemAt(index + 1); + if (subItem && subItem->OutlineLevel() > 0) + delete RemoveItem(index + 1); + else + break; + } + + if (completeItem) { + // remove file item itself + delete RemoveItem(index); + item = NULL; + } + + return item; +} + diff --git a/src/apps/text_search/GrepListView.h b/src/apps/text_search/GrepListView.h index a7f9c647fa..f0355a0dd3 100644 --- a/src/apps/text_search/GrepListView.h +++ b/src/apps/text_search/GrepListView.h @@ -41,6 +41,9 @@ public: ResultItem* FindItem(const entry_ref& ref, int32* _index) const; + + ResultItem* RemoveResults(const entry_ref& ref, + bool completeItem); }; #endif // GREP_LIST_VIEW_H