* @brief Appends the Connection Settings header and one row per live driver property. */
| 2966 | * @brief Appends the Connection Settings header and one row per live driver property. |
| 2967 | */ |
| 2968 | void DataModel::ProjectEditor::appendDriverPropertyRows(const DataModel::Source& source) |
| 2969 | { |
| 2970 | auto* driverHdr = new QStandardItem(); |
| 2971 | driverHdr->setData(SectionHeader, WidgetType); |
| 2972 | driverHdr->setData(tr("Connection Settings"), PlaceholderValue); |
| 2973 | driverHdr->setData(busTypeIcon(source.busType), ParameterIcon); |
| 2974 | m_sourceModel->appendRow(driverHdr); |
| 2975 | |
| 2976 | IO::HAL_Driver* driver = IO::ConnectionManager::instance().driverForEditing(source.sourceId); |
| 2977 | if (!driver) |
| 2978 | return; |
| 2979 | |
| 2980 | const auto widgetForProperty = [](IO::DriverProperty::Type t) -> EditorWidget { |
| 2981 | switch (t) { |
| 2982 | case IO::DriverProperty::Text: |
| 2983 | return TextField; |
| 2984 | case IO::DriverProperty::HexText: |
| 2985 | return HexTextField; |
| 2986 | case IO::DriverProperty::IntField: |
| 2987 | return IntField; |
| 2988 | case IO::DriverProperty::FloatField: |
| 2989 | return FloatField; |
| 2990 | case IO::DriverProperty::CheckBox: |
| 2991 | return CheckBox; |
| 2992 | case IO::DriverProperty::ComboBox: |
| 2993 | return ComboBox; |
| 2994 | case IO::DriverProperty::Password: |
| 2995 | return PasswordField; |
| 2996 | } |
| 2997 | return TextField; |
| 2998 | }; |
| 2999 | |
| 3000 | const auto props = driver->driverProperties(); |
| 3001 | for (const auto& prop : props) { |
| 3002 | auto* item = new QStandardItem(); |
| 3003 | item->setEditable(true); |
| 3004 | item->setData(true, Active); |
| 3005 | item->setData(prop.key, ParameterKey); |
| 3006 | item->setData(kSourceView_Property, ParameterType); |
| 3007 | item->setData(prop.label, ParameterName); |
| 3008 | |
| 3009 | if (!prop.description.isEmpty()) |
| 3010 | item->setData(prop.description, ParameterDescription); |
| 3011 | |
| 3012 | item->setData(widgetForProperty(prop.type), WidgetType); |
| 3013 | if (prop.type == IO::DriverProperty::ComboBox) |
| 3014 | item->setData(prop.options, ComboBoxData); |
| 3015 | |
| 3016 | item->setData(prop.value, EditableValue); |
| 3017 | m_sourceModel->appendRow(item); |
| 3018 | } |
| 3019 | } |
| 3020 | |
| 3021 | /** |
| 3022 | * @brief Applies a source-title edit and syncs the tree-item cache. |
nothing calls this directly
no test coverage detected