From cea53aadd59a5196d0b35d5a2b69c2e00d18d22a Mon Sep 17 00:00:00 2001 From: Mark Long Date: Wed, 26 Oct 2016 02:27:58 -0500 Subject: [PATCH] Continued work on assembler metadata dialog --- src/binaryfile/AssemblerSymbols.cpp | 26 +++++++++---------- src/binaryfile/AssemblerSymbols.h | 16 ++++++------ src/ui/widgets/DisassemblerMetadataDialog.cpp | 6 +++-- 3 files changed, 25 insertions(+), 23 deletions(-) diff --git a/src/binaryfile/AssemblerSymbols.cpp b/src/binaryfile/AssemblerSymbols.cpp index e321d7f..f7a757b 100644 --- a/src/binaryfile/AssemblerSymbols.cpp +++ b/src/binaryfile/AssemblerSymbols.cpp @@ -8,17 +8,17 @@ AssemblerSymbols::AssemblerSymbols(QObject *parent) : QObject(parent) bool AssemblerSymbols::hasAssemSymbolAtAddress(quint16 address) { // Assume list m_assemblerSymbols is sorted by address (it should be) - QListIterator it(m_assemblerSymbols); + QListIterator it(m_assemblerSymbols); while (it.hasNext()) { - AssemSymbol ep = it.next(); + AssemblerSymbol ep = it.next(); if (ep.address == address) return true; if (ep.address > address) return false; } return false; } -void AssemblerSymbols::editSymbol(int location, AssemSymbol newSymbol) +void AssemblerSymbols::editSymbol(int location, AssemblerSymbol newSymbol) { if (m_assemblerSymbols.at(location).address == newSymbol.address) @@ -33,7 +33,7 @@ void AssemblerSymbols::editSymbol(int location, AssemSymbol newSymbol) } } -void AssemblerSymbols::addSymbol(AssemSymbol ep) +void AssemblerSymbols::addSymbol(AssemblerSymbol ep) { if (hasAssemSymbolAtAddress(ep.address)) return; @@ -88,14 +88,14 @@ QDataStream &operator>>(QDataStream &in, AssemblerSymbols&model) return model.read(in); } -QDataStream &operator<<(QDataStream &out, const AssemSymbol &model) +QDataStream &operator<<(QDataStream &out, const AssemblerSymbol &model) { out << model.address; out << model.name; return out; } -QDataStream &operator>>(QDataStream &in, AssemSymbol &model) +QDataStream &operator>>(QDataStream &in, AssemblerSymbol &model) { in >> model.address; in >> model.name; @@ -108,15 +108,15 @@ QDataStream &operator>>(QDataStream &in, AssemSymbol &model) void AssemblerSymbols::doTestData() { - AssemSymbol ep; - ep.address = 0x0010; - ep.name = "Test Entry Symbol 1"; + AssemblerSymbol ep; + ep.address = 0x0100; + ep.name = "Test Symbol 1"; addSymbol(ep); - ep.address = 0x0020; - ep.name = "Test Entry Symbol 2"; + ep.address = 0x0200; + ep.name = "Test Symbol 2"; addSymbol(ep); - ep.address = 0x0030; - ep.name = "Test Entry Symbol 3"; + ep.address = 0x0300; + ep.name = "Test Symbol 3"; addSymbol(ep); } diff --git a/src/binaryfile/AssemblerSymbols.h b/src/binaryfile/AssemblerSymbols.h index 211927c..ab9694a 100644 --- a/src/binaryfile/AssemblerSymbols.h +++ b/src/binaryfile/AssemblerSymbols.h @@ -4,7 +4,7 @@ #include #include -struct AssemSymbol { +struct AssemblerSymbol { quint16 address; QString name; }; @@ -17,11 +17,11 @@ public: bool hasAssemSymbolAtAddress(quint16 address); - const AssemSymbol &at(int location) const { return m_assemblerSymbols.at(location); } - AssemSymbol &symbolRefAt(int location) { return m_assemblerSymbols[location]; } - AssemSymbol &operator[](int location) { return m_assemblerSymbols[location]; } + const AssemblerSymbol &at(int location) const { return m_assemblerSymbols.at(location); } + AssemblerSymbol &symbolRefAt(int location) { return m_assemblerSymbols[location]; } + AssemblerSymbol &operator[](int location) { return m_assemblerSymbols[location]; } - void editSymbol(int at, AssemSymbol newSymbol); + void editSymbol(int at, AssemblerSymbol newSymbol); QDataStream &read(QDataStream &dataStream); QDataStream &write(QDataStream &dataStream) const; @@ -31,17 +31,17 @@ public: void doTestData(); signals: - void symbolAdded(AssemSymbol &AssemSymbol, int location); + void symbolAdded(AssemblerSymbol &AssemblerSymbol, int location); void symbolAddedAt(int location); void symbolRemovedAt(int location); void symbolChangedAt(int location); public slots: - void addSymbol(AssemSymbol ep); + void addSymbol(AssemblerSymbol ep); void removeSymbolAt(int location); protected: - QList m_assemblerSymbols; + QList m_assemblerSymbols; }; QDataStream &operator<<(QDataStream &out, const AssemblerSymbols &model); diff --git a/src/ui/widgets/DisassemblerMetadataDialog.cpp b/src/ui/widgets/DisassemblerMetadataDialog.cpp index f94cec6..95eec83 100644 --- a/src/ui/widgets/DisassemblerMetadataDialog.cpp +++ b/src/ui/widgets/DisassemblerMetadataDialog.cpp @@ -42,6 +42,8 @@ DisassemblerMetadataDialog::~DisassemblerMetadataDialog() void DisassemblerMetadataDialog::showEvent(QShowEvent *){ ui->entryTable->resizeRowsToContents(); + ui->symbolTable->resizeRowsToContents(); + } void DisassemblerMetadataDialog::setRelocatable(bool relocatable) @@ -97,7 +99,7 @@ void DisassemblerMetadataDialog::handleAddSymbolButton() lid.setWindowTitle("Add Symbol"); if (lid.exec() == Accepted) { - AssemSymbol as; + AssemblerSymbol as; as.address = lid.getAddress(); as.name = lid.getInfo(); m_as->addSymbol(as); @@ -113,7 +115,7 @@ void DisassemblerMetadataDialog::handleRemoveSymbolButton() void DisassemblerMetadataDialog::processSymbols() { - + m_as->doTestData(); } void DisassemblerMetadataDialog::processEntryPoints()