Various Changes

This commit is contained in:
Mark Long 2017-06-29 00:21:45 -05:00
parent 30010dc1a4
commit 177ecdfea1
47 changed files with 6667 additions and 1142 deletions

View File

@ -2,6 +2,10 @@
QT += core gui printsupport
CONFIG += c++11
MOC_DIR = ./.build
UI_DIR = ./.build
OBJECTS_DIR = ./.build
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = AppleSAWS
@ -120,7 +124,8 @@ HEADERS += \
src/applesoftfile/ApplesoftRetokenizer.h \
src/util/AppleColors.h \
src/internals/JumpLineManager.h \
src/ui/widgets/FlowLineTextBrowser.h
src/ui/widgets/FlowLineTextBrowser.h \
src/ui/widgets/asciiinfodialog.h
FORMS += \
src/ui/catalogwidget.ui \
@ -134,4 +139,5 @@ FORMS += \
src/ui/viewers/viewerbase.ui \
src/ui/widgets/CharacterSetExplorer.ui \
src/ui/widgets/DisassemblerMetadataDialog.ui \
src/ui/widgets/LocationInfoDialog.ui
src/ui/widgets/LocationInfoDialog.ui \
src/ui/widgets/asciiinfodialog.ui

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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);

View File

@ -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;
}

View File

@ -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);

View File

@ -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);
}
//---------------------------------------------------------------------------

View File

@ -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";
}

View File

@ -13,8 +13,6 @@ CatalogSector::CatalogSector(Sector *data)
FileDescriptiveEntry fde = makeFDE(idx*0x23+0x0B);
if (fde.firstTSListSector != TSPair(0,0)) {
m_fdes.append(fde);
// qDebug() << "FDE #"<<idx;
// fde.dump();
}
}
}

View File

@ -4,6 +4,7 @@
#include <QDataStream>
#include <QFileInfo>
#include <QDebug>
#include <QDir>
#include "tracksectorlist.h"
#include "applesoftfile.h"
@ -29,6 +30,7 @@ DiskFile::~DiskFile()
bool DiskFile::read(QString filename)
{
m_fullImageName = filename;
m_imageName = QFileInfo(filename).fileName();
if (m_imageName.toUpper().contains(".D13"))
{
@ -132,6 +134,7 @@ GenericFile *DiskFile::getFile(FileDescriptiveEntry fde)
}
m_files[fde] = retval;
}
if (retval) { retval->setDiskFile(this); }
return retval;
}
@ -167,3 +170,12 @@ QList<FileDescriptiveEntry> DiskFile::getAllFDEs() {
return retval;
}
QString DiskFile::getMetaDataPath() const {
QString path = QString("%1.metadata/").arg(getFullDiskImageName());
QDir dir(path);
dir.mkpath(".");
return path;
}

View File

@ -11,7 +11,7 @@
#include "sector.h"
#include "vtoc.h"
#include "genericfile.h"
class GenericFile;
class DiskFile
{
@ -40,6 +40,9 @@ public:
QByteArray fileHash() const { return m_hash; }
QString getDiskImageName() const { return m_imageName; }
QString getFullDiskImageName() const { return m_fullImageName; }
QString getMetaDataPath() const;
private:
QMap< int, QMap< int, Sector> > m_contents;
@ -47,6 +50,8 @@ private:
QByteArray m_hash;
QString m_imageName;
QString m_fullImageName;
quint8 m_sectors_per_track;
};

View File

