| 569 | } |
| 570 | |
| 571 | void TempVariableSelection::PopulateSelection() |
| 572 | { |
| 573 | std::vector<TempVariable> vars; |
| 574 | const auto appendVars = [&vars](const Macro *macro, |
| 575 | const MacroSegment *segment) { |
| 576 | const auto newVars = macro->GetTempVars(segment); |
| 577 | vars.insert(vars.end(), newVars.begin(), newVars.end()); |
| 578 | }; |
| 579 | |
| 580 | const auto segment = GetSegment(); |
| 581 | if (!segment) { |
| 582 | return; |
| 583 | } |
| 584 | |
| 585 | auto macro = segment->GetMacro(); |
| 586 | appendVars(macro, segment); |
| 587 | |
| 588 | while ((macro = getParentMacro(macro))) { |
| 589 | appendVars(macro, |
| 590 | getMacroSegmentFromNestedMacro(macro, _macroEdits)); |
| 591 | } |
| 592 | |
| 593 | if (vars.empty()) { |
| 594 | return; |
| 595 | } |
| 596 | |
| 597 | for (const auto &var : vars) { |
| 598 | QVariant variant; |
| 599 | variant.setValue(var.GetRef()); |
| 600 | _selection->addItem(QString::fromStdString(var.Name()), |
| 601 | variant); |
| 602 | } |
| 603 | |
| 604 | // Make sure content is readable when expanding combobox |
| 605 | auto view = _selection->view(); |
| 606 | if (view) { |
| 607 | view->setMinimumWidth(view->sizeHintForColumn(0)); |
| 608 | _selection->setMinimumWidth(view->sizeHintForColumn(0)); |
| 609 | view->updateGeometry(); |
| 610 | _selection->updateGeometry(); |
| 611 | } |
| 612 | |
| 613 | adjustSize(); |
| 614 | updateGeometry(); |
| 615 | } |
| 616 | |
| 617 | static MacroEdit * |
| 618 | getMacroEditFromMacro(const std::vector<MacroEdit *> ¯oEdits, Macro *macro) |
nothing calls this directly
no test coverage detected