| 237 | |
| 238 | |
| 239 | void DebugRegistersListModel::updateRows(std::vector<DebugRegister> newRows) |
| 240 | { |
| 241 | const auto usedRegisterNames = getUsedRegisterNames(); |
| 242 | bool emptyUsedRegisters = usedRegisterNames.size() == 0; |
| 243 | |
| 244 | // TODO: This might cause performance problems. We can instead only update the chained registers. |
| 245 | // However, the cost for that is we need to attach an index to each item and sort accordingly |
| 246 | beginResetModel(); |
| 247 | std::map<std::string, uint64_t> oldRegValues; |
| 248 | for (const DebugRegisterItem& item : m_items) |
| 249 | oldRegValues[item.name()] = item.value(); |
| 250 | |
| 251 | m_items.clear(); |
| 252 | if (newRows.size() == 0) |
| 253 | { |
| 254 | endResetModel(); |
| 255 | return; |
| 256 | } |
| 257 | |
| 258 | for (const DebugRegister& reg : newRows) |
| 259 | { |
| 260 | auto iter = oldRegValues.find(reg.m_name); |
| 261 | DebugRegisterValueStatus status; |
| 262 | if (iter == oldRegValues.end()) |
| 263 | { |
| 264 | status = DebugRegisterValueNormal; |
| 265 | } |
| 266 | else |
| 267 | { |
| 268 | if (iter->second == reg.m_value) |
| 269 | { |
| 270 | status = DebugRegisterValueNormal; |
| 271 | } |
| 272 | else |
| 273 | { |
| 274 | status = DebugRegisterValueChanged; |
| 275 | } |
| 276 | } |
| 277 | |
| 278 | // If we get an empty list of used registers, we wish to show all regs |
| 279 | bool used = (emptyUsedRegisters || (usedRegisterNames.find(reg.m_name) != usedRegisterNames.end())); |
| 280 | m_items.emplace_back(reg.m_name, reg.m_value, status, reg.m_hint, used); |
| 281 | } |
| 282 | endResetModel(); |
| 283 | } |
| 284 | |
| 285 | |
| 286 | bool DebugRegistersListModel::setData(const QModelIndex& index, const QVariant& value, int role) |
no test coverage detected