| 656 | } |
| 657 | |
| 658 | void MemoryDialog::populateTable() |
| 659 | { |
| 660 | const QSignalBlocker blocker(m_table); |
| 661 | const QSet<int> previousSelection = selectedMemoryIndices(); |
| 662 | const int currentMemoryIndex = (m_table->currentRow() >= 0 && m_table->item(m_table->currentRow(), 0)) |
| 663 | ? m_table->item(m_table->currentRow(), 0)->data(Qt::UserRole).toInt() |
| 664 | : -1; |
| 665 | m_table->setSortingEnabled(false); |
| 666 | m_table->setRowCount(0); |
| 667 | const auto& memories = m_model->memories(); |
| 668 | const QString filterProfile = m_filterCombo->currentData().toString(); |
| 669 | const QString nameFilter = m_searchEdit ? m_searchEdit->text().trimmed() : QString(); |
| 670 | bool hasRows = false; |
| 671 | |
| 672 | for (auto it = memories.begin(); it != memories.end(); ++it) { |
| 673 | const auto& m = it.value(); |
| 674 | |
| 675 | // Apply profile filter: skip memories whose group doesn't match |
| 676 | if (!filterProfile.isEmpty() && m.group != filterProfile) { |
| 677 | continue; |
| 678 | } |
| 679 | if (!nameFilter.isEmpty() && !m.name.contains(nameFilter, Qt::CaseInsensitive)) { |
| 680 | continue; |
| 681 | } |
| 682 | int row = m_table->rowCount(); |
| 683 | m_table->insertRow(row); |
| 684 | hasRows = true; |
| 685 | |
| 686 | int col = 0; |
| 687 | m_table->setItem(row, col++, new QTableWidgetItem(m.group)); |
| 688 | m_table->setItem(row, col++, new QTableWidgetItem(m.owner)); |
| 689 | // Show the full MHz value so the last 3 digits (Hz) are not lost. |
| 690 | auto* freqItem = new MemoryTableItem(QString::number(m.freq, 'f', 6)); |
| 691 | freqItem->setData(Qt::UserRole, m.freq); |
| 692 | m_table->setItem(row, col++, freqItem); |
| 693 | m_table->setItem(row, col++, new QTableWidgetItem(m.name)); |
| 694 | m_table->setItem(row, col++, new QTableWidgetItem(m.mode)); |
| 695 | m_table->setItem(row, col++, new QTableWidgetItem( |
| 696 | QString::number(m.step))); |
| 697 | m_table->setItem(row, col++, new QTableWidgetItem( |
| 698 | MemoryFields::offsetDirToDisplay(m.offsetDir))); |
| 699 | m_table->setItem(row, col++, new QTableWidgetItem( |
| 700 | QString::number(m.repeaterOffset, 'f', 1))); |
| 701 | m_table->setItem(row, col++, new QTableWidgetItem( |
| 702 | MemoryFields::toneModeToDisplay(m.toneMode))); |
| 703 | m_table->setItem(row, col++, new QTableWidgetItem( |
| 704 | QString::number(m.toneValue, 'f', 1))); |
| 705 | |
| 706 | // Squelch checkbox column |
| 707 | auto* sqItem = new QTableWidgetItem(); |
| 708 | sqItem->setCheckState(m.squelch ? Qt::Checked : Qt::Unchecked); |
| 709 | m_table->setItem(row, col++, sqItem); |
| 710 | |
| 711 | m_table->setItem(row, col++, new QTableWidgetItem( |
| 712 | QString::number(m.squelchLevel))); |
| 713 | m_table->setItem(row, col++, new QTableWidgetItem( |
| 714 | QString::number(m.rxFilterLow))); |
| 715 | m_table->setItem(row, col++, new QTableWidgetItem( |
no test coverage detected