From 76cfe6621919be43a68b098249093ab8c5765677 Mon Sep 17 00:00:00 2001 From: Simon Kagstrom Date: Mon, 8 Jul 2024 13:30:28 +0200 Subject: [PATCH] qt: Correct symbol activation with new sorting --- qt/emilpro/mainwindow.cc | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/qt/emilpro/mainwindow.cc b/qt/emilpro/mainwindow.cc index b085bcc..0077f28 100644 --- a/qt/emilpro/mainwindow.cc +++ b/qt/emilpro/mainwindow.cc @@ -157,7 +157,9 @@ MainWindow::LoadFile(const std::string& filename, std::optionalsectionTableView->setCurrentIndex(m_section_view_model->index(0, 0)); } - for (auto& sym_ref : m_database.Symbols()) + m_visible_symbols = m_database.Symbols(); + auto sym_index = 0; + for (auto& sym_ref : m_visible_symbols) { const auto& sym = sym_ref.get(); @@ -171,7 +173,12 @@ MainWindow::LoadFile(const std::string& filename, std::optionalsetData(sym_index, Qt::UserRole + 1); + sym_index++; + + lst.append(std::move(addr_item)); lst.append(new QStandardItem(size)); lst.append(new QStandardItem(flags)); lst.append(new QStandardItem(section)); @@ -207,7 +214,7 @@ MainWindow::LoadFile(const std::string& filename, std::optionalsort(0, Qt::AscendingOrder); - m_visible_symbols = m_database.Symbols(); + return std::nullopt; } @@ -604,7 +611,9 @@ MainWindow::on_symbolTableView_activated(const QModelIndex& index) return; } - auto& sym = m_visible_symbols[row].get(); + auto sym_index = index.model()->index(row, 0).data(Qt::UserRole + 1).toInt(); + + auto& sym = m_visible_symbols[sym_index].get(); sym.WaitForCommit(); @@ -746,14 +755,19 @@ MainWindow::UpdateReferredByView(const emilpro::IInstruction& insn) void MainWindow::on_symbolTableView_entered(const QModelIndex& index) { - auto row = index.row(); + int row = index.row(); if (row < 0 || row >= m_visible_symbols.size()) { return; } - const auto& sym = m_visible_symbols[row].get(); + + // Create a new QModelIndex for column 0 of the same row + auto sym_index = index.model()->index(row, 0).data(Qt::UserRole + 1).toInt(); + + // Assuming m_visible_symbols stores some kind of symbol objects and you need to retrieve it + const auto& sym = m_visible_symbols[sym_index].get(); UpdateRefersToView(sym); UpdateReferredByView(sym);