Starting to implement the switch addr tab

This commit is contained in:
Anonymus Raccoon
2020-02-25 01:55:53 +01:00
parent 3ff896f8f0
commit 4437df4666
3 changed files with 39 additions and 1 deletions

View File

@@ -79,6 +79,7 @@ namespace ComSquare::Debugger
this->_ui.tabs->addTab("&Rom");
// this->_ui.tabs->addTab("&VRam");
QMainWindow::connect(this->_ui.actionGoto, &QAction::triggered, this, &MemoryViewer::gotoAddr);
QMainWindow::connect(this->_ui.actionGoto_Absolute, &QAction::triggered, this, &MemoryViewer::gotoAbsoluteAddr);
QObject::connect(this->_ui.tabs, &QTabBar::currentChanged, this, &MemoryViewer::changeRam);
this->show();
}
@@ -102,22 +103,40 @@ namespace ComSquare::Debugger
}
}
void MemoryViewer::gotoAddr()
{
this->_internalGoto(false);
}
void MemoryViewer::gotoAbsoluteAddr()
{
this->_internalGoto(true);
}
void MemoryViewer::_internalGoto(bool isAbsolute)
{
QDialog dialog(this);
dialog.setWindowModality(Qt::WindowModal);
Ui::GotoDialog dialogUI;
dialogUI.setupUi(&dialog);
QFont font = dialogUI.spinBox->font();
font.setCapitalization(QFont::AllUppercase);
dialogUI.spinBox->setFont(font);
dialogUI.spinBox->selectAll();
dialogUI.checkBox->setChecked(isAbsolute);
if (dialog.exec() != QDialog::Accepted)
return;
long value = std::strtol(dialogUI.spinBox->text().toStdString().c_str() + 1, nullptr, 16);
if (dialogUI.checkBox->isChecked())
this->switchToAddrTab(value);
QModelIndex index = this->_ui.tableView->model()->index(value >> 4, value & 0x0000000F);
this->_ui.tableView->scrollTo(index);
this->_ui.tableView->selectionModel()->select(index, QItemSelectionModel::ClearAndSelect);
}
void MemoryViewer::switchToAddrTab(uint24_t addr)
{
}
}

View File

@@ -56,11 +56,18 @@ namespace ComSquare
Ui::RamView _ui;
//! @brief The Ram visualizer model for QT.
MemoryViewerModel _model;
//! @brief Helper function to create the goto dialog.
void _internalGoto(bool isAbsolute);
public:
//! @brief Select the memory tab corresponding to a 24 bit address (map the address via the bus).
void switchToAddrTab(uint24_t addr);
//! @brief Callback called when a memory tab is selected.
void changeRam(int id);
//! @brief Create a popup asking you where you want to jump to.
void gotoAddr();
//! @brief Create a popup asking you where you want to jump to with the absolute mode selected.
void gotoAbsoluteAddr();
explicit MemoryViewer(SNES &snes);
MemoryViewer(const MemoryViewer &) = delete;

View File

@@ -45,6 +45,7 @@
<bool>false</bool>
</attribute>
<addaction name="actionGoto"/>
<addaction name="actionGoto_Absolute"/>
</widget>
<action name="actionGoto">
<property name="text">
@@ -57,6 +58,17 @@
<string>Ctrl+G</string>
</property>
</action>
<action name="actionGoto_Absolute">
<property name="text">
<string>Goto Absolute</string>
</property>
<property name="toolTip">
<string>Go to an absolute address</string>
</property>
<property name="shortcut">
<string>Ctrl+Shift+G</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>