| 2430 | } |
| 2431 | |
| 2432 | void MainWindow::opModified(QTableWidgetItem *item) { |
| 2433 | if (item == Q_NULLPTR) { |
| 2434 | return; |
| 2435 | } |
| 2436 | |
| 2437 | int col = item->column(); |
| 2438 | int row = item->row(); |
| 2439 | |
| 2440 | QString txt = item->text(); |
| 2441 | QString data; |
| 2442 | QByteArray array; |
| 2443 | uint32_t addr = static_cast<uint32_t>(hex2int(ui->opView->item(row, OP_ADDR_COL)->text())); |
| 2444 | array.resize(11); |
| 2445 | |
| 2446 | sender()->blockSignals(true); |
| 2447 | |
| 2448 | if (col == OP_DATA_COL) { |
| 2449 | array.fill(0); |
| 2450 | for (int i = 0; i < 11 && i < txt.length() / 2; i++) { |
| 2451 | array[i] = hex2int(txt.mid(i * 2, 2)); |
| 2452 | } |
| 2453 | } else if (col == OP_STRING_COL) { |
| 2454 | array.fill('.'); |
| 2455 | for (int i = 0; i < 11 && i < txt.length(); i++) { |
| 2456 | array[i] = txt[i].toLatin1(); |
| 2457 | } |
| 2458 | } else if (col == OP_VALUE_COL) { |
| 2459 | array.fill(0); |
| 2460 | try { |
| 2461 | data_t value = tivars::TypeHandlers::TH_GenericReal::makeDataFromString(txt.toStdString()); |
| 2462 | for (int i = 0; i < 11 && i < static_cast<int>(value.size()); i++) { |
| 2463 | array[i] = value[i]; |
| 2464 | } |
| 2465 | } catch(...) {} |
| 2466 | } |
| 2467 | |
| 2468 | for (int i = 0; i < 11; i++) { |
| 2469 | mem_poke_byte(addr + i, array[i]); |
| 2470 | } |
| 2471 | |
| 2472 | array.clear(); |
| 2473 | data.clear(); |
| 2474 | |
| 2475 | for (uint32_t j = addr; j < addr + 11; j++) { |
| 2476 | uint8_t ch = mem_peek_byte(j); |
| 2477 | array.append(static_cast<char>(ch)); |
| 2478 | if ((ch < 0x20) || (ch > 0x7e)) { |
| 2479 | ch = '.'; |
| 2480 | } |
| 2481 | data += QChar(ch); |
| 2482 | } |
| 2483 | |
| 2484 | data_t vect(array.constData(), array.constEnd() - 2); |
| 2485 | |
| 2486 | ui->opView->item(row, OP_STRING_COL)->setText(data); |
| 2487 | ui->opView->item(row, OP_DATA_COL)->setText(QString(array.toHex())); |
| 2488 | try { |
| 2489 | ui->opView->item(row, OP_VALUE_COL)->setText(QString::fromStdString(tivars::TypeHandlers::TH_GenericReal::makeStringFromData(vect))); |
nothing calls this directly
no test coverage detected