| 2495 | } |
| 2496 | |
| 2497 | void MainWindow::fpModified(QTableWidgetItem *item) { |
| 2498 | if (item == Q_NULLPTR) { |
| 2499 | return; |
| 2500 | } |
| 2501 | |
| 2502 | int col = item->column(); |
| 2503 | int row = item->row(); |
| 2504 | |
| 2505 | QString txt = item->text(); |
| 2506 | QString data; |
| 2507 | QByteArray array; |
| 2508 | uint32_t addr = static_cast<uint32_t>(hex2int(ui->fpStack->item(row, FP_ADDR_COL)->text())); |
| 2509 | array.resize(11); |
| 2510 | |
| 2511 | sender()->blockSignals(true); |
| 2512 | |
| 2513 | if (col == FP_DATA_COL) { |
| 2514 | array.fill(0); |
| 2515 | for (int i = 0; i < 9 && i < txt.length() / 2; i++) { |
| 2516 | array[i] = hex2int(txt.mid(i * 2, 2)); |
| 2517 | } |
| 2518 | } else if (col == FP_STRING_COL) { |
| 2519 | array.fill('.'); |
| 2520 | for (int i = 0; i < 9 && i < txt.length(); i++) { |
| 2521 | array[i] = txt[i].toLatin1(); |
| 2522 | } |
| 2523 | } else if (col == FP_VALUE_COL) { |
| 2524 | array.fill(0); |
| 2525 | try { |
| 2526 | data_t value = tivars::TypeHandlers::TH_GenericReal::makeDataFromString(txt.toStdString()); |
| 2527 | for (int i = 0; i < 9 && i < static_cast<int>(value.size()); i++) { |
| 2528 | array[i] = value[i]; |
| 2529 | } |
| 2530 | } catch(...) {} |
| 2531 | } |
| 2532 | |
| 2533 | for (unsigned int i = 0; i < 9; i++) { |
| 2534 | mem_poke_byte(addr + i, array[i]); |
| 2535 | } |
| 2536 | |
| 2537 | array.clear(); |
| 2538 | data.clear(); |
| 2539 | |
| 2540 | for (uint32_t j = addr; j < addr + 9; j++) { |
| 2541 | uint8_t ch = mem_peek_byte(j); |
| 2542 | array.append(static_cast<char>(ch)); |
| 2543 | if ((ch < 0x20) || (ch > 0x7e)) { |
| 2544 | ch = '.'; |
| 2545 | } |
| 2546 | data += QChar(ch); |
| 2547 | } |
| 2548 | |
| 2549 | data_t vect(array.constData(), array.constEnd()); |
| 2550 | |
| 2551 | ui->fpStack->item(row, FP_STRING_COL)->setText(data); |
| 2552 | ui->fpStack->item(row, FP_DATA_COL)->setText(QString(array.toHex())); |
| 2553 | try { |
| 2554 | ui->fpStack->item(row, FP_VALUE_COL)->setText(QString::fromStdString(tivars::TypeHandlers::TH_GenericReal::makeStringFromData(vect))); |
nothing calls this directly
no test coverage detected