| 693 | } |
| 694 | |
| 695 | void OutputWidget::setSectionVisibility(const QString& section, bool visible) |
| 696 | { |
| 697 | if (_sections[section] == visible) { |
| 698 | return; |
| 699 | } |
| 700 | TextLayoutLock lock(this, false); |
| 701 | auto cursor = ui->textBrowser->textCursor(); |
| 702 | cursor.movePosition(QTextCursor::Start); |
| 703 | auto* rootFrame = cursor.currentFrame(); |
| 704 | auto rootFrameFormat = rootFrame->frameFormat(); |
| 705 | while (!cursor.atEnd()) { |
| 706 | auto frameVisible = isFrameVisible(cursor.currentFrame()); |
| 707 | if (!frameVisible) { |
| 708 | cursor = cursor.currentFrame()->lastCursorPosition(); |
| 709 | cursor.movePosition(QTextCursor::NextBlock); |
| 710 | continue; |
| 711 | } |
| 712 | auto block = cursor.block(); |
| 713 | auto blockFormat = block.blockFormat(); |
| 714 | if (blockFormat.hasProperty(Property::Section) |
| 715 | && blockFormat.property(Property::Section).toString() == section) { |
| 716 | block.setVisible(visible); |
| 717 | } |
| 718 | cursor.movePosition(QTextCursor::NextBlock); |
| 719 | } |
| 720 | _sections[section] = visible; |
| 721 | rootFrame->setFrameFormat(rootFrameFormat); // Force relayout |
| 722 | |
| 723 | emit sectionToggled(section, visible); |
| 724 | |
| 725 | for (auto v : _sections) { |
| 726 | if (!v) { |
| 727 | ui->toggleAll_pushButton->setText("Show all"); |
| 728 | return; |
| 729 | } |
| 730 | } |
| 731 | ui->toggleAll_pushButton->setText("Hide all"); |
| 732 | } |
| 733 | |
| 734 | void OutputWidget::setAllSectionsVisibility(bool visible) |
| 735 | { |
nothing calls this directly
no test coverage detected