66 const std::array<bool, CATEGORY_COUNT>& aVisibleCategories )
68 std::vector<CHANGE_TREE_GROUP> out;
73 std::map<CHANGE_KIND, std::vector<CHANGE_TREE_ENTRY>> byKind;
74 std::map<std::pair<CHANGE_KIND, wxString>,
const ITEM_CHANGE*> netEntries;
76 const bool listChildren = aDiff.
docType != wxS(
"kicad_sym" );
78 auto collect = [&byKind, &netEntries, listChildren](
auto& aSelf,
const ITEM_CHANGE& aC ) ->
void
82 netEntries.try_emplace( std::make_pair( aC.kind, *aC.refdes ), &aC );
92 aSelf( aSelf, child );
97 collect( collect, c );
99 for(
const auto& [key, change] : netEntries )
101 const auto& [kind, netName] = key;
102 byKind[kind].push_back( { change, wxS(
"NET [" ) + netName + wxS(
"]" ) } );
105 const wxString lowerFilter = aSearchFilter.Lower();
107 for(
const auto& [kind, items] : byKind )
111 if( !aVisibleCategories[
static_cast<std::size_t
>( cat )] )
114 std::vector<CHANGE_TREE_ENTRY> visibleEntries;
115 visibleEntries.reserve( items.size() );
120 && !item.itemLabel.Lower().Contains( lowerFilter ) )
125 visibleEntries.push_back( item );
128 if( visibleEntries.empty() )
133 if( lowerFilter.IsEmpty() || visibleEntries.size() == items.size() )
134 groupLabel = wxString::Format( wxS(
"%s (%zu)" ),
ChangeKindLabel( kind ), visibleEntries.size() );
136 groupLabel = wxString::Format( wxS(
"%s (%zu/%zu)" ),
ChangeKindLabel( kind ), visibleEntries.size(),
139 out.push_back(
CHANGE_TREE_GROUP{ kind, std::move( groupLabel ), std::move( visibleEntries ) } );
std::vector< CHANGE_TREE_GROUP > BuildChangeTreeGroups(const DOCUMENT_DIFF &aDiff, const wxString &aSearchFilter, const std::array< bool, CATEGORY_COUNT > &aVisibleCategories)
Group the changes in a DOCUMENT_DIFF by kind, apply category and search filters, and return the resul...
One row in a grouped change tree — an ITEM_CHANGE plus its display label (typeName + optional refdes ...