relatica/lib/models/entry_tree_item.dart

39 lines
824 B
Dart
Raw Normal View History

2022-11-17 16:04:14 +00:00
import 'timeline_entry.dart';
class EntryTreeItem {
final TimelineEntry entry;
final bool isMine;
bool isOrphaned;
final _children = <String, EntryTreeItem>{};
EntryTreeItem(this.entry, {this.isMine = true, this.isOrphaned = false});
String get id => entry.id;
void addChild(EntryTreeItem child) {
_children[child.id] = child;
}
int get totalChildren {
int t = _children.length;
for (final c in _children.values) {
t += c.totalChildren;
}
return t;
}
List<EntryTreeItem> get children => List.unmodifiable(_children.values);
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is EntryTreeItem &&
runtimeType == other.runtimeType &&
entry == other.entry;
@override
int get hashCode => entry.hashCode;
}