示例#1
0
void NodeUpdateProxy::removeNode(
        const Device::NodePath& parentPath,
        const Device::AddressSettings& settings)
{
    Device::Node* parentnode = parentPath.toNode(&devModel.rootNode());
    if(!parentnode)
        return;

    auto addr = Device::address(*parentnode);
    addr.path.append(settings.name);

    // Remove from the device implementation
    const auto& dev_node = devModel.rootNode().childAt(parentPath.at(0));
    devModel.list().device(
                dev_node.template get<Device::DeviceSettings>().name)
            .removeNode(addr);

    // Remove from the device explorer
    auto it = std::find_if(
                  parentnode->begin(), parentnode->end(),
                  [&] (const Device::Node& n) { return n.get<Device::AddressSettings>().name == settings.name; });
    ISCORE_ASSERT(it != parentnode->end());

    if(deviceExplorer)
    {
        deviceExplorer->removeNode(it);
    }
    else
    {
        parentnode->erase(it);
    }
}