| 21 | } |
| 22 | |
| 23 | QWidget* SymbolTreeValueDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const |
| 24 | { |
| 25 | if (!index.isValid()) |
| 26 | return nullptr; |
| 27 | |
| 28 | const SymbolTreeModel* tree_model = qobject_cast<const SymbolTreeModel*>(index.model()); |
| 29 | if (!tree_model) |
| 30 | return nullptr; |
| 31 | |
| 32 | const SymbolTreeDisplayOptions& display_options = tree_model->displayOptions(); |
| 33 | |
| 34 | SymbolTreeNode* node = tree_model->nodeFromIndex(index); |
| 35 | if (!node || !node->type.valid()) |
| 36 | return nullptr; |
| 37 | |
| 38 | QWidget* result = nullptr; |
| 39 | m_cpu.GetSymbolGuardian().Read([&](const ccc::SymbolDatabase& database) { |
| 40 | const ccc::ast::Node* logical_type = node->type.lookup_node(database); |
| 41 | if (!logical_type) |
| 42 | return; |
| 43 | |
| 44 | const ccc::ast::Node& physical_type = *logical_type->physical_type(database).first; |
| 45 | QVariant value = node->readValueAsVariant(physical_type, m_cpu, database); |
| 46 | |
| 47 | const ccc::ast::Node& type = *logical_type->physical_type(database).first; |
| 48 | switch (type.descriptor) |
| 49 | { |
| 50 | case ccc::ast::BUILTIN: |
| 51 | { |
| 52 | const ccc::ast::BuiltIn& builtin = type.as<ccc::ast::BuiltIn>(); |
| 53 | |
| 54 | switch (builtin.bclass) |
| 55 | { |
| 56 | case ccc::ast::BuiltInClass::UNSIGNED_8: |
| 57 | case ccc::ast::BuiltInClass::UNQUALIFIED_8: |
| 58 | case ccc::ast::BuiltInClass::UNSIGNED_16: |
| 59 | case ccc::ast::BuiltInClass::UNSIGNED_32: |
| 60 | case ccc::ast::BuiltInClass::UNSIGNED_64: |
| 61 | { |
| 62 | SymbolTreeIntegerLineEdit* editor = new SymbolTreeIntegerLineEdit( |
| 63 | display_options, ccc::ast::builtin_class_size(builtin.bclass) * 8, parent); |
| 64 | editor->setUnsignedValue(value.toULongLong()); |
| 65 | result = editor; |
| 66 | |
| 67 | break; |
| 68 | } |
| 69 | case ccc::ast::BuiltInClass::SIGNED_8: |
| 70 | case ccc::ast::BuiltInClass::SIGNED_16: |
| 71 | case ccc::ast::BuiltInClass::SIGNED_32: |
| 72 | case ccc::ast::BuiltInClass::SIGNED_64: |
| 73 | { |
| 74 | SymbolTreeIntegerLineEdit* editor = new SymbolTreeIntegerLineEdit( |
| 75 | display_options, ccc::ast::builtin_class_size(builtin.bclass) * 8, parent); |
| 76 | editor->setSignedValue(value.toLongLong()); |
| 77 | result = editor; |
| 78 | |
| 79 | break; |
| 80 | } |
nothing calls this directly
no test coverage detected