Initial commit for memory tab connection
MODIFY
src/memorytab.cpp
src/memorytab.cpp
@@ -80,6 +80,10 @@ MemoryTab::MemoryTab(QWidget *parent)
reg->setAlias(ABInames[i]);
reg->setNumber(i);
reg->setToolTip(descriptions[i]);
+ reg->setDisplayType(m_ui->registerdisplaytype->currentText());
+ reg->setRegPtr(&(*m_regPtr)[i]);
+ connect(m_ui->registerdisplaytype, &QComboBox::currentTextChanged,
+ [=](const QString &text) { reg->setDisplayType(text); });
m_ui->registerLayout->addWidget(reg);
}
}

MODIFY
src/memorytab.h
src/memorytab.h
@@ -14,8 +14,14 @@ public:
explicit MemoryTab(QWidget *parent = 0);
~MemoryTab();
+ void setMemoryPtr(uint32_t *ptr) { m_memoryPtr = ptr; }
+ void setRegPtr(std::vector<uint32_t> *ptr) { m_regPtr = ptr; }
+
private:
Ui::MemoryTab *m_ui;
+
+ uint32_t *m_memoryPtr;
+ std::vector<uint32_t> *m_regPtr;
};
#endif // MEMORYTAB_H

MODIFY
src/memorytab.ui
src/memorytab.ui
</widget>
</item>
<item>
- <widget class="QComboBox" name="comboBox_2">
+ <widget class="QComboBox" name="registerdisplaytype">
<item>
<property name="text">
<string>Hex</string>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_6">
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <property name="horizontalSpacing">
+ <number>6</number>
+ </property>
<item row="0" column="0">
- <layout class="QVBoxLayout" name="memoryLayout"/>
+ <layout class="QVBoxLayout" name="memoryLayout">
+ <item>
+ <widget class="QTableView" name="tableView"/>
+ </item>
+ </layout>
</item>
</layout>
</widget>

MODIFY
src/registerwidget.cpp
src/registerwidget.cpp
RegisterWidget::RegisterWidget(QWidget *parent)
: QWidget(parent), m_ui(new Ui::RegisterWidget) {
m_ui->setupUi(this);
+ m_ui->value->setValidator(&m_validator);
}
RegisterWidget::~RegisterWidget() { delete m_ui; }
@@ -13,3 +14,35 @@ void RegisterWidget::setAlias(QString text) { m_ui->alias->setText(text); }
void RegisterWidget::setNumber(int number) {
m_ui->number->setText(QString("x(%1)").arg(number));
}
+
+void RegisterWidget::setDisplayType(QString type) {
+ if (type == displayTypes[0]) {
+ // hex
+ m_ui->value->setInputMask("HHHHHHHH");
+ m_ui->value->setText(QString().setNum(*m_regPtr, 16));
+ // m_validator.setRange(0, 4294967295);
+ } else if (type == displayTypes[1]) {
+ // binary
+ m_ui->value->setInputMask("BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB");
+ m_ui->value->setText(QString().setNum(*m_regPtr, 2));
+ // m_validator.setRange(0, 4294967295);
+ } else if (type == displayTypes[2]) {
+ // Decimal
+ m_ui->value->setInputMask("#9999999999");
+ m_ui->value->setText(QString().setNum((int32_t)*m_regPtr, 10));
+ // m_validator.setRange(-2147483648, 2147483647);
+ } else if (type == displayTypes[3]) {
+ // Unsigned
+ m_ui->value->setInputMask("9999999999");
+ m_ui->value->setText(QString().setNum(*m_regPtr, 10));
+ // m_validator.setRange(0, 4294967295);
+ } else if (type == displayTypes[4]) {
+ // ASCII - valid ascii characters will not be able to fill the 32-bit range
+ m_ui->value->setInputMask("NNNN");
+ // m_validator.setRange(0, 4294967295);
+ } else if (type == displayTypes[5]) {
+ // float
+ m_ui->value->setInputMask("B");
+ // m_validator.setRange(0, 4294967295);
+ }
+}

MODIFY
src/registerwidget.h
src/registerwidget.h
#ifndef REGISTERWIDGET_H
#define REGISTERWIDGET_H
+#include <QValidator>
#include <QWidget>
+const static QStringList displayTypes = QStringList() << "Hex"
+ << "Binary"
+ << "Decimal"
+ << "Unsigned"
+ << "ASCII"
+ << "Float (IEEE-754)";
+
namespace Ui {
class RegisterWidget;
}
@@ -16,9 +24,14 @@ public:
void setAlias(QString text);
void setNumber(int number);
+ void setDisplayType(QString type);
+ void setRegPtr(uint32_t *ptr) { m_regPtr = ptr; }
private:
Ui::RegisterWidget *m_ui;
+ QIntValidator m_validator;
+
+ uint32_t *m_regPtr;
};
#endif // REGISTERWIDGET_H

Initial commit for memory tab connection