mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-04-04 05:17:36 +03:00
feat: Number of children #421
This commit is contained in:
parent
0312b504a9
commit
9fb4754430
12 changed files with 72 additions and 38 deletions
|
@ -295,19 +295,19 @@ class Group : Node, GroupVersionedInterface<Group, Entry> {
|
|||
*/
|
||||
private fun getNumberOfChildEntriesInGroups(filter: (Node) -> Boolean): Int {
|
||||
var counter = 0
|
||||
getChildGroups().forEach { childGroup ->
|
||||
getChildGroups().filter(filter).forEach { childGroup ->
|
||||
counter += childGroup.getNumberOfChildEntriesInGroups(filter)
|
||||
}
|
||||
return getChildEntries().filter(filter).size + counter
|
||||
}
|
||||
|
||||
fun getNumberOfChildEntries(
|
||||
directChildren: Boolean = true,
|
||||
recursive: Boolean = false,
|
||||
filter: (Node) -> Boolean = { true }
|
||||
): Int {
|
||||
numberOfChildEntries = getChildEntries().filter(filter).size
|
||||
recursiveNumberOfChildEntries = getNumberOfChildEntriesInGroups(filter)
|
||||
return if (directChildren) numberOfChildEntries else recursiveNumberOfChildEntries
|
||||
return if (recursive) recursiveNumberOfChildEntries else numberOfChildEntries
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue