| 12 | #include <QWidget> |
| 13 | |
| 14 | ProgramDock::ProgramDock(QWidget *parent, QSettings *settings) : Super(parent) { |
| 15 | setObjectName("Program"); |
| 16 | setWindowTitle("Program"); |
| 17 | |
| 18 | this->settings = settings; |
| 19 | follow_source |
| 20 | = (enum FollowSource)settings->value("ProgramViewFollowSource", FOLLOWSRC_FETCH).toInt(); |
| 21 | |
| 22 | for (auto &i : follow_addr) { |
| 23 | i = machine::Address::null(); |
| 24 | } |
| 25 | |
| 26 | auto *content = new QWidget(); |
| 27 | |
| 28 | auto *follow_inst = new QComboBox(); |
| 29 | follow_inst->addItem("Follow none"); |
| 30 | follow_inst->addItem("Follow fetch"); |
| 31 | follow_inst->addItem("Follow decode"); |
| 32 | follow_inst->addItem("Follow execute"); |
| 33 | follow_inst->addItem("Follow memory"); |
| 34 | follow_inst->addItem("Follow writeback"); |
| 35 | follow_inst->setCurrentIndex((int)follow_source); |
| 36 | |
| 37 | auto *program_content = new ProgramTableView(nullptr, settings); |
| 38 | // program_content->setSizePolicy(); |
| 39 | auto *program_model = new ProgramModel(this); |
| 40 | program_content->setModel(program_model); |
| 41 | program_content->verticalHeader()->hide(); |
| 42 | // program_content->setHorizontalHeader(program_model->); |
| 43 | |
| 44 | auto *go_edit = new HexLineEdit(nullptr, 8, 16, "0x"); |
| 45 | |
| 46 | auto *layout = new QVBoxLayout; |
| 47 | layout->addWidget(follow_inst); |
| 48 | layout->addWidget(program_content); |
| 49 | layout->addWidget(go_edit); |
| 50 | |
| 51 | content->setLayout(layout); |
| 52 | |
| 53 | setWidget(content); |
| 54 | |
| 55 | connect(this, &ProgramDock::machine_setup, program_model, &ProgramModel::setup); |
| 56 | connect( |
| 57 | go_edit, &HexLineEdit::value_edit_finished, program_content, |
| 58 | [program_content](uint32_t value) { |
| 59 | program_content->go_to_address(machine::Address(value)); |
| 60 | }); |
| 61 | connect(program_content, &ProgramTableView::address_changed, go_edit, &HexLineEdit::set_value); |
| 62 | connect(this, &ProgramDock::jump_to_pc, program_content, &ProgramTableView::go_to_address); |
| 63 | connect( |
| 64 | follow_inst, QOverload<int>::of(&QComboBox::currentIndexChanged), this, |
| 65 | &ProgramDock::set_follow_inst); |
| 66 | connect(this, &ProgramDock::focus_addr, program_content, &ProgramTableView::focus_address); |
| 67 | connect( |
| 68 | this, &ProgramDock::focus_addr_with_save, program_content, |
| 69 | &ProgramTableView::focus_address_with_save); |
| 70 | connect( |
| 71 | program_content, &QAbstractItemView::doubleClicked, program_model, |
nothing calls this directly
no test coverage detected