mirror of
https://github.com/markdavidlong/AppleSAWS.git
synced 2026-04-20 05:16:40 +00:00
Various Changes
This commit is contained in:
@@ -15,9 +15,9 @@ void AssemblerSymbolModel::setAssemblerSymbolsData(AssemblerSymbols *symbols)
|
||||
|
||||
if (assemblerSymbols)
|
||||
{
|
||||
connect(assemblerSymbols,SIGNAL(symbolAddedAt(int)),SLOT(handleSymbolAddition(int)));
|
||||
connect(assemblerSymbols,SIGNAL(symbolChangedAt(int)),SLOT(handleSymbolChange(int)));
|
||||
connect(assemblerSymbols,SIGNAL(symbolRemovedAt(int)),SLOT(handleSymbolRemoval(int)));
|
||||
connect(assemblerSymbols, &AssemblerSymbols::symbolAddedAt, this, &AssemblerSymbolModel::handleSymbolAddition);
|
||||
connect(assemblerSymbols, &AssemblerSymbols::symbolChangedAt, this, &AssemblerSymbolModel::handleSymbolChange);
|
||||
connect(assemblerSymbols, &AssemblerSymbols::symbolRemovedAt, this, &AssemblerSymbolModel::handleSymbolRemoval);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -57,7 +57,7 @@ int AssemblerSymbolModel::rowCount(const QModelIndex &parent) const
|
||||
int AssemblerSymbolModel::columnCount(const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(parent);
|
||||
return 1;
|
||||
return 2;
|
||||
}
|
||||
|
||||
QVariant AssemblerSymbolModel::data(const QModelIndex &index, int role) const
|
||||
@@ -67,6 +67,19 @@ QVariant AssemblerSymbolModel::data(const QModelIndex &index, int role) const
|
||||
if (role == Qt::DisplayRole)
|
||||
{
|
||||
if (index.column() == 0)
|
||||
{
|
||||
QString val;
|
||||
if (assemblerSymbols->at(index.row()).symbolsize == SizeWord)
|
||||
{
|
||||
val = "WORD";
|
||||
}
|
||||
else if (assemblerSymbols->at(index.row()).symbolsize == SizeByte)
|
||||
{
|
||||
val = "BYTE";
|
||||
}
|
||||
return val;
|
||||
}
|
||||
else if (index.column() == 1)
|
||||
{
|
||||
return assemblerSymbols->at(index.row()).name;
|
||||
}
|
||||
@@ -79,9 +92,9 @@ bool AssemblerSymbolModel::setData(const QModelIndex &index, const QVariant &val
|
||||
if (!assemblerSymbols) return false;
|
||||
|
||||
if (data(index, role) != value) {
|
||||
if (index.column() == 0)
|
||||
if (index.column() == 1)
|
||||
{
|
||||
assemblerSymbols->symbolRefAt(index.row()).name = value.toString();
|
||||
assemblerSymbols->symbolRefAt(index.row()).name = value.toString();
|
||||
}
|
||||
emit dataChanged(index, index, QVector<int>() << role);
|
||||
return true;
|
||||
@@ -92,7 +105,7 @@ bool AssemblerSymbolModel::setData(const QModelIndex &index, const QVariant &val
|
||||
Qt::ItemFlags AssemblerSymbolModel::flags(const QModelIndex &index) const
|
||||
{
|
||||
Q_UNUSED(index);
|
||||
if (index.column() == 0)
|
||||
if (index.column() == 1)
|
||||
return Qt::ItemIsEditable | QAbstractTableModel::flags(index);
|
||||
else
|
||||
return QAbstractTableModel::flags(index);
|
||||
@@ -108,14 +121,16 @@ bool AssemblerSymbolModel::insertRows(int row, int count, const QModelIndex &par
|
||||
bool AssemblerSymbolModel::removeRows(int row, int count, const QModelIndex &parent)
|
||||
{
|
||||
if (!assemblerSymbols) return false;
|
||||
bool success = false;
|
||||
|
||||
beginRemoveRows(parent, row, row + count - 1);
|
||||
for (int idx = 0; idx < count; idx++)
|
||||
{
|
||||
assemblerSymbols->removeSymbolAt(row);
|
||||
success = true;
|
||||
}
|
||||
endRemoveRows();
|
||||
return false;
|
||||
return success;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,10 +1,26 @@
|
||||
#include "AssemblerSymbols.h"
|
||||
|
||||
|
||||
AssemblerSymbols::AssemblerSymbols(QObject *parent) : QObject(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int AssemblerSymbols::locationOfSymbolAtAddress(quint16 address)
|
||||
{
|
||||
// Assume list m_assemblerSymbols is sorted by address (it should be)
|
||||
QListIterator<AssemblerSymbol> it(m_assemblerSymbols);
|
||||
int idx = 0;
|
||||
while (it.hasNext())
|
||||
{
|
||||
AssemblerSymbol ep = it.next();
|
||||
if (ep.address == address) return idx;
|
||||
if (ep.address > address) return -1;
|
||||
idx++;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool AssemblerSymbols::hasAssemSymbolAtAddress(quint16 address)
|
||||
{
|
||||
// Assume list m_assemblerSymbols is sorted by address (it should be)
|
||||
@@ -51,7 +67,6 @@ void AssemblerSymbols::addSymbol(AssemblerSymbol ep)
|
||||
void AssemblerSymbols::removeSymbolAt(int location)
|
||||
{
|
||||
m_assemblerSymbols.removeAt(location);
|
||||
emit symbolRemovedAt(location);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
@@ -92,6 +107,7 @@ QDataStream &operator<<(QDataStream &out, const AssemblerSymbol &model)
|
||||
{
|
||||
out << model.address;
|
||||
out << model.name;
|
||||
out << (qint32) model.symbolsize;
|
||||
return out;
|
||||
}
|
||||
|
||||
@@ -99,7 +115,9 @@ QDataStream &operator>>(QDataStream &in, AssemblerSymbol &model)
|
||||
{
|
||||
in >> model.address;
|
||||
in >> model.name;
|
||||
|
||||
qint32 size;
|
||||
in >> size;
|
||||
model.symbolsize = (SymbolSize) size;
|
||||
return in;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,11 +4,19 @@
|
||||
#include <QObject>
|
||||
#include <QDataStream>
|
||||
|
||||
typedef enum {
|
||||
SizeUnknown = 0,
|
||||
SizeByte = 1,
|
||||
SizeWord = 2
|
||||
} SymbolSize;
|
||||
|
||||
struct AssemblerSymbol {
|
||||
quint16 address;
|
||||
QString name;
|
||||
SymbolSize symbolsize;
|
||||
};
|
||||
|
||||
|
||||
class AssemblerSymbols : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -30,6 +38,7 @@ public:
|
||||
|
||||
void doTestData();
|
||||
|
||||
int locationOfSymbolAtAddress(quint16 address);
|
||||
signals:
|
||||
void symbolAdded(AssemblerSymbol &AssemblerSymbol, int location);
|
||||
void symbolAddedAt(int location);
|
||||
|
||||
@@ -17,10 +17,9 @@ void EntryPointModel::setEntryPointsData(EntryPoints *points)
|
||||
|
||||
if (entryPoints)
|
||||
{
|
||||
connect(entryPoints,SIGNAL(pointAddedAt(int)),SLOT(handlePointAddition(int)));
|
||||
connect(entryPoints,SIGNAL(pointChangedAt(int)),SLOT(handlePointChange(int)));
|
||||
connect(entryPoints,SIGNAL(pointRemovedAt(int)),SLOT(handlePointRemoval(int)));
|
||||
// insertRows(0,entryPoints->numEntryPoints());
|
||||
connect(entryPoints, &EntryPoints::pointAddedAt, this, &EntryPointModel::handlePointAddition);
|
||||
connect(entryPoints, &EntryPoints::pointChangedAt, this, &EntryPointModel::handlePointChange);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -110,15 +109,26 @@ bool EntryPointModel::insertRows(int row, int count, const QModelIndex &parent)
|
||||
|
||||
bool EntryPointModel::removeRows(int row, int count, const QModelIndex &parent)
|
||||
{
|
||||
qDebug() << __FILE__ << __LINE__;
|
||||
|
||||
if (!entryPoints) return false;
|
||||
qDebug() << __FILE__ << __LINE__;
|
||||
bool success = false;
|
||||
qDebug() << __FILE__ << __LINE__;
|
||||
|
||||
beginRemoveRows(parent, row, row + count - 1);
|
||||
qDebug() << __FILE__ << __LINE__;
|
||||
for (int idx = 0; idx < count; idx++)
|
||||
{
|
||||
qDebug() << __FILE__ << __LINE__;
|
||||
entryPoints->removePointAt(row);
|
||||
qDebug() << __FILE__ << __LINE__;
|
||||
success = true;
|
||||
}
|
||||
qDebug() << __FILE__ << __LINE__;
|
||||
endRemoveRows();
|
||||
return false;
|
||||
qDebug() << __FILE__ << __LINE__;
|
||||
return success;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -18,8 +18,7 @@ public:
|
||||
void setEntryPointsData(EntryPoints *points);
|
||||
|
||||
// Header:
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;//DONE
|
||||
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
||||
// Basic functionality:
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
@@ -43,7 +42,7 @@ public:
|
||||
|
||||
protected slots:
|
||||
void handlePointAddition(int location) { insertRows(location,1); }
|
||||
void handlePointRemoval(int location) { removeRows(location, 1); }
|
||||
// void handlePointRemoval(int location) { removeRows(location, 1); }
|
||||
void handlePointChange(int location)
|
||||
{
|
||||
QModelIndex ind = createIndex(location,0);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "EntryPoints.h"
|
||||
#include <QDebug>
|
||||
|
||||
EntryPoints::EntryPoints(QObject *parent) : QObject(parent)
|
||||
{
|
||||
@@ -51,7 +52,6 @@ void EntryPoints::addPoint(EntryPoint ep)
|
||||
void EntryPoints::removePointAt(int location)
|
||||
{
|
||||
m_entryPoints.removeAt(location);
|
||||
emit pointRemovedAt(location);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#include "binaryfilemetadata.h"
|
||||
#include "genericfile.h"
|
||||
#include <QFile>
|
||||
#include <QDataStream>
|
||||
#include <QDebug>
|
||||
|
||||
BinaryFileMetadata::BinaryFileMetadata(GenericFile *file, quint16 defaultAddress, QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
@@ -17,31 +17,49 @@ BinaryFileMetadata::BinaryFileMetadata(GenericFile *file, quint16 defaultAddress
|
||||
|
||||
void BinaryFileMetadata::load()
|
||||
{
|
||||
QFile infile(QString("%1%2").arg(m_file->filename()).arg(".bfm"));
|
||||
QFile infile(QString("%1%2%3")
|
||||
.arg(m_file->diskFile()->getMetaDataPath())
|
||||
.arg(m_file->filename())
|
||||
.arg(".bfm"));
|
||||
if (infile.open(QIODevice::ReadOnly))
|
||||
{
|
||||
qDebug() << "Loading binary file metadata from" << QString("%1%2").arg(m_file->filename()).arg(".bfm");
|
||||
qDebug() << "Loading binary file metadata from" << QString("%1%2%3")
|
||||
.arg(m_file->diskFile()->getMetaDataPath())
|
||||
.arg(m_file->filename())
|
||||
.arg(".bfm");
|
||||
QDataStream ds(&infile);
|
||||
ds >> *m_eps;
|
||||
ds >> *m_as;
|
||||
infile.close();
|
||||
}
|
||||
else qDebug() << "Cannot open " << QString("%1%2").arg(m_file->filename()).arg(".bfm") << "for reading";
|
||||
else qDebug() << "Cannot open " << QString("%1%2%3")
|
||||
.arg(m_file->diskFile()->getMetaDataPath())
|
||||
.arg(m_file->filename())
|
||||
.arg(".bfm") << "for reading";
|
||||
|
||||
}
|
||||
|
||||
void BinaryFileMetadata::save()
|
||||
{
|
||||
QFile infile(QString("%1%2").arg(m_file->filename()).arg(".bfm"));
|
||||
if (infile.open(QIODevice::WriteOnly))
|
||||
QFile outfile(QString("%1%2%3")
|
||||
.arg(m_file->diskFile()->getMetaDataPath())
|
||||
.arg(m_file->filename())
|
||||
.arg(".bfm"));
|
||||
if (outfile.open(QIODevice::WriteOnly))
|
||||
{
|
||||
qDebug() << "Saving binary file metadata to" << QString("%1%2").arg(m_file->filename()).arg(".bfm");
|
||||
QDataStream ds(&infile);
|
||||
qDebug() << "Saving binary file metadata to" << QString("%1%2%3")
|
||||
.arg(m_file->diskFile()->getMetaDataPath())
|
||||
.arg(m_file->filename())
|
||||
.arg(".bfm");
|
||||
QDataStream ds(&outfile);
|
||||
ds << *m_eps;
|
||||
ds << *m_as;
|
||||
infile.close();
|
||||
outfile.close();
|
||||
}
|
||||
else qDebug() << "Cannot open " << QString("%1%2").arg(m_file->filename()).arg(".bfm") << "for writing";
|
||||
else qDebug() << "Cannot open " << QString("%1%2%3")
|
||||
.arg(m_file->diskFile()->getMetaDataPath())
|
||||
.arg(m_file->filename())
|
||||
.arg(".bfm") << "for writing";
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user