示例#1
0
bool DeviceExplorerModel::checkAddressEditable(
        Device::Node& parent,
        const Device::AddressSettings& before,
        const Device::AddressSettings& after)
{
    ISCORE_ASSERT(!parent.is<InvisibleRootNodeTag>());

    if(after.name.isEmpty())
        return false;

    auto it = std::find_if(
                parent.begin(),
                parent.end(),
                [&] (const Device::Node& n) { return n.get<Device::AddressSettings>().name == after.name; });
    if(it != parent.end())
    {
        //  We didn't change name, it's ok
        if(after.name == before.name)
            return true;
        else
            return false;
    }
    else
    {
        // Ok, no conflicts
        return true;
    }
}
示例#2
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);
    }
}
示例#3
0
bool DeviceExplorerModel::checkAddressInstantiatable(
        Device::Node& parent,
        const Device::AddressSettings& addr)
{
    ISCORE_ASSERT(!parent.is<InvisibleRootNodeTag>());

    if(addr.name.isEmpty())
        return false;

    return std::none_of(parent.begin(),
                        parent.end(),
                        [&] (const Device::Node& n) {
        return n.get<Device::AddressSettings>().name == addr.name;
    });
}
示例#4
0
void NodeUpdateProxy::addLocalAddress(
        Device::Node& parentnode,
        const Device::AddressSettings& settings,
        int row)
{
    if(deviceExplorer)
    {
        deviceExplorer->addAddress(
                    &parentnode,
                    settings,
                    row);
    }
    else
    {
        parentnode.emplace(parentnode.begin() + row, settings, &parentnode);
    }
}
示例#5
0
void NodeUpdateProxy::addLocalNode(
        Device::Node& parent,
        Device::Node&& node)
{
    ISCORE_ASSERT(node.template is<Device::AddressSettings>());

    int row = parent.childCount();
    if(deviceExplorer)
    {
        deviceExplorer->addNode(
                    &parent,
                    std::move(node),
                    row);
    }
    else
    {
        parent.emplace(parent.begin() + row,
                       std::move(node));
    }
}