| 93 | } |
| 94 | |
| 95 | QVariant SymbolTreeModel::data(const QModelIndex& index, int role) const |
| 96 | { |
| 97 | if (!index.isValid()) |
| 98 | return QVariant(); |
| 99 | |
| 100 | SymbolTreeNode* node = nodeFromIndex(index); |
| 101 | if (!node) |
| 102 | return QVariant(); |
| 103 | |
| 104 | if (role == Qt::ForegroundRole) |
| 105 | { |
| 106 | bool active = true; |
| 107 | |
| 108 | // Gray out the names of symbols that have been overwritten in memory. |
| 109 | if (index.column() == NAME) |
| 110 | active = node->matchesMemory(); |
| 111 | |
| 112 | // Gray out the values of variables that are dead. |
| 113 | if (index.column() == VALUE && node->liveness().has_value()) |
| 114 | active = *node->liveness(); |
| 115 | |
| 116 | QPalette::ColorGroup group = active ? QPalette::Active : QPalette::Disabled; |
| 117 | return QBrush(QApplication::palette().color(group, QPalette::Text)); |
| 118 | } |
| 119 | |
| 120 | if (role != Qt::DisplayRole) |
| 121 | return QVariant(); |
| 122 | |
| 123 | switch (index.column()) |
| 124 | { |
| 125 | case NAME: |
| 126 | { |
| 127 | return node->name; |
| 128 | } |
| 129 | case VALUE: |
| 130 | { |
| 131 | if (node->tag != SymbolTreeNode::OBJECT) |
| 132 | return QVariant(); |
| 133 | |
| 134 | return node->display_value(); |
| 135 | } |
| 136 | case LOCATION: |
| 137 | { |
| 138 | return node->location.toString(m_cpu).rightJustified(8); |
| 139 | } |
| 140 | case SIZE: |
| 141 | { |
| 142 | if (!node->size.has_value()) |
| 143 | return QVariant(); |
| 144 | |
| 145 | return QString::number(*node->size); |
| 146 | } |
| 147 | case TYPE: |
| 148 | { |
| 149 | QVariant result; |
| 150 | m_cpu.GetSymbolGuardian().Read([&](const ccc::SymbolDatabase& database) -> void { |
| 151 | const ccc::ast::Node* type = node->type.lookup_node(database); |
| 152 | if (!type) |
no test coverage detected