MCPcopy Create free account
hub / github.com/PlotJuggler/PlotJuggler / xmlLoadState

Method xmlLoadState

pj_plotting/widget/src/PlotDocker.cpp:545–612  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

543}
544
545bool PlotDocker::xmlLoadState(const QDomElement& tab_element) {
546 if (tab_element.isNull() || tab_element.tagName() != QStringLiteral("Tab")) {
547 return false;
548 }
549
550 setStateId(tab_element.attribute(QStringLiteral("id")));
551 if (tab_element.hasAttribute(QStringLiteral("tab_name"))) {
552 setName(tab_element.attribute(QStringLiteral("tab_name")));
553 }
554
555 QVector<LayoutNode> container_nodes;
556 for (QDomElement container = tab_element.firstChildElement(QStringLiteral("Container")); !container.isNull();
557 container = container.nextSiblingElement(QStringLiteral("Container"))) {
558 QDomElement child = container.firstChildElement(QStringLiteral("DockSplitter"));
559 if (child.isNull()) {
560 child = container.firstChildElement(QStringLiteral("DockArea"));
561 }
562 LayoutNode node = parseLayoutNode(child);
563 if (node.valid) {
564 container_nodes.push_back(std::move(node));
565 }
566 }
567
568 if (container_nodes.isEmpty()) {
569 return false;
570 }
571
572 const bool was_hidden = isHidden();
573 if (!was_hidden) {
574 hide();
575 }
576
577 restoring_state_ = true;
578 QVector<DockWidget*> old_docks;
579 for (int index = 0; index < plotCount(); ++index) {
580 if (DockWidget* dock = plotAt(index)) {
581 old_docks.push_back(dock);
582 }
583 }
584
585 RestorePlotPool pool(old_docks, session_, catalog_, this);
586 for (DockWidget* dock : old_docks) {
587 removeDockWidget(dock);
588 dock->deleteLater();
589 }
590
591 const LayoutNode& root_node = container_nodes.front();
592 // Decide top-level dock kind by peeking the first leaf's content tag. An
593 // object-widget root (<scene3d>, <scene2d>, …) needs a plot-less placeholder
594 // DockWidget, into which restoreNode installs the dock via the factory.
595 const bool root_is_object = isObjectWidgetElement(firstLeafElement(root_node));
596 DockWidget* root_widget = nullptr;
597 if (root_is_object) {
598 root_widget = addDockWithPlot(nullptr, ads::TopDockWidgetArea);
599 } else {
600 PlotWidget* root_plot = pool.takeFirstForNode(root_node);
601 root_widget = addDockWithPlot(root_plot, ads::TopDockWidgetArea);
602 }

Callers 1

restoreNodeFunction · 0.45

Calls 9

setNameFunction · 0.85
parseLayoutNodeFunction · 0.85
isObjectWidgetElementFunction · 0.85
firstLeafElementFunction · 0.85
restoreNodeFunction · 0.85
takeFirstForNodeMethod · 0.80
deleteUnusedMethod · 0.80
isNullMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected