Added preliminary Applesoft Variable Viewer tool

This commit is contained in:
Mark Long 2016-10-12 17:52:13 -05:00
parent 6125c0523c
commit c5d1c575e1
10 changed files with 159 additions and 10 deletions

View File

@ -36,7 +36,6 @@ SOURCES += \
src/applesoftfile/applesoftfile.cxx \
src/applesoftfile/applesofttoken.cxx \
src/applesoftfile/applesoftformatter.cxx \
src/applesoftfile/applesoftline.cpp \
src/binaryfile/disassembler.cxx \
src/binaryfile/binaryfile.cxx \
src/textfile/textfile.cxx \
@ -53,7 +52,8 @@ SOURCES += \
src/relocatablefile/relocatablefile.cxx \
src/binaryfile/binaryfilemetadata.cpp \
src/util/charset.cpp \
src/ui/widgets/characterwidget.cpp
src/ui/widgets/characterwidget.cpp \
src/ui/viewers/applesoftfiledetailviewer.cpp
HEADERS += \
@ -86,7 +86,8 @@ HEADERS += \
src/binaryfile/binaryfilemetadata.h \
src/ui/widgets/characterwidget.h \
src/util/charset.h \
src/ui/viewers/charsetviewer.h
src/ui/viewers/charsetviewer.h \
src/ui/viewers/applesoftfiledetailviewer.h
FORMS += \
src/ui/catalogwidget.ui \
@ -94,4 +95,5 @@ FORMS += \
src/ui/viewers/applesoftfileviewer.ui \
src/ui/viewers/disassemblerviewer.ui \
src/ui/viewers/hexdumpviewer.ui \
src/ui/viewers/texthexdumpviewer.ui
src/ui/viewers/texthexdumpviewer.ui \
src/ui/viewers/applesoftfiledetailviewer.ui

View File

@ -22,7 +22,6 @@ void ApplesoftFile::setData(QByteArray data)
quint8 addhi = m_data.at(1);
m_length = addlo + (addhi * 256);
m_data.remove(0,2);
// m_data = m_data.left(m_length);
parse();
}

View File

@ -1,2 +0,0 @@
#include "applesoftline.h"

View File

@ -106,8 +106,6 @@ QString ApplesoftToken::getHtmlPrintableString()
if (getTokenId() == ApplesoftToken::IntegerTokenVal || getTokenId() == ApplesoftToken::FloatAryVarTokenVal)
return QString("<font color=\"blue\">%1</font>").arg(baseval);
return QString("<font color=\"orange\">%1</font>").arg(baseval);
}

View File

@ -0,0 +1,56 @@
#include "applesoftfiledetailviewer.h"
#include "ui_applesoftfiledetailviewer.h"
#include <QMap>
#include <QString>
#include <QStringList>
ApplesoftFileDetailViewer::ApplesoftFileDetailViewer(QWidget *parent) :
QWidget(parent),
ui(new Ui::ApplesoftFileDetailViewer)
{
ui->setupUi(this);
}
ApplesoftFileDetailViewer::~ApplesoftFileDetailViewer()
{
delete ui;
}
void ApplesoftFileDetailViewer::process()
{
QMap<QString,QStringList> vardata;
foreach (ApplesoftLine line, m_lines)
{
quint16 linenum = line.linenum;
foreach(ApplesoftToken token, line.tokens)
{
quint16 tid = token.getTokenId();
if (tid == ApplesoftToken::IntVarTokenVal ||
tid == ApplesoftToken::IntAryVarTokenVal ||
tid == ApplesoftToken::FloatVarTokenVal ||
tid == ApplesoftToken::FloatAryVarTokenVal ||
tid == ApplesoftToken::StringVarTokenVal ||
tid == ApplesoftToken::StringAryVarTokenVal)
{
QString varname = token.getStringValue();
if (varname.contains("(")) { varname.append(")"); }
vardata[varname].append(QString("%1").arg(linenum));
}
}
}
QStringList keys = vardata.keys();
ui->m_varView->setRowCount(keys.count());
qSort(keys);
int idx = 0;
foreach (QString key, keys)
{
QString linenums = vardata[key].join(",");
ui->m_varView->setItem(idx,1,new QTableWidgetItem(key));
ui->m_varView->setItem(idx,2,new QTableWidgetItem(linenums));
idx++;
}
}

View File

@ -0,0 +1,29 @@
#ifndef APPLESOFTFILEDETAILVIEWER_H
#define APPLESOFTFILEDETAILVIEWER_H
#include <QWidget>
#include "applesoftline.h"
#include "applesofttoken.h"
namespace Ui {
class ApplesoftFileDetailViewer;
}
class ApplesoftFileDetailViewer : public QWidget
{
Q_OBJECT
public:
explicit ApplesoftFileDetailViewer(QWidget *parent = 0);
~ApplesoftFileDetailViewer();
void setLineData(QVector<ApplesoftLine> lineData) { m_lines = lineData; process(); }
private:
void process();
Ui::ApplesoftFileDetailViewer *ui;
QVector<ApplesoftLine> m_lines;
};
#endif // APPLESOFTFILEDETAILVIEWER_H

View File

@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ApplesoftFileDetailViewer</class>
<widget class="QWidget" name="ApplesoftFileDetailViewer">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>607</width>
<height>389</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QTableWidget" name="m_varView">
<attribute name="horizontalHeaderVisible">
<bool>true</bool>
</attribute>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
<column>
<property name="text">
<string>Type</string>
</property>
</column>
<column>
<property name="text">
<string>Variable</string>
</property>
</column>
<column>
<property name="text">
<string>Lines</string>
</property>
</column>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -1,6 +1,7 @@
#include "applesoftfileviewer.h"
#include "ui_applesoftfileviewer.h"
#include "applesoftformatter.h"
#include "applesoftfiledetailviewer.h"
#include <QDebug>
ApplesoftFileViewer::ApplesoftFileViewer(QWidget *parent) :
@ -19,6 +20,8 @@ ApplesoftFileViewer::ApplesoftFileViewer(QWidget *parent) :
ui->textArea->setUndoRedoEnabled(false);
ui->textArea->setUndoRedoEnabled(true);
connect(ui->varBrowserButton, SIGNAL(clicked(bool)), SLOT(launchVarBrowser()));
}
ApplesoftFileViewer::~ApplesoftFileViewer()
@ -46,6 +49,14 @@ void ApplesoftFileViewer::setText(QString text)
ui->textArea->setHtml(text);
}
void ApplesoftFileViewer::launchVarBrowser()
{
ApplesoftFileDetailViewer *afdv = new ApplesoftFileDetailViewer();
afdv->setLineData(m_file->getLines());
afdv->show();
}
void ApplesoftFileViewer::findText()
{
QString searchString = ui->findText->text();

View File

@ -26,6 +26,9 @@ public slots:
void findText();
protected slots:
void launchVarBrowser();
private:
ApplesoftFile *m_file;
ApplesoftFormatter *m_formatter;

View File

@ -21,7 +21,7 @@
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="1,1">
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="1,1,0">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
@ -47,6 +47,13 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="varBrowserButton">
<property name="text">
<string>Var Broswer</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">