all repos — mgba @ 605d5ddcfd1ba1cbf81c98fb4333099a0bbc58d5

mGBA Game Boy Advance Emulator

Qt: Add string view to memory viewer
Jeffrey Pfau jeffrey@endrift.com
Tue, 01 Nov 2016 18:26:54 -0700
commit

605d5ddcfd1ba1cbf81c98fb4333099a0bbc58d5

parent

9972ff5019484ae421d1c4079070e9ea0fc469e6

3 files changed, 50 insertions(+), 21 deletions(-)

jump to
M src/platform/qt/MemoryModel.hsrc/platform/qt/MemoryModel.h

@@ -32,6 +32,9 @@

void setAlignment(int); int alignment() const { return m_align; } + QByteArray serialize(); + void deserialize(const QByteArray&); + public slots: void jumpToAddress(const QString& hex); void jumpToAddress(uint32_t);

@@ -60,9 +63,6 @@ bool isEditing(uint32_t address);

void drawEditingText(QPainter& painter, const QPointF& origin); void adjustCursor(int adjust, bool shift); - - QByteArray serialize(); - void deserialize(const QByteArray&); mCore* m_core; QFont m_font;
M src/platform/qt/MemoryView.cppsrc/platform/qt/MemoryView.cpp

@@ -167,15 +167,25 @@ }

void MemoryView::updateStatus() { int align = m_ui.hexfield->alignment(); + if (!m_controller->isLoaded()) { + return; + } + mCore* core = m_controller->thread()->core; + QByteArray selection(m_ui.hexfield->serialize()); + QString text; + for (QChar c : selection) { + if (!c.isPrint() || c >= 127) { + continue; + } + text.append(c); + } + m_ui.stringVal->setText(text); + if (m_selection.first & (align - 1) || m_selection.second - m_selection.first != align) { m_ui.sintVal->clear(); m_ui.uintVal->clear(); return; } - if (!m_controller->isLoaded()) { - return; - } - mCore* core = m_controller->thread()->core; union { uint32_t u32; int32_t i32;
M src/platform/qt/MemoryView.uisrc/platform/qt/MemoryView.ui

@@ -6,8 +6,8 @@ <property name="geometry">

<rect> <x>0</x> <y>0</y> - <width>550</width> - <height>640</height> + <width>565</width> + <height>658</height> </rect> </property> <property name="windowTitle">

@@ -168,20 +168,39 @@ <horstretch>0</horstretch>

<verstretch>0</verstretch> </sizepolicy> </property> + <zorder></zorder> </widget> </item> <item> - <layout class="QHBoxLayout" name="horizontalLayout_4"> - <item> - <layout class="QFormLayout" name="formLayout"> - <item row="0" column="0"> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="1"> + <layout class="QHBoxLayout" name="horizontalLayout_6"> + <item> + <widget class="QLabel" name="label_4"> + <property name="text"> + <string>Unsigned Integer:</string> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="uintVal"> + <property name="readOnly"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </item> + <item row="0" column="0"> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <item> <widget class="QLabel" name="label_3"> <property name="text"> <string>Signed Integer:</string> </property> </widget> </item> - <item row="0" column="1"> + <item> <widget class="QLineEdit" name="sintVal"> <property name="readOnly"> <bool>true</bool>

@@ -190,17 +209,17 @@ </widget>

</item> </layout> </item> - <item> - <layout class="QFormLayout" name="formLayout_4"> - <item row="0" column="0"> - <widget class="QLabel" name="label_4"> + <item row="1" column="0" colspan="2"> + <layout class="QHBoxLayout" name="horizontalLayout_4"> + <item> + <widget class="QLabel" name="label_5"> <property name="text"> - <string>Unsigned Integer:</string> + <string>String:</string> </property> </widget> </item> - <item row="0" column="1"> - <widget class="QLineEdit" name="uintVal"> + <item> + <widget class="QLineEdit" name="stringVal"> <property name="readOnly"> <bool>true</bool> </property>