@@ -631,26 +631,39 @@ bool DataManager::matchesSearch(AzulObject &object) {
631
631
}
632
632
633
633
bool DataManager::isExpandable (AzulObject &object) {
634
- for (auto &child: object.children ) {
635
- if (matchesSearch (child)) return true ;
636
- } return false ;
634
+ if (searchString.empty ()) {
635
+ if (!object.children .empty ()) return true ;
636
+ return false ;
637
+ } else {
638
+ for (auto &child: object.children ) {
639
+ if (matchesSearch (child)) return true ;
640
+ } return false ;
641
+ }
637
642
}
638
643
639
644
int DataManager::numberOfChildren (AzulObject &object) {
640
- int matchingChildren = 0 ;
641
- for (auto &child: object.children ) {
642
- if (matchesSearch (child)) ++matchingChildren;
643
- } return matchingChildren;
645
+ if (searchString.empty ()) {
646
+ return (int )object.children .size ();
647
+ } else {
648
+ int matchingChildren = 0 ;
649
+ for (auto &child: object.children ) {
650
+ if (matchesSearch (child)) ++matchingChildren;
651
+ } return matchingChildren;
652
+ }
644
653
}
645
654
646
655
std::vector<AzulObject>::iterator DataManager::child (AzulObject &object, long index) {
647
- int matchingChildren = 0 ;
648
- for (std::vector<AzulObject>::iterator child = object.children .begin ();
649
- child != object.children .end ();
650
- ++child) {
651
- if (matchesSearch (*child)) {
652
- if (matchingChildren == index) return child;
653
- ++matchingChildren;
654
- }
655
- } return object.children .begin ();
656
+ if (searchString.empty ()) {
657
+ return object.children .begin ()+index;
658
+ } else {
659
+ int matchingChildren = 0 ;
660
+ for (std::vector<AzulObject>::iterator child = object.children .begin ();
661
+ child != object.children .end ();
662
+ ++child) {
663
+ if (matchesSearch (*child)) {
664
+ if (matchingChildren == index) return child;
665
+ ++matchingChildren;
666
+ }
667
+ } return object.children .begin ();
668
+ }
656
669
}
0 commit comments