mirror of
https://github.com/markdavidlong/AppleSAWS.git
synced 2024-11-22 00:31:04 +00:00
Added status bar to DiskExplorer
This commit is contained in:
parent
048ab309c7
commit
f5be4abd7c
@ -17,7 +17,7 @@ CatalogWidget::CatalogWidget(QWidget *parent) :
|
||||
ui->catalog_list->setFont(QFont("monospace"));
|
||||
|
||||
connect(ui->catalog_list, SIGNAL(itemDoubleClicked(QListWidgetItem*)),
|
||||
SLOT(itemClicked(QListWidgetItem*)));
|
||||
SLOT(itemDoubleClicked(QListWidgetItem*)));
|
||||
}
|
||||
|
||||
CatalogWidget::~CatalogWidget()
|
||||
@ -107,10 +107,18 @@ void CatalogWidget::unloadDisk(DiskFile *disk)
|
||||
ui->volume_label->clear();
|
||||
}
|
||||
|
||||
void CatalogWidget::itemClicked(QListWidgetItem *item)
|
||||
void CatalogWidget::itemDoubleClicked(QListWidgetItem *item)
|
||||
{
|
||||
int idx = item->data(0x0100).toInt();
|
||||
FileDescriptiveEntry fde = m_disk->getAllFDEs()[idx];
|
||||
// qDebug() << "Default File " << AppleString(fde.filename).printable().trimmed();
|
||||
emit openWithDefaultViewer(m_disk,fde);
|
||||
}
|
||||
|
||||
void CatalogWidget::itemClicked(QListWidgetItem *item)
|
||||
{
|
||||
int idx = item->data(0x0100).toInt();
|
||||
FileDescriptiveEntry fde = m_disk->getAllFDEs()[idx];
|
||||
// qDebug() << "Default File " << AppleString(fde.filename).printable().trimmed();
|
||||
emit newFileSelected(m_disk,fde);
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ public slots:
|
||||
void unloadDisk(DiskFile *disk);
|
||||
|
||||
signals:
|
||||
void newFileSelected(FileDescriptiveEntry *entry);
|
||||
void newFileSelected(DiskFile *disk, FileDescriptiveEntry entry);
|
||||
void openWithDefaultViewer(DiskFile *disk, FileDescriptiveEntry fde);
|
||||
|
||||
protected:
|
||||
@ -33,6 +33,7 @@ protected:
|
||||
|
||||
private slots:
|
||||
void itemClicked(QListWidgetItem *item);
|
||||
void itemDoubleClicked(QListWidgetItem *item);
|
||||
|
||||
private:
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <QFileDialog>
|
||||
#include <QShowEvent>
|
||||
#include <QDebug>
|
||||
#include <QStatusBar>
|
||||
|
||||
#include "genericfile.h"
|
||||
#include "viewerbase.h"
|
||||
@ -27,6 +28,8 @@ DiskExplorer::~DiskExplorer()
|
||||
|
||||
void DiskExplorer::initUi()
|
||||
{
|
||||
|
||||
|
||||
QMenuBar *menuBar = new QMenuBar(this);
|
||||
setMenuBar(menuBar);
|
||||
QMenu *menu = new QMenu(tr("&File"),this);
|
||||
@ -41,8 +44,6 @@ void DiskExplorer::initUi()
|
||||
menu->addAction(m_action_Unload_Disk_Image);
|
||||
connect(m_action_Unload_Disk_Image, SIGNAL(triggered()), SLOT(unloadDiskFile()));
|
||||
|
||||
|
||||
|
||||
menu->addSeparator();
|
||||
|
||||
QAction *action_Quit = new QAction(tr("&Quit"),this);
|
||||
@ -78,13 +79,11 @@ void DiskExplorer::initUi()
|
||||
m_hexConverter = new HexConverter(this);
|
||||
connect(action_Hex_Converter, SIGNAL(triggered()), m_hexConverter, SLOT(show()));
|
||||
|
||||
|
||||
QWidget *widget = new QWidget(0);
|
||||
m_gridLayout = new QGridLayout();
|
||||
m_gridLayout->setVerticalSpacing(4);
|
||||
m_gridLayout->setHorizontalSpacing(4);
|
||||
widget->setLayout(m_gridLayout);
|
||||
//m_gridLayout->setSizeConstraint(QLayout::SetFixedSize);
|
||||
m_cw = new CatalogWidget(widget);
|
||||
m_demw = new DiskExplorerMapWidget(35,16,widget);
|
||||
m_frame = new QFrame(widget);
|
||||
@ -112,6 +111,14 @@ void DiskExplorer::initUi()
|
||||
connect(m_demw, SIGNAL(showSectorData(QByteArray,int,int,QVariant)),
|
||||
SLOT(handleShowSectorData(QByteArray,int,int,QVariant)));
|
||||
|
||||
|
||||
QStatusBar *statusBar = new QStatusBar(this);
|
||||
setStatusBar(statusBar);
|
||||
|
||||
m_demwStatusWidget = m_demw->getStatusWidget();
|
||||
statusBar->addPermanentWidget(m_demwStatusWidget);
|
||||
|
||||
|
||||
setDiskToolsVisible(false);
|
||||
}
|
||||
|
||||
@ -145,7 +152,6 @@ void DiskExplorer::loadDiskFile(QString filename)
|
||||
delete m_disk;
|
||||
m_disk = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void DiskExplorer::handleShowSectorData(QByteArray data, int track, int sector, QVariant metadata)
|
||||
@ -197,6 +203,8 @@ void DiskExplorer::setDiskToolsVisible(bool visible)
|
||||
m_gridLayout->setColumnStretch(2,0);
|
||||
}
|
||||
|
||||
if (m_demwStatusWidget) { m_demwStatusWidget->setVisible(visible); }
|
||||
|
||||
m_demw->setVisible(visible);
|
||||
m_frame->setVisible(visible);
|
||||
m_hdv->setVisible(visible);
|
||||
@ -210,6 +218,7 @@ void DiskExplorer::setDiskToolsVisible(bool visible)
|
||||
|
||||
void DiskExplorer::handleViewerClosing(ViewerBase *viewer)
|
||||
{
|
||||
qDebug() << "Removing viewer " << viewer;
|
||||
m_viewerList.removeAll(viewer);
|
||||
}
|
||||
|
||||
@ -224,6 +233,7 @@ void DiskExplorer::showEvent(QShowEvent *event)
|
||||
if (m_horizSizePref == -1)
|
||||
{
|
||||
m_horizSizePref = this->width();
|
||||
qDebug() << "New Horiz Size Pref = " << m_horizSizePref;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -59,6 +59,8 @@ private:
|
||||
QWidget *m_key;
|
||||
QGridLayout *m_gridLayout;
|
||||
|
||||
QWidget *m_demwStatusWidget;
|
||||
|
||||
DiskFile *m_disk;
|
||||
|
||||
HRCGControlsInfo *m_hrcgDialog;
|
||||
|
@ -8,11 +8,16 @@
|
||||
#include <QGridLayout>
|
||||
#include <QButtonGroup>
|
||||
#include <QDebug>
|
||||
#include <QHBoxLayout>
|
||||
|
||||
DiskExplorerMapWidget::DiskExplorerMapWidget(int numtracks, int numsectors, QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
m_numtracks = numtracks;
|
||||
m_numsectors = numsectors;
|
||||
m_diskLabel = Q_NULLPTR;
|
||||
m_statusWidget = Q_NULLPTR;
|
||||
|
||||
m_deferredSetup = false;
|
||||
|
||||
setWindowTitle("Disk Explorer");
|
||||
|
||||
@ -59,6 +64,52 @@ DiskExplorerMapWidget::DiskExplorerMapWidget(int numtracks, int numsectors, QWid
|
||||
layout->addWidget(tb,sec+2,track+1);
|
||||
}
|
||||
}
|
||||
|
||||
makeStatusWidget();
|
||||
}
|
||||
|
||||
void DiskExplorerMapWidget::makeStatusWidget()
|
||||
{
|
||||
QWidget *statusWidget = new QWidget(this);
|
||||
QHBoxLayout *hbl = new QHBoxLayout(this);
|
||||
statusWidget->setLayout(hbl);
|
||||
|
||||
m_trackSectorLabel = new QLabel(this);
|
||||
m_trackSectorLabel->setFrameStyle(QFrame::Panel | QFrame::Sunken);
|
||||
m_trackSectorLabel->setText("No Track/Sector selected");
|
||||
hbl->insertWidget(0,m_trackSectorLabel,0,Qt::AlignLeft | Qt::AlignVCenter);
|
||||
|
||||
m_diskLabel = new QLabel(this);
|
||||
m_diskLabel->setFrameStyle(QFrame::Panel | QFrame::Sunken);
|
||||
m_diskLabel->setText("[No Disk]");
|
||||
hbl->insertWidget(1,m_diskLabel,0,Qt::AlignLeft | Qt::AlignVCenter);
|
||||
|
||||
m_statusWidget = statusWidget;
|
||||
}
|
||||
|
||||
QString DiskExplorerMapWidget::getSectorDescription(int track, int sector)
|
||||
{
|
||||
if (track == 0) {
|
||||
return "Boot Sector";
|
||||
}
|
||||
else if (track <= 2)
|
||||
{
|
||||
return "DOS Image";
|
||||
}
|
||||
else if (track == 17 && sector == 0)
|
||||
{
|
||||
return "VTOC";
|
||||
}
|
||||
else
|
||||
{
|
||||
QString desc = "xxx";
|
||||
if (m_sectorDescriptions.contains(DETSPair(track,sector)))
|
||||
{
|
||||
desc = m_sectorDescriptions[DETSPair(track,sector)];
|
||||
}
|
||||
return desc.simplified();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void DiskExplorerMapWidget::handleButtonCheck(int track, int sector, bool checked)
|
||||
@ -68,7 +119,7 @@ void DiskExplorerMapWidget::handleButtonCheck(int track, int sector, bool checke
|
||||
if (m_currentChecked)
|
||||
{
|
||||
// Do anything needed to clean up after previous button click
|
||||
// m_currentClicked->setHighlighted(false);
|
||||
// m_currentClicked->setHighlighted(false);
|
||||
}
|
||||
|
||||
if (checked)
|
||||
@ -76,9 +127,15 @@ void DiskExplorerMapWidget::handleButtonCheck(int track, int sector, bool checke
|
||||
Sector sec = m_disk->getSector(track,sector);
|
||||
QByteArray data = sec.rawData();
|
||||
emit showSectorData(data,track,sector,QVariant());
|
||||
m_trackSectorLabel->setText(
|
||||
QString("Track: %1 Sector: %2 (%3)")
|
||||
.arg(track)
|
||||
.arg(sector)
|
||||
.arg(getSectorDescription(track,sector)));
|
||||
}
|
||||
else{
|
||||
emit showSectorData(QByteArray(),-1,-1,QVariant());
|
||||
m_trackSectorLabel->setText("No Track/Sector selected");
|
||||
}
|
||||
|
||||
m_currentChecked = currbutton;
|
||||
@ -93,9 +150,23 @@ void DiskExplorerMapWidget::setDisk(DiskFile *disk)
|
||||
{
|
||||
if (disk)
|
||||
{
|
||||
m_sectorDescriptions.clear();
|
||||
|
||||
m_disk = disk;
|
||||
setWindowTitle(QString("Disk Explorer - %1").arg(m_disk->getDiskImageName()));
|
||||
mapDiskToButtons();
|
||||
m_diskLabel->setText(disk->getDiskImageName());
|
||||
|
||||
if (!isHidden())
|
||||
{
|
||||
if (m_disk)
|
||||
{
|
||||
mapDiskToButtons();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_deferredSetup = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -103,6 +174,7 @@ void DiskExplorerMapWidget::unloadDisk()
|
||||
{
|
||||
if (m_disk)
|
||||
{
|
||||
m_sectorDescriptions.clear();
|
||||
m_bgroup->setExclusive(false);
|
||||
for (int track = 0; track < m_numtracks; track++)
|
||||
{
|
||||
@ -218,9 +290,14 @@ void DiskExplorerMapWidget::mapDiskToButtons()
|
||||
buttonAt(17,0)->setBgColor(m_vtocColor);
|
||||
buttonAt(17,0)->setText(QString("%1").arg(idx++));
|
||||
|
||||
int catseccount = 0;
|
||||
foreach (CatalogSector cs, m_disk->getCatalogSectors())
|
||||
{
|
||||
Sector *sec = cs.getSector();
|
||||
|
||||
QString desc = QString("Catalog Sector #%1").arg(++catseccount);
|
||||
m_sectorDescriptions.insert(DETSPair(sec->track(),sec->sector()),desc);
|
||||
|
||||
buttonAt(sec->track(),sec->sector())->setBgColor(m_dirEntryColor);
|
||||
buttonAt(sec->track(),sec->sector())->setText(QString("%1").arg(idx++));
|
||||
|
||||
@ -232,18 +309,31 @@ void DiskExplorerMapWidget::mapDiskToButtons()
|
||||
int tsltr = fde.firstTSListSector.track;
|
||||
int tslse = fde.firstTSListSector.sector;
|
||||
|
||||
int tslcount = 0;
|
||||
while (tsltr != 0)
|
||||
{
|
||||
tslcount++;
|
||||
buttonAt(tsltr,tslse)->setBgColor(m_tsListColor);
|
||||
buttonAt(tsltr,tslse)->setText(QString("%1").arg(idx));
|
||||
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);
|
||||
|
||||
idx++;
|
||||
|
||||
int sectorcount = 0;
|
||||
foreach(TSPair tsp, tsl.getDataTSPairs())
|
||||
{
|
||||
int se = tsp.sector;
|
||||
int tr = tsp.track;
|
||||
|
||||
QString description = QString("Sector #%1.%2 of %3")
|
||||
.arg(tslcount)
|
||||
.arg(++sectorcount)
|
||||
.arg(fde.filename.printable());
|
||||
m_sectorDescriptions.insert(DETSPair(tr,se),description);
|
||||
|
||||
QColor color;
|
||||
if (fde.fileType() == "I") color = m_intBasicFileColor;
|
||||
else if (fde.fileType() == "A") color = m_applesoftFileColor;
|
||||
@ -270,3 +360,14 @@ void DiskExplorerMapWidget::mapDiskToButtons()
|
||||
|
||||
}
|
||||
|
||||
void DiskExplorerMapWidget::showEvent(QShowEvent *)
|
||||
{
|
||||
if (m_deferredSetup)
|
||||
{
|
||||
if (m_disk)
|
||||
{
|
||||
mapDiskToButtons();
|
||||
}
|
||||
m_deferredSetup = false;
|
||||
}
|
||||
}
|
||||
|
@ -72,18 +72,6 @@ private:
|
||||
" QPushButton:checked { font: bold italic 11px; } "
|
||||
) .arg(m_fgColor)
|
||||
.arg(m_backgroundColor);
|
||||
|
||||
|
||||
|
||||
// return QString(
|
||||
// "background-color: %1;"
|
||||
// "font: %2; "
|
||||
// "border-radius: 0px; "
|
||||
// "color: %3;"
|
||||
// ).arg(m_isHighlighted?m_hlColor:m_backgroundColor)
|
||||
// .arg(m_isHighlighted?"bold italic 11px":"10px")
|
||||
// .arg(m_fgColor)
|
||||
// ;
|
||||
}
|
||||
|
||||
int m_track;
|
||||
@ -97,7 +85,7 @@ private:
|
||||
|
||||
|
||||
|
||||
|
||||
typedef QPair<int,int> DETSPair;
|
||||
|
||||
class DiskExplorerMapWidget : public QWidget
|
||||
{
|
||||
@ -112,11 +100,12 @@ public:
|
||||
}
|
||||
|
||||
void setDisk(DiskFile *disk);
|
||||
void unloadDisk();
|
||||
|
||||
void setAllButtonsEnabled(bool enabled);
|
||||
|
||||
QGroupBox *makeKeyWidget();
|
||||
|
||||
void unloadDisk();
|
||||
void setAllButtonsEnabled(bool enabled);
|
||||
QWidget *getStatusWidget() const { return m_statusWidget; }
|
||||
|
||||
signals:
|
||||
void showSectorData(QByteArray data, int track, int sector, QVariant metadata);
|
||||
@ -140,6 +129,10 @@ protected:
|
||||
}
|
||||
|
||||
QLabel *makeKeyLabel(QWidget *parent, QString name, QColor color);
|
||||
void showEvent(QShowEvent *);
|
||||
void makeStatusWidget();
|
||||
QString getSectorDescription(int track, int sector);
|
||||
|
||||
private:
|
||||
|
||||
QMap<int, QMap<int,DEButton*> > m_buttons;
|
||||
@ -166,6 +159,13 @@ private:
|
||||
QButtonGroup *m_bgroup;
|
||||
DiskFile *m_disk;
|
||||
|
||||
bool m_deferredSetup;
|
||||
|
||||
QLabel *m_diskLabel;
|
||||
QLabel *m_trackSectorLabel;
|
||||
QWidget *m_statusWidget;
|
||||
|
||||
QMap< DETSPair, QString> m_sectorDescriptions;
|
||||
};
|
||||
|
||||
#endif // DISKEXPLORERMAPWIDGET_H
|
||||
|
Loading…
Reference in New Issue
Block a user