@ -2,6 +2,7 @@
GenericFile::GenericFile(QByteArray data)
{
m_diskfile = 0;
if (!data.isEmpty()) {
setData(data);
}

View File

@ -1,9 +1,12 @@
#ifndef GENERICFILE_H
#define GENERICFILE_H
#include "diskfile.h"
#include <QByteArray>
#include <QString>
class GenericFile
{
public:
@ -21,12 +24,15 @@ public:
virtual void setLength(quint16 length) { m_length = length; }
virtual quint16 length() { return m_length; }
DiskFile *diskFile() const { return m_diskfile; }
void setDiskFile(DiskFile *diskfile) { m_diskfile = diskfile; }
protected:
QByteArray m_data;
QString m_filename;
quint16 m_address;
qint16 m_length;
DiskFile * m_diskfile;
};

View File

@ -4,7 +4,7 @@ JumpLineManager::JumpLineManager(quint16 from, quint16 to)
: m_start(from),
m_end(to)
{
qDebug() << "JumpLineManager(from:"<<uint16ToHex(m_start)<<", to:"<<uint16ToHex(m_end) << ")";
//qDebug() << "JumpLineManager(from:"<<uint16ToHex(m_start)<<", to:"<<uint16ToHex(m_end) << ")";
}
@ -20,12 +20,12 @@ void JumpLineManager::addJump(quint16 src, quint16 dest, JumpType type, quint16
}
else
{
qDebug() << "JumpLineManager::addJump: Not adding duplicate jump:" << uint16ToHex(src) << "," << uint16ToHex(dest);
//qDebug() << "JumpLineManager::addJump: Not adding duplicate jump:" << uint16ToHex(src) << "," << uint16ToHex(dest);
}
}
else
{
qDebug() << "JumpLineManager::addJump: Address range is out of bounds";
// qDebug() << "JumpLineManager::addJump: Address range is out of bounds";
}
}
@ -36,7 +36,7 @@ void JumpLineManager::dumpJumps() const {
void JumpLineManager::dumpJumps(JumpMap map) const
{
qDebug() << "JumpLineManager::dumpJumps()\n JumpTable:";
//qDebug() << "JumpLineManager::dumpJumps()\n JumpTable:";
QMapIterator<TJump,JumpType> it(map);
while (it.hasNext())
{
@ -47,14 +47,14 @@ void JumpLineManager::dumpJumps(JumpMap map) const
if (it.value() == IsBranch) { jumptypelabel = "Branch"; }
if (it.value() == IsJSR) { jumptypelabel = "JSR"; }
if (it.value() == IsBRA) { jumptypelabel = "BRA"; }
qDebug() << " Jump from" << uint16ToHex(it.key().first) << "to"
<< uint16ToHex(it.key().second) << jumptypelabel;
//qDebug() << " Jump from" << uint16ToHex(it.key().first) << "to"
// << uint16ToHex(it.key().second) << jumptypelabel;
}
}
JumpLines JumpLineManager::buildJumpLines()
{
qDebug() << "A";
//qDebug() << "A";
m_channelsAtAddress.clear();
m_jumplines.m_maxChannel = 0;
@ -74,7 +74,7 @@ qDebug() << "A";
m_jumplines.jumpLines.append(jl);
m_jumplines.m_maxChannel = qMax(m_jumplines.m_maxChannel, channel);
}
qDebug() << "A";
//qDebug() << "A";
return m_jumplines;
@ -85,7 +85,7 @@ qDebug() << "A";
int JumpLineManager::findBestChannel(JumpLine &jl)
{
qDebug() << "findBestChannel()";
//qDebug() << "findBestChannel()";
if (m_jumplines.jumpLines.count() == 0)
{
return 0;
@ -95,7 +95,7 @@ int JumpLineManager::findBestChannel(JumpLine &jl)
bool foundChannel = false;
while (!foundChannel)
{
qDebug() << "Tryning potential channel" << potentialChannel;
//qDebug() << "Tryning potential channel" << potentialChannel;
bool matched = false;
for (quint16 addr = jl.min(); addr <= jl.max(); addr++)
{
@ -129,12 +129,12 @@ void JumpLineManager::setChannelForJumpLine(int channel, JumpLine &jl)
void JumpLineManager::dumpJumpLines() const
{
foreach (JumpLine jl, m_jumplines.jumpLines)
{
qDebug() << " JumpLine from:" << uint16ToHex(jl.from)
<< " to:" << uint16ToHex(jl.to)
<< "channel: " << jl.channel << " type:" << jl.type;
}
//foreach (JumpLine jl, m_jumplines.jumpLines)
// {
//qDebug() << " JumpLine from:" << uint16ToHex(jl.from)
// << " to:" << uint16ToHex(jl.to)
// << "channel: " << jl.channel << " type:" << jl.type;
// }
}
bool JumpLineManager::doJumpsIntersect(TJump &A, TJump &B) const

View File

@ -8,6 +8,7 @@
#include <QDebug>
#include <QMenu>
#include <QAction>
#include <QPalette>
CatalogWidget::CatalogWidget(QWidget *parent) :
QWidget(parent),
@ -15,9 +16,11 @@ CatalogWidget::CatalogWidget(QWidget *parent) :
{
ui->setupUi(this);
ui->catalog_list->setFont(QFont("monospace"));
ui->noteButton->setText(QChar(0x270d));
ui->noteButton->setFont(QFont("sans",16,QFont::Bold));
connect(ui->catalog_list, SIGNAL(itemDoubleClicked(QListWidgetItem*)),
SLOT(itemDoubleClicked(QListWidgetItem*)));
connect(ui->catalog_list, &QListWidget::itemDoubleClicked,
this, &CatalogWidget::itemDoubleClicked);
}
CatalogWidget::~CatalogWidget()
@ -86,6 +89,17 @@ void CatalogWidget::processNewlyLoadedDisk(QString diskfilename, DiskFile *disk)
QString sizeStr = QString("%1").arg(size,5,10,QChar(' ')).toUpper();
QString text = QString("%1 %2 %3 %4").arg(locked?"*":" ").arg(sizeStr).arg(filetype).arg(filename);
QListWidgetItem *item = new QListWidgetItem(text);
if (filetype == "A") { item->setForeground(Qt::blue); }
else if (filetype == "I") { item->setForeground(Qt::darkYellow); }
else if (filetype == "B") { item->setForeground(Qt::darkGreen); }
else if (filetype == "T") { item->setForeground(Qt::red); }
else if (filetype == "R") { item->setForeground(Qt::darkRed); }
else if (filetype == "S") { item->setForeground(Qt::magenta); }
else if (filetype == "a") { item->setForeground(Qt::darkBlue); }
else if (filetype == "b") { item->setForeground(Qt::darkMagenta); }
else { item->setForeground(Qt::black); }
item->setToolTip(createToolTip(fde));
item->setData(0x0100,idx);
ui->catalog_list->addItem(item);
@ -95,6 +109,20 @@ void CatalogWidget::processNewlyLoadedDisk(QString diskfilename, DiskFile *disk)
}
idx++;
}
// QFont italfont = ui->catalog_list->font();
// italfont.setItalic(true);
// QListWidgetItem *item = new QListWidgetItem("Boot Sector");
// item->setForeground(Qt::black);
// item->setFont(italfont);
// item->setData(0x0100,-1);
// ui->catalog_list->addItem(item);
// item = new QListWidgetItem("DOS Image");
// item->setForeground(Qt::black);
// item->setFont(italfont);
// item->setData(0x0100,-2);
// ui->catalog_list->addItem(item);
ui->catalog_list->resize(maxrect.width(),ui->catalog_list->size().height());
}
}
@ -111,9 +139,23 @@ void CatalogWidget::unloadDisk(DiskFile *disk)
void CatalogWidget::itemDoubleClicked(QListWidgetItem *item)
{
int idx = item->data(0x0100).toInt();
FileDescriptiveEntry fde = m_disk->getAllFDEs()[idx];
if (idx >= 0)
{
FileDescriptiveEntry fde = m_disk->getAllFDEs()[idx];
// qDebug() << "Default File " << AppleString(fde.filename).printable().trimmed();
emit openWithDefaultViewer(m_disk,fde);
emit openWithDefaultViewer(m_disk,fde);
}
else
{
if (idx == -1) // Boot Sector
{
}
else if (idx == -2) // DOS Image
{
}
}
}
void CatalogWidget::itemClicked(QListWidgetItem *item)

View File

@ -32,22 +32,71 @@
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<property name="spacing">
<number>2</number>
</property>
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>2</number>
</property>
<item>
<widget class="QLabel" name="volume_label">
<property name="text">
<string/>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>4</number>
</property>
</widget>
<item>
<widget class="QLabel" name="volume_label">
<property name="font">
<font>
<family>Sans Serif</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="noteButton">
<property name="font">
<font>
<family>Sans Serif</family>
</font>
</property>
<property name="toolTip">
<string>Notes for image.</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="catalog_list"/>
</item>
<item>
<widget class="QLabel" name="file_label">
<property name="text">
<string/>
<widget class="QListWidget" name="catalog_list">
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionRectVisible">
<bool>false</bool>
</property>
</widget>
</item>

View File

@ -29,8 +29,6 @@ DiskExplorer::~DiskExplorer()
void DiskExplorer::initUi()
{
QMenuBar *menuBar = new QMenuBar(this);
setMenuBar(menuBar);
QMenu *menu = new QMenu(tr("&File"),this);
@ -38,18 +36,23 @@ void DiskExplorer::initUi()
QAction *action_Load_Disk_Image = new QAction(tr("&Load Disk Image..."),this);
menu->addAction(action_Load_Disk_Image);
connect(action_Load_Disk_Image, SIGNAL(triggered()), SLOT(showLoadDialog()));
connect(action_Load_Disk_Image, &QAction::triggered,
this, &DiskExplorer::showLoadDialog);
m_action_Unload_Disk_Image = new QAction(tr("&Unload Disk Image"),this);
m_action_Unload_Disk_Image->setEnabled(false);
menu->addAction(m_action_Unload_Disk_Image);
connect(m_action_Unload_Disk_Image, SIGNAL(triggered()), SLOT(unloadDiskFile()));
connect(m_action_Unload_Disk_Image, &QAction::triggered,
this, &DiskExplorer::unloadDiskFile);
menu->addSeparator();
QAction *action_Quit = new QAction(tr("&Quit"),this);
menu->addAction(action_Quit);
connect(action_Quit, SIGNAL(triggered()), qApp, SLOT(quit()));
connect(action_Quit, &QAction::triggered, qApp, &QApplication::quit);
menu = new QMenu(tr("&Util"),this);
menuBar->addMenu(menu);
@ -62,8 +65,9 @@ void DiskExplorer::initUi()
m_setDiskToolsVisibleAction = new QAction(tr("Show &Disk tools"),this);
m_setDiskToolsVisibleAction->setCheckable(true);
m_setDiskToolsVisibleAction->setChecked(false);
connect(m_setDiskToolsVisibleAction, SIGNAL(toggled(bool)),
SLOT(setDiskToolsVisible(bool)));
connect(m_setDiskToolsVisibleAction, &QAction::triggered, this, &DiskExplorer::setDiskToolsVisible);
menu->addAction(m_setDiskToolsVisibleAction);
@ -72,13 +76,17 @@ void DiskExplorer::initUi()
QAction *action_HRCG_Commands = new QAction(tr("&HRCG Commands..."),this);
menu->addAction(action_HRCG_Commands);
m_hrcgDialog = new HRCGControlsInfo(this);
connect(action_HRCG_Commands, SIGNAL(triggered()), m_hrcgDialog, SLOT(show()));
connect(action_HRCG_Commands, &QAction::triggered, m_hrcgDialog, &HRCGControlsInfo::show);
m_hexConverter = new HexConverter(this);
connect(action_Hex_Converter, SIGNAL(triggered()), m_hexConverter, SLOT(show()));
connect(action_Hex_Converter, &QAction::triggered, m_hexConverter, &HexConverter::show);
QAction *action_Ascii_Info = new QAction(tr("&ASCII Table..."),this);
menu->addAction(action_Ascii_Info);
m_AsciiInfoDialog = new AsciiInfoDialog(this);
connect(action_Ascii_Info, &QAction::triggered, m_AsciiInfoDialog, &AsciiInfoDialog::show);
QWidget *widget = new QWidget(0);
m_gridLayout = new QGridLayout();
@ -106,12 +114,10 @@ void DiskExplorer::initUi()
m_gridLayout->addWidget(m_frame,1,2);
this->setCentralWidget(widget);
connect(m_cw,SIGNAL(openWithDefaultViewer(DiskFile*,FileDescriptiveEntry)),
SLOT(handleDiskItemSelectedDefaultOpen(DiskFile*,FileDescriptiveEntry)));
connect(m_demw, SIGNAL(showSectorData(QByteArray,int,int,QVariant)),
SLOT(handleShowSectorData(QByteArray,int,int,QVariant)));
connect(m_cw, &CatalogWidget::openWithDefaultViewer,
this, &DiskExplorer::handleDiskItemSelectedDefaultOpen);
connect(m_demw, &DiskExplorerMapWidget::showSectorData,
this, &DiskExplorer::handleShowSectorData);
QStatusBar *statusBar = new QStatusBar(this);
setStatusBar(statusBar);
@ -119,7 +125,6 @@ void DiskExplorer::initUi()
m_demwStatusWidget = m_demw->getStatusWidget();
statusBar->addPermanentWidget(m_demwStatusWidget);
setDiskToolsVisible(false);
}
@ -184,7 +189,9 @@ void DiskExplorer::handleDiskItemSelectedDefaultOpen(DiskFile *disk, FileDescrip
ViewerBase *vb = new ViewerBase();
qDebug() << "Adding viewer" << vb;
m_viewerList.append(vb);
connect(vb,SIGNAL(viewerClosing(ViewerBase*)), SLOT(handleViewerClosing(ViewerBase*)));
connect(vb,&ViewerBase::viewerClosing,
this, &DiskExplorer::handleViewerClosing);
vb->setFile(file);
vb->show();
}

View File

@ -10,6 +10,7 @@
#include "hexconverter.h"
#include "hexdumpviewer.h"
#include "viewerbase.h"
#include "asciiinfodialog.h"
#include <QFrame>
#include <QTimer>
@ -66,6 +67,7 @@ private:
HRCGControlsInfo *m_hrcgDialog;
HexConverter *m_hexConverter;
AsciiInfoDialog *m_AsciiInfoDialog;
QAction *m_action_Unload_Disk_Image;

View File

@ -56,7 +56,7 @@ DiskExplorerMapWidget::DiskExplorerMapWidget(int numtracks, int numsectors, QWid
tb->setBgColor(m_defaultColor);
tb->setCheckable(true);
m_bgroup->addButton(tb,(track * numsectors) + sec);
connect(tb,SIGNAL(checked(int,int,bool)),SLOT(handleButtonCheck(int,int,bool)));
connect(tb, &DEButton::checked, this, &DiskExplorerMapWidget::handleButtonCheck);
m_buttons[track][sec] = tb;
tb->setAutoFillBackground(true);
@ -315,7 +315,7 @@ void DiskExplorerMapWidget::mapDiskToButtons()
tslcount++;
buttonAt(tsltr,tslse)->setBgColor(m_tsListColor);
buttonAt(tsltr,tslse)->setText(QString("%1").arg(idx));
qDebug() << "Button" << idx << "=" << tsltr << "," << tslse << " " << fde.filename.printable() << "TSL";
//qDebug() << "Button" << idx << "=" << tsltr << "," << tslse << " " << fde.filename.printable() << "TSL";
QString description = QString("T/S List #%1 for %2").arg(tslcount).arg(fde.filename.printable());
m_sectorDescriptions.insert(DETSPair(tsltr,tslse),description);
@ -346,7 +346,7 @@ void DiskExplorerMapWidget::mapDiskToButtons()
else qDebug() << "Unknown file type: " << fde.fileType();
buttonAt(tr,se)->setBgColor(color);
setButtonText(tr,se,QString("%1").arg(idx));
qDebug() << "Button" << idx << "=" << tr << "," << se << " " << fde.filename.printable();
//qDebug() << "Button" << idx << "=" << tr << "," << se << " " << fde.filename.printable();
// fde.dump();
idx++;
}

View File

@ -21,7 +21,7 @@ public:
{
setTrack(track);
setSector(sec);
connect(this,SIGNAL(clicked(bool)),SLOT(handleClick(bool)));
connect(this, &DEButton::clicked, this, &DEButton::handleClick);
m_isHighlighted = false;
}
void setTrack(int track) { m_track = track; }

View File

@ -7,16 +7,20 @@
#include <QTableWidgetItem>
ApplesoftFileDetailViewer::ApplesoftFileDetailViewer(QWidget *parent) :
ApplesoftFileDetailViewer::ApplesoftFileDetailViewer(ApplesoftFile *file, QWidget *parent) :
QWidget(parent),
ui(new Ui::ApplesoftFileDetailViewer)
{
ui->setupUi(this);
ui->m_varView->setSortingEnabled(true);
m_file = file;
load();
setLineData(m_file->getLines());
}
ApplesoftFileDetailViewer::~ApplesoftFileDetailViewer()
{
save();
delete ui;
}
@ -26,10 +30,64 @@ void ApplesoftFileDetailViewer::setLineData(QVector<ApplesoftLine> lineData)
process();
}
bool ApplesoftFileDetailViewer::save()
{
if (ui->gridLayout->rowCount() == 0) { return false; }
QMap <QString,QString> map;
for (int idx = 0; idx < ui->m_varView->rowCount(); idx++)
{
QString var = ui->m_varView->item(idx,1)->text();
if (var.contains(","))
{
var.truncate(var.indexOf(","));
}
var = var.trimmed();
QString note = ui->m_varView->item(idx,2)->text().trimmed();
if (note.length())
{
map.insert(var,note);
}
}
QFile outfile(QString("%1%2%3")
.arg(m_file->diskFile()->getMetaDataPath())
.arg(m_file->filename())
.arg(".asvar"));
if (outfile.open(QIODevice::WriteOnly))
{
QDataStream ds(&outfile);
ds << map;
outfile.close();
return true;
}
return false;
}
bool ApplesoftFileDetailViewer::load()
{
QFile infile(QString("%1%2%3")
.arg(m_file->diskFile()->getMetaDataPath())
.arg(m_file->filename())
.arg(".asvar"));
if (infile.open(QIODevice::ReadOnly))
{
QDataStream ds(&infile);
ds >> m_notes;
infile.close();
return true;
}
return false;
}
void ApplesoftFileDetailViewer::process()
{
QMap<QString,QStringList> vardata;
QMap<QString,quint16> vartypes;
QMap<QString,QStringList> varalias;
foreach (ApplesoftLine line, m_lines)
{
@ -45,9 +103,16 @@ void ApplesoftFileDetailViewer::process()
tid == ApplesoftToken::StringAryVarTokenVal)
{
QString varname = token.getStringValue();
QString fullname = varname;
varname = shortenName(varname);
if (varname.contains("(")) { varname.append(")"); }
if (fullname.contains("(")) { fullname.append(")"); }
vardata[varname].append(QString("%1").arg(linenum));
vartypes[varname] = tid;
if (fullname != varname)
{
varalias[varname].append(fullname);
}
}
}
}
@ -78,11 +143,23 @@ void ApplesoftFileDetailViewer::process()
twi->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
ui->m_varView->setItem(idx,0,twi);
twi = new QTableWidgetItem(key);
QString keywithalias = key;
if (varalias.contains(key))
{
varalias[key].removeDuplicates();
QString aliases = varalias[key].join(", ");
keywithalias.append(", ");
keywithalias.append(aliases);
}
twi = new QTableWidgetItem(keywithalias);
twi->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
ui->m_varView->setItem(idx,1,twi);
twi = new QTableWidgetItem(" ");
if (m_notes.contains(key))
{
twi->setText(m_notes[key]);
}
twi->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
ui->m_varView->setItem(idx,2,twi);
@ -98,3 +175,22 @@ void ApplesoftFileDetailViewer::process()
ui->m_varView->resizeColumnToContents(2);
}
QString ApplesoftFileDetailViewer::shortenName(QString name)
{
bool hasParen = name.contains('(');
if (hasParen) { name.remove(name.indexOf('('),1); }
bool hasDollar = name.contains('$');
if (hasDollar) { name.remove(name.indexOf('$'),1); }
bool hasPercent = name.contains('%');
if (hasPercent) { name.remove(name.indexOf('%'),1); }
name = name.left(2);
if (hasDollar) { name.append("$"); }
if (hasPercent) { name.append("%"); }
if (hasParen) { name.append("("); }
return name;
}

