MCPcopy Create free account
hub / github.com/MITK/MITK / ListWindowDescriptors

Method ListWindowDescriptors

Modules/QtWidgets/src/QmitkMxNMultiWidget.cpp:884–923  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

882}
883
884std::vector<QmitkMxNMultiWidget::WindowDescriptor>
885QmitkMxNMultiWidget::ListWindowDescriptors() const
886{
887 // Validate layout shape: same precondition as SerializeLayout.
888 auto* topLayout = this->layout();
889 if (nullptr == topLayout || topLayout->count() == 0)
890 {
891 mitkThrow() << "ListWindowDescriptors: editor has no top-level layout.";
892 }
893 auto* item = topLayout->itemAt(0);
894 auto* widget = (item == nullptr) ? nullptr : item->widget();
895 auto* rootSplitter = dynamic_cast<QSplitter*>(widget);
896 if (nullptr == rootSplitter)
897 {
898 mitkThrow() << "ListWindowDescriptors: top-level widget is not a QSplitter.";
899 }
900
901 std::vector<WindowDescriptor> result;
902 std::function<void(const QSplitter*)> walk = [&](const QSplitter* split)
903 {
904 for (int i = 0; i < split->count(); ++i)
905 {
906 auto* child = split->widget(i);
907 if (auto* sub = dynamic_cast<QSplitter*>(child))
908 {
909 walk(sub);
910 }
911 else if (auto* cell = dynamic_cast<QmitkRenderWindowWidget*>(child))
912 {
913 result.push_back(this->MakeWindowDescriptor(cell));
914 }
915 else
916 {
917 mitkThrow() << "ListWindowDescriptors: unknown child widget type at splitter index " << i << ".";
918 }
919 }
920 };
921 walk(rootSplitter);
922 return result;
923}
924
925QSplitter* QmitkMxNMultiWidget::BuildSplitterFromJsonV2(
926 const nlohmann::json& splitNode,

Calls 2

MakeWindowDescriptorMethod · 0.95
countMethod · 0.80