| 54 | } |
| 55 | |
| 56 | virtual void initModel(QtNodes::Node& node, int nodeCnt, bool darkMode) override |
| 57 | { |
| 58 | if (!restored()) { |
| 59 | setCaption(node.nodeDataModel()->caption() + " #" + QString::number(nodeCnt)); |
| 60 | } |
| 61 | |
| 62 | // For some reason QWidget title is being set to name instead of caption. |
| 63 | // TODO: investigate why |
| 64 | setCaption(node.nodeDataModel()->caption()); |
| 65 | setColorMode(darkMode); |
| 66 | |
| 67 | connect((Derived*)this, &Derived::requestRedraw, [&node] { node.nodeGraphicsObject().update(); }); |
| 68 | connect(this, &ComponentModelInterface::startSimulation, &_component, &C::startSimulation); |
| 69 | connect(this, &ComponentModelInterface::stopSimulation, &_component, &C::stopSimulation); |
| 70 | connect(&_component, &C::mainWidgetDockToggled, this, &ComponentModelInterface::handleDock); |
| 71 | connect(&_component, &C::simBcastSnd, this, &ComponentModelInterface::simBcastSndSlot); |
| 72 | |
| 73 | _id = node.id(); |
| 74 | |
| 75 | if (hasSeparateThread()) { |
| 76 | _thread = std::make_unique<QThread>(); |
| 77 | if (_thread) { |
| 78 | cds_info("Setting separate event loop for component {}", _caption.toStdString()); |
| 79 | |
| 80 | this->moveToThread(_thread.get()); |
| 81 | _component.moveToThread(_thread.get()); |
| 82 | |
| 83 | _thread->start(); |
| 84 | } |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | /** |
| 89 | * @brief Used to get node caption |
no test coverage detected