mirror of
https://github.com/markdavidlong/AppleSAWS.git
synced 2024-11-22 00:31:04 +00:00
Added HiresViewWidget, removed MDI stuff
This commit is contained in:
parent
80d4a47d9d
commit
1c6ae0358e
@ -21,7 +21,8 @@ SOURCES += src/main.cpp \
|
||||
src/disassembler.cxx \
|
||||
src/binaryfile.cxx \
|
||||
src/catalogwidget.cxx \
|
||||
src/mainwindow.cxx
|
||||
src/mainwindow.cxx \
|
||||
src/hiresviewwidget.cxx
|
||||
|
||||
HEADERS += \
|
||||
src/diskfile.h \
|
||||
@ -37,7 +38,8 @@ HEADERS += \
|
||||
src/disassembler.h \
|
||||
src/binaryfile.h \
|
||||
src/catalogwidget.h \
|
||||
src/mainwindow.h
|
||||
src/mainwindow.h \
|
||||
src/hiresviewwidget.h
|
||||
|
||||
FORMS += \
|
||||
src/catalogwidget.ui \
|
||||
|
@ -10,6 +10,9 @@ CatalogWidget::CatalogWidget(QWidget *parent) :
|
||||
ui->setupUi(this);
|
||||
ui->catalog_list->setFont(QFont("monospace"));
|
||||
|
||||
connect(ui->catalog_list, SIGNAL(itemDoubleClicked(QListWidgetItem*)),
|
||||
SLOT(itemClicked(QListWidgetItem*)));
|
||||
|
||||
}
|
||||
|
||||
CatalogWidget::~CatalogWidget()
|
||||
@ -31,18 +34,22 @@ void CatalogWidget::processNewlyLoadedDisk(QString diskfilename, DiskFile *disk)
|
||||
QFontMetrics *fm = new QFontMetrics(ui->catalog_list->font());
|
||||
QRect maxrect;
|
||||
ui->volume_label->setText(shortfilename);
|
||||
int idx = 0;
|
||||
foreach(FileDescriptiveEntry fde, m_disk->getAllFDEs()) {
|
||||
QString filetype = fde.fileType();
|
||||
QString filename = AppleString(fde.filename).printable().simplified();
|
||||
QString filename = AppleString(fde.filename).printable().trimmed();
|
||||
int size = fde.lengthInSectors;
|
||||
bool locked = fde.isLocked();
|
||||
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);
|
||||
ui->catalog_list->addItem(new QListWidgetItem(text));
|
||||
QListWidgetItem *item = new QListWidgetItem(text);
|
||||
item->setData(0x0100,idx);
|
||||
ui->catalog_list->addItem(item);
|
||||
QRect rect = fm->boundingRect(text);
|
||||
if (rect.width() > maxrect.width()) {
|
||||
maxrect = rect;
|
||||
}
|
||||
idx++;
|
||||
}
|
||||
ui->catalog_list->resize(maxrect.width(),ui->catalog_list->size().height());
|
||||
|
||||
@ -58,4 +65,12 @@ void CatalogWidget::unloadDisk(DiskFile *disk)
|
||||
ui->volume_label->clear();
|
||||
}
|
||||
|
||||
void CatalogWidget::itemClicked(QListWidgetItem *item)
|
||||
{
|
||||
int idx = item->data(0x0100).toInt();
|
||||
FileDescriptiveEntry fde = m_disk->getAllFDEs()[idx];
|
||||
qDebug() << "File " << AppleString(fde.filename).printable().trimmed();
|
||||
emit itemSelected(m_disk,fde);
|
||||
}
|
||||
|
||||
|
||||
|
@ -2,6 +2,8 @@
|
||||
#define CATALOGWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QListWidgetItem>
|
||||
|
||||
|
||||
#include "diskfile.h"
|
||||
|
||||
@ -25,6 +27,10 @@ public slots:
|
||||
|
||||
signals:
|
||||
void newFileSelected(FileDescriptiveEntry *entry);
|
||||
void itemSelected(DiskFile *disk, FileDescriptiveEntry fde);
|
||||
|
||||
private slots:
|
||||
void itemClicked(QListWidgetItem *item);
|
||||
|
||||
private:
|
||||
|
||||
|
128
src/hiresviewwidget.cxx
Normal file
128
src/hiresviewwidget.cxx
Normal file
@ -0,0 +1,128 @@
|
||||
#include "hiresviewwidget.h"
|
||||
#include <QPainter>
|
||||
#include <QMap>
|
||||
#include <QDebug>
|
||||
#include <QResizeEvent>
|
||||
|
||||
HiresViewWidget::HiresViewWidget(QWidget *parent) :
|
||||
QWidget(parent)
|
||||
{
|
||||
if (m_rowTable == 0) { makeOffsetTable(); }
|
||||
|
||||
qDebug() << "ctor";
|
||||
m_pixmap = QPixmap(280,192);
|
||||
qDebug() << "Pixmap size: " << m_pixmap.size();
|
||||
QPainter painter(&m_pixmap);
|
||||
painter.setBrush(Qt::black);
|
||||
painter.drawRect(0,0,this->width(),this->height());
|
||||
}
|
||||
|
||||
void HiresViewWidget::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
qDebug() << "paintEvent";
|
||||
|
||||
// if (m_pixmap.size() != this->size()) {
|
||||
// m_pixmap = m_pixmap.scaled(this->size(),Qt::KeepAspectRatio);
|
||||
// }
|
||||
QPainter painter(this);
|
||||
|
||||
QPixmap tmppixmap = m_pixmap;
|
||||
tmppixmap = tmppixmap.scaled(this->size(), Qt::KeepAspectRatio);
|
||||
|
||||
painter.drawPixmap(0,0,tmppixmap);
|
||||
}
|
||||
|
||||
void HiresViewWidget::resizeEvent(QResizeEvent *)
|
||||
{
|
||||
qDebug() << "resizeEvent";
|
||||
|
||||
}
|
||||
|
||||
void HiresViewWidget::setData(QByteArray data) {
|
||||
qDebug() << "setData";
|
||||
m_data = data;
|
||||
QPainter pmpainter(&m_pixmap);
|
||||
pmpainter.setPen(Qt::white);
|
||||
pmpainter.setBrush(Qt::white);
|
||||
|
||||
for (int idx = 0; idx < m_data.size() ; idx++) {
|
||||
int rowcol = findRowCol(idx);
|
||||
|
||||
quint8 byte = m_data[idx];
|
||||
|
||||
// qDebug() << "idx: " << idx << (rowcol / 1000) << (rowcol % 1000);
|
||||
int xoff = (rowcol / 10000) * 7;
|
||||
int yoff = (rowcol % 10000);
|
||||
|
||||
if (byte & 0x01) { pmpainter.drawPoint(xoff+0,yoff); }
|
||||
if (byte & 0x02) { pmpainter.drawPoint(xoff+1,yoff); }
|
||||
if (byte & 0x04) { pmpainter.drawPoint(xoff+2,yoff); }
|
||||
if (byte & 0x08) { pmpainter.drawPoint(xoff+3,yoff); }
|
||||
if (byte & 0x10) { pmpainter.drawPoint(xoff+4,yoff); }
|
||||
if (byte & 0x20) { pmpainter.drawPoint(xoff+5,yoff); }
|
||||
if (byte & 0x40) { pmpainter.drawPoint(xoff+6,yoff); }
|
||||
|
||||
if (idx >= (280*192)) break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int HiresViewWidget::findRowCol(int offset) {
|
||||
int retval = 0;
|
||||
|
||||
retval = (*m_rowTable)[offset];
|
||||
|
||||
// qDebug() << offset << " = " << row << col << retval;
|
||||
return retval;
|
||||
}
|
||||
|
||||
void HiresViewWidget::makeOffsetTable() {
|
||||
m_rowTable = new QMap<int,int>();
|
||||
|
||||
int count = 0;
|
||||
|
||||
int outer = 0x0000;
|
||||
for (int idx = 0; idx < 8; idx++) {
|
||||
int inner = 0x0000;
|
||||
for (int jdx = 0; jdx < 8; jdx++) {
|
||||
for (int kdx = 0; kdx<40;kdx++) {
|
||||
(*m_rowTable)[outer+inner+kdx] = count + (kdx*10000);
|
||||
}
|
||||
count++;
|
||||
inner += 0x0400;
|
||||
}
|
||||
outer += 0x0080;
|
||||
}
|
||||
|
||||
|
||||
outer = 0x0028;
|
||||
for (int idx = 0; idx < 8; idx++) {
|
||||
int inner = 0x0000;
|
||||
for (int jdx = 0; jdx < 8; jdx++) {
|
||||
for (int kdx = 0; kdx<40;kdx++) {
|
||||
(*m_rowTable)[outer+inner+kdx] = count + (kdx*10000);
|
||||
}
|
||||
count++;
|
||||
inner += 0x0400;
|
||||
}
|
||||
outer += 0x0080;
|
||||
}
|
||||
|
||||
outer = 0x0050;
|
||||
for (int idx = 0; idx < 8; idx++) {
|
||||
int inner = 0x0000;
|
||||
for (int jdx = 0; jdx < 8; jdx++) {
|
||||
for (int kdx = 0; kdx<40;kdx++) {
|
||||
(*m_rowTable)[outer+inner+kdx] = count + (kdx*10000);
|
||||
}
|
||||
count++;
|
||||
inner += 0x0400;
|
||||
}
|
||||
outer += 0x0080;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
QMap<int,int> *HiresViewWidget::m_rowTable = 0;
|
||||
|
34
src/hiresviewwidget.h
Normal file
34
src/hiresviewwidget.h
Normal file
@ -0,0 +1,34 @@
|
||||
#ifndef HIRESVIEWWIDGET_H
|
||||
#define HIRESVIEWWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QPixmap>
|
||||
#include <QByteArray>
|
||||
#include <QPair>
|
||||
#include <QMap>
|
||||
|
||||
class HiresViewWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit HiresViewWidget(QWidget *parent = 0);
|
||||
void paintEvent(QPaintEvent *event);
|
||||
|
||||
void resizeEvent(QResizeEvent *event);
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
void setData(QByteArray data);
|
||||
|
||||
private:
|
||||
QPixmap m_pixmap;
|
||||
QByteArray m_data;
|
||||
|
||||
int findRowCol(int offset);
|
||||
static QMap<int,int> *m_rowTable;
|
||||
|
||||
void makeOffsetTable();
|
||||
};
|
||||
|
||||
|
||||
#endif // HIRESVIEWWIDGET_H
|
@ -39,7 +39,8 @@ int main(int argc, char** argv)
|
||||
|
||||
QApplication a(argc, argv);
|
||||
MainWindow w;
|
||||
w.loadDiskFile("/home/mlong/Desktop/missing_ring_good.dsk");
|
||||
// w.loadDiskFile("/home/mlong/Desktop/missing_ring_good.dsk");
|
||||
w.loadDiskFile("/home/mlong/Desktop/dos.3.3.system.master.dsk");
|
||||
w.show();
|
||||
|
||||
return a.exec();
|
||||
|
@ -2,6 +2,8 @@
|
||||
#include "ui_mainwindow.h"
|
||||
|
||||
#include <QFileDialog>
|
||||
#include "hiresviewwidget.h"
|
||||
#include <QMdiSubWindow>
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
@ -15,12 +17,17 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
connect(ui->action_Quit, SIGNAL(triggered()), qApp, SLOT(quit()));
|
||||
connect(ui->action_Load_Disk_Image, SIGNAL(triggered()), SLOT(showLoadDialog()));
|
||||
connect(ui->action_Unload_Disk_Image, SIGNAL(triggered()), SLOT(unloadDiskFile()));
|
||||
connect(ui->catalogWidget,SIGNAL(itemSelected(DiskFile*,FileDescriptiveEntry)),
|
||||
SLOT(handleDiskItemSelected(DiskFile*,FileDescriptiveEntry)));
|
||||
|
||||
|
||||
connect(this, SIGNAL(diskFileLoading(QString, DiskFile*)),
|
||||
ui->catalogWidget, SLOT(prepForNewDisk(QString,DiskFile*)));
|
||||
connect(this, SIGNAL(diskFileLoaded(QString,DiskFile*)),
|
||||
ui->catalogWidget, SLOT(processNewlyLoadedDisk(QString,DiskFile*)));
|
||||
connect(this, SIGNAL(diskFileUnloading(DiskFile*)),
|
||||
ui->catalogWidget, SLOT(unloadDisk(DiskFile*)));
|
||||
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
@ -65,3 +72,16 @@ void MainWindow::showLoadDialog()
|
||||
loadDiskFile(filename);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::handleDiskItemSelected(DiskFile *disk, FileDescriptiveEntry fde)
|
||||
{
|
||||
HiresViewWidget *hvwma = new HiresViewWidget(0);
|
||||
hvwma->resize(280,192);
|
||||
QString title = QString("Image: %1").arg(AppleString(fde.filename).printable().trimmed());
|
||||
hvwma->setWindowTitle(title);
|
||||
hvwma->show();
|
||||
|
||||
QByteArray data = disk->getFile(fde).mid(4);
|
||||
hvwma->setData(data);
|
||||
|
||||
}
|
||||
|
@ -23,6 +23,9 @@ public slots:
|
||||
|
||||
void showLoadDialog();
|
||||
|
||||
private slots:
|
||||
void handleDiskItemSelected(DiskFile *disk, FileDescriptiveEntry fde);
|
||||
|
||||
signals:
|
||||
void diskFileLoading(QString filename, DiskFile *file);
|
||||
void diskFileLoaded(QString filename, DiskFile *file);
|
||||
|
@ -6,7 +6,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<width>273</width>
|
||||
<height>600</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -16,47 +16,25 @@
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QSplitter" name="splitter">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<widget class="CatalogWidget" name="catalogWidget" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="childrenCollapsible">
|
||||
<bool>false</bool>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="baseSize">
|
||||
<size>
|
||||
<width>300</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<widget class="CatalogWidget" name="catalogWidget" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>400</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="baseSize">
|
||||
<size>
|
||||
<width>300</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QMdiArea" name="mdiArea">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Expanding">
|
||||
<horstretch>3</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
@ -66,7 +44,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<width>273</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
Loading…
Reference in New Issue
Block a user