454 | | BList expandedItems; |
455 | | BString* signature = NULL; |
456 | | if (fVertical && Expando() |
457 | | && static_cast<TBarApp*>(be_app)->Settings()->superExpando) { |
458 | | // Get a list of the signatures of expanded apps. Can't use |
459 | | // team_id because there can be more than one team per application |
460 | | if (fVertical && Expando() && vertical && fExpando) { |
461 | | for (int index = 0; index < fExpando->CountItems(); index++) { |
462 | | TTeamMenuItem* item |
463 | | = dynamic_cast<TTeamMenuItem*>(fExpando->ItemAt(index)); |
464 | | if (item != NULL && item->IsExpanded()) { |
465 | | signature = new BString(item->Signature()); |
466 | | expandedItems.AddItem((void*)signature); |
467 | | } |
468 | | } |
469 | | } |
470 | | } |
| 464 | SaveExpandedItems(); |
478 | | if (expandedItems.CountItems() > 0) { |
479 | | for (int sigIndex = expandedItems.CountItems(); sigIndex-- > 0;) { |
480 | | signature = static_cast<BString*>(expandedItems.ItemAt(sigIndex)); |
481 | | if (signature == NULL) |
482 | | continue; |
483 | | |
484 | | // Start at the 'bottom' of the list working up. |
485 | | // Prevents being thrown off by expanding items. |
486 | | for (int teamIndex = fExpando->CountItems(); teamIndex-- > 0;) { |
487 | | TTeamMenuItem* item |
488 | | = dynamic_cast<TTeamMenuItem*>(fExpando->ItemAt(teamIndex)); |
489 | | if (item != NULL && !signature->Compare(item->Signature())) { |
490 | | item->ToggleExpandState(false); |
| 472 | ExpandItems(); |
| 473 | Invalidate(); |
| 474 | } |
| 475 | |
| 476 | |
| 477 | void |
| 478 | TBarView::SaveExpandedItems() |
| 479 | { |
| 480 | if (!fExpando) |
| 481 | return; |
| 482 | |
| 483 | // Get a list of the signatures of expanded apps. Can't use |
| 484 | // team_id because there can be more than one team per application |
| 485 | for (int32 teamIndex = fExpando->CountItems(); teamIndex-- > 0;) { |
| 486 | TTeamMenuItem* teamItem |
| 487 | = dynamic_cast<TTeamMenuItem*>(fExpando->ItemAt(teamIndex)); |
| 488 | if (teamItem == NULL || teamItem->Signature() == NULL || |
| 489 | *teamItem->Signature() == '\0') |
| 490 | continue; |
| 491 | |
| 492 | if (teamItem->IsExpanded()) { |
| 493 | // Expanded, if signature is not in the list add it |
| 494 | bool shouldAdd = true; |
| 495 | for (int32 sigIndex = sExpandedItems.CountItems(); |
| 496 | sigIndex-- > 0;) { |
| 497 | BString *signature = (BString *)sExpandedItems.ItemAt(sigIndex); |
| 498 | if (signature->ICompare(teamItem->Signature()) == 0) { |
| 499 | // already in the list, don't add the signature |
| 500 | shouldAdd = false; |
501 | | fExpando->SizeWindow(); |
| 514 | void |
| 515 | TBarView::ExpandItems() |
| 516 | { |
| 517 | if (!fExpando || !fVertical || !Expando() |
| 518 | || !static_cast<TBarApp*>(be_app)->Settings()->superExpando |
| 519 | || sExpandedItems.CountItems() <= 0) |
| 520 | return; |
| 521 | |
| 522 | // Start at the 'bottom' of the list working up. |
| 523 | // Prevents being thrown off by expanding items. |
| 524 | for (int32 teamIndex = fExpando->CountItems(); teamIndex-- > 0;) { |
| 525 | TTeamMenuItem* teamItem |
| 526 | = dynamic_cast<TTeamMenuItem*>(fExpando->ItemAt(teamIndex)); |
| 527 | if (teamItem == NULL || teamItem->Signature() == NULL |
| 528 | || *teamItem->Signature() == '\0') |
| 529 | continue; |
| 530 | |
| 531 | for (int32 sigIndex = sExpandedItems.CountItems(); sigIndex-- > 0;) { |
| 532 | BString* signature = (BString *)sExpandedItems.ItemAt(sigIndex); |
| 533 | |
| 534 | if (signature->ICompare(teamItem->Signature()) == 0) { |
| 535 | teamItem->ToggleExpandState(false); |
| 536 | sExpandedItems.RemoveItem(sigIndex); |
| 537 | break; |
| 538 | } |
| 539 | } |