示例#1
0
void
DeviceExplorerModel::debug_printIndexes(const QModelIndexList& indexes)
{
    std::cerr << "indexes: " << indexes.size() << " nodes: \n";
    foreach(const QModelIndex & index, indexes)
    {
        if(index.isValid())
        {
            std::cerr << " index.row=" << index.row() << " col=" << index.column() << " ";
            Device::Node* n = &nodeFromModelIndex(index);
            std::cerr << " n=" << n << " ";
            Device::Node* parent = n->parent();

            if(n == &m_rootNode)
            {
                std::cerr << " rootNode parent=" << parent << "\n";
            }
            else
            {
                std::cerr << " n->name=" << n->displayName().toStdString();
                std::cerr << " parent=" << parent;
                std::cerr << " parent->name=" << parent->displayName().toStdString() << "\n";
            }

        }
        else
        {
            std::cerr << " invalid index \n";
        }
    }
}
示例#2
0
/**
 * @brief DeviceExplorerModel::editData
 *
 * This functions gets called by the command
 * that edit the columns.
 */
void DeviceExplorerModel::editData(
        const Device::NodePath &path,
        Explorer::Column column,
        const State::Value &value,
        int role)
{
    Device::Node* node = path.toNode(&rootNode());
    ISCORE_ASSERT(node->parent());

    QModelIndex index = createIndex(node->parent()->indexOfChild(node), (int)column, node->parent());

    QModelIndex changedTopLeft = index;
    QModelIndex changedBottomRight = index;

    if(node->is<Device::DeviceSettings>())
        return;

    if(role == Qt::EditRole)
    {
        ISCORE_TODO;
        /*
        if(index.column() == (int)Column::Name)
        {
            const QString s = value.toString();

            if(! s.isEmpty())
            {
                node->get<Device::AddressSettings>().name = s;
            }
        }
        else */if(index.column() == (int)Column::Value)
        {
            node->get<Device::AddressSettings>().value = value;
        }
        // TODO min/max/tags editing
    }

    emit dataChanged(changedTopLeft, changedBottomRight);
}
示例#3
0
void DeviceInterface::addNode(const Device::Node& n)
{
    auto full = Device::FullAddressSettings::make<Device::FullAddressSettings::as_parent>(
                    n.get<Device::AddressSettings>(),
                    Device::address(*n.parent()));

    // Add in the device implementation
    addAddress(full);

    for(const auto& child : n)
    {
        addNode(child);
    }
}