diff options
Diffstat (limited to 'qtmips_gui/programdock.cpp')
-rw-r--r-- | qtmips_gui/programdock.cpp | 132 |
1 files changed, 37 insertions, 95 deletions
diff --git a/qtmips_gui/programdock.cpp b/qtmips_gui/programdock.cpp index 4c379eb..39a3f77 100644 --- a/qtmips_gui/programdock.cpp +++ b/qtmips_gui/programdock.cpp @@ -33,114 +33,56 @@ * ******************************************************************************/ +#include <QWidget> +#include <QPushButton> +#include <QVBoxLayout> +#include <QTableView> +#include <QComboBox> +#include <QHeaderView> #include "programdock.h" -#include "qtmipsexception.h" +#include "programmodel.h" +#include "programtableview.h" +#include "hexlineedit.h" -ProgramView::ProgramView(QWidget *parent, QSettings *settings) : MemoryView(parent, settings->value("ProgramViewAddr0", 0x8001FF80).toULongLong()) { - this->settings = settings; - /* - cb_single = new QComboBox(this); - cb_single->addItems({ - "Don't follow", - "Follow executing instruction" - }); - cb_single->setCurrentIndex(1); - cb_single->hide(); - layout->addWidget(cb_single); - connect(cb_single, SIGNAL(currentIndexChanged(int)), this, SLOT(cb_single_changed(int))); - cb_pipelined = new QComboBox(this); - cb_pipelined->addItems({ - "Don't follow", - "Follow Instruction fetch stage", - "Follow Instruction decode stage", - "Follow Execution stage", - "Follow Memory access stage", - "Follow Registers write back stage", - }); - cb_pipelined->hide(); - cb_pipelined->setCurrentIndex(1); - layout->addWidget(cb_pipelined); - connect(cb_pipelined, SIGNAL(currentIndexChanged(int)), this, SLOT(cb_pipelined_changed(int))); - */ -} - -void ProgramView::setup(machine::QtMipsMachine *machine) { - MemoryView::setup(machine); - if (machine == nullptr) - return; - /* - bool pipelined = machine->config().pipelined(); - cb_single->setVisible(!pipelined); - cb_pipelined->setVisible(pipelined); - // Sync selection somewhat - if (pipelined) { - if (cb_single->currentIndex() == 0) - cb_pipelined->setCurrentIndex(0); - else if (cb_pipelined->currentIndex() == 0) - cb_pipelined->setCurrentIndex(1); - } else - cb_single->setCurrentIndex(cb_pipelined->currentIndex() == 0 ? 0 : 1); - // TODO connect to instructuion hooks - */ -} - -void ProgramView::jump_to_pc(std::uint32_t addr) { - set_focus(addr); -} - -QList<QWidget*> ProgramView::row_widget(std::uint32_t address, QWidget *parent) { - QList<QWidget*> widgs; - QLabel *l; - - QFont f; - f.setStyleHint(QFont::Monospace); - - l = new QLabel(" ", parent); - l->setFont(f); - widgs.append(l); +ProgramDock::ProgramDock(QWidget *parent, QSettings *settings) : Super(parent) { + setObjectName("Program"); + setWindowTitle("Program"); - l = new QLabel(QString("0x") + QString("%1").arg(address, 8, 16, QChar('0')).toUpper(), parent); - l->setTextInteractionFlags(Qt::TextSelectableByMouse); - l->setFont(f); - widgs.append(l); + QWidget *content = new QWidget(); - l = new QLabel(parent); - l->setTextInteractionFlags(Qt::TextSelectableByMouse); - l->setFont(f); - l->setMinimumWidth(60); - if (memory != nullptr) - l->setText(machine::Instruction(memory->read_word(address)).to_str(address)); - widgs.append(l); + QComboBox *follow_inst = new QComboBox(); + follow_inst->addItem("Follow - none"); + follow_inst->addItem("Follow - fetch"); - return widgs; -} + QTableView *program_content = new ProgramTableView(0, settings); + // program_content->setSizePolicy(); + ProgramModel *program_model = new ProgramModel(0); + program_content->setModel(program_model); + program_content->verticalHeader()->hide(); + //program_content->setHorizontalHeader(program_model->); -void ProgramView::addr0_save_change(std::uint32_t val) { - settings->setValue("ProgramViewAddr0", val); -} + QLineEdit *go_edit = new HexLineEdit(0, 8, 16, "0x"); -void ProgramView::cb_single_changed(int index) { - // TODO set memory view -} + QVBoxLayout *layout = new QVBoxLayout; + layout->addWidget(follow_inst); + layout->addWidget(program_content); + layout->addWidget(go_edit); -void ProgramView::cb_pipelined_changed(int index) { - // TODO set memory view -} + content->setLayout(layout); -ProgramDock::ProgramDock(QWidget *parent, QSettings *settings) : QDockWidget(parent) { - view = new ProgramView(this, settings); - setWidget(view); + setWidget(content); - setObjectName("Program"); - setWindowTitle("Program"); + connect(this, &ProgramDock::machine_setup, program_model, &ProgramModel::setup); + connect(go_edit, SIGNAL(value_edit_finished(std::uint32_t)), + program_content, SLOT(go_to_address(std::uint32_t))); + connect(program_content, SIGNAL(address_changed(std::uint32_t)), + go_edit, SLOT(set_value(std::uint32_t))); + connect(this, SIGNAL(jump_to_pc(std::uint32_t)), + program_content, SLOT(go_to_address(std::uint32_t))); } void ProgramDock::setup(machine::QtMipsMachine *machine) { - view->setup(machine); -} - -void ProgramDock::jump_to_pc(std::uint32_t addr) { - view->jump_to_pc(addr); + emit machine_setup(machine); } |