View File

@ -4,6 +4,7 @@
#include <QWidget>
#include "applesoftline.h"
#include "applesofttoken.h"
#include "applesoftfile.h"
#include <QDebug>
namespace Ui {
@ -15,16 +16,26 @@ class ApplesoftFileDetailViewer : public QWidget
Q_OBJECT
public:
explicit ApplesoftFileDetailViewer(QWidget *parent = 0);
explicit ApplesoftFileDetailViewer(ApplesoftFile *file, QWidget *parent = 0);
~ApplesoftFileDetailViewer();
void setLineData(QVector<ApplesoftLine> lineData);
void foo() { qDebug() << "AFDV::foo!"; }
bool save();
bool load();
protected:
QString shortenName(QString name);
private:
void process();
Ui::ApplesoftFileDetailViewer *ui;
QVector<ApplesoftLine> m_lines;
QMap<QString,QString> m_notes;
ApplesoftFile *m_file;
};
#endif // APPLESOFTFILEDETAILVIEWER_H

View File

@ -22,7 +22,7 @@ ApplesoftFileViewer::ApplesoftFileViewer(QWidget *parent) :
m_formatter = new ApplesoftFormatter(this);
m_formatter->setFlags(ApplesoftFormatter::ShowCtrlChars);
connect(ui->findButton,SIGNAL(clicked(bool)), SLOT(findText()));
connect(ui->findButton, &QToolButton::clicked, this, &ApplesoftFileViewer::findText);
m_isFirstFind = true;
ui->textArea->setUndoRedoEnabled(false);
ui->textArea->setUndoRedoEnabled(true);
@ -46,11 +46,11 @@ ApplesoftFileViewer::ApplesoftFileViewer(QWidget *parent) :
ApplesoftFileViewer::~ApplesoftFileViewer()
{
delete ui;
if (m_afdv)
{ m_afdv->foo();
delete m_afdv;
{
m_afdv->deleteLater();
}
delete ui;
}
bool ApplesoftFileViewer::makeMenuOptions(QMenu *menu)
@ -63,8 +63,11 @@ bool ApplesoftFileViewer::makeMenuOptions(QMenu *menu)
m_showIntsAction->setCheckable(true);
m_showIntsAction->setChecked(settings.value("ASViewer.intsAsHex",false).toBool());
setIntsAsHex(settings.value("ASViewer.intsAsHex",false).toBool(),NoReformat);
connect(m_showIntsAction, SIGNAL(toggled(bool)), ui->findText,SLOT(clear()));
connect(m_showIntsAction, SIGNAL(toggled(bool)),SLOT(setIntsAsHex(bool)));
connect(m_showIntsAction, &QAction::toggled, ui->findText, &QLineEdit::clear);
connect(m_showIntsAction, &QAction::toggled,
this, static_cast< void (ApplesoftFileViewer::*)(bool)>(&ApplesoftFileViewer::setIntsAsHex));
}
menu->addAction(m_showIntsAction);
@ -74,8 +77,11 @@ bool ApplesoftFileViewer::makeMenuOptions(QMenu *menu)
m_reindentCodeAction->setCheckable(true);
m_reindentCodeAction->setChecked(settings.value("ASViewer.indentCode",false).toBool());
setIndentCode(settings.value("ASViewer.indentCode",false).toBool(),NoReformat);
connect(m_reindentCodeAction, SIGNAL(toggled(bool)), ui->findText,SLOT(clear()));
connect(m_reindentCodeAction, SIGNAL(toggled(bool)),SLOT(setIndentCode(bool)));
connect(m_reindentCodeAction, &QAction::toggled, ui->findText, &QLineEdit::clear);
connect(m_reindentCodeAction, &QAction::toggled,
this, static_cast< void (ApplesoftFileViewer::*)(bool)>(&ApplesoftFileViewer::setIndentCode));
}
menu->addAction(m_reindentCodeAction);
@ -85,8 +91,10 @@ bool ApplesoftFileViewer::makeMenuOptions(QMenu *menu)
m_blankAfterReturnsAction->setCheckable(true);
m_blankAfterReturnsAction->setChecked(settings.value("ASViewer.breakAfterReturn",false).toBool());
setIndentCode(settings.value("ASViewer.breakAfterReturn",false).toBool(),NoReformat);
connect(m_blankAfterReturnsAction, SIGNAL(toggled(bool)), ui->findText,SLOT(clear()));
connect(m_blankAfterReturnsAction, SIGNAL(toggled(bool)),SLOT(setBreakAfterReturn(bool)));
connect(m_blankAfterReturnsAction, &QAction::toggled, ui->findText, &QLineEdit::clear);
connect(m_blankAfterReturnsAction, &QAction::toggled,
this, static_cast< void (ApplesoftFileViewer::*)(bool)>(&ApplesoftFileViewer::setBreakAfterReturn));
}
menu->addAction(m_blankAfterReturnsAction);
@ -96,8 +104,10 @@ bool ApplesoftFileViewer::makeMenuOptions(QMenu *menu)
m_showCtrlCharsAction->setCheckable(true);
m_showCtrlCharsAction->setChecked(settings.value("ASViewer.showCtrlChars",false).toBool());
setIndentCode(settings.value("ASViewer.showCtrlChars",false).toBool(),NoReformat);
connect(m_showCtrlCharsAction, SIGNAL(toggled(bool)), ui->findText,SLOT(clear()));
connect(m_showCtrlCharsAction, SIGNAL(toggled(bool)),SLOT(setShowCtrlChars(bool)));
connect(m_showCtrlCharsAction, &QAction::toggled, ui->findText, &QLineEdit::clear);
connect(m_showCtrlCharsAction, &QAction::toggled,
this, static_cast<void (ApplesoftFileViewer::*)(bool)>(&ApplesoftFileViewer::setShowCtrlChars));
}
menu->addAction(m_showCtrlCharsAction);
@ -110,7 +120,7 @@ bool ApplesoftFileViewer::makeMenuOptions(QMenu *menu)
m_wordWrapAction->setCheckable(true);
m_wordWrapAction->setChecked(settings.value("ASViewer.WordWrap",true).toBool());
toggleWordWrap(settings.value("ASViewer.WordWrap",true).toBool());
connect(m_wordWrapAction, SIGNAL(toggled(bool)), SLOT(toggleWordWrap(bool)));
connect(m_wordWrapAction, &QAction::triggered, this, &ApplesoftFileViewer::toggleWordWrap);
}
menu->addAction(m_wordWrapAction);
@ -120,8 +130,10 @@ bool ApplesoftFileViewer::makeMenuOptions(QMenu *menu)
m_syntaxHighlightingAction->setCheckable(true);
m_syntaxHighlightingAction->setChecked(settings.value("ASViewer.syntaxHighlighting",false).toBool());
setIndentCode(settings.value("ASViewer.syntaxHighlighting",false).toBool(),NoReformat);
connect(m_syntaxHighlightingAction, SIGNAL(toggled(bool)), ui->findText,SLOT(clear()));
connect(m_syntaxHighlightingAction, SIGNAL(toggled(bool)),SLOT(setSyntaxHighlighting(bool)));
connect(m_syntaxHighlightingAction, &QAction::toggled, ui->findText, &QLineEdit::clear);
connect(m_syntaxHighlightingAction, &QAction::toggled,
this, static_cast<void (ApplesoftFileViewer::*)(bool)>(&ApplesoftFileViewer::setSyntaxHighlighting));
}
menu->addAction(m_syntaxHighlightingAction);